From 3048f2fc807c82f2d5c8d14d0d50cec0cda8fdf7 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Wed, 14 Feb 2024 17:04:11 +0000 Subject: [PATCH] Ford: handle metric cruise speed (v2) **Description** I found a signal which appears to match the IPC "Show km/h" setting. Requires https://github.com/commaai/opendbc/pull/1010. **Verification** - [ ] Test in car and confirm that toggling the "Show km/h" setting does not result in the cruise speed shown in openpilot being incorrect. - [ ] Test in a non-English (metric) car. --- selfdrive/car/ford/carstate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/ford/carstate.py b/selfdrive/car/ford/carstate.py index b3ee6a4649..de37a85a92 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -57,7 +57,8 @@ class CarState(CarStateBase): ret.steerFaultTemporary |= cp.vl["Lane_Assist_Data3_FD1"]["LatCtlSte_D_Stat"] not in (1, 2, 3) # cruise state - ret.cruiseState.speed = cp.vl["EngBrakeData"]["Veh_V_DsplyCcSet"] * CV.MPH_TO_MS + is_metric = cp.vl["INSTRUMENT_PANEL"]["METRIC_UNITS"] == 1 + ret.cruiseState.speed = cp.vl["EngBrakeData"]["Veh_V_DsplyCcSet"] * (CV.KPH_TO_MS if is_metric else CV.MPH_TO_MS) ret.cruiseState.enabled = cp.vl["EngBrakeData"]["CcStat_D_Actl"] in (4, 5) ret.cruiseState.available = cp.vl["EngBrakeData"]["CcStat_D_Actl"] in (3, 4, 5) ret.cruiseState.nonAdaptive = cp.vl["Cluster_Info1_FD1"]["AccEnbl_B_RqDrv"] == 0 @@ -120,6 +121,7 @@ class CarState(CarStateBase): ("BrakeSnData_4", 50), ("EngBrakeData", 10), ("Cluster_Info1_FD1", 10), + ("INSTRUMENT_PANEL", 10), ("SteeringPinion_Data", 100), ("EPAS_INFO", 50), ("Steering_Data_FD1", 10),