Skip to content

Commit a488442

Browse files
authored
Revert the changes to GM in 0.5.4 (#380) (#386)
* Revert 0.5.4 changes for GM for 18ers * Redo the refactor of stock control msgs * Fixed missing CONTROL_MSGS -> STOCK_CONTROL_MSGS * Remove spacing * Need candidate array idx
1 parent ed69575 commit a488442

File tree

4 files changed

+20
-28
lines changed

4 files changed

+20
-28
lines changed

selfdrive/car/gm/carcontroller.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from selfdrive.boardd.boardd import can_list_to_can_capnp
55
from selfdrive.car import apply_std_steer_torque_limits
66
from selfdrive.car.gm import gmcan
7-
from selfdrive.car.gm.values import CAR, DBC, AccState
7+
from selfdrive.car.gm.values import CAR, DBC
88
from selfdrive.can.packer import CANPacker
99

1010

@@ -29,11 +29,11 @@ def __init__(self, car_fingerprint):
2929
self.ADAS_KEEPALIVE_STEP = 10
3030
# pedal lookups, only for Volt
3131
MAX_GAS = 3072 # Only a safety limit
32-
self.ZERO_GAS = 2048
32+
ZERO_GAS = 2048
3333
MAX_BRAKE = 350 # Should be around 3.5m/s^2, including regen
3434
self.MAX_ACC_REGEN = 1404 # ACC Regen braking is slightly less powerful than max regen paddle
3535
self.GAS_LOOKUP_BP = [-0.25, 0., 0.5]
36-
self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, self.ZERO_GAS, MAX_GAS]
36+
self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS]
3737
self.BRAKE_LOOKUP_BP = [-1., -0.25]
3838
self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0]
3939

@@ -83,6 +83,7 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
8383
return
8484

8585
P = self.params
86+
8687
# Send CAN commands.
8788
can_sends = []
8889
canbus = self.canbus
@@ -130,18 +131,12 @@ def update(self, sendcan, enabled, CS, frame, actuators, \
130131
if (frame % 4) == 0:
131132
idx = (frame / 4) % 4
132133

133-
car_stopping = apply_gas < P.ZERO_GAS
134-
standstill = CS.pcm_acc_status == AccState.STANDSTILL
135-
at_full_stop = enabled and standstill and car_stopping
136-
near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE) and car_stopping
134+
at_full_stop = enabled and CS.standstill
135+
near_stop = enabled and (CS.v_ego < P.NEAR_STOP_BRAKE_PHASE)
137136
can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, canbus.chassis, apply_brake, idx, near_stop, at_full_stop))
138137

139-
# Auto-resume from full stop by resetting ACC control
140-
acc_enabled = enabled
141-
if standstill and not car_stopping:
142-
acc_enabled = False
143-
144-
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, acc_enabled, at_full_stop))
138+
at_full_stop = enabled and CS.standstill
139+
can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, canbus.powertrain, apply_gas, idx, enabled, at_full_stop))
145140

146141
# Send dashboard UI commands (ACC status), 25hz
147142
if (frame % 4) == 0:

selfdrive/car/gm/gmcan.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ def create_gas_regen_command(packer, bus, throttle, idx, acc_engaged, at_full_st
6060

6161
def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_full_stop):
6262

63-
mode = 0x1
64-
if apply_brake > 0:
63+
if apply_brake == 0:
64+
mode = 0x1
65+
else:
6566
mode = 0xa
6667

67-
if near_stop:
68-
mode = 0xb
69-
70-
if at_full_stop:
71-
mode = 0xd
68+
if at_full_stop:
69+
mode = 0xd
70+
# TODO: this is to have GM bringing the car to complete stop,
71+
# but currently it conflicts with OP controls, so turned off.
72+
#elif near_stop:
73+
# mode = 0xb
7274

7375
brake = (0x1000 - apply_brake) & 0xfff
7476
checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff

selfdrive/car/gm/interface.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def update(self, c):
193193
ret.cruiseState.available = bool(self.CS.main_on)
194194
cruiseEnabled = self.CS.pcm_acc_status != 0
195195
ret.cruiseState.enabled = cruiseEnabled
196-
ret.cruiseState.standstill = False
196+
ret.cruiseState.standstill = self.CS.pcm_acc_status == 4
197197

198198
ret.leftBlinker = self.CS.left_blinker_on
199199
ret.rightBlinker = self.CS.right_blinker_on
@@ -276,6 +276,8 @@ def update(self, c):
276276
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
277277
if ret.gasPressed:
278278
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
279+
if ret.cruiseState.standstill:
280+
events.append(create_event('resumeRequired', [ET.WARNING]))
279281

280282
# handle button presses
281283
for b in ret.buttonEvents:

selfdrive/car/gm/values.py

-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ class CruiseButtons:
1212
MAIN = 5
1313
CANCEL = 6
1414

15-
class AccState:
16-
OFF = 0
17-
ACTIVE = 1
18-
FAULTED = 3
19-
STANDSTILL = 4
20-
2115
def is_eps_status_ok(eps_status, car_fingerprint):
2216
valid_eps_status = []
2317
if car_fingerprint == CAR.VOLT:
@@ -55,7 +49,6 @@ def parse_gear_shifter(can_gear):
5549

5650
STEER_THRESHOLD = 1.0
5751

58-
5952
STOCK_CONTROL_MSGS = {
6053
CAR.VOLT: [384, 715], # 384 = "ASCMLKASteeringCmd", 715 = "ASCMGasRegenCmd"
6154
CAR.CADILLAC_CT6: [], # Cadillac does not require ASCMs to be disconnected

0 commit comments

Comments
 (0)