Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honda Radarless: Create&send buttons to camera when engaged. #31022

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e32bfa8
Honda Radarless: Send buttons to camera when engaged vs forwarding or…
csouers Jan 26, 2024
4d0256b
fix that
csouers Jan 26, 2024
8f8d952
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Feb 14, 2024
494a82f
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Feb 22, 2024
803affb
revert. don't think it's needed
csouers Feb 22, 2024
8867288
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Feb 22, 2024
797c879
name
csouers Feb 22, 2024
995a050
comment
csouers Feb 22, 2024
20e0ebd
less. momentary press for auto resume and lkas button
csouers Feb 22, 2024
f4053b0
comment
csouers Feb 22, 2024
4d50ccf
shorter
csouers Feb 22, 2024
aeb4e94
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Mar 21, 2024
c3a138a
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Apr 30, 2024
e62c43c
update these
csouers Apr 30, 2024
6f3fd1b
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers May 2, 2024
bd11479
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers May 3, 2024
209cab0
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Jun 1, 2024
b85baaa
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Jun 11, 2024
9bc79f2
rename
csouers Jun 11, 2024
a21935f
remove LKAS button from CC
csouers Jun 11, 2024
2773f80
rm the rest
csouers Jun 11, 2024
cd4ddf7
Merge remote-tracking branch 'upstream/master' into honda_scm_pr
csouers Jun 11, 2024
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
28 changes: 23 additions & 5 deletions selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from openpilot.common.realtime import DT_CTRL
from opendbc.can.packer import CANPacker
from openpilot.selfdrive.car.honda import hondacan
from openpilot.selfdrive.car.honda.values import CruiseButtons, VISUAL_HUD, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams
from openpilot.selfdrive.car.honda.values import CruiseButtons, CruiseSettings, VISUAL_HUD, HONDA_BOSCH, HONDA_BOSCH_RADARLESS, HONDA_NIDEC_ALT_PCM_ACCEL, \
CarControllerParams
from openpilot.selfdrive.car.interfaces import CarControllerBase
from openpilot.selfdrive.controls.lib.drive_helpers import rate_limit

Expand Down Expand Up @@ -203,11 +204,28 @@ def update(self, CC, CS, now_nanos):
if not self.CP.openpilotLongitudinalControl:
if self.frame % 2 == 0 and self.CP.carFingerprint not in HONDA_BOSCH_RADARLESS: # radarless cars don't have supplemental message
can_sends.append(hondacan.create_bosch_supplemental_1(self.packer, self.CAN, self.CP.carFingerprint))
# If using stock ACC, spam cancel command to kill gas when OP disengages.
# Buttons: spam the cancel or resume buttons.
cruise = None
setting = CruiseSettings.NONE
if pcm_cancel_cmd:
can_sends.append(hondacan.spam_buttons_command(self.packer, self.CAN, CruiseButtons.CANCEL, self.CP.carFingerprint))
elif CC.cruiseControl.resume:
can_sends.append(hondacan.spam_buttons_command(self.packer, self.CAN, CruiseButtons.RES_ACCEL, self.CP.carFingerprint))
cruise = CruiseButtons.CANCEL
elif self.CP.carFingerprint not in HONDA_BOSCH_RADARLESS and CC.cruiseControl.resume:
cruise = CruiseButtons.RES_ACCEL
elif self.CP.carFingerprint in HONDA_BOSCH_RADARLESS and CC.enabled and self.frame % 4 == 0:
# Send buttons to the camera when engaged. Only send the LKAS button to turn off stock LKAS off so it can't disengage cruise.
# Priority: pcm_cancel > user > auto resume > turn off lkas > none/idle
cruise = CruiseButtons.NONE
if CS.cruise_buttons or (CS.cruise_setting and CS.cruise_setting != CruiseSettings.LKAS):
cruise = CS.cruise_buttons
setting = CS.cruise_setting
# simulate a momentary press
elif self.frame % 100 <= 25:
if CC.cruiseControl.resume:
cruise = CruiseButtons.RES_ACCEL
elif CS.lkas_hud['ENABLED']:
setting = CruiseSettings.LKAS
if cruise is not None:
can_sends.append(hondacan.create_buttons_command(self.packer, self.CAN, cruise, setting, CS.scm_buttons, self.CP.carFingerprint))

else:
# Send gas and brake commands.
Expand Down
1 change: 1 addition & 0 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def update(self, cp, cp_cam, cp_body):
ret.cruiseState.nonAdaptive = cp_cam.vl["ACC_HUD"]["CRUISE_CONTROL_LABEL"] != 0

if not self.CP.openpilotLongitudinalControl:
self.scm_buttons = cp.vl["SCM_BUTTONS"] if self.CP.carFingerprint in HONDA_BOSCH_RADARLESS else {}
# ACC_HUD is on camera bus on radarless cars
acc_hud = cp_cam.vl["ACC_HUD"] if self.CP.carFingerprint in HONDA_BOSCH_RADARLESS else cp.vl["ACC_HUD"]
ret.cruiseState.nonAdaptive = acc_hud["CRUISE_CONTROL_LABEL"] != 0
Expand Down
15 changes: 11 additions & 4 deletions selfdrive/car/honda/hondacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_
commands.append(packer.make_can_msg("ACC_HUD", CAN.pt, acc_hud_values))

lkas_hud_values = {
'SET_ME_X41': 0x41,
'ENABLED': 1,
Copy link
Contributor

@sshane sshane May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename enabled to something more clear? We have LDW_ON/OFF in the same message. Is ENABLED meant to be LKAS active or just enabled?

Copy link
Contributor Author

@csouers csouers May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just enabled. available or ready might be a good alternative.

'SET_ME_X20': 0x20,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this maintain both MSB 30 and LDW_OFF at MSB 27?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are still just for LKAS. I will rename ENABLED.

'STEERING_REQUIRED': hud.steer_required,
'SOLID_LANES': hud.lanes_visible,
'BEEP': 0,
Expand Down Expand Up @@ -201,11 +202,17 @@ def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_
return commands


def spam_buttons_command(packer, CAN, button_val, car_fingerprint):
def create_buttons_command(packer, CAN, button_val, setting_val, stock_scm_buttons, car_fingerprint):
values = {
'CRUISE_BUTTONS': button_val,
'CRUISE_SETTING': 0,
'CRUISE_BUTTONS': button_val
}
# Radarless: set CRUISE_SETTING & forward unmodified data bits
if len(stock_scm_buttons):
values.update({
'CRUISE_SETTING': setting_val,
'BOH_1': stock_scm_buttons['BOH_1'],
'BOH_2': stock_scm_buttons['BOH_2'],
})
# send buttons to camera on radarless cars
bus = CAN.camera if car_fingerprint in HONDA_BOSCH_RADARLESS else CAN.pt
return packer.make_can_msg("SCM_BUTTONS", bus, values)
2 changes: 2 additions & 0 deletions selfdrive/car/honda/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ class CruiseButtons:
DECEL_SET = 3
CANCEL = 2
MAIN = 1
NONE = 0


class CruiseSettings:
DISTANCE = 3
LKAS = 1
NONE = 0


# See dbc files for info on values
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/tests/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CarTestRoute(NamedTuple):
CarTestRoute("f34a60d68d83b1e5|2020-10-06--14-35-55", HONDA.ACURA_RDX),
CarTestRoute("54fd8451b3974762|2021-04-01--14-50-10", HONDA.HONDA_RIDGELINE),
CarTestRoute("2d5808fae0b38ac6|2021-09-01--17-14-11", HONDA.HONDA_E),
CarTestRoute("f44aa96ace22f34a|2021-12-22--06-22-31", HONDA.HONDA_CIVIC_2022),
CarTestRoute("f44aa96ace22f34a|2021-12-22--06-22-31", HONDA.HONDA_CIVIC_2022), # TODO: Replace with route where OP sends buttons to the cam when engaged

CarTestRoute("87d7f06ade479c2e|2023-09-11--23-30-11", HYUNDAI.HYUNDAI_AZERA_6TH_GEN),
CarTestRoute("66189dd8ec7b50e6|2023-09-20--07-02-12", HYUNDAI.HYUNDAI_AZERA_HEV_6TH_GEN),
Expand Down
Loading