Skip to content

Commit

Permalink
Test all torque cars' lateral limits (#1232)
Browse files Browse the repository at this point in the history
* test more models!

* Impreza 2020: reach max in ~0.8s instead of ~0.6

* leave todo for gen2, not safety critical since jerk is under threshold (1000/40*2/100=0.5s)

* fix honda
  • Loading branch information
sshane authored Sep 10, 2024
1 parent ef7102a commit 3ff9057
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
9 changes: 2 additions & 7 deletions opendbc/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -138,7 +132,8 @@ 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 * DT_CTRL,
self.params.STEER_DELTA_UP * DT_CTRL)
self.last_steer = limited_steer

# *** apply brake hysteresis ***
Expand Down
4 changes: 4 additions & 0 deletions opendbc/car/honda/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions opendbc/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ 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
elif CP.carFingerprint == CAR.SUBARU_IMPREZA_2020:
self.STEER_DELTA_UP = 35
self.STEER_MAX = 1439
else:
self.STEER_MAX = 2047
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/tests/test_lateral_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3ff9057

Please sign in to comment.