7 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
"..",
9 from topic_compare
import ROSTopicCompare
16 return abs(a - b) < err
20 """Subscribing three topics 22 * /origin (the same topic) 27 while not tc.isAllTopicAvailable(20):
29 print tc.getTotalBytes(0) / (tc.getEndTime(0) - tc.getStartTime(0))
30 print tc.getTotalBytes(1) / (tc.getEndTime(1) - tc.getStartTime(1))
31 self.assertTrue(
eps_equal(tc.getBandwidth(0), tc.getBandwidth(1), 20))
34 while not tc.isAllTopicAvailable(20):
36 print tc.getTotalBytes(0) / (tc.getEndTime(0) - tc.getStartTime(0))
37 print tc.getTotalBytes(2) / (tc.getEndTime(2) - tc.getStartTime(2))
38 self.assertTrue(
eps_equal(tc.getBandwidth(0), 2 * tc.getBandwidth(2), 20))
41 if __name__ ==
"__main__":
43 rospy.init_node(
"test_topic_compare")
45 tc.registerTopic(
"/origin")
46 tc.registerTopic(
"/origin")
47 tc.registerTopic(
"/half")
48 rostest.rosrun(
"jsk_topic_tools",
"test_topic_compare", TestTopicCompare)
def eps_equal(a, b, err=0.001)
def test_half_topic(self)
def test_same_topic(self)