33 from __future__
import division, with_statement
35 from cStringIO
import StringIO
37 from io
import StringIO
39 from python_qt_binding.QtCore
import qWarning
43 from rostopic
import ROSTopicHz
57 self.
message_class = roslib.message.get_message_class(topic_type)
58 except Exception
as e:
60 qWarning(
'TopicInfo.__init__(): %s' % (e))
63 self.
error =
'can not get message class for type "%s"' % topic_type
64 qWarning(
'TopicInfo.__init__(): topic "%s": %s' % (topic_name, self.
error))
88 self._subscriber.unregister()
91 ROSTopicHz.callback_hz(self, message)
93 self.timestamps.append(rospy.get_time())
99 message.serialize(buff)
100 self.sizes.append(len(buff.getvalue()))
102 if len(self.
timestamps) > self.window_size - 1:
103 self.timestamps.pop(0)
111 return None,
None,
None,
None 112 current_time = rospy.get_time()
114 return None,
None,
None,
None 117 total = sum(self.
sizes)
118 bytes_per_s = total / (current_time - self.
timestamps[0])
120 max_size = max(self.
sizes)
121 min_size = min(self.
sizes)
122 return bytes_per_s, mean_size, min_size, max_size
126 return None,
None,
None,
None 129 mean = sum(self.
times) / n
130 rate = 1. / mean
if mean > 0.
else 0
131 min_delta = min(self.
times)
132 max_delta = max(self.
times)
133 return rate, mean, min_delta, max_delta
def stop_monitoring(self)
def toggle_monitoring(self)
def message_callback(self, message)
def start_monitoring(self)
def __init__(self, topic_name, topic_type)