mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 21:14:01 +08:00
* init * bump * bump * bump * recheck openpilot long availability * bump * bump * bump * bump * bump * just base for now * bump * bump * bump * bump * flipped * apparently it's yucky, reverting most * bump * need to add for toyota * should've been remove * flipped * bump * no way * fix * test sdsu distance * final tuning for pedal * bump
60 lines
3.1 KiB
Python
60 lines
3.1 KiB
Python
from cereal import car, custom
|
|
from openpilot.selfdrive.controls.lib.longcontrol import LongCtrlState, long_control_state_trans
|
|
|
|
|
|
|
|
|
|
class TestLongControlStateTransition:
|
|
|
|
def test_stay_stopped(self):
|
|
CP = car.CarParams.new_message()
|
|
CP_SP = custom.CarParamsSP.new_message()
|
|
active = True
|
|
current_state = LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=True, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=True, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=True)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=1.0,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.pid
|
|
active = False
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=1.0,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.off
|
|
|
|
def test_engage():
|
|
CP = car.CarParams.new_message()
|
|
CP_SP = custom.CarParamsSP.new_message()
|
|
active = True
|
|
current_state = LongCtrlState.off
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=True, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=True, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=True)
|
|
assert next_state == LongCtrlState.stopping
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.pid
|
|
|
|
def test_starting():
|
|
CP = car.CarParams.new_message(startingState=True, vEgoStarting=0.5)
|
|
CP_SP = custom.CarParamsSP.new_message()
|
|
active = True
|
|
current_state = LongCtrlState.starting
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=0.1,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.starting
|
|
next_state = long_control_state_trans(CP, CP_SP, active, current_state, v_ego=1.0,
|
|
should_stop=False, brake_pressed=False, cruise_standstill=False)
|
|
assert next_state == LongCtrlState.pid
|