|
|
|
@ -27,14 +27,14 @@ TIMEOUT = 15 |
|
|
|
|
PROC_REPLAY_DIR = os.path.dirname(os.path.abspath(__file__)) |
|
|
|
|
FAKEDATA = os.path.join(PROC_REPLAY_DIR, "fakedata/") |
|
|
|
|
|
|
|
|
|
ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'init_callback', 'should_recv_callback', 'tolerance', 'fake_pubsubmaster', 'submaster_config'], defaults=({},)) |
|
|
|
|
ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'init_callback', 'should_recv_callback', 'tolerance', 'fake_pubsubmaster', 'submaster_config', 'environ', 'subtest_name'], defaults=({}, {}, "")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wait_for_event(evt): |
|
|
|
|
if not evt.wait(TIMEOUT): |
|
|
|
|
if threading.currentThread().getName() == "MainThread": |
|
|
|
|
# tested process likely died. don't let test just hang |
|
|
|
|
raise Exception("Timeout reached. Tested process likely crashed.") |
|
|
|
|
raise Exception(f"Timeout reached. Tested process {os.environ['PROC_NAME']} likely crashed.") |
|
|
|
|
else: |
|
|
|
|
# done testing this process, let it die |
|
|
|
|
sys.exit(0) |
|
|
|
@ -190,6 +190,7 @@ def get_car_params(msgs, fsm, can_sock, fingerprint): |
|
|
|
|
_, CP = get_car(can, sendcan) |
|
|
|
|
Params().put("CarParams", CP.to_bytes()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def controlsd_rcv_callback(msg, CP, cfg, fsm): |
|
|
|
|
# no sendcan until controlsd is initialized |
|
|
|
|
socks = [s for s in cfg.pub_sub[msg.which()] if |
|
|
|
@ -198,6 +199,7 @@ def controlsd_rcv_callback(msg, CP, cfg, fsm): |
|
|
|
|
socks.remove("sendcan") |
|
|
|
|
return socks, len(socks) > 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def radar_rcv_callback(msg, CP, cfg, fsm): |
|
|
|
|
if msg.which() != "can": |
|
|
|
|
return [], False |
|
|
|
@ -240,7 +242,7 @@ def laika_rcv_callback(msg, CP, cfg, fsm): |
|
|
|
|
if msg.ubloxGnss.which() == "measurementReport": |
|
|
|
|
return ["gnssMeasurements"], True |
|
|
|
|
else: |
|
|
|
|
return [], False |
|
|
|
|
return [], True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONFIGS = [ |
|
|
|
@ -345,6 +347,19 @@ CONFIGS = [ |
|
|
|
|
tolerance=None, |
|
|
|
|
fake_pubsubmaster=False, |
|
|
|
|
), |
|
|
|
|
ProcessConfig( |
|
|
|
|
proc_name="laikad", |
|
|
|
|
subtest_name="Offline", |
|
|
|
|
pub_sub={ |
|
|
|
|
"ubloxGnss": ["gnssMeasurements"], |
|
|
|
|
}, |
|
|
|
|
ignore=["logMonoTime"], |
|
|
|
|
init_callback=get_car_params, |
|
|
|
|
should_recv_callback=laika_rcv_callback, |
|
|
|
|
tolerance=NUMPY_TOLERANCE, |
|
|
|
|
fake_pubsubmaster=True, |
|
|
|
|
environ={"LAIKAD_NO_INTERNET": "1"}, |
|
|
|
|
), |
|
|
|
|
ProcessConfig( |
|
|
|
|
proc_name="laikad", |
|
|
|
|
pub_sub={ |
|
|
|
@ -366,7 +381,8 @@ def replay_process(cfg, lr, fingerprint=None): |
|
|
|
|
else: |
|
|
|
|
return cpp_replay_process(cfg, lr, fingerprint) |
|
|
|
|
|
|
|
|
|
def setup_env(simulation=False, CP=None): |
|
|
|
|
|
|
|
|
|
def setup_env(simulation=False, CP=None, cfg=None): |
|
|
|
|
params = Params() |
|
|
|
|
params.clear_all() |
|
|
|
|
params.put_bool("OpenpilotEnabledToggle", True) |
|
|
|
@ -380,6 +396,16 @@ def setup_env(simulation=False, CP=None): |
|
|
|
|
os.environ['SKIP_FW_QUERY'] = "" |
|
|
|
|
os.environ['FINGERPRINT'] = "" |
|
|
|
|
|
|
|
|
|
if cfg is not None: |
|
|
|
|
# Clear all custom processConfig environment variables |
|
|
|
|
for cfg in CONFIGS: |
|
|
|
|
for k, _ in cfg.environ.items(): |
|
|
|
|
if k in os.environ: |
|
|
|
|
del os.environ[k] |
|
|
|
|
|
|
|
|
|
os.environ.update(cfg.environ) |
|
|
|
|
os.environ['PROC_NAME'] = cfg.proc_name |
|
|
|
|
|
|
|
|
|
if simulation: |
|
|
|
|
os.environ["SIMULATION"] = "1" |
|
|
|
|
elif "SIMULATION" in os.environ: |
|
|
|
@ -396,6 +422,7 @@ def setup_env(simulation=False, CP=None): |
|
|
|
|
os.environ['SKIP_FW_QUERY'] = "1" |
|
|
|
|
os.environ['FINGERPRINT'] = CP.carFingerprint |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def python_replay_process(cfg, lr, fingerprint=None): |
|
|
|
|
sub_sockets = [s for _, sub in cfg.pub_sub.items() for s in sub] |
|
|
|
|
pub_sockets = [s for s in cfg.pub_sub.keys() if s != 'can'] |
|
|
|
@ -413,10 +440,10 @@ def python_replay_process(cfg, lr, fingerprint=None): |
|
|
|
|
if fingerprint is not None: |
|
|
|
|
os.environ['SKIP_FW_QUERY'] = "1" |
|
|
|
|
os.environ['FINGERPRINT'] = fingerprint |
|
|
|
|
setup_env() |
|
|
|
|
setup_env(cfg=cfg) |
|
|
|
|
else: |
|
|
|
|
CP = [m for m in lr if m.which() == 'carParams'][0].carParams |
|
|
|
|
setup_env(CP=CP) |
|
|
|
|
setup_env(CP=CP, cfg=cfg) |
|
|
|
|
|
|
|
|
|
assert(type(managed_processes[cfg.proc_name]) is PythonProcess) |
|
|
|
|
managed_processes[cfg.proc_name].prepare() |
|
|
|
@ -477,7 +504,7 @@ def cpp_replay_process(cfg, lr, fingerprint=None): |
|
|
|
|
log_msgs = [] |
|
|
|
|
|
|
|
|
|
# We need to fake SubMaster alive since we can't inject a fake clock |
|
|
|
|
setup_env(simulation=True) |
|
|
|
|
setup_env(simulation=True, cfg=cfg) |
|
|
|
|
|
|
|
|
|
managed_processes[cfg.proc_name].prepare() |
|
|
|
|
managed_processes[cfg.proc_name].start() |
|
|
|
|