diff --git a/tools/replay/can_replay.py b/tools/replay/can_replay.py index 590a37734c..4be516a108 100755 --- a/tools/replay/can_replay.py +++ b/tools/replay/can_replay.py @@ -4,13 +4,11 @@ import os import time import threading import multiprocessing -from tqdm import tqdm os.environ['FILEREADER_CACHE'] = '1' from openpilot.common.realtime import config_realtime_process, Ratekeeper, DT_CTRL 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 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.") 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...") if args.route_or_segment_name is None: - ROUTE = "77611a1fac303767/2020-03-24--09-50-38" - REPLAY_SEGS = list(range(10, 16)) # route has 82 segments available + args.route_or_segment_name = "77611a1fac303767/2020-03-24--09-50-38/10:16" + + sr = SegmentRangeReader(args.route_or_segment_name) + + with multiprocessing.Pool(24) as pool: CAN_MSGS = [] - logs = [f"https://commadataci.blob.core.windows.net/openpilotci/{ROUTE}/{i}/rlog.bz2" for i in REPLAY_SEGS] - with multiprocessing.Pool(24) as pool: - for lr in tqdm(pool.map(load_segment, logs)): - CAN_MSGS += [can_capnp_to_can_list(m.can) for m in lr if m.which() == 'can'] - else: - lr = SegmentRangeReader(args.route_or_segment_name) - 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): + CAN_MSGS.extend(p) + + print("Finished loading...") # set both to cycle ignition IGN_ON = int(os.getenv("ON", "0"))