Honda: fix brake pressed signal (#23683)

* or brake_switch

* remove car exceptions

* Revert "remove car exceptions"

This reverts commit cad6a552aa4a17c69616014d3e9333d30c1fadd3.

* does have ts noise, use updated

* bump panda for tests

* bump

* messsssy draft

* clean up

* clean up

* bump

* CS: process all messages at once, like we do during real openpilot usage

* handle multiple messages updated in one cycle

* bump

* bump

* use less confusing, but equivalent cp.vl

* Update selfdrive/test/test_models.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* no msg

* bump opendbc

* Update selfdrive/car/honda/carstate.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* same test logic

* add brake_switch_prev to class

* need to set previous brake switch when not lagging (most of the time)

* need to compare

* only update previous if updated this cycle

rm

* need to maintain previous active state

* move brake_switch

* bump opendbc

* bump

* bump

* bump

* bump

* bump

* bump

* bump opendbc

* rename

* oops

* bump opendbc

* bump

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 209bfe536b
commatwo_master
Shane Smiskol 3 years ago committed by GitHub
parent 1ccf50fb3f
commit 1cd3c05a70
  1. 2
      opendbc
  2. 2
      panda
  3. 20
      selfdrive/car/honda/carstate.py
  4. 2
      selfdrive/test/test_models.py
  5. 8
      selfdrive/test/test_onroad.py

@ -1 +1 @@
Subproject commit 572ab7641bf88b6b156d902c625ca8ad9a9a77be Subproject commit 053a761244d75bcae4ca99684098f3188586832e

@ -1 +1 @@
Subproject commit 2d96ef02df0e591244988739008e5d162da28cd0 Subproject commit ab10c977d20cab4b2e2540c372aedc12170fa25b

@ -163,8 +163,8 @@ class CarState(CarStateBase):
self.steer_status_values = defaultdict(lambda: "UNKNOWN", can_define.dv["STEER_STATUS"]["STEER_STATUS"]) self.steer_status_values = defaultdict(lambda: "UNKNOWN", can_define.dv["STEER_STATUS"]["STEER_STATUS"])
self.brake_error = False self.brake_error = False
self.brake_switch_prev = 0 self.brake_switch_prev = False
self.brake_switch_prev_ts = 0 self.brake_switch_active = False
self.cruise_setting = 0 self.cruise_setting = 0
self.v_cruise_pcm_prev = 0 self.v_cruise_pcm_prev = 0
@ -260,18 +260,20 @@ class CarState(CarStateBase):
else: else:
ret.cruiseState.speed = cp.vl["CRUISE"]["CRUISE_SPEED_PCM"] * CV.KPH_TO_MS ret.cruiseState.speed = cp.vl["CRUISE"]["CRUISE_SPEED_PCM"] * CV.KPH_TO_MS
self.brake_switch = cp.vl["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != 0
if self.CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL: if self.CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL:
ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0 ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0
else: else:
# brake switch has shown some single time step noise, so only considered when # brake switch has shown some single time step noise, so only considered when
# switch is on for at least 2 consecutive CAN samples # switch is on for at least 2 consecutive CAN samples
# panda safety only checks BRAKE_PRESSED signal # brake switch rises earlier than brake pressed but is never 1 when in park
ret.brakePressed = bool(cp.vl["POWERTRAIN_DATA"]["BRAKE_PRESSED"] or brake_switch_vals = cp.vl_all["POWERTRAIN_DATA"]["BRAKE_SWITCH"]
(self.brake_switch and self.brake_switch_prev and cp.ts["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != self.brake_switch_prev_ts)) if len(brake_switch_vals):
brake_switch = cp.vl["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != 0
self.brake_switch_prev = self.brake_switch if len(brake_switch_vals) > 1:
self.brake_switch_prev_ts = cp.ts["POWERTRAIN_DATA"]["BRAKE_SWITCH"] self.brake_switch_prev = brake_switch_vals[-2] != 0
self.brake_switch_active = brake_switch and self.brake_switch_prev
self.brake_switch_prev = brake_switch
ret.brakePressed = (cp.vl["POWERTRAIN_DATA"]["BRAKE_PRESSED"] != 0) or self.brake_switch_active
ret.brake = cp.vl["VSA_STATUS"]["USER_BRAKE"] ret.brake = cp.vl["VSA_STATUS"]["USER_BRAKE"]
ret.cruiseState.enabled = cp.vl["POWERTRAIN_DATA"]["ACC_STATUS"] != 0 ret.cruiseState.enabled = cp.vl["POWERTRAIN_DATA"]["ACC_STATUS"] != 0

@ -220,8 +220,6 @@ class TestCarModel(unittest.TestCase):
if CS.brakePressed and not self.safety.get_brake_pressed_prev(): if CS.brakePressed and not self.safety.get_brake_pressed_prev():
if self.CP.carFingerprint in (HONDA.PILOT, HONDA.PASSPORT, HONDA.RIDGELINE) and CS.brake > 0.05: if self.CP.carFingerprint in (HONDA.PILOT, HONDA.PASSPORT, HONDA.RIDGELINE) and CS.brake > 0.05:
brake_pressed = False brake_pressed = False
if self.CP.carName == "honda" and self.CI.CS.brake_switch:
brake_pressed = False
checks['brakePressed'] += brake_pressed != self.safety.get_brake_pressed_prev() checks['brakePressed'] += brake_pressed != self.safety.get_brake_pressed_prev()
if self.CP.pcmCruise: if self.CP.pcmCruise:

@ -22,7 +22,7 @@ from tools.lib.logreader import LogReader
# Baseline CPU usage by process # Baseline CPU usage by process
PROCS = { PROCS = {
"selfdrive.controls.controlsd": 50.0, "selfdrive.controls.controlsd": 55.0,
"./loggerd": 45.0, "./loggerd": 45.0,
"./locationd": 9.1, "./locationd": 9.1,
"selfdrive.controls.plannerd": 22.6, "selfdrive.controls.plannerd": 22.6,
@ -30,7 +30,7 @@ PROCS = {
"selfdrive.locationd.paramsd": 9.1, "selfdrive.locationd.paramsd": 9.1,
"./camerad": 7.07, "./camerad": 7.07,
"./_sensord": 6.17, "./_sensord": 6.17,
"selfdrive.controls.radard": 5.67, "selfdrive.controls.radard": 7.0,
"./_modeld": 4.48, "./_modeld": 4.48,
"./boardd": 3.63, "./boardd": 3.63,
"./_dmonitoringmodeld": 2.67, "./_dmonitoringmodeld": 2.67,
@ -55,13 +55,13 @@ if EON:
if TICI: if TICI:
PROCS.update({ PROCS.update({
"./loggerd": 70.0, "./loggerd": 70.0,
"selfdrive.controls.controlsd": 28.0, "selfdrive.controls.controlsd": 31.0,
"./camerad": 31.0, "./camerad": 31.0,
"./_ui": 33.0, "./_ui": 33.0,
"selfdrive.controls.plannerd": 11.7, "selfdrive.controls.plannerd": 11.7,
"./_dmonitoringmodeld": 10.0, "./_dmonitoringmodeld": 10.0,
"selfdrive.locationd.paramsd": 5.0, "selfdrive.locationd.paramsd": 5.0,
"selfdrive.controls.radard": 3.6, "selfdrive.controls.radard": 4.5,
"selfdrive.thermald.thermald": 3.87, "selfdrive.thermald.thermald": 3.87,
}) })

Loading…
Cancel
Save