Fix cruise MPC convergence bug and add test (#22295)
* fix tests * fix cruise convergence bug * update refs * Update selfdrive/controls/tests/test_cruise_speed.py Co-authored-by: Willem Melching <willem.melching@gmail.com> * Update selfdrive/controls/tests/test_cruise_speed.py * add msgh Co-authored-by: Willem Melching <willem.melching@gmail.com>pull/22299/head
parent
8a836b7e1e
commit
fcda55fbf1
7 changed files with 74 additions and 80 deletions
@ -0,0 +1,33 @@ |
||||
#!/usr/bin/env python3 |
||||
import unittest |
||||
import numpy as np |
||||
from selfdrive.test.longitudinal_maneuvers.maneuver import Maneuver |
||||
|
||||
def run_cruise_simulation(cruise, t_end=100.): |
||||
man = Maneuver( |
||||
'', |
||||
duration=t_end, |
||||
initial_speed=float(0.), |
||||
lead_relevancy=True, |
||||
initial_distance_lead=100, |
||||
cruise_values=[cruise], |
||||
prob_lead_values=[0.0], |
||||
breakpoints=[0.], |
||||
) |
||||
valid, output = man.evaluate() |
||||
assert valid |
||||
return output[-1,3] |
||||
|
||||
|
||||
class TestCruiseSpeed(unittest.TestCase): |
||||
def test_cruise_speed(self): |
||||
for speed in np.arange(5, 40, 5): |
||||
print(f'Testing {speed} m/s') |
||||
cruise_speed = float(speed) |
||||
|
||||
simulation_steady_state = run_cruise_simulation(cruise_speed) |
||||
self.assertAlmostEqual(simulation_steady_state, cruise_speed, delta=.01, msg=f'Did not reach {speed} m/s') |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
unittest.main() |
@ -1 +1 @@ |
||||
03585a6e067ff58f1030450efc55cd225dc2ffc3 |
||||
1e029954854211b6277f98e6b0c3438fd11e6667 |
Loading…
Reference in new issue