Skip to content

Commit

Permalink
Merge branch 'commaai:master' into secoc-long
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispypatt authored Dec 31, 2024
2 parents 95573ec + 309f5a4 commit fc029da
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 29 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/update-cars-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update CARS.md

on:
schedule:
- cron: '0 8 * * *' # 12am PST (8am UTC)
workflow_dispatch:

jobs:
update-cars:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Generate Car Docs
run: |
pip install -e .
scons -c && scons -j$(nproc)
python -m pip install jinja2==3.1.4 natsort==8.4.0
python opendbc/car/docs.py
- uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
with:
commit_message: 'docs: Scheduled auto-update CARS.md'
file_pattern: 'docs/CARS.md'

2 changes: 1 addition & 1 deletion docs/CARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
|Volkswagen|Teramont 2018-22|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Teramont Cross Sport 2021-22|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Teramont X 2021-22|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Tiguan 2018-24|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Tiguan 2018-23|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Tiguan eHybrid 2021-23|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|
|Volkswagen|Touran 2016-23|Adaptive Cruise Control (ACC) & Lane Assist|[Upstream](#upstream)|

Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_all_footnotes() -> dict[Enum, int]:
return {fn: idx + 1 for idx, fn in enumerate(all_footnotes)}


def build_sorted_car_docs_list(platforms, footnotes=None, include_dashcam=False, include_custom=False):
def build_sorted_car_docs_list(platforms, footnotes=None, include_dashcam=False):
collected_car_docs: list[CarDocs | ExtraCarDocs] = []
for model, platform in platforms.items():
car_docs = platform.config.car_docs
Expand Down Expand Up @@ -70,7 +70,7 @@ def get_all_car_docs() -> list[CarDocs]:


def get_car_docs_with_extras() -> list[CarDocs | ExtraCarDocs]:
sorted_list: list[CarDocs] = build_sorted_car_docs_list(EXTRA_PLATFORMS, include_custom=True, include_dashcam=True)
sorted_list: list[CarDocs] = build_sorted_car_docs_list(EXTRA_PLATFORMS, include_dashcam=True)
return sorted_list


Expand Down
5 changes: 2 additions & 3 deletions opendbc/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def update(self, CC, CS, now_nanos):
can_sends.append(make_tester_present_msg(0x18DAB0F1, 1, suppress_response=True))

# Send steering command.
can_sends.append(hondacan.create_steering_control(self.packer, self.CAN, apply_steer, CC.latActive, self.CP.carFingerprint,
CS.CP.openpilotLongitudinalControl))
can_sends.append(hondacan.create_steering_control(self.packer, self.CAN, apply_steer, CC.latActive))

# wind brake from air resistance decel at high speed
wind_brake = interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15])
Expand Down Expand Up @@ -194,7 +193,7 @@ 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))
can_sends.append(hondacan.create_bosch_supplemental_1(self.packer, self.CAN))
# If using stock ACC, spam cancel command to kill gas when OP disengages.
if pcm_cancel_cmd:
can_sends.append(hondacan.spam_buttons_command(self.packer, self.CAN, CruiseButtons.CANCEL, self.CP.carFingerprint))
Expand Down
36 changes: 18 additions & 18 deletions opendbc/car/honda/hondacan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def __init__(self, CP=None, fingerprint=None) -> None:

if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS):
self._pt, self._radar = self.offset + 1, self.offset
# normally steering commands are sent to radar, which forwards them to powertrain bus
# when radar is disabled, steering commands are sent directly to powertrain bus
self._lkas = self._pt if CP.openpilotLongitudinalControl else self._radar
else:
self._pt, self._radar = self.offset, self.offset + 1
self._pt, self._radar, self._lkas = self.offset, self.offset + 1, self.offset

@property
def pt(self) -> int:
Expand All @@ -31,14 +34,14 @@ def radar(self) -> int:
def camera(self) -> int:
return self.offset + 2

@property
def lkas(self) -> int:
return self._lkas

def get_lkas_cmd_bus(CAN, car_fingerprint, radar_disabled=False):
no_radar = car_fingerprint in HONDA_BOSCH_RADARLESS
if radar_disabled or no_radar:
# when radar is disabled, steering commands are sent directly to powertrain bus
return CAN.pt
# normally steering commands are sent to radar, which forwards them to powertrain bus
return 0
# B-CAN is forwarded to ACC-CAN radar side (CAN 0 on fake ethernet port)
@property
def body(self) -> int:
return self.offset


def get_cruise_speed_conversion(car_fingerprint: str, is_metric: bool) -> float:
Expand Down Expand Up @@ -114,30 +117,27 @@ def create_acc_commands(packer, CAN, enabled, active, accel, gas, stopping_count
return commands


def create_steering_control(packer, CAN, apply_steer, lkas_active, car_fingerprint, radar_disabled):
def create_steering_control(packer, CAN, apply_steer, lkas_active):
values = {
"STEER_TORQUE": apply_steer if lkas_active else 0,
"STEER_TORQUE_REQUEST": lkas_active,
}
bus = get_lkas_cmd_bus(CAN, car_fingerprint, radar_disabled)
return packer.make_can_msg("STEERING_CONTROL", bus, values)
return packer.make_can_msg("STEERING_CONTROL", CAN.lkas, values)


def create_bosch_supplemental_1(packer, CAN, car_fingerprint):
def create_bosch_supplemental_1(packer, CAN):
# non-active params
values = {
"SET_ME_X04": 0x04,
"SET_ME_X80": 0x80,
"SET_ME_X10": 0x10,
}
bus = get_lkas_cmd_bus(CAN, car_fingerprint)
return packer.make_can_msg("BOSCH_SUPPLEMENTAL_1", bus, values)
return packer.make_can_msg("BOSCH_SUPPLEMENTAL_1", CAN.lkas, values)


def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_hud, lkas_hud):
commands = []
radar_disabled = CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS) and CP.openpilotLongitudinalControl
bus_lkas = get_lkas_cmd_bus(CAN, CP.carFingerprint, radar_disabled)

if CP.openpilotLongitudinalControl:
acc_hud_values = {
Expand Down Expand Up @@ -183,10 +183,10 @@ def create_ui_commands(packer, CAN, CP, enabled, pcm_speed, hud, is_metric, acc_
lkas_hud_values['SET_ME_X48'] = 0x48

if CP.flags & HondaFlags.BOSCH_EXT_HUD and not CP.openpilotLongitudinalControl:
commands.append(packer.make_can_msg('LKAS_HUD_A', bus_lkas, lkas_hud_values))
commands.append(packer.make_can_msg('LKAS_HUD_B', bus_lkas, lkas_hud_values))
commands.append(packer.make_can_msg('LKAS_HUD_A', CAN.lkas, lkas_hud_values))
commands.append(packer.make_can_msg('LKAS_HUD_B', CAN.lkas, lkas_hud_values))
else:
commands.append(packer.make_can_msg('LKAS_HUD', bus_lkas, lkas_hud_values))
commands.append(packer.make_can_msg('LKAS_HUD', CAN.lkas, lkas_hud_values))

if radar_disabled:
radar_hud_values = {
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
@staticmethod
def init(CP, can_recv, can_send):
if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS) and CP.openpilotLongitudinalControl:
disable_ecu(can_recv, can_send, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03')
disable_ecu(can_recv, can_send, bus=CanBus(CP).pt, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03')
4 changes: 1 addition & 3 deletions opendbc/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def __init__(self, dbc_names, CP):
self.secoc_lta_message_counter = 0
self.secoc_acc_message_counter = 0
self.secoc_prev_reset_counter = 0
self.secoc_mismatch_counter = 0

def update(self, CC, CS, now_nanos):
actuators = CC.actuators
Expand All @@ -111,9 +110,8 @@ def update(self, CC, CS, now_nanos):
self.secoc_prev_reset_counter = CS.secoc_synchronization['RESET_CNT']

expected_mac = build_sync_mac(self.secoc_key, int(CS.secoc_synchronization['TRIP_CNT']), int(CS.secoc_synchronization['RESET_CNT']))
if int(CS.secoc_synchronization['AUTHENTICATOR']) != expected_mac and self.secoc_mismatch_counter < 100:
if int(CS.secoc_synchronization['AUTHENTICATOR']) != expected_mac:
carlog.error("SecOC synchronization MAC mismatch, wrong key?")
self.secoc_mismatch_counter += 1

# *** steer torque ***
new_steer = int(round(actuators.steer * self.params.STEER_MAX))
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/volkswagen/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class CAR(Platforms):
)
VOLKSWAGEN_TIGUAN_MK2 = VolkswagenMQBPlatformConfig(
[
VWCarDocs("Volkswagen Tiguan 2018-24"),
VWCarDocs("Volkswagen Tiguan 2018-23"),
VWCarDocs("Volkswagen Tiguan eHybrid 2021-23"),
],
VolkswagenCarSpecs(mass=1715, wheelbase=2.74),
Expand Down

0 comments on commit fc029da

Please sign in to comment.