Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all torque cars' lateral limits #1232

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading