Skip to content

Commit 95c6cb3

Browse files
author
Casey Francis
committed
Revert "Steering fault fix"
This reverts commit 6600370.
1 parent cc84e6b commit 95c6cb3

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

panda/board/safety/safety_toyota.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ addr_checks toyota_rx_checks = {toyota_addr_checks, TOYOTA_ADDR_CHECKS_LEN};
4444
// global actuation limit states
4545
int toyota_dbc_eps_torque_factor = 100; // conversion factor for STEER_TORQUE_EPS in %: see dbc file
4646

47-
// steering faults occur when the angle rate is above a certain threshold for too long,
48-
// allow setting STEER_REQUEST bit to 0 with a non-zero desired torque when expected
49-
const uint8_t TOYOTA_MAX_STEER_RATE_FRAMES = 19U;
50-
uint8_t toyota_steer_req_matches; // counter for steer request bit matching non-zero torque
51-
5247
static uint8_t toyota_compute_checksum(CANPacket_t *to_push) {
5348
int addr = GET_ADDR(to_push);
5449
int len = GET_LEN(to_push);
@@ -205,7 +200,6 @@ static int toyota_tx_hook(CANPacket_t *to_send) {
205200
if (addr == 0x2E4) {
206201
int desired_torque = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2);
207202
desired_torque = to_signed(desired_torque, 16);
208-
bool steer_req = GET_BIT(to_send, 0U) != 0U;
209203
bool violation = 0;
210204

211205
uint32_t ts = microsecond_timer_get();
@@ -233,27 +227,13 @@ static int toyota_tx_hook(CANPacket_t *to_send) {
233227
}
234228
}
235229

236-
// handle steer_req bit mismatches: we set the bit to 0 at an expected
237-
// interval to bypass an EPS fault, violation if we exceed that frequency
238-
bool steer_req_mismatch = (desired_torque != 0) && !steer_req;
239-
if (!steer_req_mismatch) {
240-
toyota_steer_req_matches = MIN(toyota_steer_req_matches + 1U, 255U);
241-
} else {
242-
// no torque if controls is not allowed or mismatch with STEER_REQUEST bit
243-
if ((!controls_allowed || !steer_req) && (desired_torque != 0)) {
244-
violation = 1;
245-
}
246-
toyota_steer_req_matches = 0U;
247-
}
248-
249230
// no torque if controls is not allowed
250231
if (!controls_allowed && (desired_torque != 0)) {
251232
violation = 1;
252233
}
253234

254235
// reset to 0 if either controls is not allowed or there's a violation
255236
if (violation || !controls_allowed) {
256-
toyota_steer_req_matches = 0U;
257237
desired_torque_last = 0;
258238
rt_torque_last = 0;
259239
ts_last = ts;
@@ -270,7 +250,6 @@ static int toyota_tx_hook(CANPacket_t *to_send) {
270250

271251
static const addr_checks* toyota_init(int16_t param) {
272252
controls_allowed = 0;
273-
toyota_steer_req_matches = 0U;
274253
relay_malfunction_reset();
275254
gas_interceptor_detected = 0;
276255
toyota_dbc_eps_torque_factor = param;

selfdrive/car/toyota/carcontroller.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
from opendbc.can.packer import CANPacker
1111
VisualAlert = car.CarControl.HUDControl.VisualAlert
1212

13-
# constants for fault workaround
14-
MAX_STEER_RATE = 100 # deg/s
15-
MAX_STEER_RATE_FRAMES = 19
1613

1714
class CarController():
1815
def __init__(self, dbc_name, CP, VM):
@@ -22,7 +19,7 @@ def __init__(self, dbc_name, CP, VM):
2219
self.standstill_req = False
2320
self.steer_rate_limited = False
2421
self.CP = CP
25-
self.steer_rate_counter = 0
22+
2623
self.packer = CANPacker(dbc_name)
2724
self.gas = 0
2825
self.accel = 0
@@ -54,22 +51,12 @@ def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd, hud_aler
5451
apply_steer = apply_toyota_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, CarControllerParams)
5552
self.steer_rate_limited = new_steer != apply_steer
5653

57-
# EPS_STATUS->LKA_STATE either goes to 21 or 25 on rising edge of a steering fault and
58-
# the value seems to describe how many frames the steering rate was above 100 deg/s, so
59-
# cut torque with some margin for the lower state
60-
if active and abs(CS.out.steeringRateDeg) >= MAX_STEER_RATE:
61-
self.steer_rate_counter += 1
62-
else:
63-
self.rate_limit_counter = 0
64-
65-
apply_steer_req = 1
6654
# Cut steering while we're in a known fault state (2s)
67-
if not active: # or CS.steer_state in (9, 25) or abs(CS.out.steeringRateDeg) > 100 or (abs(CS.out.steeringAngleDeg) > 150 and CS.CP.carFingerprint in [CAR.RAV4H, CAR.PRIUS]):
55+
if not active or CS.steer_state in (9, 25):
6856
apply_steer = 0
6957
apply_steer_req = 0
70-
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
71-
apply_steer_req = 0
72-
self.steer_rate_counter = 0
58+
else:
59+
apply_steer_req = 1
7360

7461
# TODO: probably can delete this. CS.pcm_acc_status uses a different signal
7562
# than CS.cruiseState.enabled. confirm they're not meaningfully different

selfdrive/car/toyota/carstate.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ def update(self, cp, cp_cam):
8585
ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_EPS"] * self.eps_torque_scale
8686
# we could use the override bit from dbc, but it's triggered at too high torque values
8787
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
88-
# steer rate fault, goes to 21 or 25 for 1 frame, then 9 for ~2 seconds
89-
ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] in (0, 9, 21, 25)
90-
# 17 is a fault from a prolonged high torque delta between cmd and user
91-
ret.steerError = cp.vl["EPS_STATUS"]["LKA_STATE"] == 17
88+
ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5)
9289

9390
if self.CP.carFingerprint in (CAR.LEXUS_IS, CAR.LEXUS_RC):
9491
ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0
@@ -127,7 +124,7 @@ def update(self, cp, cp_cam):
127124

128125
ret.espDisabled = cp.vl["ESP_CONTROL"]["TC_DISABLED"] != 0
129126
# 2 is standby, 10 is active. TODO: check that everything else is really a faulty state
130-
#self.steer_state = cp.vl["EPS_STATUS"]["LKA_STATE"]
127+
self.steer_state = cp.vl["EPS_STATUS"]["LKA_STATE"]
131128

132129
if self.CP.enableBsm:
133130
ret.leftBlindspot = (cp.vl["BSM"]["L_ADJACENT"] == 1) or (cp.vl["BSM"]["L_APPROACHING"] == 1)

0 commit comments

Comments
 (0)