This is a test of both PRs combined

pull/26480/head
Shane Smiskol 2 years ago
parent 03d37330e2
commit 22cc0e6900
  1. 7
      selfdrive/car/gm/interface.py
  2. 10
      selfdrive/controls/lib/drive_helpers.py

@ -218,9 +218,14 @@ class CarInterface(CarInterfaceBase):
ret.buttonEvents = buttonEvents ret.buttonEvents = buttonEvents
# The ECM allows enabling on falling edge of set, but only rising edge of resume.
# Override standard behavior and enable on rising edge of resume below
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low, events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low,
GearShifter.eco, GearShifter.manumatic], GearShifter.eco, GearShifter.manumatic],
pcm_enable=self.CP.pcmCruise) pcm_enable=self.CP.pcmCruise, enable_buttons=(ButtonType.decelCruise,))
if not self.CP.pcmCruise:
if any(b.type == ButtonType.accelCruise and b.pressed for b in ret.buttonEvents):
events.add(EventName.buttonEnable)
# Enabling at a standstill with brake is allowed # Enabling at a standstill with brake is allowed
# TODO: verify 17 Volt can enable for the first time at a stop and allow for all GMs # TODO: verify 17 Volt can enable for the first time at a stop and allow for all GMs

@ -56,7 +56,7 @@ class VCruiseHelper:
# if stock cruise is completely disabled, then we can use our own set speed logic # if stock cruise is completely disabled, then we can use our own set speed logic
self._update_v_cruise_non_pcm(CS, enabled, is_metric) self._update_v_cruise_non_pcm(CS, enabled, is_metric)
self.v_cruise_cluster_kph = self.v_cruise_kph self.v_cruise_cluster_kph = self.v_cruise_kph
self.update_button_timers(CS) self.update_button_timers(CS, enabled)
else: else:
self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH
self.v_cruise_cluster_kph = CS.cruiseState.speedCluster * CV.MS_TO_KPH self.v_cruise_cluster_kph = CS.cruiseState.speedCluster * CV.MS_TO_KPH
@ -97,6 +97,10 @@ class VCruiseHelper:
if button_type == ButtonType.accelCruise and cruise_standstill: if button_type == ButtonType.accelCruise and cruise_standstill:
return return
# Don't adjust speed if we've enabled since the button was depressed
if not self.button_change_states[button_type]["enabled"]:
return
v_cruise_delta = v_cruise_delta * (5 if long_press else 1) v_cruise_delta = v_cruise_delta * (5 if long_press else 1)
if long_press and self.v_cruise_kph % v_cruise_delta != 0: # partial interval if long_press and self.v_cruise_kph % v_cruise_delta != 0: # partial interval
self.v_cruise_kph = CRUISE_NEAREST_FUNC[button_type](self.v_cruise_kph / v_cruise_delta) * v_cruise_delta self.v_cruise_kph = CRUISE_NEAREST_FUNC[button_type](self.v_cruise_kph / v_cruise_delta) * v_cruise_delta
@ -109,7 +113,7 @@ class VCruiseHelper:
self.v_cruise_kph = clip(round(self.v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX) self.v_cruise_kph = clip(round(self.v_cruise_kph, 1), V_CRUISE_MIN, V_CRUISE_MAX)
def update_button_timers(self, CS): def update_button_timers(self, CS, enabled):
# increment timer for buttons still pressed # increment timer for buttons still pressed
for k in self.button_timers: for k in self.button_timers:
if self.button_timers[k] > 0: if self.button_timers[k] > 0:
@ -119,7 +123,7 @@ class VCruiseHelper:
if b.type.raw in self.button_timers: if b.type.raw in self.button_timers:
# Start/end timer and store current state on change of button pressed # Start/end timer and store current state on change of button pressed
self.button_timers[b.type.raw] = 1 if b.pressed else 0 self.button_timers[b.type.raw] = 1 if b.pressed else 0
self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill} self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled}
def initialize_v_cruise(self, CS): def initialize_v_cruise(self, CS):
# initializing is handled by the PCM # initializing is handled by the PCM

Loading…
Cancel
Save