00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 from sr_robot_commander import SrRobotCommander
00019 from geometry_msgs.msg import PoseStamped
00020 from rospy import get_rostime
00021
00022
00023 class SrArmCommander(SrRobotCommander):
00024 """
00025 Commander class for arm
00026 """
00027
00028 def __init__(self, name="right_arm", set_ground=True):
00029 """
00030 Initialize object
00031 @param name - name of the MoveIt group
00032 @param set_ground - sets the ground plane in moveit for planning
00033 """
00034 super(SrArmCommander, self).__init__(name)
00035
00036 if set_ground:
00037 self._set_ground()
00038
00039 def move_to_position_target(self, xyz, end_effector_link="", wait=True):
00040 """
00041 Specify a target position for the end-effector and moves to it.
00042 @param xyz - new position of end-effector
00043 @param end_effector_link - name of the end effector link
00044 @param wait - should method wait for movement end or not
00045 """
00046 self._move_to_position_target(xyz, end_effector_link, wait=wait)
00047
00048 def plan_to_position_target(self, xyz, end_effector_link=""):
00049 """
00050 Specify a target position for the end-effector and plans.
00051 This is a blocking method.
00052 @param xyz - new position of end-effector
00053 @param end_effector_link - name of the end effector link
00054 """
00055 self._plan_to_position_target(xyz, end_effector_link)
00056
00057 def move_to_pose_target(self, pose, end_effector_link="", wait=True):
00058 """
00059 Specify a target pose for the end-effector and moves to it
00060 @param pose - new pose of end-effector: a Pose message, a PoseStamped
00061 message or a list of 6 floats: [x, y, z, rot_x, rot_y, rot_z]
00062 or a list of 7 floats: [x, y, z, qx, qy, qz, qw]
00063
00064 @param end_effector_link - name of the end effector link
00065 @param wait - should method wait for movement end or not
00066 """
00067 self._move_to_pose_target(pose, end_effector_link, wait=wait)
00068
00069 def plan_to_pose_target(self, pose, end_effector_link=""):
00070 """
00071 Specify a target pose for the end-effector and plans.
00072 This is a blocking method.
00073 @param pose - new pose of end-effector: a Pose message, PoseStamped
00074 message or a list of 6 floats: [x, y, z, rot_x, rot_y, rot_z]
00075 or a list of 7 floats [x, y, z, qx, qy, qz, qw]
00076
00077 @param end_effector_link - name of the end effector link
00078 """
00079 self._plan_to_pose_target(pose, end_effector_link)
00080
00081 def _set_ground(self):
00082 """
00083 Sets a plane for the ground.
00084 """
00085 pose = PoseStamped()
00086 pose.pose.position.x = 0
00087 pose.pose.position.y = 0
00088
00089
00090 pose.pose.position.z = -0.0501
00091 pose.pose.orientation.x = 0
00092 pose.pose.orientation.y = 0
00093 pose.pose.orientation.z = 0
00094 pose.pose.orientation.w = 1
00095 pose.header.stamp = get_rostime()
00096 pose.header.frame_id = self._robot_commander.get_root_link()
00097 self._planning_scene.add_box("ground", pose, (3, 3, 0.1))