Skip to content

Commit

Permalink
Added common vehicle_moving state
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Aug 19, 2024
1 parent a7c2b77 commit 03ba0f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion board/safety/safety_bmw.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void bmw_rx_hook(const CANPacket_t *to_push) {
if ((addr == BMW_SteeringWheelAngle) && (bus == BMW_PT_CAN)) {
float meas_angle = to_signed((GET_BYTE(to_push, 1) << 8) | GET_BYTE(to_push, 0), 16) * CAN_BMW_ANGLE_FAC; // deg
float angle_rate = to_signed((GET_BYTE(to_push, 4) << 8) | GET_BYTE(to_push, 3), 16) * CAN_BMW_ANGLE_FAC; // deg/s

// todo use common steer_angle_cmd_checks()
if(bmw_fmax_limit_check(meas_angle, bmw_max_angle, -bmw_max_angle)){
// We should not be able to STEER under these conditions
controls_allowed = false;
Expand All @@ -158,6 +158,12 @@ static void bmw_rx_hook(const CANPacket_t *to_push) {
}
}

// Update in motion state from standstill signal
if (addr == BMW_Speed) {
// check moving forward and reverse
vehicle_moving = (GET_BYTE(to_push, 1) & 0x30U) != 0U;
}

// exit controls on brake press
if (addr == BMW_EngineAndBrake) {
// any of two bits at position 61 & 62
Expand Down

0 comments on commit 03ba0f3

Please sign in to comment.