18 This example demonstrates how two joints can have their positions 'linked' by 19 having a child joint subscribing to the parent joint's controller state topic. 20 The messages are then published to the child joint's controller. 22 The hand should be launched but the trajectory controllers should 23 not be running as they overwrite position commands. To check if they are, a call 24 to rosservice can be made with the following command: 25 >rosservice call /controller_manager/list_controllers 26 To stop the trajectory controllers, open the gui (type rqt) and select position control in 27 plugins > Shadow Robot > Change controllers 28 NOTE: If the joint sliders plugin is open during this change of controllers, it will 31 A position can then be published to the parent joint or the joint could be moved by 32 using the joint sliders in the gui, plugins > Shadow Robot > joint slider 34 If you move the joint slider for the parent joint, the child joint will move as well. 39 from std_msgs.msg
import Float64
40 from control_msgs.msg
import JointControllerState
42 roslib.load_manifest(
'sr_example')
45 parent_name =
"rh_ffj3" 46 child_name =
"rh_rfj3" 49 controller_type =
"_position_controller" 51 pub = rospy.Publisher(
52 '/sh_' + child_name + controller_type +
'/command', Float64, queue_size=1)
57 The callback function: called each time a message is received on the 58 topic parent joint controller state topic 60 @param data: the message 64 pub.publish(data.set_point)
72 rospy.init_node(
'link_joints_example', anonymous=
True)
77 rospy.Subscriber(
'/sh_' + parent_name + controller_type +
78 '/state', JointControllerState, callback)
83 if __name__ ==
'__main__':