mirror of
https://gitlvb.teallvbs.xyz/IQ.Lvbs/IQ.Pilot.git
synced 2026-07-24 04:52:13 +08:00
44 lines
2.3 KiB
Python
44 lines
2.3 KiB
Python
from cereal import custom
|
|
from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState, long_control_state_trans
|
|
|
|
|
|
class TestLongControlStateTransition:
|
|
|
|
def test_stay_stopped(self):
|
|
CP_IQ = custom.IQCarParams.new_message()
|
|
active = True
|
|
current_state = LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=True, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=True, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=True)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.pid
|
|
active = False
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.off
|
|
|
|
def test_engage():
|
|
CP_IQ = custom.IQCarParams.new_message()
|
|
active = True
|
|
current_state = LongCtrlState.off
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=True, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=True, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=True)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP_IQ, active, current_state,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.pid
|