Skip to content

Commit

Permalink
most recent sim progress and reverting active diff change to do it on…
Browse files Browse the repository at this point in the history
… seperate branch
  • Loading branch information
shayana18 committed Jan 21, 2025
1 parent b1c02be commit 89a92ea
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,9 @@ void app_tractionControl_computeTorque(TractionControl_Inputs *inputs, TractionC
float slip_ratio_right =
app_tractionControl_computeSlip(inputs->motor_speed_right_rpm, wheel_speed_front_right_rpm);

float slip_ratio_max = fmaxf(slip_ratio_left, slip_ratio_right);
float k = app_pid_compute(pid, SLIP_RATIO_IDEAL, slip_ratio_max);

// corrected as we should correct the wheel that deviates most from the ideal slip ratio rather than just the one with the highest slip ratio
// ex. left wheel = 0.04 slip ratio and right wheel = 0.03, our old logic would correct left wheel due to max(left wheel, right wheel)
// however we should correct the left wheel first to get it in ideal operating range

float slip_ratio_error_left = (float)fabs(slip_ratio_left - SLIP_RATIO_IDEAL);
float slip_ratio_error_right = (float)fabs(slip_ratio_right - SLIP_RATIO_IDEAL);

float k;

if( slip_ratio_error_left <= slip_ratio_error_right){
k = app_pid_compute(pid, SLIP_RATIO_IDEAL, slip_ratio_right);

}
else{
k = app_pid_compute(pid, SLIP_RATIO_IDEAL, slip_ratio_left);
}
// Send debug messages over CAN
app_canTx_VC_SlipRatioLeft_set(slip_ratio_left);
app_canTx_VC_SlipRatioRight_set(slip_ratio_right);
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 89a92ea

Please sign in to comment.