From ac4006d88d7e26746faa2a9c7cf5d9951ff504d7 Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Thu, 6 Sep 2018 01:12:24 -0700 Subject: [PATCH] GM: disengage on PCM fault --- selfdrive/car/gm/carstate.py | 2 +- selfdrive/car/gm/interface.py | 17 ++++++++++++----- selfdrive/car/gm/values.py | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 7c0c63f54631ce..8f873b5331906d 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -5,7 +5,7 @@ from selfdrive.can.parser import CANParser from selfdrive.car.gm.values import DBC, CAR, parse_gear_shifter, \ CruiseButtons, is_eps_status_ok, \ - STEER_THRESHOLD + STEER_THRESHOLD, AccState def get_powertrain_can_parser(CP, canbus): # this function generates lists for signal, messages and initial values diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index ec531d3db85e08..fc4e6ce7f87e13 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -5,7 +5,8 @@ from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.car.gm.values import DBC, CAR -from selfdrive.car.gm.carstate import CarState, CruiseButtons, get_powertrain_can_parser +from selfdrive.car.gm.carstate import CarState, CruiseButtons, \ + AccState, get_powertrain_can_parser try: from selfdrive.car.gm.carcontroller import CarController @@ -78,8 +79,12 @@ def get_params(candidate, fingerprint): std_cargo = 136 if candidate == CAR.VOLT: - # supports stop and go, but initial engage must be above 18mph (which include conservatism) - ret.minEnableSpeed = 18 * CV.MPH_TO_MS + # initial engage must be above ~18mph, and resume + # can happen at any speed, unless brake pedal was pressed, + # in which case resume can only happen above ~7mph. + # TODO: track PCM state to know exactly when set/res are allowed, + # instead of disengaging on a PCM fault. + ret.minEnableSpeed = -1 # kg of standard extra cargo to count for drive, gas, etc... ret.mass = 1607 + std_cargo ret.safetyModel = car.CarParams.SafetyModels.gm @@ -194,9 +199,9 @@ def update(self, c): # cruise state ret.cruiseState.available = bool(self.CS.main_on) - cruiseEnabled = self.CS.pcm_acc_status != 0 + cruiseEnabled = self.CS.pcm_acc_status in [AccState.ACTIVE, AccState.STANDSTILL] ret.cruiseState.enabled = cruiseEnabled - ret.cruiseState.standstill = self.CS.pcm_acc_status == 4 + ret.cruiseState.standstill = self.CS.pcm_acc_status == AccState.STANDSTILL ret.leftBlinker = self.CS.left_blinker_on ret.rightBlinker = self.CS.right_blinker_on @@ -281,6 +286,8 @@ def update(self, c): events.append(create_event('pedalPressed', [ET.PRE_ENABLE])) if ret.cruiseState.standstill: events.append(create_event('resumeRequired', [ET.WARNING])) + if self.CS.pcm_acc_status == AccState.FAULTED: + events.append(create_event('speedTooLow', [ET.NO_ENTRY, ET.IMMEDIATE_DISABLE])) # handle button presses for b in ret.buttonEvents: diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index b69109f356735d..1a238725188110 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -12,6 +12,12 @@ class CruiseButtons: MAIN = 5 CANCEL = 6 +class AccState: + OFF = 0 + ACTIVE = 1 + FAULTED = 3 + STANDSTILL = 4 + def is_eps_status_ok(eps_status, car_fingerprint): valid_eps_status = [] if car_fingerprint == CAR.VOLT: