20 An example that demonstrates how to publish command messages to joints in the hand. 21 The hand should be launched but the trajectory controllers should 22 not be running as they overwrite position commands. To check if they are, a call to 23 rosservice can be made with the following command: 24 >rosservice call /controller_manager/list_controllers 25 To stop the trajectory controllers, open the gui (type rqt) and select position control in 26 plugins > Shadow Robot > Change controllers 35 from std_msgs.msg
import Float64
37 roslib.load_manifest(
'sr_example')
41 controller_type =
"_position_controller" 46 The Publisher publishes two commands to move joint rh_FFJ0 and rh_RFJ0 53 rospy.init_node(
'publisher_example')
55 pub1 = rospy.Publisher(
56 'sh_' + joint1 + controller_type +
'/command', Float64, latch=
True, queue_size=1)
57 pub2 = rospy.Publisher(
58 'sh_' + joint2 + controller_type +
'/command', Float64, latch=
True, queue_size=1)
62 new_target_1 = math.radians(20)
63 new_target_2 = math.radians(20)
67 print (joint1 +
" to " + str(math.degrees(new_target_1)) +
" degrees\n" +
68 joint2 +
" to " + str(math.degrees(new_target_2)) +
" degrees")
71 pub1.publish(new_target_1)
74 pub2.publish(new_target_2)
77 if __name__ ==
'__main__':
80 except rospy.ROSInterruptException: