2020-05-29 00:15:19 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
from cereal import car
|
2022-03-13 21:42:39 -07:00
|
|
|
from common.conversions import Conversions as CV
|
2020-11-03 19:56:25 -08:00
|
|
|
from selfdrive.car.mazda.values import CAR, LKAS_LIMITS
|
2022-11-29 11:49:13 -08:00
|
|
|
from selfdrive.car import STD_CARGO_KG, scale_tire_stiffness, get_safety_config
|
2020-05-29 00:15:19 -05:00
|
|
|
from selfdrive.car.interfaces import CarInterfaceBase
|
|
|
|
|
|
|
|
|
|
ButtonType = car.CarState.ButtonEvent.Type
|
|
|
|
|
EventName = car.CarEvent.EventName
|
|
|
|
|
|
|
|
|
|
class CarInterface(CarInterfaceBase):
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2023-04-18 12:22:22 -07:00
|
|
|
def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
|
2020-05-29 00:15:19 -05:00
|
|
|
ret.carName = "mazda"
|
2021-10-08 17:54:34 +02:00
|
|
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.mazda)]
|
2023-02-02 11:38:09 -08:00
|
|
|
ret.radarUnavailable = True
|
2020-05-29 00:15:19 -05:00
|
|
|
|
2022-02-05 01:34:37 -06:00
|
|
|
ret.dashcamOnly = candidate not in (CAR.CX5_2022, CAR.CX9_2021)
|
2020-05-29 00:15:19 -05:00
|
|
|
|
|
|
|
|
ret.steerActuatorDelay = 0.1
|
|
|
|
|
ret.steerLimitTimer = 0.8
|
|
|
|
|
tire_stiffness_factor = 0.70 # not optimized yet
|
|
|
|
|
|
2022-07-25 15:16:38 -07:00
|
|
|
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
|
|
|
|
|
2022-02-05 01:34:37 -06:00
|
|
|
if candidate in (CAR.CX5, CAR.CX5_2022):
|
2020-05-30 20:14:58 -07:00
|
|
|
ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG
|
2020-05-29 00:15:19 -05:00
|
|
|
ret.wheelbase = 2.7
|
|
|
|
|
ret.steerRatio = 15.5
|
2022-01-10 23:36:51 +08:00
|
|
|
elif candidate in (CAR.CX9, CAR.CX9_2021):
|
2020-09-09 18:02:26 -05:00
|
|
|
ret.mass = 4217 * CV.LB_TO_KG + STD_CARGO_KG
|
|
|
|
|
ret.wheelbase = 3.1
|
|
|
|
|
ret.steerRatio = 17.6
|
2021-06-06 16:40:57 -05:00
|
|
|
elif candidate == CAR.MAZDA3:
|
2020-09-09 18:02:26 -05:00
|
|
|
ret.mass = 2875 * CV.LB_TO_KG + STD_CARGO_KG
|
|
|
|
|
ret.wheelbase = 2.7
|
|
|
|
|
ret.steerRatio = 14.0
|
2021-06-06 16:40:57 -05:00
|
|
|
elif candidate == CAR.MAZDA6:
|
|
|
|
|
ret.mass = 3443 * CV.LB_TO_KG + STD_CARGO_KG
|
|
|
|
|
ret.wheelbase = 2.83
|
|
|
|
|
ret.steerRatio = 15.5
|
2020-09-09 18:02:26 -05:00
|
|
|
|
2022-02-05 01:34:37 -06:00
|
|
|
if candidate not in (CAR.CX5_2022, ):
|
|
|
|
|
ret.minSteerSpeed = LKAS_LIMITS.DISABLE_SPEED * CV.KPH_TO_MS
|
2020-05-29 00:15:19 -05:00
|
|
|
|
|
|
|
|
ret.centerToFront = ret.wheelbase * 0.41
|
|
|
|
|
|
|
|
|
|
# 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,
|
|
|
|
|
tire_stiffness_factor=tire_stiffness_factor)
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
# returns a car.CarState
|
2022-04-12 22:58:34 -07:00
|
|
|
def _update(self, c):
|
2020-05-29 00:15:19 -05:00
|
|
|
ret = self.CS.update(self.cp, self.cp_cam)
|
|
|
|
|
|
|
|
|
|
# events
|
|
|
|
|
events = self.create_common_events(ret)
|
|
|
|
|
|
2022-01-30 23:04:07 -06:00
|
|
|
if self.CS.lkas_disabled:
|
|
|
|
|
events.add(EventName.lkasDisabled)
|
|
|
|
|
elif self.CS.low_speed_alert:
|
2020-05-29 00:15:19 -05:00
|
|
|
events.add(EventName.belowSteerSpeed)
|
|
|
|
|
|
|
|
|
|
ret.events = events.to_msg()
|
|
|
|
|
|
2022-04-12 22:58:34 -07:00
|
|
|
return ret
|
2020-05-29 00:15:19 -05:00
|
|
|
|
2023-02-09 15:37:39 -08:00
|
|
|
def apply(self, c, now_nanos):
|
|
|
|
|
return self.CC.update(c, self.CS, now_nanos)
|