From a71c8ec2036fa41b025d25d983ac24583f0f5ffb Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Wed, 2 Mar 2022 06:32:00 -0800 Subject: [PATCH 1/2] initialize solverExecutionTime longitudinal_planner --- selfdrive/controls/lib/longitudinal_planner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 865442f73538c1..ad44953e94d576 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -55,6 +55,7 @@ def __init__(self, CP, init_v=0.0, init_a=0.0): self.v_desired_trajectory = np.zeros(CONTROL_N) self.a_desired_trajectory = np.zeros(CONTROL_N) self.j_desired_trajectory = np.zeros(CONTROL_N) + self.solverExecutionTime = 0.0 def update(self, sm): v_ego = sm['carState'].vEgo From 8a70d19c8999eaca1b8afc322144635836d1001f Mon Sep 17 00:00:00 2001 From: Jonathan Frey Date: Wed, 2 Mar 2022 15:53:25 +0100 Subject: [PATCH 2/2] test_onroad: improve timing evaluation --- selfdrive/test/test_onroad.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index a49f93e37d062d..80a381d3fc8030 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -216,8 +216,9 @@ def test_mpc_execution_timings(self): 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(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}' avg execution time: {np.mean(ts)}\n" + result += f"'{s}' execution time: min {min(ts):.5f}s\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" print(result) @@ -237,8 +238,8 @@ def test_model_execution_timings(self): 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(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}' avg execution time: {np.mean(ts)}\n" + result += f"'{s}' execution time: min {min(ts):.5f}s\n" + result += f"'{s}' execution time: mean {np.mean(ts):.5f}s\n" result += "------------------------------------------------\n" print(result)