Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LongitudinalMpc: Remove class accel_limit_arr #23295

Merged
merged 6 commits into from
Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ class LongitudinalMpc:
def __init__(self, e2e=False):
self.e2e = e2e
self.reset()
self.accel_limit_arr = np.zeros((N+1, 2))
self.accel_limit_arr[:,0] = -1.2
self.accel_limit_arr[:,1] = 1.2
self.source = SOURCES[2]

def reset(self):
Expand Down Expand Up @@ -224,6 +221,9 @@ def reset(self):
def set_weights(self):
if self.e2e:
self.set_weights_for_xva_policy()
self.params[:,0] = -10.
self.params[:,1] = 10.
self.params[:,2] = 1e5
else:
self.set_weights_for_lead_policy()

Expand Down Expand Up @@ -348,15 +348,9 @@ def update_with_xva(self, x, v, a):
for i in range(N):
self.solver.cost_set(i, "yref", self.yref[i])
self.solver.cost_set(N, "yref", self.yref[N][:COST_E_DIM])
self.accel_limit_arr[:,0] = -10.
self.accel_limit_arr[:,1] = 10.
x_obstacle = 1e5*np.ones(N+1)
self.params = np.concatenate([self.accel_limit_arr,
x_obstacle[:, None],
self.prev_a[:,None]], axis=1)
self.params[:,3] = np.copy(self.prev_a)
self.run()


def run(self):
for i in range(N+1):
self.solver.set(i, 'p', self.params[i])
Expand Down