コード例 #1
0
 def pub_timer_callback(self, dummy):
     msg = DIAG.DiagnosticArray()
     msg.header.stamp = rospy.get_rostime()
     with self.mutex:
         if self.stat is not None:
             msg.status.append(
                 create_timed_message(self.stat, self.stat_stamp))
         if self.do_self_test and self.self_stat is not None:
             msg.status.append(
                 create_timed_message(self.self_stat, self.self_stat_stamp))
     self.pub.publish(msg)
コード例 #2
0
    def checkCB(self, ev):
        new_msg = DIAG.DiagnosticArray()
        new_msg.header.stamp = rospy.get_rostime()

        st = ntp_diag(self.stat, self.ntp_hostname, self.offset,
                      self.error_offset)
        if st is not None:
            new_msg.status.append(st)

        if self.do_self_test:
            st = ntp_diag(self.self_stat, self.hostname, self.self_offset,
                          self.error_offset)
            if st is not None:
                new_msg.status.append(st)

        with self.mutex:
            self.current_msg = new_msg

        self.checktimer = rospy.Timer(rospy.Duration(10), self.checkCB, True)