|
|
|
@ -19,6 +19,12 @@ BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.D |
|
|
|
|
CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NON_LINEAR_TORQUE_PARAMS = { |
|
|
|
|
CAR.BOLT_EUV: [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178], |
|
|
|
|
CAR.ACADIA: [4.78003305, 1.0, 0.3122, 0.05591772] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CarInterface(CarInterfaceBase): |
|
|
|
|
@staticmethod |
|
|
|
|
def get_pid_accel_limits(CP, current_speed, cruise_speed): |
|
|
|
@ -31,23 +37,14 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
sigmoid = desired_angle / (1 + fabs(desired_angle)) |
|
|
|
|
return 0.10006696 * sigmoid * (v_ego + 3.12485927) |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def get_steer_feedforward_acadia(desired_angle, v_ego): |
|
|
|
|
desired_angle *= 0.09760208 |
|
|
|
|
sigmoid = desired_angle / (1 + fabs(desired_angle)) |
|
|
|
|
return 0.04689655 * sigmoid * (v_ego + 10.028217) |
|
|
|
|
|
|
|
|
|
def get_steer_feedforward_function(self): |
|
|
|
|
if self.CP.carFingerprint == CAR.VOLT: |
|
|
|
|
return self.get_steer_feedforward_volt |
|
|
|
|
elif self.CP.carFingerprint == CAR.ACADIA: |
|
|
|
|
return self.get_steer_feedforward_acadia |
|
|
|
|
else: |
|
|
|
|
return CarInterfaceBase.get_steer_feedforward_default |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def torque_from_lateral_accel_bolt(lateral_accel_value: float, torque_params: car.CarParams.LateralTorqueTuning, |
|
|
|
|
lateral_accel_error: float, lateral_accel_deadzone: float, friction_compensation: bool) -> float: |
|
|
|
|
def torque_from_lateral_accel_siglin(self, lateral_accel_value: float, torque_params: car.CarParams.LateralTorqueTuning, |
|
|
|
|
lateral_accel_error: float, lateral_accel_deadzone: float, friction_compensation: bool) -> float: |
|
|
|
|
friction = get_friction(lateral_accel_error, lateral_accel_deadzone, FRICTION_THRESHOLD, torque_params, friction_compensation) |
|
|
|
|
|
|
|
|
|
def sig(val): |
|
|
|
@ -57,14 +54,15 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
# An important thing to consider is that the slope at 0 should be > 0 (ideally >1) |
|
|
|
|
# This has big effect on the stability about 0 (noise when going straight) |
|
|
|
|
# ToDo: To generalize to other GMs, explore tanh function as the nonlinear |
|
|
|
|
a, b, c, _ = [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178] # weights computed offline |
|
|
|
|
|
|
|
|
|
non_linear_torque_params = NON_LINEAR_TORQUE_PARAMS.get(self.CP.carFingerprint) |
|
|
|
|
assert non_linear_torque_params, "The params are not defined" |
|
|
|
|
a, b, c, _ = non_linear_torque_params |
|
|
|
|
steer_torque = (sig(lateral_accel_value * a) * b) + (lateral_accel_value * c) |
|
|
|
|
return float(steer_torque) + friction |
|
|
|
|
|
|
|
|
|
def torque_from_lateral_accel(self) -> TorqueFromLateralAccelCallbackType: |
|
|
|
|
if self.CP.carFingerprint == CAR.BOLT_EUV: |
|
|
|
|
return self.torque_from_lateral_accel_bolt |
|
|
|
|
if self.CP.carFingerprint in NON_LINEAR_TORQUE_PARAMS: |
|
|
|
|
return self.torque_from_lateral_accel_siglin |
|
|
|
|
else: |
|
|
|
|
return self.torque_from_lateral_accel_linear |
|
|
|
|
|
|
|
|
@ -169,7 +167,8 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
ret.wheelbase = 2.86 |
|
|
|
|
ret.steerRatio = 14.4 # end to end is 13.46 |
|
|
|
|
ret.centerToFront = ret.wheelbase * 0.4 |
|
|
|
|
ret.lateralTuning.pid.kf = 1. # get_steer_feedforward_acadia() |
|
|
|
|
ret.steerActuatorDelay = 0.2 |
|
|
|
|
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) |
|
|
|
|
|
|
|
|
|
elif candidate == CAR.BUICK_LACROSSE: |
|
|
|
|
ret.mass = 1712. + STD_CARGO_KG |
|
|
|
|