|
|
@ -18,33 +18,39 @@ def test_time_to_onroad(): |
|
|
|
proc = subprocess.Popen(["python", manager_path]) |
|
|
|
proc = subprocess.Popen(["python", manager_path]) |
|
|
|
|
|
|
|
|
|
|
|
start_time = time.monotonic() |
|
|
|
start_time = time.monotonic() |
|
|
|
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents']) |
|
|
|
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents', 'sendcan']) |
|
|
|
try: |
|
|
|
try: |
|
|
|
# wait for onroad |
|
|
|
# wait for onroad. timeout assumes panda is up to date |
|
|
|
with Timeout(20, "timed out waiting to go onroad"): |
|
|
|
with Timeout(10, "timed out waiting to go onroad"): |
|
|
|
while True: |
|
|
|
while not sm['deviceState'].started: |
|
|
|
sm.update(1000) |
|
|
|
sm.update(100) |
|
|
|
if sm['deviceState'].started: |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# wait for engageability |
|
|
|
# wait for engageability |
|
|
|
try: |
|
|
|
try: |
|
|
|
with Timeout(10, "timed out waiting for engageable"): |
|
|
|
with Timeout(10, "timed out waiting for engageable"): |
|
|
|
|
|
|
|
sendcan_frame = None |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
sm.update(1000) |
|
|
|
sm.update(100) |
|
|
|
if sm['controlsState'].engageable: |
|
|
|
|
|
|
|
|
|
|
|
# sendcan is only sent once we're initialized |
|
|
|
|
|
|
|
if sm.seen['controlsState'] and sendcan_frame is None: |
|
|
|
|
|
|
|
sendcan_frame = sm.frame |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sendcan_frame is not None and sm.recv_frame['sendcan'] > sendcan_frame: |
|
|
|
|
|
|
|
sm.update(100) |
|
|
|
|
|
|
|
assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}" |
|
|
|
break |
|
|
|
break |
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
finally: |
|
|
|
finally: |
|
|
|
print(f"onroad events: {sm['onroadEvents']}") |
|
|
|
print(f"onroad events: {sm['onroadEvents']}") |
|
|
|
print(f"engageable after {time.monotonic() - start_time:.2f}s") |
|
|
|
print(f"engageable after {time.monotonic() - start_time:.2f}s") |
|
|
|
|
|
|
|
|
|
|
|
# once we're enageable, must be for the next few seconds |
|
|
|
# once we're enageable, must stay for the next few seconds |
|
|
|
for _ in range(500): |
|
|
|
st = time.monotonic() |
|
|
|
|
|
|
|
while (time.monotonic() - st) < 10.: |
|
|
|
sm.update(100) |
|
|
|
sm.update(100) |
|
|
|
|
|
|
|
assert sm.all_alive(), sm.alive |
|
|
|
assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}" |
|
|
|
assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}" |
|
|
|
finally: |
|
|
|
finally: |
|
|
|
proc.terminate() |
|
|
|
proc.terminate() |
|
|
|
if proc.wait(60) is None: |
|
|
|
if proc.wait(20) is None: |
|
|
|
proc.kill() |
|
|
|
proc.kill() |
|
|
|