From f56bee86eb48a2e4d33cae2dd2ae86b9f04a2c22 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Sep 2024 14:51:38 -0700 Subject: [PATCH 1/4] test more models! --- opendbc/car/honda/carcontroller.py | 8 +------- opendbc/car/honda/values.py | 4 ++++ opendbc/car/tests/test_lateral_limits.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/opendbc/car/honda/carcontroller.py b/opendbc/car/honda/carcontroller.py index 20358c67fb..f00906dac4 100644 --- a/opendbc/car/honda/carcontroller.py +++ b/opendbc/car/honda/carcontroller.py @@ -97,12 +97,6 @@ def process_hud_alert(hud_alert): "lanes_visible", "fcw", "acc_alert", "steer_required", "lead_distance_bars"]) -def rate_limit_steer(new_steer, last_steer): - # TODO just hardcoded ramp to min/max in 0.33s for all Honda - MAX_DELTA = 3 * DT_CTRL - return clip(new_steer, last_steer - MAX_DELTA, last_steer + MAX_DELTA) - - class CarController(CarControllerBase): def __init__(self, dbc_name, CP): super().__init__(dbc_name, CP) @@ -138,7 +132,7 @@ def update(self, CC, CS, now_nanos): gas, brake = 0.0, 0.0 # *** rate limit steer *** - limited_steer = rate_limit_steer(actuators.steer, self.last_steer) + limited_steer = rate_limit(actuators.steer, self.last_steer, -self.params.STEER_DELTA_DOWN, self.params.STEER_DELTA_UP) self.last_steer = limited_steer # *** apply brake hysteresis *** diff --git a/opendbc/car/honda/values.py b/opendbc/car/honda/values.py index 70ccecb0ed..1200f69cca 100644 --- a/opendbc/car/honda/values.py +++ b/opendbc/car/honda/values.py @@ -35,6 +35,10 @@ class CarControllerParams: BOSCH_GAS_LOOKUP_BP = [-0.2, 2.0] # 2m/s^2 BOSCH_GAS_LOOKUP_V = [0, 1600] + STEER_STEP = 1 # 100 Hz + STEER_DELTA_UP = 3 # min/max in 0.33s for all Honda + STEER_DELTA_DOWN = 3 + def __init__(self, CP): self.STEER_MAX = CP.lateralParams.torqueBP[-1] # mirror of list (assuming first item is zero) for interp of signed request values diff --git a/opendbc/car/tests/test_lateral_limits.py b/opendbc/car/tests/test_lateral_limits.py index 585289968d..2a0b7eb90a 100755 --- a/opendbc/car/tests/test_lateral_limits.py +++ b/opendbc/car/tests/test_lateral_limits.py @@ -35,7 +35,7 @@ def setup_class(cls): pytest.skip("Platform is behind dashcamOnly") # TODO: test all platforms - if CP.lateralTuning.which() != 'torque': + if CP.steerControlType != 'torque': pytest.skip() if CP.notCar: From 42801dfaf5d66b61489b91bcd7a8a8e3350c6905 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Sep 2024 15:08:12 -0700 Subject: [PATCH 2/4] Impreza 2020: reach max in ~0.8s instead of ~0.6 --- opendbc/car/subaru/values.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opendbc/car/subaru/values.py b/opendbc/car/subaru/values.py index 15b8a8b8ec..bc586778b0 100644 --- a/opendbc/car/subaru/values.py +++ b/opendbc/car/subaru/values.py @@ -24,6 +24,7 @@ def __init__(self, CP): self.STEER_DELTA_UP = 40 self.STEER_DELTA_DOWN = 40 elif CP.carFingerprint == CAR.SUBARU_IMPREZA_2020: + self.STEER_DELTA_UP = 35 self.STEER_MAX = 1439 else: self.STEER_MAX = 2047 From b2c800dfc8aeef1a30bc7c28154df064f4def1ba Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Sep 2024 15:10:02 -0700 Subject: [PATCH 3/4] leave todo for gen2, not safety critical since jerk is under threshold (1000/40*2/100=0.5s) --- opendbc/car/subaru/values.py | 1 + 1 file changed, 1 insertion(+) diff --git a/opendbc/car/subaru/values.py b/opendbc/car/subaru/values.py index bc586778b0..c7f93f9fae 100644 --- a/opendbc/car/subaru/values.py +++ b/opendbc/car/subaru/values.py @@ -20,6 +20,7 @@ def __init__(self, CP): self.STEER_DRIVER_FACTOR = 1 # from dbc if CP.flags & SubaruFlags.GLOBAL_GEN2: + # TODO: lower rate limits, this reaches min/max in 0.5s which negatively affects tuning self.STEER_MAX = 1000 self.STEER_DELTA_UP = 40 self.STEER_DELTA_DOWN = 40 From b1be2b9db7ceed029cd00235f1f7db8d339c5f53 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 10 Sep 2024 15:15:00 -0700 Subject: [PATCH 4/4] fix honda --- opendbc/car/honda/carcontroller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opendbc/car/honda/carcontroller.py b/opendbc/car/honda/carcontroller.py index f00906dac4..85199a2b91 100644 --- a/opendbc/car/honda/carcontroller.py +++ b/opendbc/car/honda/carcontroller.py @@ -132,7 +132,8 @@ def update(self, CC, CS, now_nanos): gas, brake = 0.0, 0.0 # *** rate limit steer *** - limited_steer = rate_limit(actuators.steer, self.last_steer, -self.params.STEER_DELTA_DOWN, self.params.STEER_DELTA_UP) + limited_steer = rate_limit(actuators.steer, self.last_steer, -self.params.STEER_DELTA_DOWN * DT_CTRL, + self.params.STEER_DELTA_UP * DT_CTRL) self.last_steer = limited_steer # *** apply brake hysteresis ***