35 Integration test for topic statistics
38 from __future__
import print_function
44 from rosgraph_msgs.msg
import TopicStatistics
56 if msg.delivered_msgs > 1:
60 self, cond, timeout=rospy.Duration(5.0), interval=rospy.Duration(0.5)
62 started = rospy.Time.now()
63 while rospy.Time.now() - started < timeout:
67 self.assertTrue(
False)
70 ''' return True if topic message's measured frequency
71 is within some error margin of expected frequency '''
74 assert msg.delivered_msgs > 1
75 found_freq = 1.0 / msg.period_mean.to_sec()
77 "Testing {}'s found frequency {} against expected {}".format(
78 topic, found_freq, expected))
79 return abs(found_freq - expected) / expected <= error_margin
82 sub = rospy.Subscriber(
'/statistics', TopicStatistics, self.
new_msg)
92 timeout=rospy.Duration(10.0))
100 if __name__ ==
'__main__':
101 rospy.init_node(
'test_topic_statistics')
102 rostest.run(PKG,
'rospy_topic_statistics', TestTopicStatistics, sys.argv)