process_replay: fix support for single cam segments (#30143)

* Fix assertion for vision_pubs

* Get camera states from meta

* Convert deviceType to string

* Use neo instead of eon for frame sizes dict

* update vision_pubs of process config when creating vipc
old-commit-hash: 9c5bbe1a91
laptop
Kacper Rączy 2 years ago committed by GitHub
parent a24af381f7
commit 71ad6ce228
  1. 21
      selfdrive/test/process_replay/process_replay.py
  2. 4
      selfdrive/test/process_replay/vision_meta.py

@ -204,7 +204,7 @@ class ProcessContainer:
def _setup_vision_ipc(self, all_msgs): def _setup_vision_ipc(self, all_msgs):
assert len(self.cfg.vision_pubs) != 0 assert len(self.cfg.vision_pubs) != 0
device_type = next(msg.initData.deviceType for msg in all_msgs if msg.which() == "initData") device_type = next(str(msg.initData.deviceType) for msg in all_msgs if msg.which() == "initData")
vipc_server = VisionIpcServer("camerad") vipc_server = VisionIpcServer("camerad")
streams_metas = available_streams(all_msgs) streams_metas = available_streams(all_msgs)
@ -214,6 +214,7 @@ class ProcessContainer:
vipc_server.start_listener() vipc_server.start_listener()
self.vipc_server = vipc_server self.vipc_server = vipc_server
self.cfg.vision_pubs = [meta.camera_state for meta in streams_metas if meta.camera_state in self.cfg.vision_pubs]
def _start_process(self): def _start_process(self):
if self.capture is not None: if self.capture is not None:
@ -393,9 +394,8 @@ class ModeldCameraSyncRcvCallback:
self.is_dual_camera = True self.is_dual_camera = True
def __call__(self, msg, cfg, frame): def __call__(self, msg, cfg, frame):
if msg.which() == "initData": self.is_dual_camera = len(cfg.vision_pubs) == 2
self.is_dual_camera = msg.initData.deviceType in ["tici", "tizi"] if msg.which() == "roadCameraState":
elif msg.which() == "roadCameraState":
self.road_present = True self.road_present = True
elif msg.which() == "wideRoadCameraState": elif msg.which() == "wideRoadCameraState":
self.wide_road_present = True self.wide_road_present = True
@ -681,14 +681,13 @@ def _replay_multi_process(
env_config = generate_environ_config(CP=CP) env_config = generate_environ_config(CP=CP)
# validate frs and vision pubs # validate frs and vision pubs
for cfg in cfgs: all_vision_pubs = [pub for cfg in cfgs for pub in cfg.vision_pubs]
if len(cfg.vision_pubs) == 0: if len(all_vision_pubs) != 0:
continue
assert frs is not None, "frs must be provided when replaying process using vision streams" assert frs is not None, "frs must be provided when replaying process using vision streams"
assert all(meta_from_camera_state(st) is not None for st in cfg.vision_pubs),\ assert all(meta_from_camera_state(st) is not None for st in all_vision_pubs), \
f"undefined vision stream spotted, probably misconfigured process: {cfg.vision_pubs}" f"undefined vision stream spotted, probably misconfigured process: (vision pubs: {all_vision_pubs})"
assert all(st in frs for st in cfg.vision_pubs), f"frs for this process must contain following vision streams: {cfg.vision_pubs}" required_vision_pubs = {m.camera_state for m in available_streams(lr)} & set(all_vision_pubs)
assert all(st in frs for st in required_vision_pubs), f"frs for this process must contain following vision streams: {required_vision_pubs}"
all_msgs = sorted(lr, key=lambda msg: msg.logMonoTime) all_msgs = sorted(lr, key=lambda msg: msg.logMonoTime)
log_msgs = [] log_msgs = []

@ -4,9 +4,9 @@ from openpilot.common.realtime import DT_MDL, DT_DMON
from openpilot.common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size, eon_f_frame_size, eon_d_frame_size from openpilot.common.transformations.camera import tici_f_frame_size, tici_d_frame_size, tici_e_frame_size, eon_f_frame_size, eon_d_frame_size
VideoStreamMeta = namedtuple("VideoStreamMeta", ["camera_state", "encode_index", "stream", "dt", "frame_sizes"]) VideoStreamMeta = namedtuple("VideoStreamMeta", ["camera_state", "encode_index", "stream", "dt", "frame_sizes"])
ROAD_CAMERA_FRAME_SIZES = {"tici": tici_f_frame_size, "tizi": tici_f_frame_size, "eon": eon_f_frame_size} ROAD_CAMERA_FRAME_SIZES = {"tici": tici_f_frame_size, "tizi": tici_f_frame_size, "neo": eon_f_frame_size}
WIDE_ROAD_CAMERA_FRAME_SIZES = {"tici": tici_e_frame_size, "tizi": tici_e_frame_size} WIDE_ROAD_CAMERA_FRAME_SIZES = {"tici": tici_e_frame_size, "tizi": tici_e_frame_size}
DRIVER_FRAME_SIZES = {"tici": tici_d_frame_size, "tizi": tici_d_frame_size, "eon": eon_d_frame_size} DRIVER_FRAME_SIZES = {"tici": tici_d_frame_size, "tizi": tici_d_frame_size, "neo": eon_d_frame_size}
VIPC_STREAM_METADATA = [ VIPC_STREAM_METADATA = [
# metadata: (state_msg_type, encode_msg_type, stream_type, dt, frame_sizes) # metadata: (state_msg_type, encode_msg_type, stream_type, dt, frame_sizes)
("roadCameraState", "roadEncodeIdx", VisionStreamType.VISION_STREAM_ROAD, DT_MDL, ROAD_CAMERA_FRAME_SIZES), ("roadCameraState", "roadEncodeIdx", VisionStreamType.VISION_STREAM_ROAD, DT_MDL, ROAD_CAMERA_FRAME_SIZES),

Loading…
Cancel
Save