mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-18 03:12:05 +08:00
Mazda: car state cleanup + comments
This commit is contained in:
@@ -12,7 +12,6 @@ class CarState(CarStateBase):
|
||||
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
|
||||
self.shifter_values = can_define.dv["GEAR"]["GEAR"]
|
||||
|
||||
self.cruise_speed = 0
|
||||
self.acc_active_last = False
|
||||
self.low_speed_alert = False
|
||||
self.lkas_allowed = False
|
||||
@@ -34,6 +33,8 @@ class CarState(CarStateBase):
|
||||
can_gear = int(cp.vl["GEAR"]["GEAR"])
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None))
|
||||
|
||||
ret.leftBlindspot = cp.vl["BSM"]["LEFT_BS1"] == 1
|
||||
ret.rightBlindspot = cp.vl["BSM"]["RIGHT_BS1"] == 1
|
||||
ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(40, cp.vl["BLINK_INFO"]["LEFT_BLINK"] == 1,
|
||||
cp.vl["BLINK_INFO"]["RIGHT_BLINK"] == 1)
|
||||
|
||||
@@ -44,6 +45,7 @@ class CarState(CarStateBase):
|
||||
ret.steeringTorqueEps = cp.vl["STEER_TORQUE"]["STEER_TORQUE_MOTOR"]
|
||||
ret.steeringRateDeg = cp.vl["STEER_RATE"]["STEER_ANGLE_RATE"]
|
||||
|
||||
# TODO: this should be from 0 - 1.
|
||||
ret.brakePressed = cp.vl["PEDALS"]["BRAKE_ON"] == 1
|
||||
ret.brake = cp.vl["BRAKE"]["BRAKE_PRESSURE"]
|
||||
|
||||
@@ -51,18 +53,18 @@ class CarState(CarStateBase):
|
||||
ret.doorOpen = any([cp.vl["DOORS"]["FL"], cp.vl["DOORS"]["FR"],
|
||||
cp.vl["DOORS"]["BL"], cp.vl["DOORS"]["BR"]])
|
||||
|
||||
# TODO: this should be from 0 - 1.
|
||||
ret.gas = cp.vl["ENGINE_DATA"]["PEDAL_GAS"]
|
||||
ret.gasPressed = ret.gas > 0
|
||||
|
||||
ret.leftBlindspot = cp.vl["BSM"]["LEFT_BS1"] == 1
|
||||
ret.rightBlindspot = cp.vl["BSM"]["RIGHT_BS1"] == 1
|
||||
|
||||
# LKAS is enabled at 52kph going up and disabled at 45kph going down
|
||||
if speed_kph > LKAS_LIMITS.ENABLE_SPEED:
|
||||
self.lkas_allowed = True
|
||||
elif speed_kph < LKAS_LIMITS.DISABLE_SPEED:
|
||||
self.lkas_allowed = False
|
||||
|
||||
# TODO: the signal used for available seems to be the adaptive cruise signal, instead of the main on
|
||||
# it should be used for carState.cruiseState.nonAdaptive instead
|
||||
ret.cruiseState.available = cp.vl["CRZ_CTRL"]["CRZ_AVAILABLE"] == 1
|
||||
ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]["CRZ_ACTIVE"] == 1
|
||||
ret.cruiseState.speed = cp.vl["CRZ_EVENTS"]["CRZ_SPEED"] * CV.KPH_TO_MS
|
||||
|
||||
Reference in New Issue
Block a user