Skip to content

Commit 92a19b2

Browse files
committed
suburban attempt #1
1 parent cc6358d commit 92a19b2

File tree

5 files changed

+113
-83
lines changed

5 files changed

+113
-83
lines changed

panda/board/safety/safety_gm.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ static int gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
109109
// on powertrain bus.
110110
// 384 = ASCMLKASteeringCmd
111111
// 715 = ASCMGasRegenCmd
112-
if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && ((addr == 384) || (addr == 715))) {
112+
// if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && ((addr == 384) || (addr == 715))) {
113+
// relay_malfunction = true;
114+
// }
115+
// comment out ASCM check. this needs to be fixed.
116+
if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && ((addr == 384))) {
113117
relay_malfunction = true;
114118
}
115119
}

selfdrive/car/car_helpers.py

+85-78
Original file line numberDiff line numberDiff line change
@@ -66,85 +66,92 @@ def only_toyota_left(candidate_cars):
6666

6767
# **** for use live only ****
6868
def fingerprint(logcan, sendcan, has_relay):
69-
if has_relay:
70-
# Vin query only reliably works thorugh OBDII
71-
bus = 1
72-
73-
cached_params = Params().get("CarParamsCache")
74-
if cached_params is not None:
75-
cached_params = car.CarParams.from_bytes(cached_params)
76-
if cached_params.carName == "mock":
77-
cached_params = None
78-
79-
if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN:
80-
cloudlog.warning("Using cached CarParams")
81-
vin = cached_params.carVin
82-
car_fw = list(cached_params.carFw)
83-
else:
84-
cloudlog.warning("Getting VIN & FW versions")
85-
_, vin = get_vin(logcan, sendcan, bus)
86-
car_fw = get_fw_versions(logcan, sendcan, bus)
87-
88-
fw_candidates = match_fw_to_car(car_fw)
89-
else:
90-
vin = VIN_UNKNOWN
91-
fw_candidates, car_fw = set(), []
92-
93-
cloudlog.warning("VIN %s", vin)
94-
Params().put("CarVin", vin)
95-
69+
# if has_relay:
70+
# # Vin query only reliably works thorugh OBDII
71+
# bus = 1
72+
73+
# cached_params = Params().get("CarParamsCache")
74+
# if cached_params is not None:
75+
# cached_params = car.CarParams.from_bytes(cached_params)
76+
# if cached_params.carName == "mock":
77+
# cached_params = None
78+
79+
# if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN:
80+
# cloudlog.warning("Using cached CarParams")
81+
# vin = cached_params.carVin
82+
# car_fw = list(cached_params.carFw)
83+
# else:
84+
# cloudlog.warning("Getting VIN & FW versions")
85+
# _, vin = get_vin(logcan, sendcan, bus)
86+
# car_fw = get_fw_versions(logcan, sendcan, bus)
87+
88+
# fw_candidates = match_fw_to_car(car_fw)
89+
# else:
90+
# vin = VIN_UNKNOWN
91+
# fw_candidates, car_fw = set(), []
92+
93+
# cloudlog.warning("VIN %s", vin)
94+
# Params().put("CarVin", vin)
95+
96+
# finger = gen_empty_fingerprint()
97+
# candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1
98+
# frame = 0
99+
# frame_fingerprint = 10 # 0.1s
100+
# car_fingerprint = None
101+
# done = False
102+
103+
# while not done:
104+
# a = messaging.get_one_can(logcan)
105+
106+
# for can in a.can:
107+
# # need to independently try to fingerprint both bus 0 and 1 to work
108+
# # for the combo black_panda and honda_bosch. Ignore extended messages
109+
# # and VIN query response.
110+
# # Include bus 2 for toyotas to disambiguate cars using camera messages
111+
# # (ideally should be done for all cars but we can't for Honda Bosch)
112+
# if can.src in range(0, 4):
113+
# finger[can.src][can.address] = len(can.dat)
114+
# for b in candidate_cars:
115+
# if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \
116+
# can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]:
117+
# candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b])
118+
119+
# # if we only have one car choice and the time since we got our first
120+
# # message has elapsed, exit
121+
# for b in candidate_cars:
122+
# # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
123+
# if only_toyota_left(candidate_cars[b]):
124+
# frame_fingerprint = 100 # 1s
125+
# if len(candidate_cars[b]) == 1:
126+
# if frame > frame_fingerprint:
127+
# # fingerprint done
128+
# car_fingerprint = candidate_cars[b][0]
129+
130+
# # bail if no cars left or we've been waiting for more than 2s
131+
# failed = all(len(cc) == 0 for cc in candidate_cars.values()) or frame > 200
132+
# succeeded = car_fingerprint is not None
133+
# done = failed or succeeded
134+
135+
# frame += 1
136+
137+
# source = car.CarParams.FingerprintSource.can
138+
139+
# # If FW query returns exactly 1 candidate, use it
140+
# if len(fw_candidates) == 1:
141+
# car_fingerprint = list(fw_candidates)[0]
142+
# source = car.CarParams.FingerprintSource.fw
143+
144+
# fixed_fingerprint = os.environ.get('FINGERPRINT', "")
145+
# if len(fixed_fingerprint):
146+
# car_fingerprint = fixed_fingerprint
147+
# source = car.CarParams.FingerprintSource.fixed
148+
149+
# force the SUBURBAN
150+
car_fingerprint = "CHEVROLET SUBURBAN 2019"
96151
finger = gen_empty_fingerprint()
97-
candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1
98-
frame = 0
99-
frame_fingerprint = 10 # 0.1s
100-
car_fingerprint = None
101-
done = False
102-
103-
while not done:
104-
a = messaging.get_one_can(logcan)
105-
106-
for can in a.can:
107-
# need to independently try to fingerprint both bus 0 and 1 to work
108-
# for the combo black_panda and honda_bosch. Ignore extended messages
109-
# and VIN query response.
110-
# Include bus 2 for toyotas to disambiguate cars using camera messages
111-
# (ideally should be done for all cars but we can't for Honda Bosch)
112-
if can.src in range(0, 4):
113-
finger[can.src][can.address] = len(can.dat)
114-
for b in candidate_cars:
115-
if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \
116-
can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]:
117-
candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b])
118-
119-
# if we only have one car choice and the time since we got our first
120-
# message has elapsed, exit
121-
for b in candidate_cars:
122-
# Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
123-
if only_toyota_left(candidate_cars[b]):
124-
frame_fingerprint = 100 # 1s
125-
if len(candidate_cars[b]) == 1:
126-
if frame > frame_fingerprint:
127-
# fingerprint done
128-
car_fingerprint = candidate_cars[b][0]
129-
130-
# bail if no cars left or we've been waiting for more than 2s
131-
failed = all(len(cc) == 0 for cc in candidate_cars.values()) or frame > 200
132-
succeeded = car_fingerprint is not None
133-
done = failed or succeeded
134-
135-
frame += 1
136-
137-
source = car.CarParams.FingerprintSource.can
138-
139-
# If FW query returns exactly 1 candidate, use it
140-
if len(fw_candidates) == 1:
141-
car_fingerprint = list(fw_candidates)[0]
142-
source = car.CarParams.FingerprintSource.fw
143-
144-
fixed_fingerprint = os.environ.get('FINGERPRINT', "")
145-
if len(fixed_fingerprint):
146-
car_fingerprint = fixed_fingerprint
147-
source = car.CarParams.FingerprintSource.fixed
152+
vin = VIN_UNKNOWN
153+
car_fw = []
154+
source = car.CarParams.FingerprintSource.fixed
148155

149156
cloudlog.warning("fingerprinted %s", car_fingerprint)
150157
return car_fingerprint, finger, vin, car_fw, source

selfdrive/car/gm/carcontroller.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from selfdrive.config import Conversions as CV
55
from selfdrive.car import apply_std_steer_torque_limits
66
from selfdrive.car.gm import gmcan
7-
from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS, CanBus
7+
from selfdrive.car.gm.values import DBC, SUPERCRUISE_CARS, NO_ASCM_CARS, CanBus
88
from opendbc.can.packer import CANPacker
99

1010
VisualAlert = car.CarControl.HUDControl.VisualAlert
@@ -116,7 +116,7 @@ def update(self, enabled, CS, frame, actuators, \
116116

117117
### GAS/BRAKE ###
118118

119-
if self.car_fingerprint not in SUPERCRUISE_CARS:
119+
if self.car_fingerprint not in SUPERCRUISE_CARS or self.car_fingerprint not in NO_ASCM_CARS:
120120
# no output if not enabled, but keep sending keepalive messages
121121
# treat pedals as one
122122
final_pedal = actuators.gas - actuators.brake

selfdrive/car/gm/interface.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from selfdrive.config import Conversions as CV
44
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
55
from selfdrive.car.gm.values import CAR, Ecu, ECU_FINGERPRINT, CruiseButtons, \
6-
SUPERCRUISE_CARS, AccState, FINGERPRINTS
6+
SUPERCRUISE_CARS, AccState, FINGERPRINTS, NO_ASCM_CARS
77
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, is_ecu_disconnected, gen_empty_fingerprint
88
from selfdrive.car.interfaces import CarInterfaceBase
99

@@ -29,9 +29,11 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False,
2929
# Presence of a camera on the object bus is ok.
3030
# Have to go to read_only if ASCM is online (ACC-enabled cars),
3131
# or camera is on powertrain bus (LKA cars without ACC).
32+
# TODO: ASCM/cam detection is a MESS. They need to be separated.
3233
ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, Ecu.fwdCamera) or \
3334
has_relay or \
34-
candidate == CAR.CADILLAC_CT6
35+
candidate == CAR.CADILLAC_CT6 or \
36+
candidate in NO_ASCM_CARS
3537
ret.openpilotLongitudinalControl = ret.enableCamera
3638
tire_stiffness_factor = 0.444 # not optimized yet
3739

@@ -103,6 +105,14 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), has_relay=False,
103105
ret.steerRatioRear = 0. # TODO: there is RAS on this car!
104106
ret.centerToFront = ret.wheelbase * 0.465
105107

108+
elif candidate == CAR.SUBURBAN:
109+
ret.minEnableSpeed = -1. # engage speed is decided by pcm
110+
ret.mass = 5808. * CV.LB_TO_KG + STD_CARGO_KG
111+
ret.wheelbase = 3.30
112+
ret.steerRatio = 17.3
113+
ret.steerRatioRear = 0.
114+
ret.centerToFront = ret.wheelbase * 0.4
115+
106116
# TODO: get actual value, for now starting with reasonable value for
107117
# civic and scaling by mass and wheelbase
108118
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)

selfdrive/car/gm/values.py

+9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ class CAR:
1010
MALIBU = "CHEVROLET MALIBU PREMIER 2017"
1111
ACADIA = "GMC ACADIA DENALI 2018"
1212
BUICK_REGAL = "BUICK REGAL ESSENCE 2018"
13+
SUBURBAN = "CHEVROLET SUBURBAN 2019"
1314

1415
SUPERCRUISE_CARS = [CAR.CADILLAC_CT6]
16+
NO_ASCM_CARS = [CAR.SUBURBAN]
1517

1618
class CruiseButtons:
1719
INIT = 0
@@ -78,6 +80,12 @@ def is_eps_status_ok(eps_status, car_fingerprint):
7880
{
7981
190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 338: 6, 340: 6, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8
8082
}],
83+
CAR.SUBURBAN: [
84+
# Fingerprint doesn't matter right now
85+
{
86+
999: 8
87+
}
88+
]
8189
}
8290

8391
STEER_THRESHOLD = 1.0
@@ -94,4 +102,5 @@ def is_eps_status_ok(eps_status, car_fingerprint):
94102
CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
95103
CAR.BUICK_REGAL: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'),
96104
CAR.CADILLAC_CT6: dbc_dict('cadillac_ct6_powertrain', 'cadillac_ct6_object', chassis_dbc='cadillac_ct6_chassis'),
105+
CAR.SUBURBAN: dbc_dict('gm_global_a_powertrain', None, chassis_dbc='gm_global_a_chassis'),
97106
}

0 commit comments

Comments
 (0)