move can replay to segmentrangereader (#30971)

can replay
old-commit-hash: 042ccb9244
pull/32199/head
Justin Newberry 1 year ago committed by GitHub
parent 11449845e7
commit 3231738be9
  1. 23
      tools/replay/can_replay.py

@ -4,13 +4,11 @@ import os
import time import time
import threading import threading
import multiprocessing import multiprocessing
from tqdm import tqdm
os.environ['FILEREADER_CACHE'] = '1' os.environ['FILEREADER_CACHE'] = '1'
from openpilot.common.realtime import config_realtime_process, Ratekeeper, DT_CTRL from openpilot.common.realtime import config_realtime_process, Ratekeeper, DT_CTRL
from openpilot.selfdrive.boardd.boardd import can_capnp_to_can_list from openpilot.selfdrive.boardd.boardd import can_capnp_to_can_list
from openpilot.tools.plotjuggler.juggle import load_segment
from openpilot.tools.lib.srreader import SegmentRangeReader from openpilot.tools.lib.srreader import SegmentRangeReader
from panda import Panda, PandaJungle from panda import Panda, PandaJungle
@ -92,18 +90,21 @@ if __name__ == "__main__":
parser.add_argument("route_or_segment_name", nargs='?', help="The route or segment name to replay. If not specified, a default public route will be used.") parser.add_argument("route_or_segment_name", nargs='?', help="The route or segment name to replay. If not specified, a default public route will be used.")
args = parser.parse_args() args = parser.parse_args()
def process(lr):
return [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can']
print("Loading log...") print("Loading log...")
if args.route_or_segment_name is None: if args.route_or_segment_name is None:
ROUTE = "77611a1fac303767/2020-03-24--09-50-38" args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/10:16"
REPLAY_SEGS = list(range(10, 16)) # route has 82 segments available
CAN_MSGS = [] sr = SegmentRangeReader(args.route_or_segment_name)
logs = [f"https://commadataci.blob.core.windows.net/openpilotci/{ROUTE}/{i}/rlog.bz2" for i in REPLAY_SEGS]
with multiprocessing.Pool(24) as pool: with multiprocessing.Pool(24) as pool:
for lr in tqdm(pool.map(load_segment, logs)): CAN_MSGS = []
CAN_MSGS += [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can'] for p in pool.map(process, sr.lrs):
else: CAN_MSGS.extend(p)
lr = SegmentRangeReader(args.route_or_segment_name)
CAN_MSGS = [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can'] print("Finished loading...")
# set both to cycle ignition # set both to cycle ignition
IGN_ON = int(os.getenv("ON", "0")) IGN_ON = int(os.getenv("ON", "0"))

Loading…
Cancel
Save