4 dynamixel_joint_state_publisher.py - Version 1.0 2010-12-28 6 Publish the dynamixel_controller joint states on the /joint_states topic 8 Created for the Pi Robot Project: http://www.pirobot.org 9 Copyright (c) 2010 Patrick Goebel. All rights reserved. 11 This program is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details at: 21 http://www.gnu.org/licenses/gpl.html 25 from sensor_msgs.msg
import JointState
as JointStatePR2
26 from dynamixel_msgs.msg
import JointState
as JointStateDynamixel
27 from dynamixel_controllers.srv
import SetSpeed
28 from dynamic_reconfigure.server
import Server
29 from jsk_tilt_laser.cfg
import DynamixelTiltControllerConfig
32 def __init__(self, name, position, velocity, effort):
40 rospy.init_node(
'dynamixel_joint_state_publisher', anonymous=
True)
41 rospy.wait_for_service(
'tilt_controller/set_speed')
43 dynamixel_namespace = rospy.get_namespace()
44 rate = rospy.get_param(
'~rate', 10)
50 parameters = rospy.get_param_names()
52 for parameter
in parameters:
54 if parameter.find(dynamixel_namespace) != -1
and parameter.find(
"joint_name") != -1:
55 self.joints.append(rospy.get_param(parameter))
63 servo = joint.split(
"_joint")[0]
66 self.controllers.append(dynamixel_namespace + servo +
"_controller")
68 rospy.loginfo(
"Dynamixel Joint State Publisher " + joint)
76 rospy.loginfo(
"Starting Dynamixel Joint State Publisher at " + str(rate) +
"Hz")
78 while not rospy.is_shutdown():
84 set_speed = rospy.ServiceProxy(
'tilt_controller/set_speed', SetSpeed)
85 set_speed(config.tilt_speed)
86 except rospy.ServiceException, e:
87 print "Service call failed: %s"%e
101 for joint
in self.joint_states.values():
102 msg.name.append(joint.name)
103 fudge_value = rospy.get_param(
'~fudge_factor/' + joint.name +
'/value', 0.0)
104 j_pos = joint.position - fudge_value
106 msg.position.append(j_pos)
107 msg.velocity.append(joint.velocity)
108 msg.effort.append(joint.effort)
110 msg.header.stamp = rospy.Time.now()
111 self.joint_states_pub.publish(msg)
113 if __name__ ==
'__main__':
117 except rospy.ROSInterruptException:
pass def publish_joint_states(self)
def __init__(self, name, position, velocity, effort)
def reconfigure_callback(self, config, level)
def controller_state_handler(self, msg)