Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GM: no speed limit to engage #373

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 21 additions & 6 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 @@ -38,6 +39,10 @@ def __init__(self, CP, sendcan=None):
self.can_invalid_count = 0
self.acc_active_prev = 0

# First engagement must be done with "set/-",
# ignore "res/+" until then.
self.allow_resume = False

# *** init the major players ***
canbus = CanBus()
self.CS = CarState(CP, canbus)
Expand Down Expand Up @@ -75,8 +80,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 +201,8 @@ def update(self, c):

# cruise state
ret.cruiseState.available = bool(self.CS.main_on)
cruiseEnabled = self.CS.pcm_acc_status != 0
self.allow_resume &= ret.cruiseState.available
cruiseEnabled = self.CS.pcm_acc_status in [AccState.ACTIVE, AccState.STANDSTILL]
ret.cruiseState.enabled = cruiseEnabled
ret.cruiseState.standstill = False

Expand Down Expand Up @@ -226,10 +237,12 @@ def update(self, c):
be.pressed = False
but = self.CS.prev_cruise_buttons
if but == CruiseButtons.RES_ACCEL:
if not (cruiseEnabled and self.CS.standstill):
be.type = 'accelCruise' # Suppress resume button if we're resuming from stop so we don't adjust speed.
# Suppress resume button if we're resuming from stop so we don't adjust speed.
if self.allow_resume and not (cruiseEnabled and self.CS.standstill):
be.type = 'accelCruise'
elif but == CruiseButtons.DECEL_SET:
be.type = 'decelCruise'
self.allow_resume = True
elif but == CruiseButtons.CANCEL:
be.type = 'cancel'
elif but == CruiseButtons.MAIN:
Expand Down Expand Up @@ -276,6 +289,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