process_replay: migrate cameraStates of segments without driverEncodeIdx (#30331)

Migrate camera states of segments without driverEncodeIdx
old-commit-hash: 21715d7f81
testing-closet
Kacper Rączy 2 years ago committed by GitHub
parent f22eeaa0be
commit 5fc85a7fba
  1. 12
      selfdrive/test/process_replay/migration.py

@ -94,6 +94,8 @@ def migrate_peripheralState(lr):
def migrate_cameraStates(lr):
all_msgs = []
frame_to_encode_id = defaultdict(dict)
# just for encodeId fallback mechanism
min_frame_id = defaultdict(lambda: float('inf'))
for msg in lr:
if msg.which() not in ["roadEncodeIdx", "wideRoadEncodeIdx", "driverEncodeIdx"]:
@ -111,10 +113,18 @@ def migrate_cameraStates(lr):
continue
camera_state = getattr(msg, msg.which())
min_frame_id[msg.which()] = min(min_frame_id[msg.which()], camera_state.frameId)
encode_id = frame_to_encode_id[msg.which()].get(camera_state.frameId)
if encode_id is None:
print(f"Missing encoded frame for camera feed {msg.which()} with frameId: {camera_state.frameId}")
continue
if len(frame_to_encode_id[msg.which()]) != 0:
continue
# fallback mechanism for logs without encodeIdx (e.g. logs from before 2022 with dcamera recording disabled)
# try to fake encode_id by subtracting lowest frameId
encode_id = camera_state.frameId - min_frame_id[msg.which()]
print(f"Faking encodeId to {encode_id} for camera feed {msg.which()} with frameId: {camera_state.frameId}")
new_msg = messaging.new_message(msg.which())
new_camera_state = getattr(new_msg, new_msg.which())

Loading…
Cancel
Save