Longitudinal planner: clip a_desired to cruise limits (#25928)

* Clip a_desired to cruise limits

* Update selfdrive/controls/lib/longitudinal_planner.py

* fix

* update refs

* explicit
pull/25933/head
Shane Smiskol 3 years ago committed by GitHub
parent bea960675f
commit 4bd146ee7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      selfdrive/controls/lib/longitudinal_planner.py
  2. 2
      selfdrive/test/process_replay/ref_commit

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import math
import numpy as np
from common.numpy_fast import interp
from common.numpy_fast import clip, interp
import cereal.messaging as messaging
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
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:
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
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 required so, force a smooth deceleration
accel_limits_turns[1] = min(accel_limits_turns[1], AWARENESS_DECEL)

@ -1 +1 @@
5d33199905cbf9d9b45ef722a40530b08d5cecf4
53079010a5db8105854212157b5ee90029df7b92
Loading…
Cancel
Save