@ -29,22 +29,22 @@ class VehicleModel:
CP : Car Parameters
CP : Car Parameters
"""
"""
# for math readability, convert long names car params into short names
# for math readability, convert long names car params into short names
self . m = CP . mass
self . m : float = CP . mass
self . j = CP . rotationalInertia
self . j : float = CP . rotationalInertia
self . l = CP . wheelbase
self . l : float = CP . wheelbase
self . aF = CP . centerToFront
self . aF : float = CP . centerToFront
self . aR = CP . wheelbase - CP . centerToFront
self . aR : float = CP . wheelbase - CP . centerToFront
self . chi = CP . steerRatioRear
self . chi : float = CP . steerRatioRear
self . cF_orig = CP . tireStiffnessFront
self . cF_orig : float = CP . tireStiffnessFront
self . cR_orig = CP . tireStiffnessRear
self . cR_orig : float = CP . tireStiffnessRear
self . update_params ( 1.0 , CP . steerRatio )
self . update_params ( 1.0 , CP . steerRatio )
def update_params ( self , stiffness_factor : float , steer_ratio : float ) - > None :
def update_params ( self , stiffness_factor : float , steer_ratio : float ) - > None :
""" Update the vehicle model with a new stiffness factor and steer ratio """
""" Update the vehicle model with a new stiffness factor and steer ratio """
self . cF = stiffness_factor * self . cF_orig
self . cF : float = stiffness_factor * self . cF_orig
self . cR = stiffness_factor * self . cR_orig
self . cR : float = stiffness_factor * self . cR_orig
self . sR = steer_ratio
self . sR : float = steer_ratio
def steady_state_sol ( self , sa : float , u : float , roll : float ) - > np . ndarray :
def steady_state_sol ( self , sa : float , u : float , roll : float ) - > np . ndarray :
""" Returns the steady state solution.
""" Returns the steady state solution.
@ -221,10 +221,10 @@ def dyn_ss_sol(sa: float, u: float, roll: float, VM: VehicleModel) -> np.ndarray
"""
"""
A , B = create_dyn_state_matrices ( u , VM )
A , B = create_dyn_state_matrices ( u , VM )
inp = np . array ( [ [ sa ] , [ roll ] ] )
inp = np . array ( [ [ sa ] , [ roll ] ] )
return - solve ( A , B ) @ inp
return - solve ( A , B ) @ inp # type: ignore
def calc_slip_factor ( VM ) :
def calc_slip_factor ( VM : VehicleModel ) - > float :
""" The slip factor is a measure of how the curvature changes with speed
""" The slip factor is a measure of how the curvature changes with speed
it ' s positive for Oversteering vehicle, negative (usual case) otherwise.
it ' s positive for Oversteering vehicle, negative (usual case) otherwise.
"""
"""