Skip to content

Commit 1067a18

Browse files
Honda: Car Port for Clarity 2018-22 (commaai#154)
* Fork * Revert "Fork" This reverts commit a10cb9677bcaf42010314b04d37dcb2e96b92057. * I think this is it, to be tested. * Correct panda * update panda * Revert "update panda" This reverts commit 09d7cc9330c81528d355a4cea59be66d4106ae2b. * Revert "Correct panda" This reverts commit aa052a52e7895390753aa9c7feba0e47a933457c. * Update sunnypilot_carname.json * bump panda * sort * formatting * could break OP long cars * simpler * separate * missed * format * cleaner * bump panda * Clarity is not in HONDA_BOSCH_RADARLESS * match * update MY in docs * format * format * Update CHANGELOGS.md --------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
1 parent 5351d6f commit 1067a18

File tree

8 files changed

+78
-8
lines changed

8 files changed

+78
-8
lines changed

CHANGELOGS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
sunnypilot - 0.9.2.x (2023-02-22)
2+
========================
3+
* Honda Clarity 2018-22 support thanks to mcallbosco, vanillagorillaa and wirelessnet2!
4+
15
sunnypilot - Version Latest (2023-02-22)
26
========================
37
* UPDATED: Synced with commaai's master branch - 2023.02.19-04:52:00:GMT - 0.9.2

panda

Submodule panda updated from 7a02545 to d17249e

selfdrive/car/honda/carstate.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
7777
signals.append(("BRAKE_PRESSED", "BRAKE_MODULE"))
7878
checks.append(("BRAKE_MODULE", 50))
7979

80-
if CP.carFingerprint in (HONDA_BOSCH | {CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN}):
80+
if CP.carFingerprint in (HONDA_BOSCH | {CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN, CAR.CLARITY}):
8181
signals.append(("EPB_STATE", "EPB_STATUS"))
8282
checks.append(("EPB_STATUS", 50))
8383

@@ -124,6 +124,12 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
124124
if CP.carFingerprint in HONDA_BOSCH_RADARLESS:
125125
signals.append(("CRUISE_FAULT", "CRUISE_FAULT_STATUS"))
126126
checks.append(("CRUISE_FAULT_STATUS", 50))
127+
elif CP.carFingerprint == CAR.CLARITY:
128+
signals += [
129+
("BRAKE_ERROR_1", "BRAKE_ERROR"),
130+
("BRAKE_ERROR_2", "BRAKE_ERROR")
131+
]
132+
checks.append(("BRAKE_ERROR", 100)),
127133
elif CP.openpilotLongitudinalControl:
128134
signals += [
129135
("BRAKE_ERROR_1", "STANDSTILL"),
@@ -197,6 +203,8 @@ def update(self, cp, cp_cam, cp_body):
197203

198204
if self.CP.carFingerprint in HONDA_BOSCH_RADARLESS:
199205
self.brake_error = cp.vl["CRUISE_FAULT_STATUS"]["CRUISE_FAULT"]
206+
elif self.CP.carFingerprint == CAR.CLARITY:
207+
self.brake_error = cp.vl["BRAKE_ERROR"]["BRAKE_ERROR_1"] or cp.vl["BRAKE_ERROR"]["BRAKE_ERROR_2"]
200208
elif self.CP.openpilotLongitudinalControl:
201209
self.brake_error = cp.vl["STANDSTILL"]["BRAKE_ERROR_1"] or cp.vl["STANDSTILL"]["BRAKE_ERROR_2"]
202210
ret.espDisabled = cp.vl["VSA_STATUS"]["ESP_DISABLED"] != 0
@@ -227,7 +235,7 @@ def update(self, cp, cp_cam, cp_body):
227235
ret.brakeHoldActive = cp.vl["VSA_STATUS"]["BRAKE_HOLD_ACTIVE"] == 1
228236

229237
# TODO: set for all cars
230-
if self.CP.carFingerprint in (HONDA_BOSCH | {CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN}):
238+
if self.CP.carFingerprint in (HONDA_BOSCH | {CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN, CAR.CLARITY}):
231239
ret.parkingBrake = cp.vl["EPB_STATUS"]["EPB_STATE"] != 0
232240

233241
gear = int(cp.vl[self.gearbox_msg]["GEAR_SHIFTER"])
@@ -297,7 +305,8 @@ def update(self, cp, cp_cam, cp_body):
297305
if self.CP.carFingerprint not in HONDA_BOSCH_RADARLESS:
298306
ret.stockAeb = (not self.CP.openpilotLongitudinalControl) and bool(cp.vl["ACC_CONTROL"]["AEB_STATUS"] and cp.vl["ACC_CONTROL"]["ACCEL_COMMAND"] < -1e-5)
299307
else:
300-
ret.stockAeb = bool(cp_cam.vl["BRAKE_COMMAND"]["AEB_REQ_1"] and cp_cam.vl["BRAKE_COMMAND"]["COMPUTER_BRAKE"] > 1e-5)
308+
aeb_sig = "COMPUTER_BRAKE_ALT" if self.CP.carFingerprint == CAR.CLARITY else "COMPUTER_BRAKE"
309+
ret.stockAeb = bool(cp_cam.vl["BRAKE_COMMAND"]["AEB_REQ_1"] and cp_cam.vl["BRAKE_COMMAND"][aeb_sig] > 1e-5)
301310

302311
self.acc_hud = False
303312
self.lkas_hud = False
@@ -338,7 +347,8 @@ def get_cam_can_parser(CP):
338347
checks.append(("ACC_HUD", 10))
339348

340349
elif CP.carFingerprint not in HONDA_BOSCH:
341-
signals += [("COMPUTER_BRAKE", "BRAKE_COMMAND"),
350+
aeb_sig = "COMPUTER_BRAKE_ALT" if CP.carFingerprint == CAR.CLARITY else "COMPUTER_BRAKE"
351+
signals += [(aeb_sig, "BRAKE_COMMAND"),
342352
("AEB_REQ_1", "BRAKE_COMMAND"),
343353
("FCW", "BRAKE_COMMAND"),
344354
("CHIME", "BRAKE_COMMAND"),

selfdrive/car/honda/hondacan.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_
3333
pcm_fault_cmd = False
3434

3535
values = {
36-
"COMPUTER_BRAKE": apply_brake,
37-
"BRAKE_PUMP_REQUEST": pump_on,
3836
"CRUISE_OVERRIDE": pcm_override,
3937
"CRUISE_FAULT_CMD": pcm_fault_cmd,
4038
"CRUISE_CANCEL_CMD": pcm_cancel_cmd,
@@ -47,6 +45,14 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_
4745
"AEB_REQ_2": 0,
4846
"AEB_STATUS": 0,
4947
}
48+
49+
if car_fingerprint == CAR.CLARITY:
50+
values["COMPUTER_BRAKE_ALT"] = apply_brake
51+
values["BRAKE_PUMP_REQUEST_ALT"] = apply_brake > 0
52+
else:
53+
values["COMPUTER_BRAKE"] = apply_brake
54+
values["BRAKE_PUMP_REQUEST"] = pump_on
55+
5056
bus = get_pt_bus(car_fingerprint)
5157
return packer.make_can_msg("BRAKE_COMMAND", bus, values)
5258

selfdrive/car/honda/interface.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,26 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
272272
tire_stiffness_factor = 0.82
273273
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] # TODO: can probably use some tuning
274274

275+
elif candidate == CAR.CLARITY:
276+
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_CLARITY
277+
ret.mass = 4052. * CV.LB_TO_KG + STD_CARGO_KG
278+
ret.wheelbase = 2.75
279+
ret.centerToFront = ret.wheelbase * 0.4
280+
ret.steerRatio = 16.50 # 12.72 is end-to-end spec
281+
if eps_modified:
282+
for fw in car_fw:
283+
if fw.ecu == "eps" and b"-" not in fw.fwVersion and b"," in fw.fwVersion:
284+
ret.lateralTuning.pid.kf = 0.00004
285+
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 0xA00, 0x3C00], [0, 2560, 3840]]
286+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.1575], [0.05175]]
287+
elif fw.ecu == "eps" and b"-" in fw.fwVersion and b"," in fw.fwVersion:
288+
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 0xA00, 0x2800], [0, 2560, 3840]]
289+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]]
290+
else:
291+
ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560], [0, 2560]]
292+
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]]
293+
tire_stiffness_factor = 1.
294+
275295
else:
276296
raise ValueError(f"unsupported car {candidate}")
277297

@@ -292,7 +312,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
292312
# min speed to enable ACC. if car can do stop and go, then set enabling speed
293313
# to a negative value, so it won't matter. Otherwise, add 0.5 mph margin to not
294314
# conflict with PCM acc
295-
stop_and_go = candidate in (HONDA_BOSCH | {CAR.CIVIC}) or ret.enableGasInterceptor
315+
stop_and_go = candidate in (HONDA_BOSCH | {CAR.CIVIC, CAR.CLARITY}) or ret.enableGasInterceptor
296316
ret.minEnableSpeed = -1. if stop_and_go else 25.5 * CV.MPH_TO_MS
297317

298318
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by

selfdrive/car/honda/values.py

+28
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class CAR:
9696
RIDGELINE = "HONDA RIDGELINE 2017"
9797
INSIGHT = "HONDA INSIGHT 2019"
9898
HONDA_E = "HONDA E 2020"
99+
CLARITY = "HONDA CLARITY 2018"
99100

100101

101102
class Footnote(Enum):
@@ -151,6 +152,7 @@ def init_make(self, CP: car.CarParams):
151152
CAR.RIDGELINE: HondaCarInfo("Honda Ridgeline 2017-23", min_steer_speed=12. * CV.MPH_TO_MS),
152153
CAR.INSIGHT: HondaCarInfo("Honda Insight 2019-22", "All", min_steer_speed=3. * CV.MPH_TO_MS),
153154
CAR.HONDA_E: HondaCarInfo("Honda e 2020", "All", min_steer_speed=3. * CV.MPH_TO_MS),
155+
CAR.CLARITY: HondaCarInfo("Honda Clarity 2018-22"),
154156
}
155157

156158
HONDA_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
@@ -1553,6 +1555,31 @@ def init_make(self, CP: car.CarParams):
15531555
b'37805-64D-P510\x00\x00',
15541556
],
15551557
},
1558+
CAR.CLARITY: {
1559+
(Ecu.shiftByWire, 0x18da0bf1, None): [
1560+
b'54008-TRW-A910\x00\x00',
1561+
],
1562+
(Ecu.vsa, 0x18da28f1, None): [
1563+
b'57114-TRW-A010\x00\x00',
1564+
b'57114-TRW-A020\x00\x00',
1565+
],
1566+
(Ecu.eps, 0x18da30f1, None): [
1567+
b'39990-TRW-A020\x00\x00',
1568+
b'39990-TRW,A020\x00\x00', # modified firmware
1569+
b'39990,TRW,A020\x00\x00', # extra modified firmware
1570+
],
1571+
(Ecu.srs, 0x18da53f1, None): [
1572+
b'77959-TRW-A210\x00\x00',
1573+
b'77959-TRW-A220\x00\x00',
1574+
],
1575+
(Ecu.gateway, 0x18daeff1, None): [
1576+
b'38897-TRW-A010\x00\x00',
1577+
],
1578+
(Ecu.combinationMeter, 0x18da60f1, None): [
1579+
b'78109-TRW-A020\x00\x00',
1580+
b'78109-TRW-A030\x00\x00',
1581+
],
1582+
},
15561583
}
15571584

15581585
DBC = {
@@ -1579,6 +1606,7 @@ def init_make(self, CP: car.CarParams):
15791606
CAR.INSIGHT: dbc_dict('honda_insight_ex_2019_can_generated', None),
15801607
CAR.HONDA_E: dbc_dict('acura_rdx_2020_can_generated', None),
15811608
CAR.CIVIC_2022: dbc_dict('honda_civic_ex_2022_can_generated', None),
1609+
CAR.CLARITY: dbc_dict('honda_clarity_hybrid_2018_can_generated', 'acura_ilx_2016_nidec'),
15821610
}
15831611

15841612
STEER_THRESHOLD = {

selfdrive/car/sunnypilot_carname.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"Honda Civic Hatchback 2017-21": "HONDA CIVIC (BOSCH) 2019",
5656
"Honda Civic Hatchback 2022": "HONDA CIVIC 2022",
5757
"Honda Civic Sedan 1.6 Diesel 2019": "HONDA CIVIC SEDAN 1.6 DIESEL 2019",
58+
"Honda Clarity 2018-22": "HONDA CLARITY 2018",
5859
"Honda CR-V 2015-16": "HONDA CR-V 2016",
5960
"Honda CR-V 2017-22": "HONDA CR-V 2017",
6061
"Honda CR-V EU 2016": "HONDA CR-V EU 2016",

selfdrive/car/torque_data/params.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ HONDA ACCORD 2018: [1.7135052593468778, 0.3461280068322071, 0.21579936052863807]
1515
HONDA ACCORD HYBRID 2018: [1.6651615004829625, 0.30322180951193245, 0.2083000440586149]
1616
HONDA CIVIC (BOSCH) 2019: [1.691708637466905, 0.40132900729454185, 0.25460295304024094]
1717
HONDA CIVIC 2016: [1.6528895627785531, 0.4018518740819229, 0.25458812851328544]
18+
HONDA CLARITY 2018: [1.6528895627785531, 0.4018518740819229, 0.25458812851328544]
1819
HONDA CR-V 2016: [0.7667141440182675, 0.5927571534745969, 0.40909087636157127]
1920
HONDA CR-V 2017: [2.01323205142022, 0.2700612209345081, 0.2238412881331528]
2021
HONDA CR-V HYBRID 2019: [2.072034634644233, 0.7152085160516978, 0.20237105008376083]

0 commit comments

Comments
 (0)