Skip to content

Commit

Permalink
better steer fault names (commaai#23890)
Browse files Browse the repository at this point in the history
* better steer fault names

* bump cereal
# Conflicts:
#	cereal
#	selfdrive/car/subaru/carstate.py
  • Loading branch information
adeebshihadeh authored and budney committed Mar 27, 2022
1 parent 84a4565 commit f4a533f
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cereal
Submodule cereal updated 1 files
+2 −2 car.capnp
2 changes: 1 addition & 1 deletion selfdrive/car/chrysler/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def update(self, cp, cp_cam):
ret.steeringTorqueEps = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"]
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"]
ret.steerError = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed)
ret.steerFaultPermanent = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed)

ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]["HIGH_BEAM_FLASH"])

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/ford/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def update(self, cp):
ret.standstill = not ret.vEgoRaw > 0.001
ret.steeringAngleDeg = cp.vl["Steering_Wheel_Data_CG1"]["SteWhlRelInit_An_Sns"]
ret.steeringPressed = not cp.vl["Lane_Keep_Assist_Status"]["LaHandsOff_B_Actl"]
ret.steerError = cp.vl["Lane_Keep_Assist_Status"]["LaActDeny_B_Actl"] == 1
ret.steerFaultPermanent = cp.vl["Lane_Keep_Assist_Status"]["LaActDeny_B_Actl"] == 1
ret.cruiseState.speed = cp.vl["Cruise_Status"]["Set_Speed"] * CV.MPH_TO_MS
ret.cruiseState.enabled = not (cp.vl["Cruise_Status"]["Cruise_State"] in (0, 3))
ret.cruiseState.available = cp.vl["Cruise_Status"]["Cruise_State"] != 0
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def update(self, c, enabled, CS, frame, actuators,
if CS.lka_steering_cmd_counter != self.lka_steering_cmd_counter_last:
self.lka_steering_cmd_counter_last = CS.lka_steering_cmd_counter
elif (frame % P.STEER_STEP) == 0:
lkas_enabled = c.active and not (CS.out.steerWarning or CS.out.steerError) and CS.out.vEgo > P.MIN_STEER_SPEED
lkas_enabled = c.active and not (CS.out.steerFaultTemporary or CS.out.steerFaultPermanent) and CS.out.vEgo > P.MIN_STEER_SPEED
if lkas_enabled:
new_steer = int(round(actuators.steer * P.STEER_MAX))
apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P)
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def update(self, pt_cp, loopback_cp):

# 0 inactive, 1 active, 2 temporarily limited, 3 failed
self.lkas_status = pt_cp.vl["PSCMStatus"]["LKATorqueDeliveredStatus"]
ret.steerWarning = self.lkas_status == 2
ret.steerError = self.lkas_status == 3
ret.steerFaultTemporary = self.lkas_status == 2
ret.steerFaultPermanent = self.lkas_status == 3

# 1 - open, 0 - closed
ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]["FrontLeftDoor"] == 1 or
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ def update(self, cp, cp_cam, cp_body):
ret.seatbeltUnlatched = bool(cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_LAMP"] or not cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_LATCHED"])

steer_status = self.steer_status_values[cp.vl["STEER_STATUS"]["STEER_STATUS"]]
ret.steerError = steer_status not in ("NORMAL", "NO_TORQUE_ALERT_1", "NO_TORQUE_ALERT_2", "LOW_SPEED_LOCKOUT", "TMP_FAULT")
ret.steerFaultPermanent = steer_status not in ("NORMAL", "NO_TORQUE_ALERT_1", "NO_TORQUE_ALERT_2", "LOW_SPEED_LOCKOUT", "TMP_FAULT")
# NO_TORQUE_ALERT_2 can be caused by bump OR steering nudge from driver
self.steer_not_allowed = steer_status not in ("NORMAL", "NO_TORQUE_ALERT_2")
# LOW_SPEED_LOCKOUT is not worth a warning
ret.steerWarning = steer_status not in ("NORMAL", "LOW_SPEED_LOCKOUT", "NO_TORQUE_ALERT_2")
ret.steerFaultTemporary = steer_status not in ("NORMAL", "LOW_SPEED_LOCKOUT", "NO_TORQUE_ALERT_2")

if self.CP.openpilotLongitudinalControl:
self.brake_error = cp.vl["STANDSTILL"]["BRAKE_ERROR_1"] or cp.vl["STANDSTILL"]["BRAKE_ERROR_2"]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def update(self, c, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert,
self.steer_rate_limited = new_steer != apply_steer

# disable when temp fault is active, or below LKA minimum speed
lkas_active = c.active and not CS.out.steerWarning and CS.out.vEgo >= CS.CP.minSteerSpeed
lkas_active = c.active and not CS.out.steerFaultTemporary and CS.out.vEgo >= CS.CP.minSteerSpeed

if not lkas_active:
apply_steer = 0
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def update(self, cp, cp_cam):
ret.steeringTorque = cp.vl["MDPS12"]["CR_Mdps_StrColTq"]
ret.steeringTorqueEps = cp.vl["MDPS12"]["CR_Mdps_OutTq"]
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
ret.steerWarning = cp.vl["MDPS12"]["CF_Mdps_ToiUnavail"] != 0 or cp.vl["MDPS12"]["CF_Mdps_ToiFlt"] != 0
ret.steerFaultTemporary = cp.vl["MDPS12"]["CF_Mdps_ToiUnavail"] != 0 or cp.vl["MDPS12"]["CF_Mdps_ToiFlt"] != 0

# cruise state
if self.CP.openpilotLongitudinalControl:
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):

# Handle permanent and temporary steering faults
self.steering_unpressed = 0 if cs_out.steeringPressed else self.steering_unpressed + 1
if cs_out.steerWarning:
if cs_out.steerFaultTemporary:
# if the user overrode recently, show a less harsh alert
if self.silent_steer_warning or cs_out.standstill or self.steering_unpressed < int(1.5 / DT_CTRL):
self.silent_steer_warning = True
Expand All @@ -154,7 +154,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):
events.add(EventName.steerTempUnavailable)
else:
self.silent_steer_warning = False
if cs_out.steerError:
if cs_out.steerFaultPermanent:
events.add(EventName.steerUnavailable)

# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/mazda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def update(self, cp, cp_cam):
# Check if LKAS is disabled due to lack of driver torque when all other states indicate
# it should be enabled (steer lockout). Don't warn until we actually get lkas active
# and lose it again, i.e, after initial lkas activation
ret.steerWarning = self.lkas_allowed_speed and lkas_blocked
ret.steerFaultTemporary = self.lkas_allowed_speed and lkas_blocked

self.acc_active_last = ret.cruiseState.enabled

Expand All @@ -98,7 +98,7 @@ def update(self, cp, cp_cam):
self.lkas_disabled = cp_cam.vl["CAM_LANEINFO"]["LANE_LINES"] == 0
self.cam_lkas = cp_cam.vl["CAM_LKAS"]
self.cam_laneinfo = cp_cam.vl["CAM_LANEINFO"]
ret.steerError = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1
ret.steerFaultPermanent = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1

return ret

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/subaru/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def update(self, cp, cp_cam, cp_body):
cp.vl["BodyInfo"]["DOOR_OPEN_RL"],
cp.vl["BodyInfo"]["DOOR_OPEN_FR"],
cp.vl["BodyInfo"]["DOOR_OPEN_FL"]])
ret.steerError = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1
ret.steerFaultPermanent = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1
self.throttle_msg = copy.copy(cp.vl["Throttle"])

if self.car_fingerprint in PREGLOBAL_CARS:
Expand All @@ -104,7 +104,7 @@ def update(self, cp, cp_cam, cp_body):
self.car_follow = cp_cam.vl["ES_Distance"]["Car_Follow"]
self.close_distance = cp_cam.vl["ES_Distance"]["Close_Distance"]
else:
ret.steerWarning = cp.vl["Steering_Torque"]["Steer_Warning"] == 1
ret.steerFaultTemporary = cp.vl["Steering_Torque"]["Steer_Warning"] == 1
ret.cruiseState.nonAdaptive = cp_cam.vl["ES_DashStatus"]["Conventional_Cruise"] == 1
self.cruise_state = cp_cam.vl["ES_DashStatus"]["Cruise_State"]
self.brake_pedal_msg = copy.copy(cp.vl["Brake_Pedal"])
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/tesla/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def update(self, cp, cp_cam):
ret.steeringRateDeg = -cp.vl["STW_ANGLHP_STAT"]["StW_AnglHP_Spd"] # This is from a different angle sensor, and at different rate
ret.steeringTorque = -cp.vl["EPAS_sysStatus"]["EPAS_torsionBarTorque"]
ret.steeringPressed = (self.hands_on_level > 0)
ret.steerError = steer_status == "EAC_FAULT"
ret.steerWarning = self.steer_warning != "EAC_ERROR_IDLE"
ret.steerFaultPermanent = steer_status == "EAC_FAULT"
ret.steerFaultTemporary = self.steer_warning != "EAC_ERROR_IDLE"

# Cruise state
cruise_state = self.can_define.dv["DI_state"]["DI_cruiseState"].get(int(cp.vl["DI_state"]["DI_cruiseState"]), None)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update(self, cp, cp_cam):
ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_EPS"] * self.eps_torque_scale
# we could use the override bit from dbc, but it's triggered at too high torque values
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5)
ret.steerFaultTemporary = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5)

if self.CP.carFingerprint in (CAR.LEXUS_IS, CAR.LEXUS_RC):
ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def update(self, c, enabled, CS, frame, ext_bus, actuators, visual_alert, left_l
# torque value. Do that anytime we happen to have 0 torque, or failing that,
# when exceeding ~1/3 the 360 second timer.

if c.active and CS.out.vEgo > CS.CP.minSteerSpeed and not (CS.out.standstill or CS.out.steerError or CS.out.steerWarning):
if c.active and CS.out.vEgo > CS.CP.minSteerSpeed and not (CS.out.standstill or CS.out.steerFaultPermanent or CS.out.steerFaultTemporary):
new_steer = int(round(actuators.steer * P.STEER_MAX))
apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P)
self.steer_rate_limited = new_steer != apply_steer
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/volkswagen/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def update(self, pt_cp, cam_cp, ext_cp, trans_type):

# Verify EPS readiness to accept steering commands
hca_status = self.hca_status_values.get(pt_cp.vl["LH_EPS_03"]["EPS_HCA_Status"])
ret.steerError = hca_status in ("DISABLED", "FAULT")
ret.steerWarning = hca_status in ("INITIALIZING", "REJECTED")
ret.steerFaultPermanent = hca_status in ("DISABLED", "FAULT")
ret.steerFaultTemporary = hca_status in ("INITIALIZING", "REJECTED")

# Update gas, brakes, and gearshift.
ret.gas = pt_cp.vl["Motor_20"]["MO_Fahrpedalrohwert_01"] / 100.0
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def state_control(self, CS):
actuators.accel = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits, t_since_plan)

# Steering PID loop and lateral MPC
lat_active = self.active and not CS.steerWarning and not CS.steerError and CS.vEgo > self.CP.minSteerSpeed
lat_active = self.active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and CS.vEgo > self.CP.minSteerSpeed
desired_curvature, desired_curvature_rate = get_lag_adjusted_curvature(self.CP, CS.vEgo,
lat_plan.psis,
lat_plan.curvatures,
Expand Down

0 comments on commit f4a533f

Please sign in to comment.