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_NAMED("manipulation"," 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
00072
00073
00074 if ( pickup_goal.lift.min_distance != 0 &&
00075 !mechInterface().checkStateValidity(pickup_goal.arm_name, interpolated_lift_trajectory_.points.back().positions,
00076 collisionOperationsForLift(pickup_goal),
00077 pickup_goal.additional_link_padding) )
00078 {
00079 ROS_DEBUG_NAMED("manipulation"," Grasp executor: last pose in lift trajectory is unfeasible with default padding");
00080 return Result(GraspResult::LIFT_UNFEASIBLE, true);
00081 }
00082
00083 ROS_DEBUG_NAMED("manipulation"," Grasp executor: interpolated IK for lift succeeded.");
00084 return Result(GraspResult::SUCCESS, true);
00085 }
00086
00087 GraspResult
00088 SimpleGraspExecutor::executeGrasp(const object_manipulation_msgs::PickupGoal &pickup_goal,
00089 const object_manipulation_msgs::Grasp &grasp)
00090 {
00091
00092
00093
00094 mechInterface().handPostureGraspAction(pickup_goal.arm_name, grasp,
00095 object_manipulation_msgs::GraspHandPostureExecutionGoal::PRE_GRASP, -1);
00096
00097 if ( !mechInterface().attemptMoveArmToGoal(pickup_goal.arm_name, ik_response_.solution.joint_state.position,
00098 pickup_goal.additional_collision_operations,
00099 pickup_goal.additional_link_padding) )
00100 {
00101 ROS_DEBUG_NAMED("manipulation"," Grasp execution: move arm reports failure");
00102 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 1.0, 0.5, 0.0);
00103 return Result(GraspResult::MOVE_ARM_FAILED, true);
00104 }
00105
00106 mechInterface().handPostureGraspAction(pickup_goal.arm_name, grasp,
00107 object_manipulation_msgs::GraspHandPostureExecutionGoal::GRASP, pickup_goal.max_contact_force);
00108 if (marker_publisher_) marker_publisher_->colorGraspMarker(marker_id_, 0.0, 1.0, 0.0);
00109 return Result(GraspResult::SUCCESS, true);
00110 }
00111
00112 }