From 19983f13b37518298a3c282d5069c090b68f6864 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 13 Sep 2022 13:52:44 -0700 Subject: [PATCH] Chrysler: match openpilot standstill check (#1065) * match openpilot standstill, and fix ram standstill parsing * misra * cmt --- board/safety/safety_chrysler.h | 11 +++-------- tests/safety/test_chrysler.py | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/board/safety/safety_chrysler.h b/board/safety/safety_chrysler.h index 36ea9dade..b158cf8a4 100644 --- a/board/safety/safety_chrysler.h +++ b/board/safety/safety_chrysler.h @@ -28,9 +28,6 @@ const SteeringLimits CHRYSLER_RAM_HD_STEERING_LIMITS = { .type = TorqueMotorLimited, }; -const int CHRYSLER_STANDSTILL_THRSLD = 10; // about 1m/s -const int CHRYSLER_RAM_STANDSTILL_THRSLD = 3; // about 1m/s changed from wheel rpm to km/h - typedef struct { const int EPS_2; const int ESP_1; @@ -204,16 +201,14 @@ static int chrysler_rx_hook(CANPacket_t *to_push) { } // TODO: use the same message for both - // update speed + // update vehicle moving if ((chrysler_platform != CHRYSLER_PACIFICA) && (bus == 0) && (addr == chrysler_addrs->ESP_8)) { - vehicle_speed = (((GET_BYTE(to_push, 4) & 0x3U) << 8) + GET_BYTE(to_push, 5))*0.0078125; - vehicle_moving = (int)vehicle_speed > CHRYSLER_RAM_STANDSTILL_THRSLD; + vehicle_moving = ((GET_BYTE(to_push, 4) << 8) + GET_BYTE(to_push, 5)) != 0U; } if ((chrysler_platform == CHRYSLER_PACIFICA) && (bus == 0) && (addr == 514)) { int speed_l = (GET_BYTE(to_push, 0) << 4) + (GET_BYTE(to_push, 1) >> 4); int speed_r = (GET_BYTE(to_push, 2) << 4) + (GET_BYTE(to_push, 3) >> 4); - vehicle_speed = (speed_l + speed_r) / 2; - vehicle_moving = (int)vehicle_speed > CHRYSLER_STANDSTILL_THRSLD; + vehicle_moving = (speed_l != 0) || (speed_r != 0); } // exit controls on rising edge of gas press diff --git a/tests/safety/test_chrysler.py b/tests/safety/test_chrysler.py index a34189c3a..bcf83cb49 100755 --- a/tests/safety/test_chrysler.py +++ b/tests/safety/test_chrysler.py @@ -74,7 +74,6 @@ class TestChryslerSafety(common.PandaSafetyTest, common.MotorTorqueSteeringSafet class TestChryslerRamDTSafety(TestChryslerSafety): TX_MSGS = [[177, 2], [166, 0], [250, 0]] - STANDSTILL_THRESHOLD = 3 RELAY_MALFUNCTION_ADDR = 166 FWD_BLACKLISTED_ADDRS = {2: [166, 250]} @@ -95,7 +94,6 @@ class TestChryslerRamDTSafety(TestChryslerSafety): class TestChryslerRamHDSafety(TestChryslerSafety): TX_MSGS = [[629, 0], [630, 0], [570, 2]] - STANDSTILL_THRESHOLD = 3 RELAY_MALFUNCTION_ADDR = 630 FWD_BLACKLISTED_ADDRS = {2: [629, 630]}