mirror of https://github.com/commaai/openpilot.git
carState: add invalid sensors field (#33266)
* add to CS
* add vehicleSensorsInvalid to CarState
* fix ord
* clean up
old-commit-hash: 7ec9986340
This commit is contained in:
parent
988d16a4c8
commit
11c9105a60
|
@ -196,6 +196,7 @@ struct CarState {
|
|||
accFaulted @42 :Bool;
|
||||
carFaultedNonCritical @47 :Bool; # some ECU is faulted, but car remains controllable
|
||||
espActive @51 :Bool;
|
||||
vehicleSensorsInvalid @52 :Bool; # invalid steering angle readings, etc.
|
||||
|
||||
# cruise state
|
||||
cruiseState @10 :CruiseState;
|
||||
|
|
|
@ -17,8 +17,6 @@ class CarState(CarStateBase):
|
|||
if CP.transmissionType == TransmissionType.automatic:
|
||||
self.shifter_values = can_define.dv["PowertrainData_10"]["TrnRng_D_Rq"]
|
||||
|
||||
self.vehicle_sensors_valid = False
|
||||
|
||||
self.prev_distance_button = 0
|
||||
self.distance_button = 0
|
||||
|
||||
|
@ -27,7 +25,7 @@ class CarState(CarStateBase):
|
|||
|
||||
# Occasionally on startup, the ABS module recalibrates the steering pinion offset, so we need to block engagement
|
||||
# The vehicle usually recovers out of this state within a minute of normal driving
|
||||
self.vehicle_sensors_valid = cp.vl["SteeringPinion_Data"]["StePinCompAnEst_D_Qf"] == 3
|
||||
ret.vehicleSensorsInvalid = cp.vl["SteeringPinion_Data"]["StePinCompAnEst_D_Qf"] != 3
|
||||
|
||||
# car speed
|
||||
ret.vEgoRaw = cp.vl["BrakeSysFeatures"]["Veh_V_ActlBrk"] * CV.KPH_TO_MS
|
||||
|
|
|
@ -73,8 +73,6 @@ class CarInterface(CarInterfaceBase):
|
|||
ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
|
||||
|
||||
events = self.create_common_events(ret, extra_gears=[GearShifter.manumatic])
|
||||
if not self.CS.vehicle_sensors_valid:
|
||||
events.add(car.CarEvent.EventName.vehicleSensorsInvalid)
|
||||
|
||||
ret.events = events.to_msg()
|
||||
|
||||
|
|
|
@ -300,6 +300,8 @@ class CarInterfaceBase(ABC):
|
|||
events.add(EventName.preEnableStandstill)
|
||||
if cs_out.gasPressed:
|
||||
events.add(EventName.gasPressedOverride)
|
||||
if cs_out.vehicleSensorsInvalid:
|
||||
events.add(EventName.vehicleSensorsInvalid)
|
||||
|
||||
# Handle button presses
|
||||
for b in cs_out.buttonEvents:
|
||||
|
|
|
@ -112,6 +112,10 @@ class CarState(CarStateBase):
|
|||
ret.steerFaultTemporary = ret.steerFaultTemporary or cp.vl["EPS_STATUS"]["LTA_STATE"] in TEMP_STEER_FAULTS
|
||||
ret.steerFaultPermanent = ret.steerFaultPermanent or cp.vl["EPS_STATUS"]["LTA_STATE"] in PERM_STEER_FAULTS
|
||||
|
||||
# Lane Tracing Assist control is unavailable (EPS_STATUS->LTA_STATE=0) until
|
||||
# the more accurate angle sensor signal is initialized
|
||||
ret.vehicleSensorsInvalid = not self.accurate_steer_angle_seen
|
||||
|
||||
if self.CP.carFingerprint in UNSUPPORTED_DSU_CAR:
|
||||
# TODO: find the bit likely in DSU_CRUISE that describes an ACC fault. one may also exist in CLUTCH
|
||||
ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0
|
||||
|
|
|
@ -154,11 +154,6 @@ class CarInterface(CarInterfaceBase):
|
|||
# events
|
||||
events = self.create_common_events(ret)
|
||||
|
||||
# Lane Tracing Assist control is unavailable (EPS_STATUS->LTA_STATE=0) until
|
||||
# the more accurate angle sensor signal is initialized
|
||||
if self.CP.steerControlType == SteerControlType.angle and not self.CS.accurate_steer_angle_seen:
|
||||
events.add(EventName.vehicleSensorsInvalid)
|
||||
|
||||
if self.CP.openpilotLongitudinalControl:
|
||||
if ret.cruiseState.standstill and not ret.brakePressed:
|
||||
events.add(EventName.resumeRequired)
|
||||
|
|
Loading…
Reference in New Issue