|
|
@ -1,7 +1,7 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
#!/usr/bin/env python3 |
|
|
|
import math |
|
|
|
import math |
|
|
|
import numpy as np |
|
|
|
import numpy as np |
|
|
|
from common.numpy_fast import interp |
|
|
|
from common.numpy_fast import clip, interp |
|
|
|
|
|
|
|
|
|
|
|
import cereal.messaging as messaging |
|
|
|
import cereal.messaging as messaging |
|
|
|
from common.conversions import Conversions as CV |
|
|
|
from common.conversions import Conversions as CV |
|
|
@ -106,15 +106,17 @@ class LongitudinalPlanner: |
|
|
|
# No change cost when user is controlling the speed, or when standstill |
|
|
|
# No change cost when user is controlling the speed, or when standstill |
|
|
|
prev_accel_constraint = not (reset_state or sm['carState'].standstill) |
|
|
|
prev_accel_constraint = not (reset_state or sm['carState'].standstill) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] |
|
|
|
|
|
|
|
accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) |
|
|
|
|
|
|
|
|
|
|
|
if reset_state: |
|
|
|
if reset_state: |
|
|
|
self.v_desired_filter.x = v_ego |
|
|
|
self.v_desired_filter.x = v_ego |
|
|
|
self.a_desired = 0.0 |
|
|
|
# Clip aEgo to cruise limits to prevent large accelerations when becoming active |
|
|
|
|
|
|
|
self.a_desired = clip(sm['carState'].aEgo, accel_limits[0], accel_limits[1]) |
|
|
|
|
|
|
|
|
|
|
|
# Prevent divergence, smooth in current v_ego |
|
|
|
# Prevent divergence, smooth in current v_ego |
|
|
|
self.v_desired_filter.x = max(0.0, self.v_desired_filter.update(v_ego)) |
|
|
|
self.v_desired_filter.x = max(0.0, self.v_desired_filter.update(v_ego)) |
|
|
|
|
|
|
|
|
|
|
|
accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] |
|
|
|
|
|
|
|
accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) |
|
|
|
|
|
|
|
if force_slow_decel: |
|
|
|
if force_slow_decel: |
|
|
|
# if required so, force a smooth deceleration |
|
|
|
# if required so, force a smooth deceleration |
|
|
|
accel_limits_turns[1] = min(accel_limits_turns[1], AWARENESS_DECEL) |
|
|
|
accel_limits_turns[1] = min(accel_limits_turns[1], AWARENESS_DECEL) |
|
|
|