Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

Commit

Permalink
Longcontrol: remove starting state (commaai#543)
Browse files Browse the repository at this point in the history
* remove starting state

* remove params
  • Loading branch information
sshane committed Dec 30, 2021
1 parent ddd4ab4 commit 589d9e2
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 22 deletions.
1 change: 0 additions & 1 deletion selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
ret.longitudinalTuning.kpV = [0.1]
ret.longitudinalTuning.kiV = [0.0]
ret.stopAccel = 0.0
ret.startAccel = 0.0

ret.longitudinalActuatorDelayUpperBound = 1.0 # s

Expand Down
2 changes: 0 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def get_std_params(candidate, fingerprint):
ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this
ret.steerRatioRear = 0. # no rear steering, at least on the listed cars aboveA
ret.openpilotLongitudinalControl = False
ret.startAccel = -0.8
ret.stopAccel = -2.0
ret.startingAccelRate = 3.2 # brake_travel/s while releasing on restart
ret.stoppingDecelRate = 0.8 # brake_travel/s while trying to stop
ret.vEgoStopping = 0.5
ret.vEgoStarting = 0.5
Expand Down
1 change: 0 additions & 1 deletion selfdrive/car/tesla/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None):
ret.longitudinalTuning.kiBP = [0]
ret.longitudinalTuning.kiV = [0]
ret.stopAccel = 0.0
ret.startAccel = 0.0
ret.longitudinalActuatorDelayUpperBound = 0.5 # s
ret.radarTimeStep = (1.0 / 8) # 8Hz

Expand Down
2 changes: 0 additions & 2 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,8 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # py
set_long_tune(ret.longitudinalTuning, LongTunes.TSS2)
ret.vEgoStopping = 0.2 # car is near 0.1 to 0.2 when car starts requesting stopping accel
ret.vEgoStarting = 0.2 # needs to be > or == vEgoStopping
ret.startAccel = 0.0 # Toyota requests 0 instantly, then hands control off to some controller
ret.stopAccel = -2.0 # Toyota requests -0.4 when stopped
ret.stoppingDecelRate = 0.8 # reach stopping target smoothly - seems to take 0.5 seconds to go from 0 to -0.4
ret.startingAccelRate = 20. # release brakes fast
else:
set_long_tune(ret.longitudinalTuning, LongTunes.TSS)

Expand Down
19 changes: 3 additions & 16 deletions selfdrive/controls/lib/longcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def long_control_state_trans(CP, active, long_control_state, v_ego, v_target_future,
output_accel, brake_pressed, cruise_standstill):
brake_pressed, cruise_standstill):
"""Update longitudinal control state machine"""
stopping_condition = (v_ego < 2.0 and cruise_standstill) or \
(v_ego < CP.vEgoStopping and
Expand All @@ -36,12 +36,6 @@ def long_control_state_trans(CP, active, long_control_state, v_ego, v_target_fut

elif long_control_state == LongCtrlState.stopping:
if starting_condition:
long_control_state = LongCtrlState.starting

elif long_control_state == LongCtrlState.starting:
if stopping_condition:
long_control_state = LongCtrlState.stopping
elif output_accel >= CP.startAccel:
long_control_state = LongCtrlState.pid

return long_control_state
Expand Down Expand Up @@ -90,8 +84,8 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras):
# Update state machine
output_accel = self.last_output_accel
self.long_control_state = long_control_state_trans(CP, active, self.long_control_state, CS.vEgo,
v_target_future, output_accel,
CS.brakePressed, CS.cruiseState.standstill)
v_target_future, CS.brakePressed,
CS.cruiseState.standstill)

if self.long_control_state == LongCtrlState.off or CS.gasPressed:
self.reset(CS.vEgo)
Expand Down Expand Up @@ -120,13 +114,6 @@ def update(self, active, CS, CP, long_plan, accel_limits, extras):
output_accel = clip(output_accel, accel_limits[0], accel_limits[1])
self.reset(CS.vEgo)

# Intention is to move again, release brake fast before handing control to PID
elif self.long_control_state == LongCtrlState.starting:
if output_accel < CP.startAccel:
output_accel += CP.startingAccelRate * DT_CTRL
output_accel = min(output_accel, CP.startAccel)
self.reset(CS.vEgo)

self.last_output_accel = output_accel
final_accel = clip(output_accel, accel_limits[0], accel_limits[1])

Expand Down

0 comments on commit 589d9e2

Please sign in to comment.