Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
6328390
Switch to ECMPRDNL2 for GM gear
JMPZ11 Jun 7, 2022
7350e9f
Removing manumatic gear #
JMPZ11 Jun 7, 2022
ad38808
values.py almost complete
JMPZ11 Jun 15, 2022
ddc36f9
Silverado and Bolt EUV val and CP
JMPZ11 Jun 15, 2022
8ec0e23
GM controller updated
JMPZ11 Jun 15, 2022
ffd1c9b
Cam hrns supp done (in theory)
JMPZ11 Jun 16, 2022
fe37111
cleanup for new cars
JMPZ11 Jun 16, 2022
c568b6c
Remove extra constant
JMPZ11 Jun 16, 2022
90394e8
WS, etc cleanup
JMPZ11 Jun 16, 2022
1c22cb9
Merge remote-tracking branch 'upstream/master' into gm-new-gears
JMPZ11 Jun 16, 2022
4c7a5e6
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 16, 2022
e90135f
removing the unused
JMPZ11 Jun 16, 2022
506b801
Merge branch 'gm-new-gears' into gm-silverado-wip
JMPZ11 Jun 16, 2022
8a1da4a
Fix kpBP typo
JMPZ11 Jun 16, 2022
cd98185
Updated docs
JMPZ11 Jun 16, 2022
2c1b33e
Skip's PIF tune
JMPZ11 Jun 17, 2022
5fda20d
Dropped LKA CAN error patch
JMPZ11 Jun 17, 2022
8db1707
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 18, 2022
2115ba6
Add silverado sigmoid ff
JMPZ11 Jun 18, 2022
2bf8cc4
CAN Err & LKA latch patch
JMPZ11 Jun 19, 2022
db39f5e
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 20, 2022
5c95a5b
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 20, 2022
2d85347
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 21, 2022
b9ca4d2
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 21, 2022
472e151
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
JMPZ11 Jun 27, 2022
fc8ff76
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
sshane Aug 3, 2022
a11d15c
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
sshane Aug 8, 2022
e0d4c82
Remove EPS fault fix (another PR)
sshane Aug 8, 2022
df40883
Remove Silverado (another PR)
sshane Aug 8, 2022
34fac56
clean up some common params
sshane Aug 8, 2022
21b76a3
Remove Escalade FP
sshane Aug 8, 2022
27b23bc
comment
sshane Aug 8, 2022
0666db0
Premier is just a trim
sshane Aug 9, 2022
c45bc8c
no footnote: new Bolt is like most other cars, older GM were outliers…
sshane Aug 9, 2022
a437afe
clean up
sshane Aug 9, 2022
e140546
bump panda
sshane Aug 9, 2022
1f8e5ad
bump panda
sshane Aug 9, 2022
9364198
bump panda
sshane Aug 10, 2022
fa0d967
bump panda
sshane Aug 10, 2022
346bd81
bump panda
sshane Aug 10, 2022
53dc101
remove comments
sshane Aug 10, 2022
96e4b39
try spamming buttons on bus 2
sshane Aug 10, 2022
f822cab
bump panda
sshane Aug 10, 2022
6af1f0b
bumping opendbc w btn rc
JMPZ11 Aug 10, 2022
70c1783
not needed for this port
sshane Aug 10, 2022
98f50d8
add button safety
sshane Aug 10, 2022
4e2fe3e
Send next rc when spamming btns
JMPZ11 Aug 10, 2022
44934e2
forward other signals in message
sshane Aug 10, 2022
10eff13
missing DriveModeButton
sshane Aug 10, 2022
66f5d12
fill cruiseState.speed
sshane Aug 10, 2022
6b1e2aa
see if resume works without counter
sshane Aug 10, 2022
d612707
try the whole message
sshane Aug 11, 2022
0d33dad
send immediately and at 10Hz
sshane Aug 11, 2022
3857788
no resume, back to just button signal
sshane Aug 11, 2022
483ad71
even holding random buttons it cancels
sshane Aug 11, 2022
1ceea6d
Use torque controller with base tune
sshane Aug 11, 2022
07f13b9
stock long GM don't auto-resume yet
sshane Aug 11, 2022
e8c5a83
Testing GM zero min steer speed
JMPZ11 Aug 11, 2022
5cd2312
Revert latcontrol
sshane Aug 11, 2022
e5e525b
revert opendbc
sshane Aug 11, 2022
ab9b4f7
latActive is basically lkas_enabled
sshane Aug 11, 2022
d3a07df
Update Bolt torque params
sshane Aug 11, 2022
79c88fe
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
sshane Aug 11, 2022
d3c724f
comment
sshane Aug 11, 2022
7b54c44
clean up
sshane Aug 11, 2022
3104512
Add to releases
sshane Aug 11, 2022
61816e7
Add test route
sshane Aug 12, 2022
8e9894d
Don't specify segment
sshane Aug 12, 2022
4991f04
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
sshane Aug 12, 2022
4426084
bump panda
sshane Aug 12, 2022
9190d1c
bump panda
sshane Aug 12, 2022
1615026
no harness for Bolt just yet
sshane Aug 12, 2022
aa1d586
Apply suggestions from code review
sshane Aug 12, 2022
9e881ba
We support all and 2023
sshane Aug 12, 2022
f7b1880
move safetyParam up to first cam check
sshane Aug 12, 2022
b590397
Merge remote-tracking branch 'upstream/master' into gm-silverado-wip
sshane Aug 12, 2022
abe714a
Bump panda and update docs
sshane Aug 12, 2022
aab0111
Update RELEASES.md
sshane Aug 12, 2022
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
8 changes: 8 additions & 0 deletions selfdrive/car/docs_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ class Harness(Enum):
hyundai_o = "Hyundai O"
custom = "Developer"
obd_ii = "OBD-II"
gm_cam = "GM Camera"
# TODO: Submit PR for gm cam harness schematic(s), diagrams and board layout(s) to https://github.com/commaai/neo/tree/master/car_harness
# Note: GM cam harness _without low-speed GMLAN support_ is simple and similar to the others
# JJS - I anticipate comma to be able to take over production easily
# It also doesn't make sense for customers to get the Developer harness - they typically don't need the wires
# Note 2: JJS - I anticipate designing a camera harness with a low-speed GMLAN gateway (design borrowed from OBD2 harness),
# unless comma plans to do so
# Note 3: JJS - I anticipate an eventual
nissan_a = "Nissan A"
nissan_b = "Nissan B"
mazda = "Mazda"
Expand Down
18 changes: 11 additions & 7 deletions selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams

VisualAlert = car.CarControl.HUDControl.VisualAlert

GearShifter = car.CarState.GearShifter
TransmissionType = car.CarParams.TransmissionType
NetworkLocation = car.CarParams.NetworkLocation

class CarController:
def __init__(self, dbc_name, CP, VM):
Expand Down Expand Up @@ -61,7 +63,7 @@ def update(self, CC, CS):
can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled))

# Gas/regen and brakes - all at 25Hz
if (self.frame % 4) == 0:
if CS.CP.openpilotLongitudinalControl and (self.frame % 4) == 0:
if not CC.longActive:
# Stock ECU sends max regen when not enabled
self.apply_gas = self.params.MAX_ACC_REGEN
Expand All @@ -76,10 +78,11 @@ def update(self, CC, CS):
near_stop = CC.longActive and (CS.out.vEgo < self.params.NEAR_STOP_BRAKE_PHASE)
# GasRegenCmdActive needs to be 1 to avoid cruise faults. It describes the ACC state, not actuation
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, CanBus.POWERTRAIN, self.apply_gas, idx, CC.enabled, at_full_stop))
# Vehicles with factory camera-based ACC expect friction brake on PT
can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, self.apply_brake, idx, near_stop, at_full_stop))

# Send dashboard UI commands (ACC status), 25hz
if (self.frame % 4) == 0:
if CS.CP.openpilotLongitudinalControl and (self.frame % 4) == 0:
send_fcw = hud_alert == VisualAlert.fcw
can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, CC.enabled,
hud_v_cruise * CV.MS_TO_KPH, hud_control.leadVisible, send_fcw))
Expand All @@ -89,18 +92,18 @@ def update(self, CC, CS):
time_and_headlights_step = 10
tt = self.frame * DT_CTRL

if self.frame % time_and_headlights_step == 0:
if CS.CP.openpilotLongitudinalControl and (not CS.CP.radarOffCan) and (self.frame % time_and_headlights_step) == 0:
idx = (self.frame // time_and_headlights_step) % 4
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE))

speed_and_accelerometer_step = 2
if self.frame % speed_and_accelerometer_step == 0:
if CS.CP.openpilotLongitudinalControl and (not CS.CP.radarOffCan) and self.frame % speed_and_accelerometer_step == 0:
idx = (self.frame // speed_and_accelerometer_step) % 4
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))

if self.frame % self.params.ADAS_KEEPALIVE_STEP == 0:
if CS.CP.openpilotLongitudinalControl and CS.CP.networkLocation == NetworkLocation.gateway and (self.frame % self.params.ADAS_KEEPALIVE_STEP) == 0:
can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN)

# Show green icon when LKA torque is applied, and
Expand All @@ -110,7 +113,8 @@ def update(self, CC, CS):
lka_active = CS.lkas_status == 1
lka_critical = lka_active and abs(actuators.steer) > 0.9
lka_icon_status = (lka_active, lka_critical)
if self.frame % self.params.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last:
# SW_GMLAN not yet on cam harness
if CS.CP.networkLocation != NetworkLocation.fwdCamera and self.frame % self.params.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last:
steer_alert = hud_alert in (VisualAlert.steerRequired, VisualAlert.ldw)
can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert))
self.lka_icon_status_last = lka_icon_status
Expand Down
9 changes: 5 additions & 4 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from opendbc.can.can_define import CANDefine
from opendbc.can.parser import CANParser
from selfdrive.car.interfaces import CarStateBase
from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, STEER_THRESHOLD

from selfdrive.car.gm.values import DBC, AccState, CanBus, STEER_THRESHOLD

TransmissionType = car.CarParams.TransmissionType
# TODO: Switch from hardcoded car to CarParams trans
class CarState(CarStateBase):
def __init__(self, CP):
super().__init__(CP)
Expand Down Expand Up @@ -35,7 +36,7 @@ def update(self, pt_cp, loopback_cp):
ret.brakePressed = pt_cp.vl["EBCMBrakePedalPosition"]["BrakePedalPosition"] >= 10

# Regen braking is braking
if self.car_fingerprint == CAR.VOLT:
if self.CP.transmissionType == TransmissionType.direct:
ret.brakePressed = ret.brakePressed or pt_cp.vl["EBCMRegenPaddle"]["RegenPaddle"] != 0

ret.gas = pt_cp.vl["AcceleratorPedal2"]["AcceleratorPedal2"] / 254.
Expand Down Expand Up @@ -120,7 +121,7 @@ def get_can_parser(CP):
("EBCMBrakePedalPosition", 100),
]

if CP.carFingerprint == CAR.VOLT:
if CP.transmissionType == TransmissionType.direct:
signals.append(("RegenPaddle", "EBCMRegenPaddle"))
checks.append(("EBCMRegenPaddle", 50))

Expand Down
70 changes: 62 additions & 8 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from cereal import car
from math import fabs
from panda import Panda

from common.conversions import Conversions as CV
from selfdrive.car import STD_CARGO_KG, create_button_enable_events, create_button_event, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
Expand All @@ -9,10 +10,13 @@

ButtonType = car.CarState.ButtonEvent.Type
EventName = car.CarEvent.EventName
GearShifter = car.CarState.GearShifter
TransmissionType = car.CarParams.TransmissionType
NetworkLocation = car.CarParams.NetworkLocation
BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.DECEL_SET: ButtonType.decelCruise,
CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel}


GM_PARAM_HW_CAM = 1
class CarInterface(CarInterfaceBase):
@staticmethod
def get_pid_accel_limits(CP, current_speed, cruise_speed):
Expand Down Expand Up @@ -45,7 +49,10 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
ret.carName = "gm"
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.gm)]
ret.pcmCruise = False # stock cruise control is kept off
ret.pcmCruise = False # For ASCM, stock cruise control is kept off (but not ACC)
ret.radarOffCan = False # For ASCM, radar is expected
ret.transmissionType = TransmissionType.automatic # or direct for EV
ret.networkLocation = NetworkLocation.gateway # or fwdCamera

# These cars have been put into dashcam only due to both a lack of users and test coverage.
# These cars likely still work fine. Once a user confirms each car works and a test route is
Expand All @@ -55,7 +62,8 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa
# Presence of a camera on the object bus is ok.
# Have to go to read_only if ASCM is online (ACC-enabled cars),
# or camera is on powertrain bus (LKA cars without ACC).
ret.openpilotLongitudinalControl = True
ret.openpilotLongitudinalControl = True # For ASCM, OP performs long

tire_stiffness_factor = 0.444 # not optimized yet

# Start with a baseline tuning for all GM vehicles. Override tuning as needed in each model section below.
Expand All @@ -76,8 +84,11 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa

# supports stop and go, but initial engage must (conservatively) be above 18mph
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
# TODO: Should this be changed to -1?
# Newer cars (that are still ASCM-based) use -1 for minEnableSpeed with the comment "engage speed is decided by pcm"

if candidate == CAR.VOLT:
ret.transmissionType = TransmissionType.direct # EV (or hybrid)
ret.mass = 1607. + STD_CARGO_KG
ret.wheelbase = 2.69
ret.steerRatio = 17.7 # Stock 15.7, LiveParameters
Expand All @@ -90,7 +101,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa
ret.lateralTuning.pid.kiV = [0.]
ret.lateralTuning.pid.kf = 1. # get_steer_feedforward_volt()
ret.steerActuatorDelay = 0.2

elif candidate == CAR.MALIBU:
ret.mass = 1496. + STD_CARGO_KG
ret.wheelbase = 2.83
Expand Down Expand Up @@ -130,11 +141,52 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None, disa
ret.wheelbase = 3.302
ret.steerRatio = 17.3
ret.centerToFront = ret.wheelbase * 0.49

ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[10., 41.0], [10., 41.0]]
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.13, 0.24], [0.01, 0.02]]
ret.lateralTuning.pid.kf = 0.000045
tire_stiffness_factor = 1.0

elif candidate == CAR.SILVERADO:
ret.minEnableSpeed = -1.
ret.mass = 2400. + STD_CARGO_KG
ret.wheelbase = 3.745
ret.steerRatio = 16.3
ret.centerToFront = ret.wheelbase * .49
ret.networkLocation = NetworkLocation.fwdCamera # Uses Cam Harness
ret.radarOffCan = True # No Radar
ret.openpilotLongitudinalControl = False # Stock ACC
ret.pcmCruise = True # CC is on
# Tune
ret.steerRateCost = .4
ret.steerActuatorDelay = 0.11
ret.lateralTuning.pid.kpBP = [[10., 41.0], [10., 41.0]]
ret.lateralTuning.pid.kpV = [0.13, 0.23]

elif candidate == CAR.BOLT_EUV:
ret.transmissionType = TransmissionType.direct # EV (or hybrid)
ret.minEnableSpeed = -1
ret.mass = 1669. + STD_CARGO_KG
ret.wheelbase = 2.675
ret.steerRatio = 16.8 # Not measured
ret.centerToFront = ret.wheelbase * 0.4
ret.networkLocation = NetworkLocation.fwdCamera # Uses Cam Harness
ret.radarOffCan = True # No Radar
ret.openpilotLongitudinalControl = False # Stock ACC
ret.pcmCruise = True # CC is on
# Tune
ret.steerRateCost = 0.5
ret.steerActuatorDelay = 0.
ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[10., 41.0], [10., 41.0]]
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18, 0.275], [0.01, 0.021]]
ret.lateralTuning.pid.kf = 0.0002
tire_stiffness_factor = 1.0

# Set Panda to camera forwarding mode
if ret.networkLocation == NetworkLocation.fwdCamera:
# TODO: Depends on Panda PR #962 (Cam Harness forwarding, stock ACC)
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_GM_HW_CAM

# TODO: get actual value, for now starting with reasonable value for
# civic and scaling by mass and wheelbase
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
Expand All @@ -151,7 +203,7 @@ def _update(self, c):
ret = self.CS.update(self.cp, self.cp_loopback)

ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False

# TODO: Depends on OP PR #24764 (Switch to ECMPRDNL2)
if self.CS.cruise_buttons != self.CS.prev_cruise_buttons and self.CS.prev_cruise_buttons != CruiseButtons.INIT:
be = create_button_event(self.CS.cruise_buttons, self.CS.prev_cruise_buttons, BUTTONS_DICT, CruiseButtons.UNPRESS)

Expand All @@ -160,8 +212,10 @@ def _update(self, c):
be.type = ButtonType.unknown

ret.buttonEvents = [be]

events = self.create_common_events(ret, pcm_enable=False)
# TODO: Depends on
events = self.create_common_events(ret, extra_gears = [GearShifter.sport, GearShifter.low,
GearShifter.eco, GearShifter.manumatic],
pcm_enable=self.CP.pcmCruise)

if ret.vEgo < self.CP.minEnableSpeed:
events.add(EventName.belowEngageSpeed)
Expand All @@ -171,7 +225,7 @@ def _update(self, c):
events.add(car.CarEvent.EventName.belowSteerSpeed)

# handle button presses
events.events.extend(create_button_enable_events(ret.buttonEvents))
events.events.extend(create_button_enable_events(ret.buttonEvents, pcm_cruise=self.CP.pcmCruise))

ret.events = events.to_msg()

Expand Down
Loading