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

replace hardcoded length
pull/32592/head
Dean Lee 11 months ago committed by GitHub
parent f717e1e4e6
commit 1e70b23855
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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