@ -13,7 +13,7 @@ ACCEL_MAX_ISO = 2.0 # m/s^2
def long_control_state_trans ( CP , active , long_control_state , v_ego , v_target_future ,
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 """
""" Update longitudinal control state machine """
stopping_condition = ( v_ego < 2.0 and cruise_standstill ) or \
stopping_condition = ( v_ego < 2.0 and cruise_standstill ) or \
( v_ego < CP . vEgoStopping and
( v_ego < CP . vEgoStopping and
@ -35,12 +35,6 @@ def long_control_state_trans(CP, active, long_control_state, v_ego, v_target_fut
elif long_control_state == LongCtrlState . stopping :
elif long_control_state == LongCtrlState . stopping :
if starting_condition :
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
long_control_state = LongCtrlState . pid
return long_control_state
return long_control_state
@ -88,8 +82,8 @@ class LongControl():
# Update state machine
# Update state machine
output_accel = self . last_output_accel
output_accel = self . last_output_accel
self . long_control_state = long_control_state_trans ( CP , active , self . long_control_state , CS . vEgo ,
self . long_control_state = long_control_state_trans ( CP , active , self . long_control_state , CS . vEgo ,
v_target_future , output_accel ,
v_target_future , CS . brakePressed ,
CS . brakePressed , CS . cruiseState . standstill )
CS . cruiseState . standstill )
if self . long_control_state == LongCtrlState . off or CS . gasPressed :
if self . long_control_state == LongCtrlState . off or CS . gasPressed :
self . reset ( CS . vEgo )
self . reset ( CS . vEgo )
@ -118,12 +112,6 @@ class LongControl():
output_accel = clip ( output_accel , accel_limits [ 0 ] , accel_limits [ 1 ] )
output_accel = clip ( output_accel , accel_limits [ 0 ] , accel_limits [ 1 ] )
self . reset ( CS . vEgo )
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
self . reset ( CS . vEgo )
self . last_output_accel = output_accel
self . last_output_accel = output_accel
final_accel = clip ( output_accel , accel_limits [ 0 ] , accel_limits [ 1 ] )
final_accel = clip ( output_accel , accel_limits [ 0 ] , accel_limits [ 1 ] )