Long planner get accel: new function args (#34288)

* Change function args

* typo

* typo

* ref commit
pull/34289/head
Harald Schäfer 4 months ago committed by GitHub
parent 1a7c284445
commit 383893d39e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      selfdrive/controls/lib/longitudinal_planner.py
  2. 2
      selfdrive/test/process_replay/migration.py
  3. 2
      selfdrive/test/process_replay/ref_commit

@ -50,24 +50,20 @@ def limit_accel_in_turns(v_ego, angle_steers, a_target, CP):
return [a_target[0], min(a_target[1], a_x_allowed)] return [a_target[0], min(a_target[1], a_x_allowed)]
def get_accel_from_plan(CP, speeds, accels): def get_accel_from_plan(speeds, accels, action_t=DT_MDL, vEgoStopping=0.05):
if len(speeds) == CONTROL_N: if len(speeds) == CONTROL_N:
v_target_now = interp(DT_MDL, CONTROL_N_T_IDX, speeds) v_now = speeds[0]
a_target_now = interp(DT_MDL, CONTROL_N_T_IDX, accels) a_now = accels[0]
v_target = interp(CP.longitudinalActuatorDelay + DT_MDL, CONTROL_N_T_IDX, speeds) v_target = interp(action_t, CONTROL_N_T_IDX, speeds)
if v_target != v_target_now: a_target = 2 * (v_target - v_now) / (action_t) - a_now
a_target = 2 * (v_target - v_target_now) / CP.longitudinalActuatorDelay - a_target_now v_target_1sec = interp(action_t + 1.0, CONTROL_N_T_IDX, speeds)
else:
a_target = a_target_now
v_target_1sec = interp(CP.longitudinalActuatorDelay + DT_MDL + 1.0, CONTROL_N_T_IDX, speeds)
else: else:
v_target = 0.0 v_target = 0.0
v_target_1sec = 0.0 v_target_1sec = 0.0
a_target = 0.0 a_target = 0.0
should_stop = (v_target < CP.vEgoStopping and should_stop = (v_target < vEgoStopping and
v_target_1sec < CP.vEgoStopping) v_target_1sec < vEgoStopping)
return a_target, should_stop return a_target, should_stop
@ -201,7 +197,9 @@ class LongitudinalPlanner:
longitudinalPlan.longitudinalPlanSource = self.mpc.source longitudinalPlan.longitudinalPlanSource = self.mpc.source
longitudinalPlan.fcw = self.fcw longitudinalPlan.fcw = self.fcw
a_target, should_stop = get_accel_from_plan(self.CP, longitudinalPlan.speeds, longitudinalPlan.accels) action_t = self.CP.longitudinalActuatorDelay + DT_MDL
a_target, should_stop = get_accel_from_plan(longitudinalPlan.speeds, longitudinalPlan.accels,
action_t=action_t, vEgoStopping=self.CP.vEgoStopping)
longitudinalPlan.aTarget = a_target longitudinalPlan.aTarget = a_target
longitudinalPlan.shouldStop = should_stop longitudinalPlan.shouldStop = should_stop
longitudinalPlan.allowBrake = True longitudinalPlan.allowBrake = True

@ -107,7 +107,7 @@ def migrate_longitudinalPlan(msgs):
if msg.which() != 'longitudinalPlan': if msg.which() != 'longitudinalPlan':
continue continue
new_msg = msg.as_builder() new_msg = msg.as_builder()
new_msg.longitudinalPlan.aTarget, new_msg.longitudinalPlan.shouldStop = get_accel_from_plan(CP, msg.longitudinalPlan.speeds, msg.longitudinalPlan.accels) new_msg.longitudinalPlan.aTarget, new_msg.longitudinalPlan.shouldStop = get_accel_from_plan(msg.longitudinalPlan.speeds, msg.longitudinalPlan.accels)
ops.append((index, new_msg.as_reader())) ops.append((index, new_msg.as_reader()))
return ops, [], [] return ops, [], []

@ -1 +1 @@
cae12bc0a2960de17104a9e22fafe33d797fbcee 1f37082d56a60f20ba9e36b702a23cbdde3caca7

Loading…
Cancel
Save