4 diagnostics.py - diagnostic output code
5 Copyright (c) 2011 Vanadium Labs LLC. All right reserved.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 * Neither the name of Vanadium Labs LLC nor the names of its
15 contributors may be used to endorse or promote products derived
16 from this software without specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL VANADIUM LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 from sensor_msgs.msg
import JointState
35 """ Class to handle publications of joint_states message. """
38 self.
t_delta = rospy.Duration(1.0/rospy.get_param(
"~diagnostic_rate", 1.0))
40 self.
pub = rospy.Publisher(
'diagnostics', DiagnosticArray, queue_size=5)
42 def update(self, joints, controllers):
43 """ Publish diagnostics. """
44 now = rospy.Time.now()
47 msg = DiagnosticArray()
48 msg.header.stamp = now
49 for controller
in controllers:
50 d = controller.getDiagnostics()
54 d = joint.getDiagnostics()
63 """ Class to handle publications of joint_states message. """
67 self.
rate = rospy.get_param(
"~read_rate", 10.0)
72 self.
pub = rospy.Publisher(
'joint_states', JointState, queue_size=5)
74 def update(self, joints, controllers):
75 """ publish joint states. """
76 if rospy.Time.now() > self.
t_next:
78 msg.header.stamp = rospy.Time.now()
83 msg.name.append(joint.name)
84 msg.position.append(joint.position)
85 msg.velocity.append(joint.velocity)
86 for controller
in controllers:
87 msg.name += controller.joint_names
88 msg.position += controller.joint_positions
89 msg.velocity += controller.joint_velocities