Skip to content

Commit

Permalink
Update shift_controller.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
JRich4 authored Jul 22, 2024
1 parent 7b60c6a commit 8772272
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,44 @@

namespace application {

int ShiftController::getCurrentGear(){
float gearR[6] = {2.833, 2.062, 1.647, 1.421, 1.272, 1.173};
float wheelRPM = (DrivenWheelSpeed() * 60)/ 1.7083;
float gearRatio = Rpm/wheelRPM;
int foundGear = -1;
switch(gearRatio){
case gearR[0]: foundGear = 1;
break;
case gearR[1]: foundGear = 2;
break;
case gearR[2]: foundGear = 3;
break;
case gearR[3]: foundGear = 4;
break;
case gearR[4]: foundGear = 5;
break;
case gearR[5]: foundGear = 6;
break;
}
if(foundGear != -1)
return foundGear;

float prevDiff = 10000;
//int prevGear = 0;
for(int i = 0; i < 6; i++){
if(prevDiff > (abs(gearR[i] - gearRatio)){
foundGearGear = gearR[i] + 1;
prevDiff = abs(gearR[i] - gearRatio)
}

}

return foundGear;


}


ShiftController::ShiftController() { }

ShiftController::~ShiftController() { }
Expand Down

0 comments on commit 8772272

Please sign in to comment.