woahhhhh buddy

This commit is contained in:
firestar5683
2026-05-13 23:24:39 -05:00
parent 6b39e4103e
commit c7c10822fb
2 changed files with 34 additions and 13 deletions
@@ -3,7 +3,6 @@ import numpy as np
from opendbc.can import CANPacker
from opendbc.car import ACCELERATION_DUE_TO_GRAVITY, Bus, DT_CTRL, create_gas_interceptor_command, rate_limit, make_tester_present_msg, structs
from opendbc.car.common.pid import PIDController
from opendbc.car.honda import hondacan
from opendbc.car.honda.values import (
CAR,
@@ -235,8 +234,6 @@ class CarController(CarControllerBase):
self.bosch_gas_factor_before_gasmax = self.bosch_gas_factor
self.bosch_wind_factor_before_gasmax = self.bosch_wind_factor
self.pitch = 0.0
self.brake_pid = PIDController(k_p=([0.0], [0.0]), k_i=([0.0], [0.5]), pos_limit=0.0, neg_limit=-2.0, rate=50)
self.brake_pid.reset()
def _modified_civic_standard_active(self) -> bool:
return self.CP.carFingerprint == CAR.HONDA_CIVIC_BOSCH and bool(self.CP.flags & HondaFlags.EPS_MODIFIED)
@@ -355,14 +352,7 @@ class CarController(CarControllerBase):
ts = self.frame * DT_CTRL
if self.CP.carFingerprint in HONDA_BOSCH:
if accel < 0.0 and CS.out.vEgo > 1e-3:
brake_addon = self.brake_pid.update(error=accel - CS.out.aEgo, speed=CS.out.vEgo)
target_accel = min(accel, accel + brake_addon)
else:
self.brake_pid.reset()
target_accel = accel
self.accel = float(np.clip(target_accel, self.params.BOSCH_ACCEL_MIN, self.params.BOSCH_ACCEL_MAX))
self.accel = float(np.clip(accel, self.params.BOSCH_ACCEL_MIN, self.params.BOSCH_ACCEL_MAX))
gas_pedal_force = self.accel + hill_brake
if self.CP.carFingerprint not in HONDA_BOSCH_RADARLESS:
@@ -2,6 +2,7 @@ import re
from types import SimpleNamespace
import pytest
from opendbc.car import structs
from opendbc.car.structs import CarParams
from opendbc.car import gen_empty_fingerprint
from opendbc.car.honda.interface import CarInterface
@@ -116,7 +117,7 @@ class TestHondaFingerprint:
def test_official_modified_eps_firmwares_restored(self):
assert b'39990-TVA,A150\x00\x00' in FW_VERSIONS[CAR.HONDA_ACCORD][(CarParams.Ecu.eps, 0x18DA30F1, None)]
assert b'39990-TBA,A030\x00\x00' in FW_VERSIONS[CAR.HONDA_CIVIC][(CarParams.Ecu.eps, 0x18DA30F1, None)]
assert b'39990-TBA,C120\x00\x00' in FW_VERSIONS[CAR.HONDA_CIVIC_BOSCH][(CarParams.Ecu.eps, 0x18DA30F1, None)]
assert b'39990-TBA-C120\x00\x00' in FW_VERSIONS[CAR.HONDA_CIVIC_BOSCH][(CarParams.Ecu.eps, 0x18DA30F1, None)]
assert b'39990-TGG,A020\x00\x00' in FW_VERSIONS[CAR.HONDA_CIVIC_BOSCH][(CarParams.Ecu.eps, 0x18DA30F1, None)]
assert b'39990-TLA,A040\x00\x00' in FW_VERSIONS[CAR.HONDA_CRV_5G][(CarParams.Ecu.eps, 0x18DA30F1, None)]
@@ -132,7 +133,7 @@ class TestHondaFingerprint:
assert list(civic_cp.lateralTuning.pid.kpV) == pytest.approx([0.3])
assert list(civic_cp.lateralTuning.pid.kiV) == pytest.approx([0.1])
civic_bosch_fw = [CarParams.CarFw(ecu=CarParams.Ecu.eps, fwVersion=b'39990-TBA,C120\x00\x00', address=0x18DA30F1, subAddress=0)]
civic_bosch_fw = [CarParams.CarFw(ecu=CarParams.Ecu.eps, fwVersion=b'39990-TGG,A020\x00\x00', address=0x18DA30F1, subAddress=0)]
civic_bosch_cp = CarInterface.get_params(CAR.HONDA_CIVIC_BOSCH, gen_empty_fingerprint(), civic_bosch_fw, False, False, False, toggles)
assert not civic_bosch_cp.dashcamOnly
assert civic_bosch_cp.flags & HondaFlags.EPS_MODIFIED
@@ -235,3 +236,33 @@ class TestHondaFingerprint:
assert controller.bosch_gas_factor == pytest.approx(1.25)
assert controller.bosch_wind_factor == pytest.approx(0.85)
def test_honda_bosch_controller_does_not_deepen_planner_braking(self, monkeypatch):
toggles = get_test_toggles()
CP = CarInterface.get_params(CAR.HONDA_HRV_3G, gen_empty_fingerprint(), [], True, False, False, toggles)
controller = CarController(DBC[CP.carFingerprint], CP)
monkeypatch.setattr("opendbc.car.honda.carcontroller.hondacan.create_steering_control", lambda *args, **kwargs: (0, []))
monkeypatch.setattr("opendbc.car.honda.carcontroller.hondacan.create_acc_commands", lambda *args, **kwargs: [])
CC = structs.CarControl.new_message()
CC.enabled = True
CC.longActive = True
CC.latActive = False
CC.cruiseControl.cancel = False
CC.cruiseControl.resume = False
CC.hudControl.speedVisible = False
CC.hudControl.setSpeed = 0.0
CC.hudControl.visualAlert = structs.CarControl.HUDControl.VisualAlert.none
CC.actuators.accel = -0.3
CC.actuators.torque = 0.0
CC.actuators.longControlState = structs.CarControl.Actuators.LongControlState.pid
controller.frame = 2
CS = SimpleNamespace(
out=SimpleNamespace(vEgo=25.0, aEgo=1.5, steeringPressed=False, gasPressed=False, brakePressed=False),
v_cruise_factor=1.0,
)
new_actuators, _ = controller.update(CC.as_reader(), CS, 0, toggles)
assert new_actuators.accel == pytest.approx(-0.3)