cleanup
parent
7b7655079a
commit
1a3cb43a67
|
@ -1,58 +0,0 @@
|
||||||
import cereal.messaging as messaging
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from collections import defaultdict
|
|
||||||
from tabulate import tabulate
|
|
||||||
import matplotlib.patches as mpatches
|
|
||||||
|
|
||||||
#TODO: meassure camera time also
|
|
||||||
# start times cereal
|
|
||||||
# one already have delay time
|
|
||||||
# fix so both planning are shown
|
|
||||||
# commit
|
|
||||||
# nicer visual
|
|
||||||
# planner publishes more than just sendcan
|
|
||||||
|
|
||||||
topics = ['roadCameraState', 'modelV2', 'lateralPlan', 'longitudinalPlan']
|
|
||||||
colors = ['red', 'blue', 'green', 'orange']
|
|
||||||
|
|
||||||
sm = messaging.SubMaster(topics)
|
|
||||||
updated = []
|
|
||||||
started = False
|
|
||||||
t0=0
|
|
||||||
size = 100
|
|
||||||
count = 0
|
|
||||||
avg_times = defaultdict(list)
|
|
||||||
|
|
||||||
fig, gnt = plt.subplots()
|
|
||||||
gnt.set_xlim(0, 75)
|
|
||||||
gnt.set_ylim(0, size)
|
|
||||||
|
|
||||||
while count < size:
|
|
||||||
sm.update()
|
|
||||||
times = sm.logMonoTime
|
|
||||||
|
|
||||||
if sm.updated[topics[0]]:
|
|
||||||
if not started:
|
|
||||||
started = True
|
|
||||||
updated = []
|
|
||||||
continue
|
|
||||||
|
|
||||||
events = {}
|
|
||||||
for topic in updated:
|
|
||||||
time = times[topic]/1e6 if topic != topics[0] else t0
|
|
||||||
time -= t0
|
|
||||||
events[(time, 0.3)] = "tab:"+colors[topics.index(topic)]
|
|
||||||
avg_times[topic].append(time)
|
|
||||||
gnt.broken_barh(events.keys(), (count, 0.9), facecolors=(events.values()))
|
|
||||||
count += 1
|
|
||||||
t0 = times[topics[0]]/1e6
|
|
||||||
updated=[]
|
|
||||||
updated.extend([topic for topic, val in sm.updated.items() if val])
|
|
||||||
|
|
||||||
print(tabulate([[topic, sum(t)/len(t), max(t), len(t)] for topic,t in avg_times.items()], headers=["Topic", "avg", "max", "len"]))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plt.legend(handles=[mpatches.Patch(color=colors[i], label=topics[i]) for i in range(len(topics))])
|
|
||||||
plt.show(block=True)
|
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
import cereal.messaging as messaging
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from collections import defaultdict
|
|
||||||
from tabulate import tabulate
|
|
||||||
import matplotlib.patches as mpatches
|
|
||||||
|
|
||||||
topics = ['roadCameraState', 'wideRoadCameraState', 'driverCameraState', 'modelV2', 'lateralPlan', 'longitudinalPlan', 'carControl']
|
|
||||||
frames = defaultdict(lambda: defaultdict(int))
|
|
||||||
|
|
||||||
sm = messaging.SubMaster(topics)
|
|
||||||
while len(frames) < 50:
|
|
||||||
sm.update()
|
|
||||||
for topic, is_updated in sm.updated.items():
|
|
||||||
if is_updated:
|
|
||||||
if topic == topics[0]:
|
|
||||||
frames[sm[topic].frameId]["road_cam_start"] = sm[topic].timestampSof
|
|
||||||
frames[sm[topic].frameId]["road_cam_end"] = sm[topic].timestampEof
|
|
||||||
if topic == topics[1]:
|
|
||||||
frames[sm[topic].frameId]["wide_cam_start"] = sm[topic].timestampSof
|
|
||||||
frames[sm[topic].frameId]["wide_cam_end"] = sm[topic].timestampEof
|
|
||||||
if topic == topics[2]:
|
|
||||||
frames[sm[topic].frameId]["driver_cam_start"] = sm[topic].timestampSof
|
|
||||||
frames[sm[topic].frameId]["driver_cam_end"] = sm[topic].timestampEof
|
|
||||||
frames[sm[topic].frameId][topic] = sm.logMonoTime[topic]
|
|
||||||
|
|
||||||
avg_times = defaultdict(list)
|
|
||||||
|
|
||||||
fig, gnt = plt.subplots()
|
|
||||||
gnt.set_xlim(0, 150)
|
|
||||||
gnt.set_ylim(0, len(frames))
|
|
||||||
colors = {"road_cam_start":'red', "wide_cam_start":'blue', "driver_cam_start":'green', "road_cam_end":'cyan', "wide_cam_end":'magenta', "driver_cam_end":'yellow', 'roadCameraState':'olive', 'wideRoadCameraState':'steelblue', 'driverCameraState':'deeppink', 'modelV2':'darkseagreen', 'lateralPlan':'coral', 'longitudinalPlan':'brown', 'carControl':'gray'}
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
for frame, times in frames.items():
|
|
||||||
t0 = min(times.values())
|
|
||||||
events = {}
|
|
||||||
for topic, time in times.items():
|
|
||||||
#print(" ", topic, (time-t0)/1e6)
|
|
||||||
events[((time-t0)/1e6, 0.3)] = colors[topic]
|
|
||||||
avg_times[topic].append((time-t0)/1e6)
|
|
||||||
gnt.broken_barh(events.keys(), (count, 0.9), facecolors=(events.values()))
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
print(tabulate([[topic, sum(avg_times[topic])/len(avg_times[topic]), max(avg_times[topic]), len(avg_times[topic])] for topic in colors.keys()], headers=["event", "avg", "max", "len"]))
|
|
||||||
|
|
||||||
plt.legend(handles=[mpatches.Patch(color=list(colors.values())[i], label=list(colors.keys())[i]) for i in range(len(colors))])
|
|
||||||
plt.show(block=True)
|
|
|
@ -1,25 +0,0 @@
|
||||||
import cereal.messaging as messaging
|
|
||||||
from collections import defaultdict
|
|
||||||
from typing import Dict
|
|
||||||
|
|
||||||
topics = ['roadCameraState', 'modelV2', 'lateralPlan', 'longitudinalPlan']
|
|
||||||
count = defaultdict(int)
|
|
||||||
|
|
||||||
sm = messaging.SubMaster(topics)
|
|
||||||
updated = []
|
|
||||||
started = False
|
|
||||||
while 1:
|
|
||||||
sm.update()
|
|
||||||
if sm.updated[topics[0]]:
|
|
||||||
#print((sm['roadCameraState'].timestampEof-sm['roadCameraState'].timestampSof)/1e6)
|
|
||||||
if not started:
|
|
||||||
started = True
|
|
||||||
updated = ['0']
|
|
||||||
continue
|
|
||||||
count["".join(updated)] += 1
|
|
||||||
for key, val in count.items():
|
|
||||||
print(", ".join([topics[int(c)] for c in key]), val)
|
|
||||||
updated = []
|
|
||||||
print("-----------")
|
|
||||||
updated.extend([str(topics.index(topic)) for topic, val in sm.updated.items() if val])
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ for frame_id, services in timestamps.items():
|
||||||
print(tabulate([[item[1][0], item[1][1], item[1][2]] for item in s], headers=["service", "event", "time (ms)"]))
|
print(tabulate([[item[1][0], item[1][1], item[1][2]] for item in s], headers=["service", "event", "time (ms)"]))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
exit()
|
'''
|
||||||
fig, gnt = plt.subplots()
|
fig, gnt = plt.subplots()
|
||||||
maxx = max([max([max(events.values()) for events in services.values()]) for services in timestamps.values()])/1e6
|
maxx = max([max([max(events.values()) for events in services.values()]) for services in timestamps.values()])/1e6
|
||||||
gnt.set_xlim(0, 150)
|
gnt.set_xlim(0, 150)
|
||||||
|
@ -51,3 +51,4 @@ for frame_id, services in timestamps.items():
|
||||||
count+=1
|
count+=1
|
||||||
print(tabulate([[event, sum(times)/len(times), max(times), len(times)] for event, times in avg_times.items()], headers=["event", "avg", "max", "len"]))
|
print(tabulate([[event, sum(times)/len(times), max(times), len(times)] for event, times in avg_times.items()], headers=["event", "avg", "max", "len"]))
|
||||||
plt.show(block=True)
|
plt.show(block=True)
|
||||||
|
'''
|
|
@ -9,8 +9,7 @@ from collections import defaultdict
|
||||||
timestamps = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
|
timestamps = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
|
||||||
translationdict = {}
|
translationdict = {}
|
||||||
|
|
||||||
#r = Route("9f583b1d93915c31|2022-03-22--15-59-29")
|
r = Route("9f583b1d93915c31|2022-03-23--14-47-10")
|
||||||
r = Route("9f583b1d93915c31|2022-03-23--12-47-33")
|
|
||||||
lr = LogReader(r.log_paths()[0])
|
lr = LogReader(r.log_paths()[0])
|
||||||
|
|
||||||
for msg in lr:
|
for msg in lr:
|
||||||
|
@ -34,14 +33,6 @@ for msg in lr:
|
||||||
timestamps[frame_id][service][event].append(time)
|
timestamps[frame_id][service][event].append(time)
|
||||||
|
|
||||||
del timestamps[0]
|
del timestamps[0]
|
||||||
'''
|
|
||||||
|
|
||||||
timestampsshort = defaultdict(lambda: defaultdict(lambda: defaultdict(int)))
|
|
||||||
for frame_id, services in timestamps.items():
|
|
||||||
for service, events in services.items():
|
|
||||||
for event, times in events.items():
|
|
||||||
timestampsshort[frame_id][service][event] = min(times)
|
|
||||||
'''
|
|
||||||
|
|
||||||
with open('timestamps.json', 'w') as outfile:
|
with open('timestamps.json', 'w') as outfile:
|
||||||
json.dump(timestamps, outfile)
|
json.dump(timestamps, outfile)
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue