Longitudinal MPC set qp tolerance to 1e-3 (#23899)

* initialize solverExecutionTime longitudinal_planner

* test_onroad: improve timing evaluation

* longitudinal MPC: set qp_tol to 1e-3

* update ref

Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com>
old-commit-hash: ab371f888a
taco
Jonathan Frey 3 years ago committed by GitHub
parent aa549592f7
commit 0d5d9a43d3
  1. 1
      selfdrive/controls/lib/longitudinal_mpc_lib/long_mpc.py
  2. 1
      selfdrive/controls/lib/longitudinal_planner.py
  3. 2
      selfdrive/test/process_replay/ref_commit
  4. 9
      selfdrive/test/test_onroad.py

@ -178,6 +178,7 @@ def gen_long_mpc_solver():
# More iterations take too much time and less lead to inaccurate convergence in # More iterations take too much time and less lead to inaccurate convergence in
# some situations. Ideally we would run just 1 iteration to ensure fixed runtime. # some situations. Ideally we would run just 1 iteration to ensure fixed runtime.
ocp.solver_options.qp_solver_iter_max = 10 ocp.solver_options.qp_solver_iter_max = 10
ocp.solver_options.qp_tol = 1e-3
# set prediction horizon # set prediction horizon
ocp.solver_options.tf = Tf ocp.solver_options.tf = Tf

@ -55,6 +55,7 @@ class Planner:
self.v_desired_trajectory = np.zeros(CONTROL_N) self.v_desired_trajectory = np.zeros(CONTROL_N)
self.a_desired_trajectory = np.zeros(CONTROL_N) self.a_desired_trajectory = np.zeros(CONTROL_N)
self.j_desired_trajectory = np.zeros(CONTROL_N) self.j_desired_trajectory = np.zeros(CONTROL_N)
self.solverExecutionTime = 0.0
def update(self, sm): def update(self, sm):
v_ego = sm['carState'].vEgo v_ego = sm['carState'].vEgo

@ -1 +1 @@
5cd22804273530aaf69ebb9f5039e8d08ca44ef8 10555bbd908c7eead5eeaa36ab07ec2189845a95

@ -216,8 +216,9 @@ class TestOnroad(unittest.TestCase):
ts = [getattr(getattr(m, s), "solverExecutionTime") for m in self.lr if m.which() == s] ts = [getattr(getattr(m, s), "solverExecutionTime") for m in self.lr if m.which() == s]
self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}") self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}")
self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}") self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}")
result += f"'{s}' execution time: {min(ts)}\n" result += f"'{s}' execution time: min {min(ts):.5f}s\n"
result += f"'{s}' avg execution time: {np.mean(ts)}\n" result += f"'{s}' execution time: max {max(ts):.5f}s\n"
result += f"'{s}' execution time: mean {np.mean(ts):.5f}s\n"
result += "------------------------------------------------\n" result += "------------------------------------------------\n"
print(result) print(result)
@ -237,8 +238,8 @@ class TestOnroad(unittest.TestCase):
ts = [getattr(getattr(m, s), "modelExecutionTime") for m in self.lr if m.which() == s] ts = [getattr(getattr(m, s), "modelExecutionTime") for m in self.lr if m.which() == s]
self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}") self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}")
self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}") self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}")
result += f"'{s}' execution time: {min(ts)}\n" result += f"'{s}' execution time: min {min(ts):.5f}s\n"
result += f"'{s}' avg execution time: {np.mean(ts)}\n" result += f"'{s}' execution time: mean {np.mean(ts):.5f}s\n"
result += "------------------------------------------------\n" result += "------------------------------------------------\n"
print(result) print(result)

Loading…
Cancel
Save