From 635db840955ca2f88136ad9edcc59ac7f5c04c8a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 3 Oct 2023 02:18:10 -0700 Subject: [PATCH] Subaru: consider true angle sign in safety (#1681) * this fails * this doesn't! --- board/safety/safety_subaru.h | 4 ++-- tests/safety/test_subaru.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_subaru.h b/board/safety/safety_subaru.h index bac8a7650..bfe800142 100644 --- a/board/safety/safety_subaru.h +++ b/board/safety/safety_subaru.h @@ -159,7 +159,7 @@ static int subaru_rx_hook(CANPacket_t *to_push) { int angle_meas_new = (GET_BYTES(to_push, 4, 2) & 0xFFFFU); // convert Steering_Torque -> Steering_Angle to centidegrees, to match the ES_LKAS_ANGLE angle request units - angle_meas_new = ROUND(to_signed(angle_meas_new, 16) * 2.17); + angle_meas_new = ROUND(to_signed(angle_meas_new, 16) * -2.17); update_sample(&angle_meas, angle_meas_new); } @@ -232,7 +232,7 @@ static int subaru_tx_hook(CANPacket_t *to_send) { if (addr == MSG_SUBARU_ES_Distance) { int cruise_throttle = (GET_BYTES(to_send, 2, 2) & 0xFFFU); bool cruise_cancel = GET_BIT(to_send, 56U) != 0U; - + if (subaru_longitudinal) { violation |= longitudinal_gas_checks(cruise_throttle, SUBARU_LONG_LIMITS); } else { diff --git a/tests/safety/test_subaru.py b/tests/safety/test_subaru.py index 219cd278e..96731c51f 100755 --- a/tests/safety/test_subaru.py +++ b/tests/safety/test_subaru.py @@ -69,7 +69,7 @@ class TestSubaruSafetyBase(common.PandaSafetyTest, MeasurementSafetyTest): ALT_MAIN_BUS = SUBARU_MAIN_BUS ALT_CAM_BUS = SUBARU_CAM_BUS - DEG_TO_CAN = -100 + DEG_TO_CAN = 100 INACTIVE_GAS = 1818