4 joint_state_publisher - Version 2.0 2017-3-18 5 dynamixel_joint_state_publisher.py - Version 1.0 2010-12-28 7 Publish the dynamixel_controller joint states on the /joint_states topic 9 Created for the Pi Robot Project: http://www.pirobot.org 10 Copyright (c) 2010 Patrick Goebel. All rights reserved. 11 Copyright (c) 2017 Svenzva Robotics 13 This program is free software; you can redistribute it and/or modify 14 it under the terms of the GNU General Public License as published by 15 the Free Software Foundation; either version 2 of the License, or 16 (at your option) any later version. 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details at: 23 http://www.gnu.org/licenses/gpl.html 29 from sensor_msgs.msg
import JointState
as JointStatePR2
30 from svenzva_msgs.msg
import MotorStateList
33 def __init__(self, name, position, velocity, effort):
41 rospy.init_node(
'joint_state_publisher', anonymous=
True)
43 rate = rospy.get_param(
'~rate', 20)
45 namespace = rospy.get_param(
'~arm_namespace',
'')
46 self.
joints = rospy.get_param(
'joint_names',
'')
51 rospy.Subscriber(namespace +
'/motor_states', MotorStateList, self.
motor_state_cb)
56 rospy.loginfo(
"Starting Joint State Publisher at " + str(rate) +
"Hz")
61 while not rospy.is_shutdown():
78 effort_nm = joint.load * 0.00336 * 1.083775
81 msg.name.append(self.
joints[i])
83 msg.velocity.append(-1 * joint.speed)
84 msg.effort.append(-1 * effort_nm)
88 msg.name.append(self.
joints[i+1])
90 msg.velocity.append(1 * joint.speed)
91 msg.effort.append(1 * effort_nm)
93 msg.name.append(self.
joints[i])
94 msg.position.append(joint.position)
95 msg.velocity.append(joint.speed)
96 msg.effort.append(effort_nm)
98 msg.header.stamp = rospy.Time.now()
100 self.joint_states_pub.publish(msg)
102 if __name__ ==
'__main__':
106 except rospy.ROSInterruptException:
pass def __init__(self, name, position, velocity, effort)
def publish_joint_states(self)
def motor_state_cb(self, msg)