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

24 integra mt #8

Merged
merged 3 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion panda
25 changes: 21 additions & 4 deletions selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,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 = CruiseButtons.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 != CruiseButtons.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 = CruiseButtons.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 @@ -219,6 +219,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,
'SET_ME_X20': 0x20,
'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)
5 changes: 5 additions & 0 deletions selfdrive/car/honda/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class CruiseButtons:
DECEL_SET = 3
CANCEL = 2
MAIN = 1
NONE = 0

# CRUISE_SETTINGS
DISTANCE = 3
LKAS = 1


class CruiseSettings:
Expand Down
Loading