@ -12,14 +12,15 @@ ACCEL_MIN_ISO = -3.5 # m/s^2
ACCEL_MAX_ISO = 2.0 # m/s^2
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 ,
brake_pressed , cruise_standstill ) :
v_target_future , brake_pressed , cruise_standstill ) :
""" Update longitudinal control state machine """
""" Update longitudinal control state machine """
accelerating = v_target_future > v_target
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
( v_target_future < CP . vEgoStopping or brake_pressed ) )
( ( v_target_future < CP . vEgoStopping and not accelerating ) or brake_pressed ) )
starting_condition = v_target_future > CP . vEgoStarting and not cruise_standstill
starting_condition = v_target_future > CP . vEgoStarting and accelerating and not cruise_standstill
if not active :
if not active :
long_control_state = LongCtrlState . off
long_control_state = LongCtrlState . off
@ -83,7 +84,7 @@ 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 , CS . brakePressed ,
v_target , v_target _future, 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 :