def message_callback(self, message): ROSTopicHz.callback_hz(self, message) with self.lock: self.timestamps.append(rospy.get_time()) # FIXME: this only works for message of class AnyMsg #self.sizes.append(len(message._buff)) # time consuming workaround... buff = StringIO() message.serialize(buff) self.sizes.append(len(buff.getvalue())) if len(self.timestamps) > self.window_size - 1: self.timestamps.pop(0) self.sizes.pop(0) assert(len(self.timestamps) == len(self.sizes)) self.last_message = message
def message_callback(self, message): ROSTopicHz.callback_hz(self, message) with self.lock: self.timestamps.append(rospy.get_time()) # FIXME: this only works for message of class AnyMsg #self.sizes.append(len(message._buff)) # time consuming workaround... buff = StringIO() message.serialize(buff) self.sizes.append(buff.len) if len(self.timestamps) > self.window_size - 1: self.timestamps.pop(0) self.sizes.pop(0) assert(len(self.timestamps) == len(self.sizes)) self.last_message = message
def message_callback(self, message): ROSTopicHz.callback_hz(self, message) with self.lock: self.timestamps.append(rospy.get_time()) # FIXME: this only works for message of class AnyMsg #self.sizes.append(len(message._buff)) # time consuming workaround... buff = StringIO() message.serialize(buff) # patch begin pos = buff.tell() buff.seek(0, os.SEEK_END) self.sizes.append(buff.tell()) buff.seek(pos) # patch end if len(self.timestamps) > self.window_size - 1: self.timestamps.pop(0) self.sizes.pop(0) assert (len(self.timestamps) == len(self.sizes)) self.last_message = message