Skip to content

Commit 85a1e9a

Browse files
committed
Fix bug - Affects only Honda Nidec with comma pedal: Hud set cruise speed doesn't always match UI max cruise speed when units is set to mph..
1 parent 84720ec commit 85a1e9a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

selfdrive/car/honda/carcontroller.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def rate_limit_steer(new_steer, last_steer):
104104
MAX_DELTA = 3 * DT_CTRL
105105
return clip(new_steer, last_steer - MAX_DELTA, last_steer + MAX_DELTA)
106106

107+
def calculate_hud_set_speed(hud_v_cruise_kph, is_metric):
108+
if (is_metric):
109+
return hud_v_cruise_kph
110+
cruise_mph = round(hud_v_cruise_kph * CV.KPH_TO_MPH)
111+
return int(round(cruise_mph * CV.MPH_TO_KPH))
107112

108113
class CarController:
109114
def __init__(self, dbc_name, CP, VM):
@@ -246,7 +251,8 @@ def update(self, CC, CS):
246251

247252
# Send dashboard UI commands.
248253
if self.frame % 10 == 0:
249-
hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), hud_control.leadVisible,
254+
hud_set_speed = calculate_hud_set_speed(hud_v_cruise, CS.is_metric)
255+
hud = HUDData(int(pcm_accel), hud_set_speed, hud_control.leadVisible,
250256
hud_control.lanesVisible, fcw_display, acc_alert, steer_required)
251257
can_sends.extend(hondacan.create_ui_commands(self.packer, self.CP, CC.enabled, pcm_speed, hud, CS.is_metric, CS.acc_hud, CS.lkas_hud))
252258

0 commit comments

Comments
 (0)