2020-01-17 10:58:43 -08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
from cereal import car
|
2020-11-03 19:56:25 -08:00
|
|
|
from selfdrive.car.chrysler.values import CAR
|
2021-10-08 17:54:34 +02:00
|
|
|
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
|
2020-01-17 10:58:43 -08:00
|
|
|
from selfdrive.car.interfaces import CarInterfaceBase
|
|
|
|
|
|
|
|
|
|
|
2020-04-27 14:10:07 -07:00
|
|
|
class CarInterface(CarInterfaceBase):
|
2020-01-17 10:58:43 -08:00
|
|
|
@staticmethod
|
2021-02-24 08:41:20 -06:00
|
|
|
def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
|
2020-11-03 19:56:25 -08:00
|
|
|
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
|
2020-01-17 10:58:43 -08:00
|
|
|
ret.carName = "chrysler"
|
2021-10-08 17:54:34 +02:00
|
|
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.chrysler)]
|
2020-01-17 10:58:43 -08:00
|
|
|
|
|
|
|
|
# Speed conversion: 20, 45 mph
|
|
|
|
|
ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017
|
2020-05-31 14:03:22 -07:00
|
|
|
ret.steerRatio = 16.2 # Pacifica Hybrid 2017
|
2021-04-11 20:18:31 -04:00
|
|
|
ret.mass = 2242. + STD_CARGO_KG # kg curb weight Pacifica Hybrid 2017
|
2020-01-17 10:58:43 -08:00
|
|
|
ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.], [9., 20.]]
|
2020-05-31 12:37:52 -07:00
|
|
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15, 0.30], [0.03, 0.05]]
|
2020-01-17 10:58:43 -08:00
|
|
|
ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594
|
|
|
|
|
ret.steerActuatorDelay = 0.1
|
|
|
|
|
ret.steerRateCost = 0.7
|
|
|
|
|
ret.steerLimitTimer = 0.4
|
|
|
|
|
|
|
|
|
|
if candidate in (CAR.JEEP_CHEROKEE, CAR.JEEP_CHEROKEE_2019):
|
|
|
|
|
ret.wheelbase = 2.91 # in meters
|
|
|
|
|
ret.steerRatio = 12.7
|
|
|
|
|
ret.steerActuatorDelay = 0.2 # in seconds
|
|
|
|
|
|
|
|
|
|
ret.centerToFront = ret.wheelbase * 0.44
|
|
|
|
|
|
|
|
|
|
ret.minSteerSpeed = 3.8 # m/s
|
2020-03-31 15:47:49 -07:00
|
|
|
if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019):
|
2020-01-17 10:58:43 -08:00
|
|
|
# TODO allow 2019 cars to steer down to 13 m/s if already engaged.
|
2020-02-20 14:06:02 -08:00
|
|
|
ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged.
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2020-02-20 14:06:02 -08:00
|
|
|
# starting with reasonable value for civic and scaling by mass and wheelbase
|
2020-01-17 10:58:43 -08:00
|
|
|
ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase)
|
|
|
|
|
|
|
|
|
|
# TODO: start from empirically derived lateral slip stiffness for the civic and scale by
|
|
|
|
|
# mass and CG position, so all cars will have approximately similar dyn behaviors
|
|
|
|
|
ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront)
|
|
|
|
|
|
2021-05-04 23:37:39 -04:00
|
|
|
ret.enableBsm = 720 in fingerprint[0]
|
2020-01-17 10:58:43 -08:00
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
# returns a car.CarState
|
|
|
|
|
def update(self, c, can_strings):
|
|
|
|
|
# ******************* do can recv *******************
|
|
|
|
|
self.cp.update_strings(can_strings)
|
|
|
|
|
self.cp_cam.update_strings(can_strings)
|
|
|
|
|
|
2020-02-17 13:35:51 -08:00
|
|
|
ret = self.CS.update(self.cp, self.cp_cam)
|
2020-01-17 10:58:43 -08:00
|
|
|
|
|
|
|
|
ret.canValid = self.cp.can_valid and self.cp_cam.can_valid
|
|
|
|
|
|
|
|
|
|
# speeds
|
|
|
|
|
ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False
|
|
|
|
|
|
|
|
|
|
# events
|
2020-05-31 17:41:18 -07:00
|
|
|
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low],
|
2020-05-14 15:21:21 -07:00
|
|
|
gas_resume_speed=2.)
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2020-02-20 16:22:25 -08:00
|
|
|
if ret.vEgo < self.CP.minSteerSpeed:
|
2020-05-14 15:21:21 -07:00
|
|
|
events.add(car.CarEvent.EventName.belowSteerSpeed)
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2020-05-14 15:21:21 -07:00
|
|
|
ret.events = events.to_msg()
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2020-02-17 13:35:51 -08:00
|
|
|
# copy back carState packet to CS
|
|
|
|
|
self.CS.out = ret.as_reader()
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2020-02-17 13:35:51 -08:00
|
|
|
return self.CS.out
|
2020-01-17 10:58:43 -08:00
|
|
|
|
|
|
|
|
# pass in a car.CarControl
|
|
|
|
|
# to be called @ 100hz
|
|
|
|
|
def apply(self, c):
|
|
|
|
|
|
|
|
|
|
if (self.CS.frame == -1):
|
2021-12-16 13:08:20 +01:00
|
|
|
return car.CarControl.Actuators.new_message(), [] # if we haven't seen a frame 220, then do not update.
|
2020-01-17 10:58:43 -08:00
|
|
|
|
2021-12-16 13:08:20 +01:00
|
|
|
return self.CC.update(c.enabled, self.CS, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert)
|