Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

juggle a whole route #20099

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions tools/plotjuggler/juggle.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
#!/usr/bin/env python3

import sys
import multiprocessing
import subprocess
from tempfile import NamedTemporaryFile
from tools.lib.route import Route
from tools.lib.logreader import LogReader
from selfdrive.test.process_replay.compare_logs import save_log
from tools.lib.url_file import URLFile



def load_segment(segment_name):
print(f"Loading {segment_name}")
lr = LogReader(segment_name)
r = [d for d in lr if d.which() not in ['can', 'sendcan']]
print(f"done {segment_name}")
return r

def juggle_file(fn):
subprocess.call(f"bin/plotjuggler -d {fn}", shell=True)
# subprocess.call(f"/home/batman/PlotJuggler/build/bin/plotjuggler -d {fn}", shell=True)

def juggle_route(route_name):
r = Route(route_name)
all_data = []

pool = multiprocessing.Pool(24)

all_data = []
for d in pool.map(load_segment, r.log_paths()):
all_data += d

tempfile = NamedTemporaryFile(suffix='.rlog')
save_log(tempfile.name, all_data, compress=False)
del all_data

juggle_file(tempfile.name)

def juggle_segment(route_name, segment_nr):

r = Route(route_name)
lp = r.log_paths()[segment_nr]

Expand All @@ -15,9 +47,11 @@ def juggle_segment(route_name, segment_nr):
return

uf = URLFile(lp)

subprocess.call(f"bin/plotjuggler -d {uf.name}", shell=True)
juggle_file(uf.name)


if __name__ == "__main__":
juggle_segment(sys.argv[1], int(sys.argv[2]))
if len(sys.argv) == 2:
juggle_route(sys.argv[1])
elif len(sys.argv) == 3:
juggle_segment(sys.argv[1], int(sys.argv[2]))