From 1e5a935ff00916efe65046f50d46a77d091c2e29 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 1 Sep 2020 18:31:26 -0700 Subject: [PATCH] paramsd process replay test (#2118) * paramsd process replay test * cleanup --- .../test/process_replay/process_replay.py | 37 +++++++++++++------ selfdrive/test/process_replay/ref_commit | 2 +- .../test/process_replay/test_processes.py | 3 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 946e13f609..d071bcf07c 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -19,6 +19,9 @@ from common.params import Params from cereal.services import service_list from collections import namedtuple +# Numpy gives different results based on CPU features after version 19 +NUMPY_TOLERANCE = 1e-7 + ProcessConfig = namedtuple('ProcessConfig', ['proc_name', 'pub_sub', 'ignore', 'init_callback', 'should_recv_callback', 'tolerance']) @@ -197,14 +200,16 @@ def radar_rcv_callback(msg, CP, cfg, fsm): def calibration_rcv_callback(msg, CP, cfg, fsm): # calibrationd publishes 1 calibrationData every 5 cameraOdometry packets. # should_recv always true to increment frame - if msg.which() == 'carState': - if ((fsm.frame + 1) % 25) == 0: - recv_socks = ["liveCalibration"] - else: - recv_socks = [] - return recv_socks, True - else: - return [], False + recv_socks = [] + if msg.which() == 'carState' and ((fsm.frame + 1) % 25) == 0: + recv_socks = ["liveCalibration"] + return recv_socks, msg.which() == 'carState' + +def paramsd_rcv_callback(msg, CP, cfg, fsm): + recv_socks = [] + if msg.which() == 'carState' and ((fsm.frame + 2) % 5) == 0: + recv_socks = ["liveParameters"] + return recv_socks, msg.which() == 'carState' CONFIGS = [ @@ -262,7 +267,7 @@ CONFIGS = [ ignore=["logMonoTime", "valid"], init_callback=get_car_params, should_recv_callback=None, - tolerance=1e-7, + tolerance=NUMPY_TOLERANCE, ), ProcessConfig( proc_name="locationd", @@ -273,9 +278,19 @@ CONFIGS = [ ignore=["logMonoTime", "valid"], init_callback=get_car_params, should_recv_callback=None, - tolerance=1e-7, # Numpy gives different results based on CPU features after version 19 + tolerance=NUMPY_TOLERANCE, + ), + ProcessConfig( + proc_name="paramsd", + pub_sub={ + "carState": ["liveParameters"], + "liveLocationKalman": [] + }, + ignore=["logMonoTime", "valid"], + init_callback=get_car_params, + should_recv_callback=paramsd_rcv_callback, + tolerance=NUMPY_TOLERANCE, ), - ] def replay_process(cfg, lr): diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index 568aab2b73..b5db61df15 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -158743f002e82b62a67c6b91308db01d715f1643 \ No newline at end of file +eac7f0ebb37c2a8a0cf70d3d25d32ecd160d6cac \ No newline at end of file diff --git a/selfdrive/test/process_replay/test_processes.py b/selfdrive/test/process_replay/test_processes.py index 73939b0d97..650c39bc6c 100755 --- a/selfdrive/test/process_replay/test_processes.py +++ b/selfdrive/test/process_replay/test_processes.py @@ -6,8 +6,7 @@ from typing import Any from selfdrive.car.car_helpers import interface_names from selfdrive.test.process_replay.compare_logs import compare_logs -from selfdrive.test.process_replay.process_replay import (CONFIGS, - replay_process) +from selfdrive.test.process_replay.process_replay import CONFIGS, replay_process from tools.lib.logreader import LogReader INJECT_MODEL = 0