コード例 #1
0
 def publishCustomStatistic(self, name, value):
     """
     Publishes a one-time statistic
     """
     msg = Statistics()
     msg.header.stamp = rospy.Time.now()
     s = Statistic()
     s.name = name
     s.value = value
     msg.statistics.append(s)
     self.pub.publish(msg)
コード例 #2
0
 def createMsg(self):
     """
     Create and return a message after reading all registrations
     """
     msg = Statistics()
     msg.header.stamp = rospy.Time.now()
     for name, func in self.functions.iteritems():
         s = Statistic()
         s.name = name
         s.value = func()
         msg.statistics.append(s)
     return msg
コード例 #3
0
    def test_statistics_2(self):
        msg = Statistics()

        msg.header.stamp = rospy.Time()

        stat = Statistic()
        stat.name = "test_stat"
        stat.value = 1234.0
        msg.statistics.append(stat)

        result = self.cc.statistics_callback(msg)
        output = result.splitlines()
        self.assertEquals(len(output), 1)
        self.assertEquals(output[0], 'test_system.test_stat 1234.000000 0')
コード例 #4
0
    def test_statistics_3(self):
        msg = Statistics()

        msg.header.stamp = rospy.Time()

        num_stats = 5
        for i in range(num_stats):
            stat = Statistic()
            stat.value = i
            stat.name = "test_stat_" + str(i)
            msg.statistics.append(stat)

        result = self.cc.statistics_callback(msg)
        output = result.splitlines()
        self.assertEquals(len(output), num_stats)
        for i in range(num_stats):
            parts = output[i].split(' ')
            self.assertEquals(parts[0], 'test_system.test_stat_' + str(i))
            self.assertEquals(float(parts[1]), float(i))
            self.assertEquals(parts[2], '0')