Skip to content

Commit

Permalink
fix: Do not steer when disengaged in external control mode. Do not pr…
Browse files Browse the repository at this point in the history
…event steering fault when driving takes control and steers fast
  • Loading branch information
alfhern committed Oct 11, 2024
1 parent 1c21e7e commit 7f68712
Show file tree
Hide file tree
Showing 12 changed files with 88,778 additions and 16 deletions.
1 change: 1 addition & 0 deletions .devcontainer/.host/.Xauthority
Empty file.
Binary file added common/tests/test_common
Binary file not shown.
15 changes: 15 additions & 0 deletions selfdrive/assets/translations_assets.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="main_en">../ui/translations/main_en.qm</file>
<file alias="main_de">../ui/translations/main_de.qm</file>
<file alias="main_fr">../ui/translations/main_fr.qm</file>
<file alias="main_pt-BR">../ui/translations/main_pt-BR.qm</file>
<file alias="main_tr">../ui/translations/main_tr.qm</file>
<file alias="main_ar">../ui/translations/main_ar.qm</file>
<file alias="main_th">../ui/translations/main_th.qm</file>
<file alias="main_zh-CHT">../ui/translations/main_zh-CHT.qm</file>
<file alias="main_zh-CHS">../ui/translations/main_zh-CHS.qm</file>
<file alias="main_ko">../ui/translations/main_ko.qm</file>
<file alias="main_ja">../ui/translations/main_ja.qm</file>
</qresource>
</RCC>
32 changes: 16 additions & 16 deletions selfdrive/car/toyota/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,26 @@ def update(self, CC, CS, now_nanos):
new_steer = int(round(actuators.steer * 1000))
apply_steer = new_steer
if self.CCP.tuvParams.torqueRateLimiting:
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)
apply_steer_req = 1
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)

else:
new_steer = int(round(actuators.steer * self.CCP.STEER_MAX))
apply_steer = apply_meas_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, self.CCP)

# Count up to MAX_STEER_RATE_FRAMES, at which point we need to cut torque to avoid a steering fault
if lat_active and abs(CS.out.steeringRateDeg) >= MAX_STEER_RATE:
self.steer_rate_counter += 1
else:
self.steer_rate_counter = 0

apply_steer_req = 1
if not lat_active:
apply_steer = 0
apply_steer_req = 0
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
apply_steer_req = 0
self.steer_rate_counter = 0

# Count up to MAX_STEER_RATE_FRAMES, at which point we need to cut torque to avoid a steering fault.
# We do not do this when in External Control Mode so that car safety is persistent after user takes control
if lat_active and not self.CCP.externalControlMode and abs(CS.out.steeringRateDeg) >= MAX_STEER_RATE:
self.steer_rate_counter += 1
else:
self.steer_rate_counter = 0

apply_steer_req = 1
if not lat_active:
apply_steer = 0
apply_steer_req = 0
elif self.steer_rate_counter > MAX_STEER_RATE_FRAMES:
apply_steer_req = 0
self.steer_rate_counter = 0

# Never actuate with LKA on cars that only support LTA
if self.CP.steerControlType == car.CarParams.SteerControlType.angle:
Expand Down
Loading

0 comments on commit 7f68712

Please sign in to comment.