LongitudinalPlanner: replace hardcoded length with ModelConstants.IDX_N (#32597)

replace hardcoded length
old-commit-hash: 1e70b23855
097
Dean Lee 11 months ago committed by GitHub
parent 10b536f73f
commit 375f2a243f
  1. 6
      selfdrive/controls/lib/longitudinal_planner.py

@ -62,9 +62,9 @@ class LongitudinalPlanner:
@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)

Loading…
Cancel
Save