From 5801582baf5022a3d3b91316a566bf3650583f38 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Mon, 7 Aug 2023 09:29:34 -0700 Subject: [PATCH] Subaru: convert measured angle to centigrees (#1567) convert to centigrees --- board/safety/safety_subaru.h | 3 ++- tests/safety/test_subaru.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/board/safety/safety_subaru.h b/board/safety/safety_subaru.h index 438a0fba9..230476898 100644 --- a/board/safety/safety_subaru.h +++ b/board/safety/safety_subaru.h @@ -108,7 +108,8 @@ static int subaru_rx_hook(CANPacket_t *to_push) { update_sample(&torque_driver, torque_driver_new); int angle_meas_new = (GET_BYTES(to_push, 4, 2) & 0xFFFFU); - angle_meas_new = ROUND(to_signed(angle_meas_new, 16)); + // 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); update_sample(&angle_meas, angle_meas_new); } diff --git a/tests/safety/test_subaru.py b/tests/safety/test_subaru.py index 17cfc5117..7cc2bdf8f 100755 --- a/tests/safety/test_subaru.py +++ b/tests/safety/test_subaru.py @@ -52,7 +52,7 @@ class TestSubaruSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSa ALT_BUS = SUBARU_MAIN_BUS - DEG_TO_CAN = -46.08 + DEG_TO_CAN = -100 def setUp(self): self.packer = CANPackerPanda("subaru_global_2017_generated")