|
1 | | -from opendbc.car.structs import car |
2 | 1 | from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState, long_control_state_trans |
3 | 2 |
|
4 | 3 |
|
5 | | - |
6 | | - |
7 | 4 | class TestLongControlStateTransition: |
8 | 5 |
|
9 | 6 | def test_stay_stopped(self): |
10 | | - CP = car.CarParams.new_message() |
11 | 7 | active = True |
12 | 8 | current_state = LongCtrlState.stopping |
13 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 9 | + next_state = long_control_state_trans(active, current_state, |
14 | 10 | should_stop=True, brake_pressed=False, cruise_standstill=False) |
15 | 11 | assert next_state == LongCtrlState.stopping |
16 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 12 | + next_state = long_control_state_trans(active, current_state, |
17 | 13 | should_stop=False, brake_pressed=True, cruise_standstill=False) |
18 | 14 | assert next_state == LongCtrlState.stopping |
19 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 15 | + next_state = long_control_state_trans(active, current_state, |
20 | 16 | should_stop=False, brake_pressed=False, cruise_standstill=True) |
21 | 17 | assert next_state == LongCtrlState.stopping |
22 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=1.0, |
| 18 | + next_state = long_control_state_trans(active, current_state, |
23 | 19 | should_stop=False, brake_pressed=False, cruise_standstill=False) |
24 | 20 | assert next_state == LongCtrlState.pid |
25 | 21 | active = False |
26 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=1.0, |
| 22 | + next_state = long_control_state_trans(active, current_state, |
27 | 23 | should_stop=False, brake_pressed=False, cruise_standstill=False) |
28 | 24 | assert next_state == LongCtrlState.off |
29 | 25 |
|
30 | 26 | def test_engage(): |
31 | | - CP = car.CarParams.new_message() |
32 | 27 | active = True |
33 | 28 | current_state = LongCtrlState.off |
34 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 29 | + next_state = long_control_state_trans(active, current_state, |
35 | 30 | should_stop=True, brake_pressed=False, cruise_standstill=False) |
36 | 31 | assert next_state == LongCtrlState.stopping |
37 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 32 | + next_state = long_control_state_trans(active, current_state, |
38 | 33 | should_stop=False, brake_pressed=True, cruise_standstill=False) |
39 | 34 | assert next_state == LongCtrlState.stopping |
40 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
| 35 | + next_state = long_control_state_trans(active, current_state, |
41 | 36 | should_stop=False, brake_pressed=False, cruise_standstill=True) |
42 | 37 | assert next_state == LongCtrlState.stopping |
43 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
44 | | - should_stop=False, brake_pressed=False, cruise_standstill=False) |
45 | | - assert next_state == LongCtrlState.pid |
46 | | - |
47 | | -def test_starting(): |
48 | | - CP = car.CarParams.new_message(startingState=True, vEgoStarting=0.5) |
49 | | - active = True |
50 | | - current_state = LongCtrlState.starting |
51 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=0.1, |
52 | | - should_stop=False, brake_pressed=False, cruise_standstill=False) |
53 | | - assert next_state == LongCtrlState.starting |
54 | | - next_state = long_control_state_trans(CP, active, current_state, v_ego=1.0, |
| 38 | + next_state = long_control_state_trans(active, current_state, |
55 | 39 | should_stop=False, brake_pressed=False, cruise_standstill=False) |
56 | 40 | assert next_state == LongCtrlState.pid |
0 commit comments