diff --git a/opendbc_repo/opendbc/car/toyota/carcontroller.py b/opendbc_repo/opendbc/car/toyota/carcontroller.py index f96eaa904..8cc561be2 100644 --- a/opendbc_repo/opendbc/car/toyota/carcontroller.py +++ b/opendbc_repo/opendbc/car/toyota/carcontroller.py @@ -389,7 +389,7 @@ class CarController(CarControllerBase): if self.frame % 20 == 0 or send_ui: can_sends.append(toyotacan.create_ui_command(self.packer, steer_alert, pcm_cancel_cmd, hud_control.leftLaneVisible, hud_control.rightLaneVisible, hud_control.leftLaneDepart, - hud_control.rightLaneDepart, CC.enabled, CS.lkas_hud)) + hud_control.rightLaneDepart, CS.lkas_hud, lat_active)) if (self.frame % 100 == 0 or send_ui) and self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: can_sends.append(toyotacan.create_fcw_command(self.packer, fcw_alert)) diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py index e2d8c713c..48b2b9ec6 100644 --- a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py +++ b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py @@ -3,8 +3,10 @@ from types import SimpleNamespace from hypothesis import given, settings, strategies as st from opendbc.car import Bus +from opendbc.can import CANPacker, CANParser from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict +from opendbc.car.toyota import toyotacan from opendbc.car.toyota.carcontroller import CarController, update_permit_braking from opendbc.car.toyota.fingerprints import FW_VERSIONS from opendbc.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, RADAR_ACC_CAR, SECOC_CAR, \ @@ -260,6 +262,30 @@ class TestToyotaCarController: assert controller.standstill_req is False + def test_ui_command_shows_aol_bars_when_lateral_active(self): + packer = CANPacker(DBC[CAR.TOYOTA_HIGHLANDER_TSS2][Bus.pt]) + parser = CANParser(DBC[CAR.TOYOTA_HIGHLANDER_TSS2][Bus.pt], [("LKAS_HUD", 0)], 0) + + msg = toyotacan.create_ui_command(packer, False, False, True, True, False, False, {}, True) + parser.update([(1, [msg])]) + + assert parser.can_valid + assert parser.vl["LKAS_HUD"]["BARRIERS"] == 1 + assert parser.vl["LKAS_HUD"]["LEFT_LINE"] == 1 + assert parser.vl["LKAS_HUD"]["RIGHT_LINE"] == 1 + + def test_ui_command_hides_lane_markers_when_lateral_inactive(self): + packer = CANPacker(DBC[CAR.TOYOTA_HIGHLANDER_TSS2][Bus.pt]) + parser = CANParser(DBC[CAR.TOYOTA_HIGHLANDER_TSS2][Bus.pt], [("LKAS_HUD", 0)], 0) + + msg = toyotacan.create_ui_command(packer, False, False, True, True, False, False, {}, False) + parser.update([(1, [msg])]) + + assert parser.can_valid + assert parser.vl["LKAS_HUD"]["BARRIERS"] == 0 + assert parser.vl["LKAS_HUD"]["LEFT_LINE"] == 0 + assert parser.vl["LKAS_HUD"]["RIGHT_LINE"] == 0 + def test_interceptor_stop_and_go_holds_small_launch_at_standstill(self): controller = self._make_controller() controller.CP.enableGasInterceptorDEPRECATED = True diff --git a/opendbc_repo/opendbc/car/toyota/toyotacan.py b/opendbc_repo/opendbc/car/toyota/toyotacan.py index d4771a771..da2771a7b 100644 --- a/opendbc_repo/opendbc/car/toyota/toyotacan.py +++ b/opendbc_repo/opendbc/car/toyota/toyotacan.py @@ -110,13 +110,13 @@ def create_fcw_command(packer, fcw): return packer.make_can_msg("PCS_HUD", 0, values) -def create_ui_command(packer, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart, enabled, stock_lkas_hud): +def create_ui_command(packer, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart, stock_lkas_hud, lat_active): values = { "TWO_BEEPS": chime, "LDA_ALERT": steer, - "RIGHT_LINE": 3 if right_lane_depart else 1 if right_line else 2, - "LEFT_LINE": 3 if left_lane_depart else 1 if left_line else 2, - "BARRIERS": 1 if enabled else 0, + "RIGHT_LINE": 0 if not lat_active else 3 if right_lane_depart else 1 if right_line else 2, + "LEFT_LINE": 0 if not lat_active else 3 if left_lane_depart else 1 if left_line else 2, + "BARRIERS": 1 if lat_active else 0, # static signals "SET_ME_X02": 2,