From e57d75a3d70e29c620d425d77c805e43db3e36d0 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 1 May 2026 11:24:47 -0500 Subject: [PATCH] honda --- opendbc_repo/opendbc/car/honda/carcontroller.py | 11 +++++++---- opendbc_repo/opendbc/car/honda/interface.py | 3 +++ opendbc_repo/opendbc/car/honda/tests/test_honda.py | 9 ++++++--- opendbc_repo/opendbc/car/honda/values.py | 1 + selfdrive/controls/lib/latcontrol_pid.py | 4 ++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/opendbc_repo/opendbc/car/honda/carcontroller.py b/opendbc_repo/opendbc/car/honda/carcontroller.py index 57bd18879..1d16109b7 100644 --- a/opendbc_repo/opendbc/car/honda/carcontroller.py +++ b/opendbc_repo/opendbc/car/honda/carcontroller.py @@ -4,7 +4,7 @@ from opendbc.can import CANPacker from opendbc.car import Bus, DT_CTRL, rate_limit, make_tester_present_msg, structs from opendbc.car.honda import hondacan from opendbc.car.honda.values import CAR, CruiseButtons, HONDA_BOSCH, HONDA_BOSCH_CANFD, HONDA_BOSCH_RADARLESS, \ - HONDA_BOSCH_TJA_CONTROL, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams + HONDA_BOSCH_TJA_CONTROL, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams, HondaFlags from opendbc.car.interfaces import CarControllerBase from openpilot.starpilot.common.testing_grounds import testing_ground @@ -18,7 +18,7 @@ def civic_bosch_modified_lateral_testing_ground_active() -> bool: def get_civic_bosch_modified_steer_can_max(base_steer_can_max: int, CP) -> int: - if CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and CP.dashcamOnly and civic_bosch_modified_lateral_testing_ground_active(): + if CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and bool(CP.flags & HondaFlags.EPS_MODIFIED) and civic_bosch_modified_lateral_testing_ground_active(): return CIVIC_BOSCH_MODIFIED_STEER_CAN_MAX return base_steer_can_max @@ -170,7 +170,10 @@ class CarController(CarControllerBase): self.steering_pressed_robust_prev = False def _modified_civic_active(self) -> bool: - return self.CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and self.CP.dashcamOnly and civic_bosch_modified_lateral_testing_ground_active() + return self.CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and bool(self.CP.flags & HondaFlags.EPS_MODIFIED) and civic_bosch_modified_lateral_testing_ground_active() + + def _modified_civic_standard_active(self) -> bool: + return self.CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and bool(self.CP.flags & HondaFlags.EPS_MODIFIED) def _filtered_steering_pressed(self, CS, torque_cmd: float) -> bool: self.steering_pressed_filter_s, steering_pressed = get_civic_bosch_modified_steering_pressed( @@ -198,7 +201,7 @@ class CarController(CarControllerBase): torque_cmd = float(actuators.torque) filtered_steering_pressed = bool(CS.out.steeringPressed) - if self._modified_civic_active(): + if self._modified_civic_standard_active(): if CC.latActive: filtered_steering_pressed = self._filtered_steering_pressed(CS, torque_cmd) if filtered_steering_pressed: diff --git a/opendbc_repo/opendbc/car/honda/interface.py b/opendbc_repo/opendbc/car/honda/interface.py index 913b7adb0..54aefdecf 100644 --- a/opendbc_repo/opendbc/car/honda/interface.py +++ b/opendbc_repo/opendbc/car/honda/interface.py @@ -95,6 +95,9 @@ class CarInterface(CarInterfaceBase): if fw.ecu == "eps" and b"," in fw.fwVersion: eps_modified = True + if eps_modified: + ret.flags |= HondaFlags.EPS_MODIFIED.value + if candidate == CAR.HONDA_CIVIC: if eps_modified: # stock request input values: 0x0000, 0x00DE, 0x014D, 0x01EF, 0x0290, 0x0377, 0x0454, 0x0610, 0x06EE diff --git a/opendbc_repo/opendbc/car/honda/tests/test_honda.py b/opendbc_repo/opendbc/car/honda/tests/test_honda.py index 8716453ec..1b3700251 100644 --- a/opendbc_repo/opendbc/car/honda/tests/test_honda.py +++ b/opendbc_repo/opendbc/car/honda/tests/test_honda.py @@ -31,13 +31,12 @@ class TestHondaFingerprint: def test_modified_civic_steer_can_max_is_scoped(self, monkeypatch): CP = CarParams.new_message() CP.carFingerprint = CAR.HONDA_CIVIC_BOSCH - CP.flags = int(HondaFlags.BOSCH) - CP.dashcamOnly = True + CP.flags = int(HondaFlags.BOSCH | HondaFlags.EPS_MODIFIED) monkeypatch.setattr("opendbc.car.honda.carcontroller.civic_bosch_modified_lateral_testing_ground_active", lambda: True) assert get_civic_bosch_modified_steer_can_max(4096, CP) == CIVIC_BOSCH_MODIFIED_STEER_CAN_MAX - CP.dashcamOnly = False + CP.flags = int(HondaFlags.BOSCH) assert get_civic_bosch_modified_steer_can_max(4096, CP) == 4096 def test_modified_civic_torque_lpf_tau_reacts_to_sign_change(self): @@ -70,6 +69,7 @@ class TestHondaFingerprint: civic_fw = [CarParams.CarFw(ecu=CarParams.Ecu.eps, fwVersion=b'39990-TBA,A030\x00\x00', address=0x18da30f1, subAddress=0)] civic_cp = CarInterface.get_params(CAR.HONDA_CIVIC, gen_empty_fingerprint(), civic_fw, False, False, False, toggles) assert not civic_cp.dashcamOnly + assert civic_cp.flags & HondaFlags.EPS_MODIFIED assert list(civic_cp.lateralParams.torqueBP) == [0, 2560, 8000] assert list(civic_cp.lateralParams.torqueV) == [0, 2560, 3840] assert list(civic_cp.lateralTuning.pid.kpV) == pytest.approx([0.3]) @@ -78,12 +78,14 @@ class TestHondaFingerprint: accord_fw = [CarParams.CarFw(ecu=CarParams.Ecu.eps, fwVersion=b'39990-TVA,A150\x00\x00', address=0x18da30f1, subAddress=0)] accord_cp = CarInterface.get_params(CAR.HONDA_ACCORD, gen_empty_fingerprint(), accord_fw, False, False, False, toggles) assert not accord_cp.dashcamOnly + assert accord_cp.flags & HondaFlags.EPS_MODIFIED assert list(accord_cp.lateralTuning.pid.kpV) == pytest.approx([0.3]) assert list(accord_cp.lateralTuning.pid.kiV) == pytest.approx([0.09]) crv_fw = [CarParams.CarFw(ecu=CarParams.Ecu.eps, fwVersion=b'39990-TLA,A040\x00\x00', address=0x18da30f1, subAddress=0)] crv_cp = CarInterface.get_params(CAR.HONDA_CRV_5G, gen_empty_fingerprint(), crv_fw, False, False, False, toggles) assert not crv_cp.dashcamOnly + assert crv_cp.flags & HondaFlags.EPS_MODIFIED assert list(crv_cp.lateralParams.torqueBP) == [0, 2560, 10000] assert list(crv_cp.lateralParams.torqueV) == [0, 2560, 3840] assert list(crv_cp.lateralTuning.pid.kpV) == pytest.approx([0.21]) @@ -96,6 +98,7 @@ class TestHondaFingerprint: CP = CarInterface.get_params(CAR.HONDA_CIVIC_BOSCH, gen_empty_fingerprint(), car_fw, False, False, False, toggles) assert not CP.dashcamOnly + assert CP.flags & HondaFlags.EPS_MODIFIED assert list(CP.lateralParams.torqueBP) == [0, 4096] assert list(CP.lateralParams.torqueV) == [0, 4096] assert list(CP.lateralTuning.pid.kpV) == pytest.approx([0.8]) diff --git a/opendbc_repo/opendbc/car/honda/values.py b/opendbc_repo/opendbc/car/honda/values.py index e5837586a..e086fcb9f 100644 --- a/opendbc_repo/opendbc/car/honda/values.py +++ b/opendbc_repo/opendbc/car/honda/values.py @@ -79,6 +79,7 @@ class HondaFlags(IntFlag): ALLOW_MANUAL_TRANS = 1024 HYBRID = 2048 BOSCH_TJA_CONTROL = 4096 + EPS_MODIFIED = 8192 # Car button codes diff --git a/selfdrive/controls/lib/latcontrol_pid.py b/selfdrive/controls/lib/latcontrol_pid.py index 6398bc211..159705a63 100644 --- a/selfdrive/controls/lib/latcontrol_pid.py +++ b/selfdrive/controls/lib/latcontrol_pid.py @@ -1,7 +1,7 @@ import math from cereal import log -from opendbc.car.honda.values import CAR as HONDA +from opendbc.car.honda.values import CAR as HONDA, HondaFlags from openpilot.starpilot.common.testing_grounds import testing_ground from openpilot.selfdrive.controls.lib.latcontrol import LatControl from openpilot.common.pid import PIDController @@ -42,7 +42,7 @@ class LatControlPID(LatControl): pos_limit=self.steer_max, neg_limit=-self.steer_max) self.ff_factor = CP.lateralTuning.pid.kf self.get_steer_feedforward = CI.get_steer_feedforward_function() - self.is_civic_bosch_modified = CP.carFingerprint == HONDA.HONDA_CIVIC_BOSCH and CP.dashcamOnly + self.is_civic_bosch_modified = CP.carFingerprint == HONDA.HONDA_CIVIC_BOSCH and bool(CP.flags & HondaFlags.EPS_MODIFIED) self.prev_angle_steers_des_no_offset = 0.0 def update(self, active, CS, VM, params, steer_limited_by_safety, desired_curvature, curvature_limited, lat_delay, calibrated_pose, model_data, starpilot_toggles):