mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-07 15:15:41 +08:00
Ram HD: locked Steering Ratio (#156)
* Ram HD: locked SR * gate to only ram hd * attribute error * gotta init first * define type
This commit is contained in:
@@ -82,6 +82,7 @@ class CarInterface(CarInterfaceBase):
|
||||
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}")
|
||||
|
||||
@@ -14,6 +14,8 @@ Ecu = car.CarParams.Ecu
|
||||
class ChryslerFlags(IntFlag):
|
||||
HIGHER_MIN_STEERING_SPEED = 1
|
||||
|
||||
SP_RAM_HD_FIXED_STEERING_RATIO = 2
|
||||
|
||||
|
||||
class CAR:
|
||||
# Chrysler
|
||||
|
||||
@@ -606,7 +606,7 @@ class Controls:
|
||||
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':
|
||||
|
||||
@@ -19,6 +19,8 @@ from numpy.linalg import solve
|
||||
|
||||
from cereal import car
|
||||
|
||||
from selfdrive.car.chrysler.values import ChryslerFlags
|
||||
|
||||
ACCELERATION_DUE_TO_GRAVITY = 9.8
|
||||
|
||||
|
||||
@@ -38,13 +40,14 @@ class VehicleModel:
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user