From cb7e96f99d59cc56ac532d4b5e08e03c013cf946 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 10 Jul 2021 13:56:11 -0700 Subject: [PATCH] rename enableCruise -> pcmCruise (#21546) --- cereal | 2 +- selfdrive/car/gm/interface.py | 2 +- selfdrive/car/honda/carcontroller.py | 2 +- selfdrive/car/honda/interface.py | 12 ++++++------ selfdrive/car/interfaces.py | 7 +++---- selfdrive/controls/controlsd.py | 8 ++++---- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cereal b/cereal index b372ab3ae1..2f64d4902e 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit b372ab3ae1a3a1097e1de87e3092ca4b05cd0471 +Subproject commit 2f64d4902eb033d027c4265db33ac8ec91e1e9eb diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index bc2159d8ae..85578cd98e 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -20,7 +20,7 @@ class CarInterface(CarInterfaceBase): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "gm" ret.safetyModel = car.CarParams.SafetyModel.gm - ret.enableCruise = False # stock cruise control is kept off + ret.pcmCruise = False # stock cruise control is kept off # GM port is a community feature # TODO: make a port that uses a car harness and it only intercepts the camera diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index db49706bec..3f43fc5814 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -104,7 +104,7 @@ class CarController(): # Never send cancel command if we never enter cruise state (no cruise if pedal) # Cancel cmd causes brakes to release at a standstill causing grinding - pcm_cancel_cmd = pcm_cancel_cmd and CS.CP.enableCruise + pcm_cancel_cmd = pcm_cancel_cmd and CS.CP.pcmCruise # *** rate limit after the enable check *** self.brake_last = rate_limit(brake, self.brake_last, -2., DT_CTRL) diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index d9e805b4aa..c91b28c8c9 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -135,14 +135,14 @@ class CarInterface(CarInterfaceBase): # WARNING: THIS DISABLES AEB! ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") - ret.enableCruise = not ret.openpilotLongitudinalControl + ret.pcmCruise = not ret.openpilotLongitudinalControl ret.communityFeature = ret.openpilotLongitudinalControl else: ret.safetyModel = car.CarParams.SafetyModel.hondaNidec ret.enableGasInterceptor = 0x201 in fingerprint[0] ret.openpilotLongitudinalControl = True - ret.enableCruise = not ret.enableGasInterceptor + ret.pcmCruise = not ret.enableGasInterceptor ret.communityFeature = ret.enableGasInterceptor if candidate == CAR.CRV_5G: @@ -509,7 +509,7 @@ class CarInterface(CarInterfaceBase): ret.buttonEvents = buttonEvents # events - events = self.create_common_events(ret, pcm_enable=self.CP.enableCruise) + events = self.create_common_events(ret, pcm_enable=self.CP.pcmCruise) if self.CS.brake_error: events.add(EventName.brakeUnavailable) if self.CS.brake_hold and self.CS.CP.openpilotLongitudinalControl: @@ -517,12 +517,12 @@ class CarInterface(CarInterfaceBase): if self.CS.park_brake: events.add(EventName.parkBrake) - if self.CP.enableCruise and ret.vEgo < self.CP.minEnableSpeed: + if self.CP.pcmCruise and ret.vEgo < self.CP.minEnableSpeed: events.add(EventName.belowEngageSpeed) # it can happen that car cruise disables while comma system is enabled: need to # keep braking if needed or if the speed is very low - if self.CP.enableCruise and not ret.cruiseState.enabled \ + if self.CP.pcmCruise and not ret.cruiseState.enabled \ and (c.actuators.brake <= 0. or not self.CP.openpilotLongitudinalControl): # non loud alert if cruise disables below 25mph as expected (+ a little margin) if ret.vEgo < self.CP.minEnableSpeed + 2.: @@ -537,7 +537,7 @@ class CarInterface(CarInterfaceBase): # do enable on both accel and decel buttons if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: - if not self.CP.enableCruise: + if not self.CP.pcmCruise: events.add(EventName.buttonEnable) # do disable on button down diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 32fb34c97a..34c6c5a543 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -69,12 +69,11 @@ class CarInterfaceBase(): ret.steerMaxV = [1.] ret.minSteerSpeed = 0. - # stock ACC by default - ret.enableCruise = True - ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this + ret.pcmCruise = True # openpilot's state is tied to the PCM's cruise state on most cars + ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this ret.steerRatioRear = 0. # no rear steering, at least on the listed cars aboveA ret.gasMaxBP = [0.] - ret.gasMaxV = [.5] # half max brake + ret.gasMaxV = [.5] # half max brake ret.brakeMaxBP = [0.] ret.brakeMaxV = [1.] ret.openpilotLongitudinalControl = False diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 51000e8e35..5f9921ac47 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -356,9 +356,9 @@ class Controls: self.v_cruise_kph_last = self.v_cruise_kph # if stock cruise is completely disabled, then we can use our own set speed logic - if not self.CP.enableCruise: + if not self.CP.pcmCruise: self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.enabled) - elif self.CP.enableCruise and CS.cruiseState.enabled: + elif self.CP.pcmCruise and CS.cruiseState.enabled: self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH # decrease the soft disable timer at every step, as it's reset on @@ -507,7 +507,7 @@ class Controls: CC.actuators = actuators CC.cruiseControl.override = True - CC.cruiseControl.cancel = not self.CP.enableCruise or (not self.enabled and CS.cruiseState.enabled) + CC.cruiseControl.cancel = not self.CP.pcmCruise or (not self.enabled and CS.cruiseState.enabled) if self.joystick_mode and self.sm.rcv_frame['testJoystick'] > 0 and self.sm['testJoystick'].buttons[0]: CC.cruiseControl.cancel = True @@ -516,7 +516,7 @@ class Controls: # brake discount removes a sharp nonlinearity brake_discount = (1.0 - clip(actuators.brake * 3., 0.0, 1.0)) speed_override = max(0.0, (self.LoC.v_pid + CS.cruiseState.speedOffset) * brake_discount) - CC.cruiseControl.speedOverride = float(speed_override if self.CP.enableCruise else 0.0) + CC.cruiseControl.speedOverride = float(speed_override if self.CP.pcmCruise else 0.0) CC.cruiseControl.accelOverride = float(self.CI.calc_accel_override(CS.aEgo, self.a_target, CS.vEgo, self.v_target))