@@ -79,18 +79,23 @@ def check_drop(inbags, plot_format='png'):
79
79
bag_time_diff = {}
80
80
seq_diff = {}
81
81
82
+ min_time = []
82
83
for key in msg_time .iterkeys ():
83
84
msg_time_diff [key ] = numpy .diff (msg_time [key ])
85
+ min_time .append (msg_time [key ][0 ])
84
86
bag_time_diff [key ] = numpy .diff (bag_time [key ])
85
87
seq_diff [key ] = numpy .diff (seq [key ])
86
88
89
+ min_time = numpy .min (min_time )
90
+
87
91
# Compute min, max and mean differences:
88
92
basename = inbags [0 ].replace ('.bag' , '' )
89
93
90
94
max_len = max (len (topic ) for topic in msg_time_diff .keys ())
91
95
topics = msg_time_diff .keys ()
92
96
topics .sort ()
93
97
98
+
94
99
for topic in topics :
95
100
msg_time_diff_topic = msg_time_diff [topic ]
96
101
bag_time_diff_topic = bag_time_diff [topic ]
@@ -120,33 +125,33 @@ def check_drop(inbags, plot_format='png'):
120
125
rospy .loginfo ('%s seq: mean = %s, min = %s, max = %s, median = %s' , topic .ljust (max_len + 2 ), seq_diff_mean , seq_diff_min , seq_diff_max , seq_diff_median )
121
126
122
127
# Create and save plots:
123
- N = len (msg_time_diff_topic )
124
- x = numpy .array ([0 , N - 1 ])
128
+ mt = msg_time [topic ][1 :] - min_time
125
129
126
130
try :
127
131
fig = plt .figure ()
128
132
fig .set_size_inches (20 , 15 )
129
133
130
134
plt .subplot (311 )
131
135
plt .title (topic + ' - Message time difference [s]' )
132
- plt .plot (msg_time_diff_topic , 'b' )
133
- plt .plot (x , numpy . array ([ msg_time_diff_min , msg_time_diff_min ]) , 'r--' )
134
- plt .plot (x , numpy . array ([ msg_time_diff_max , msg_time_diff_max ]) , 'r--' )
135
- plt .plot (x , numpy . array ([ msg_time_diff_mean , msg_time_diff_mean ]) , 'g' )
136
+ plt .plot (mt , msg_time_diff_topic , 'b' )
137
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ msg_time_diff_min , msg_time_diff_min ], 'r--' )
138
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ msg_time_diff_max , msg_time_diff_max ], 'r--' )
139
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ msg_time_diff_mean , msg_time_diff_mean ], 'g' )
136
140
137
141
plt .subplot (312 )
138
142
plt .title (topic + ' - Bag time difference [s]' )
139
- plt .plot (bag_time_diff_topic , 'b' )
140
- plt .plot (x , numpy . array ([ bag_time_diff_min , bag_time_diff_min ]) , 'r--' )
141
- plt .plot (x , numpy . array ([ bag_time_diff_max , bag_time_diff_max ]) , 'r--' )
142
- plt .plot (x , numpy . array ([ bag_time_diff_mean , bag_time_diff_mean ]) , 'g' )
143
+ plt .plot (mt , bag_time_diff_topic , 'b' )
144
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ bag_time_diff_min , bag_time_diff_min ], 'r--' )
145
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ bag_time_diff_max , bag_time_diff_max ], 'r--' )
146
+ plt .plot ([ mt [ 0 ], mt [ - 1 ]], [ bag_time_diff_mean , bag_time_diff_mean ], 'g' )
143
147
144
148
plt .subplot (313 )
145
149
plt .title (topic + ' - Sequence number difference' )
146
- plt .plot (seq_diff_topic , 'b' )
147
- plt .plot (x , numpy .array ([seq_diff_min , seq_diff_min ]), 'r--' )
148
- plt .plot (x , numpy .array ([seq_diff_max , seq_diff_max ]), 'r--' )
149
- plt .plot (x , numpy .array ([seq_diff_mean , seq_diff_mean ]), 'g' )
150
+ plt .plot (mt , seq_diff_topic , 'b' )
151
+ plt .plot ([mt [0 ], mt [- 1 ]], [seq_diff_min , seq_diff_min ], 'r--' )
152
+ plt .plot ([mt [0 ], mt [- 1 ]], [seq_diff_max , seq_diff_max ], 'r--' )
153
+ plt .plot ([mt [0 ], mt [- 1 ]], [seq_diff_mean , seq_diff_mean ], 'g' )
154
+
150
155
151
156
plt .savefig (basename + topic .replace ('/' , '_' ).replace (' ' , '_' ).replace (':' , '_' ) + '.' + plot_format )
152
157
plt .close (fig )
0 commit comments