Go to the documentation of this file.00001
00002
00003 import rospy
00004 from moveit_commander import MoveGroupCommander
00005 from sensor_msgs.msg import JointState
00006 from geometry_msgs.msg import Pose
00007
00008 group = MoveGroupCommander("right_arm")
00009 group.set_end_effector_link('r_gripper_tool_frame')
00010 group.set_pose_reference_frame('/base_footprint')
00011
00012 def pose_callback(pose):
00013 pos = pose.position
00014 qtr = pose.orientation
00015 if qtr.x == 0 and qtr.y == 0 and qtr.z == 0 and qtr.w == 0:
00016 group.set_position_target([pos.x, pos.y, pos.z])
00017 else: group.set_pose_target(pose)
00018 group.go()
00019
00020 def joint_callback(msg):
00021 goal = map(lambda joint_name: msg.position[msg.name.index(joint_name)],
00022 group.get_active_joints())
00023 group.set_joint_value_target(goal)
00024 group.go()
00025
00026 if __name__ == "__main__":
00027 rospy.init_node('movescratch')
00028 rospy.Subscriber("movescratch/pose_goal", Pose, pose_callback)
00029 rospy.Subscriber("movescratch/joint_goal", JointState, joint_callback)
00030 rospy.spin()