Skip to content

Commit fc06a11

Browse files
committed
Support offset_sec in ctt_introspect
1 parent ef03ffd commit fc06a11

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cuckoo_time_translator_python/python/cuckoo_time_translator/device_time_bags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pickle
44
import rosbag
5+
import numpy as np
56

67
from timestamp_series import TimestampSeries
78
from timestamp_series import TimestampSeries
@@ -35,13 +36,17 @@ def __init__(self, bagFile, topic, invalidate=False):
3536
bag = rosbag.Bag(bagFile)
3637

3738
self.translated_hw_times = TimestampSeries()
39+
self.translated_hw_times_without_offset = TimestampSeries()
3840
self.receive_times = TimestampSeries()
3941
self.raw_hw_times = TimestampSeries()
4042
for topic, msg, t in bag.read_messages(topics=[topic]):
4143
self.translated_hw_times.append(msg.header.stamp.to_sec())
44+
self.translated_hw_times_without_offset.append(msg.header.stamp.to_sec() - msg.offset_secs)
4245
self.receive_times.append(msg.receive_time.to_sec())
4346
self.raw_hw_times.append(float(msg.event_stamp))
4447

48+
self.zeroOffsetAllTheTime = np.linalg.norm(np.array(self.translated_hw_times_without_offset) - np.array(self.translated_hw_times)) < 1e-9
49+
4550
bag.close()
4651
# Save data to file
4752
pickle.dump(self.__dict__, open(eventsFile, "wb"))

cuckoo_time_translator_python/scripts/ctt_introspect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def addToPlot(times, label, color):
8383
if not args.dontPlotReceiveTimes:
8484
addToPlot(ds.receive_times, "receive times", "r")
8585
if not args.dontPlotPreTranslated:
86-
addToPlot(ds.translated_hw_times, "pre-translated", "g")
86+
addToPlot(ds.translated_hw_times, "pre-translated" + (" (+ zero offset)" if ds.zeroOffsetAllTheTime else " + offset"), "g")
87+
if not ds.zeroOffsetAllTheTime:
88+
addToPlot(ds.translated_hw_times_without_offset, "pre-translated without offset", "b")
8789

8890
owtColors = ['m', 'grey', 'cyan', 'k', 'orange']
8991
for i, owt in enumerate(hwOwts):

0 commit comments

Comments
 (0)