Skip to content

Commit

Permalink
GM: disengage on PCM fault
Browse files Browse the repository at this point in the history
  • Loading branch information
vntarasov committed Sep 26, 2018
1 parent a422246 commit 3fd41ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, STOCK_CONTROL_MSGS
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
Expand Down Expand Up @@ -75,8 +76,13 @@ 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
# 2017 Volt: initial engage must be done with "set/-", above ~18mph.
# Then, both "set/-" and "res/+" work at any speed.
# Unless brake pedal was pressed, in which case resume works above ~7mph
# and set works above ~18mph.
# 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
Expand Down Expand Up @@ -191,7 +197,7 @@ 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 = False

Expand Down Expand Up @@ -276,6 +282,8 @@ def update(self, c):
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
if ret.gasPressed:
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
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:
Expand Down

0 comments on commit 3fd41ad

Please sign in to comment.