Skip to content

Commit

Permalink
Ram HD: locked Steering Ratio (commaai#156)
Browse files Browse the repository at this point in the history
* Ram HD: locked SR

* gate to only ram hd

* attribute error

* gotta init first

* define type
  • Loading branch information
sunnyhaibin committed Jun 15, 2023
1 parent 7586395 commit 8db81e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions selfdrive/car/chrysler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
ret.mass = 3405. + STD_CARGO_KG
ret.minSteerSpeed = 16
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning, 1.0, False)
ret.flags |= ChryslerFlags.SP_RAM_HD_FIXED_STEERING_RATIO.value

else:
raise ValueError(f"Unsupported car: {candidate}")
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/car/chrysler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
class ChryslerFlags(IntFlag):
HIGHER_MIN_STEERING_SPEED = 1

SP_RAM_HD_FIXED_STEERING_RATIO = 2


class CAR:
# Chrysler
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def state_control(self, CS):
lp = self.sm['liveParameters']
x = max(lp.stiffnessFactor, 0.1)
sr = max(lp.steerRatio, 0.1)
self.VM.update_params(x, sr)
self.VM.update_params(x, sr, self.CP)

# Update Torque Params
if self.CP.lateralTuning.which() == 'torque':
Expand Down
9 changes: 6 additions & 3 deletions selfdrive/controls/lib/vehicle_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from cereal import car

from selfdrive.car.chrysler.values import ChryslerFlags

ACCELERATION_DUE_TO_GRAVITY = 9.8


Expand All @@ -38,13 +40,14 @@ def __init__(self, CP: car.CarParams):

self.cF_orig: float = CP.tireStiffnessFront
self.cR_orig: float = CP.tireStiffnessRear
self.update_params(1.0, CP.steerRatio)
self.chrysler_ram_hd: bool = (CP.carName == "chrysler") and CP.flags & ChryslerFlags.SP_RAM_HD_FIXED_STEERING_RATIO.value
self.update_params(1.0, CP.steerRatio, CP)

def update_params(self, stiffness_factor: float, steer_ratio: float) -> None:
def update_params(self, stiffness_factor: float, steer_ratio: float, CP: car.CarParams) -> None:
"""Update the vehicle model with a new stiffness factor and steer ratio"""
self.cF: float = stiffness_factor * self.cF_orig
self.cR: float = stiffness_factor * self.cR_orig
self.sR: float = steer_ratio
self.sR: float = CP.steerRatio if self.chrysler_ram_hd else steer_ratio

def steady_state_sol(self, sa: float, u: float, roll: float) -> np.ndarray:
"""Returns the steady state solution.
Expand Down

0 comments on commit 8db81e9

Please sign in to comment.