|
|
@ -21,23 +21,23 @@ def test_time_to_onroad(): |
|
|
|
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents']) |
|
|
|
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents']) |
|
|
|
try: |
|
|
|
try: |
|
|
|
# wait for onroad |
|
|
|
# wait for onroad |
|
|
|
|
|
|
|
with Timeout(20, "timed out waiting to go onroad"): |
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
|
|
sm.update(1000) |
|
|
|
|
|
|
|
if sm['deviceState'].started: |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# wait for engageability |
|
|
|
try: |
|
|
|
try: |
|
|
|
with Timeout(20, "timed out waiting to go onroad"): |
|
|
|
with Timeout(10, "timed out waiting for engageable"): |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
sm.update(1000) |
|
|
|
sm.update(1000) |
|
|
|
if sm['deviceState'].started: |
|
|
|
if sm['controlsState'].engageable: |
|
|
|
break |
|
|
|
break |
|
|
|
time.sleep(1) |
|
|
|
time.sleep(1) |
|
|
|
finally: |
|
|
|
finally: |
|
|
|
print(f"onroad events: {sm['onroadEvents']}") |
|
|
|
print(f"onroad events: {sm['onroadEvents']}") |
|
|
|
|
|
|
|
|
|
|
|
# wait for engageability |
|
|
|
|
|
|
|
with Timeout(10, "timed out waiting for engageable"): |
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
|
|
sm.update(1000) |
|
|
|
|
|
|
|
if sm['controlsState'].engageable: |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
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 be for the next few seconds |
|
|
|