Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "object_manipulator/grasp_execution/simple_grasp_executor.h"
00037
00038
00039
00040 using object_manipulation_msgs::GraspResult;
00041
00042 namespace object_manipulator {
00043
00044 GraspResult SimpleGraspExecutor::prepareGrasp(const object_manipulation_msgs::PickupGoal &pickup_goal,
00045 const object_manipulation_msgs::Grasp &grasp)
00046 {
00047 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 1.0, 0.0, 0.0);
00048
00049 geometry_msgs::PoseStamped grasp_pose;
00050 grasp_pose.pose = grasp.grasp_pose;
00051 grasp_pose.header.frame_id = pickup_goal.target.reference_frame_id;
00052 grasp_pose.header.stamp = ros::Time(0);
00053
00054
00055
00056
00057 if ( !mechInterface().getIKForPose(pickup_goal.arm_name, grasp_pose, ik_response_,
00058 pickup_goal.additional_collision_operations,
00059 pickup_goal.additional_link_padding) )
00060 {
00061 ROS_DEBUG_STREAM(" Grasp execution: initial IK check failed");
00062 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 1.0, 1.0, 0.0);
00063 return Result(GraspResult::GRASP_UNFEASIBLE, true);
00064 }
00065 ROS_DEBUG(" Grasp executor: IK for grasp succeeded.");
00066
00067 std::vector<double> grasp_joint_angles = ik_response_.solution.joint_state.position;
00068 GraspResult result = getInterpolatedIKForLift(pickup_goal, grasp, grasp_joint_angles, interpolated_lift_trajectory_);
00069 if (result.result_code != GraspResult::SUCCESS) return result;
00070
00071 ROS_DEBUG(" Grasp executor: interpolated IK for lift succeeded.");
00072 return Result(GraspResult::SUCCESS, true);
00073 }
00074
00075 GraspResult
00076 SimpleGraspExecutor::executeGrasp(const object_manipulation_msgs::PickupGoal &pickup_goal,
00077 const object_manipulation_msgs::Grasp &grasp)
00078 {
00079
00080
00081
00082 mechInterface().handPostureGraspAction(pickup_goal.arm_name, grasp,
00083 object_manipulation_msgs::GraspHandPostureExecutionGoal::PRE_GRASP);
00084
00085 if ( !mechInterface().attemptMoveArmToGoal(pickup_goal.arm_name, ik_response_.solution.joint_state.position,
00086 pickup_goal.additional_collision_operations,
00087 pickup_goal.additional_link_padding) )
00088 {
00089 ROS_DEBUG(" Grasp execution: move arm reports failure");
00090 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 1.0, 0.5, 0.0);
00091 return Result(GraspResult::MOVE_ARM_FAILED, true);
00092 }
00093
00094 mechInterface().handPostureGraspAction(pickup_goal.arm_name, grasp,
00095 object_manipulation_msgs::GraspHandPostureExecutionGoal::GRASP);
00096 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 0.0, 1.0, 0.0);
00097 return Result(GraspResult::SUCCESS, true);
00098 }
00099
00100 }