Skip to content

Commit

Permalink
Fix steering rate limiting checks. Handle zero crossing
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Aug 20, 2024
1 parent 8174df6 commit 34215e7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions board/safety/safety_bmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ static void bmw_rx_hook(const CANPacket_t *to_push) {
print("Too big angle \n");
}
}
if (bmw_fmax_limit_check((bmw_rt_angle_last >= 0.) ? angle_rate : -angle_rate, angle_rate_up, -angle_rate_down)) { //should be sensitive for jerks to the outside
controls_allowed = false; // todo ^ handle zero crossing a bit smarter
if (cruise_engaged){
print("To fast angle rate \n");
if (meas_angle * bmw_rt_angle_last > 0.) { // ignore when zero crossing
if (bmw_fmax_limit_check((meas_angle >= 0.) ? angle_rate : -angle_rate, angle_rate_up, -angle_rate_down)) { //should be sensitive for jerks to the outside
controls_allowed = false;
if (cruise_engaged){
print("To fast angle rate \n");
}
}
}

if ((controls_allowed && !bmw_controls_allowed_last)) {
bmw_rt_angle_last = meas_angle;
}
bmw_rt_angle_last = meas_angle;
}

// Update in motion state from standstill signal
Expand Down

0 comments on commit 34215e7

Please sign in to comment.