@ -22,7 +22,7 @@ A_CRUISE_MAX_VALS = [1.6, 1.2, 0.8, 0.6]
A_CRUISE_MAX_BP = [ 0. , 10.0 , 25. , 40. ]
A_CRUISE_MAX_BP = [ 0. , 10.0 , 25. , 40. ]
CONTROL_N_T_IDX = ModelConstants . T_IDXS [ : CONTROL_N ]
CONTROL_N_T_IDX = ModelConstants . T_IDXS [ : CONTROL_N ]
ALLOW_THROTTLE_THRESHOLD = 0.5
ALLOW_THROTTLE_THRESHOLD = 0.5
ACCEL_LIMIT_MARGIN = 0.0 5
MIN_ALLOW_THROTTLE_SPEED = 2. 5
# Lookup table for turns
# Lookup table for turns
_A_TOTAL_MAX_V = [ 1.7 , 3.2 ]
_A_TOTAL_MAX_V = [ 1.7 , 3.2 ]
@ -151,12 +151,12 @@ class LongitudinalPlanner:
self . v_model_error = get_speed_error ( sm [ ' modelV2 ' ] , v_ego )
self . v_model_error = get_speed_error ( sm [ ' modelV2 ' ] , v_ego )
x , v , a , j , throttle_prob = self . parse_model ( sm [ ' modelV2 ' ] , self . v_model_error )
x , v , a , j , throttle_prob = self . parse_model ( sm [ ' modelV2 ' ] , self . v_model_error )
# Don't clip at low speeds since throttle_prob doesn't account for creep
# Don't clip at low speeds since throttle_prob doesn't account for creep
self . allow_throttle = throttle_prob > ALLOW_THROTTLE_THRESHOLD or v_ego < = 5.0
self . allow_throttle = throttle_prob > ALLOW_THROTTLE_THRESHOLD or v_ego < = MIN_ALLOW_THROTTLE_SPEED
if not self . allow_throttle :
if not self . allow_throttle :
# MPC breaks when accel limits would cause negative velocity within the MPC horizon, so we clip the max accel limit at vEgo/T_MAX plus a bit of margin
clipped_accel_coast = max ( accel_coast , accel_limits_turns [ 0 ] )
clipped_accel_coast = max ( accel_coast , accel_limits_turns [ 0 ] , - v_ego / T_IDXS_MPC [ - 1 ] + ACCEL_LIMIT_MARGIN )
clipped_accel_coast_interp = interp ( v_ego , [ MIN_ALLOW_THROTTLE_SPEED , MIN_ALLOW_THROTTLE_SPEED * 2 ] , [ accel_limits_turns [ 1 ] , clipped_accel_coast ] )
accel_limits_turns [ 1 ] = min ( accel_limits_turns [ 1 ] , clipped_accel_coast )
accel_limits_turns [ 1 ] = min ( accel_limits_turns [ 1 ] , clipped_accel_coast_interp )
if force_slow_decel :
if force_slow_decel :
v_cruise = 0.0
v_cruise = 0.0