Skip to content

Commit

Permalink
LongitudinalPlanner: replace hardcoded length with ModelConstants.IDX…
Browse files Browse the repository at this point in the history
…_N (commaai#32597)

replace hardcoded length
  • Loading branch information
deanlee authored Jun 3, 2024
1 parent f717e1e commit 1e70b23
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions selfdrive/controls/lib/longitudinal_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def __init__(self, CP, init_v=0.0, init_a=0.0, dt=DT_MDL):

@staticmethod
def parse_model(model_msg, model_error):
if (len(model_msg.position.x) == 33 and
len(model_msg.velocity.x) == 33 and
len(model_msg.acceleration.x) == 33):
if (len(model_msg.position.x) == ModelConstants.IDX_N and
len(model_msg.velocity.x) == ModelConstants.IDX_N and
len(model_msg.acceleration.x) == ModelConstants.IDX_N):
x = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.position.x) - model_error * T_IDXS_MPC
v = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.velocity.x) - model_error
a = np.interp(T_IDXS_MPC, ModelConstants.T_IDXS, model_msg.acceleration.x)
Expand Down

0 comments on commit 1e70b23

Please sign in to comment.