49   pick_place_ = std::make_shared<pick_place::PickPlace>(context_->planning_pipeline_);
 
   50   pick_place_->displayComputedMotionPlans(
true);
 
   53     pick_place_->displayProcessedGrasps(
true);
 
   56   pickup_action_server_ = std::make_unique<actionlib::SimpleActionServer<moveit_msgs::PickupAction>>(
 
   57       root_node_handle_, 
PICKUP_ACTION, [
this](
const auto& goal) { executePickupCallback(goal); }, 
false);
 
   58   pickup_action_server_->registerPreemptCallback([
this] { preemptPickupCallback(); });
 
   59   pickup_action_server_->start();
 
   62   place_action_server_ = std::make_unique<actionlib::SimpleActionServer<moveit_msgs::PlaceAction>>(
 
   63       root_node_handle_, 
PLACE_ACTION, [
this](
const auto& goal) { executePlaceCallback(goal); }, 
false);
 
   64   place_action_server_->registerPreemptCallback([
this] { preemptPlaceCallback(); });
 
   65   place_action_server_->start();
 
   89                                                                          moveit_msgs::PickupResult& action_res)
 
   91   pick_place::PickPlanPtr plan;
 
   94     plan = pick_place_->planPick(context_->planning_scene_monitor_->copyPlanningScene(), *goal);
 
   96   catch (std::exception& ex)
 
   98     ROS_ERROR_NAMED(
"manipulation", 
"Pick&place threw an exception: %s", ex.what());
 
  103     const std::vector<pick_place::ManipulationPlanPtr>& success = plan->getSuccessfulManipulationPlans();
 
  106       action_res.error_code = plan->getErrorCode();
 
  110       const pick_place::ManipulationPlanPtr& result = success.back();
 
  111       convertToMsg(result->trajectories_, action_res.trajectory_start, action_res.trajectory_stages);
 
  112       action_res.trajectory_descriptions.resize(result->trajectories_.size());
 
  113       for (std::size_t i = 0; i < result->trajectories_.size(); ++i)
 
  114         action_res.trajectory_descriptions[i] = result->trajectories_[i].description_;
 
  115       if (result->id_ < goal->possible_grasps.size())
 
  116         action_res.grasp = goal->possible_grasps[result->id_];
 
  117       action_res.error_code.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  118       action_res.planning_time = plan->getLastPlanTime();
 
  123     action_res.error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE;
 
  128                                                                         moveit_msgs::PlaceResult& action_res)
 
  130   pick_place::PlacePlanPtr plan;
 
  133     plan = pick_place_->planPlace(context_->planning_scene_monitor_->copyPlanningScene(), *goal);
 
  135   catch (std::exception& ex)
 
  137     ROS_ERROR_NAMED(
"manipulation", 
"Pick&place threw an exception: %s", ex.what());
 
  142     const std::vector<pick_place::ManipulationPlanPtr>& success = plan->getSuccessfulManipulationPlans();
 
  145       action_res.error_code = plan->getErrorCode();
 
  149       const pick_place::ManipulationPlanPtr& result = success.back();
 
  150       convertToMsg(result->trajectories_, action_res.trajectory_start, action_res.trajectory_stages);
 
  151       action_res.trajectory_descriptions.resize(result->trajectories_.size());
 
  152       for (std::size_t i = 0; i < result->trajectories_.size(); ++i)
 
  153         action_res.trajectory_descriptions[i] = result->trajectories_[i].description_;
 
  154       if (result->id_ < goal->place_locations.size())
 
  155         action_res.place_location = goal->place_locations[result->id_];
 
  156       action_res.error_code.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  157       action_res.planning_time = plan->getLastPlanTime();
 
  162     action_res.error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE;
 
  167                                                                     moveit_msgs::PickupResult* action_res,
 
  172   pick_place::PickPlanPtr pick_plan;
 
  177   catch (std::exception& ex)
 
  179     ROS_ERROR_NAMED(
"manipulation", 
"Pick&place threw an exception: %s", ex.what());
 
  184     const std::vector<pick_place::ManipulationPlanPtr>& success = pick_plan->getSuccessfulManipulationPlans();
 
  191       const pick_place::ManipulationPlanPtr& result = success.back();
 
  193       if (result->id_ < goal.possible_grasps.size())
 
  194         action_res->grasp = goal.possible_grasps[result->id_];
 
  195       plan.
error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  196       action_res->planning_time = pick_plan->getLastPlanTime();
 
  201     plan.
error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
 
  204   return plan.
error_code_.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  208                                                                    moveit_msgs::PlaceResult* action_res,
 
  213   pick_place::PlacePlanPtr place_plan;
 
  218   catch (std::exception& ex)
 
  220     ROS_ERROR_NAMED(
"manipulation", 
"Pick&place threw an exception: %s", ex.what());
 
  225     const std::vector<pick_place::ManipulationPlanPtr>& success = place_plan->getSuccessfulManipulationPlans();
 
  232       const pick_place::ManipulationPlanPtr& result = success.back();
 
  234       if (result->id_ < goal.place_locations.size())
 
  235         action_res->place_location = goal.place_locations[result->id_];
 
  236       plan.
error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  237       action_res->planning_time = place_plan->getLastPlanTime();
 
  242     plan.
error_code_.val = moveit_msgs::MoveItErrorCodes::FAILURE;
 
  245   return plan.
error_code_.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
 
  249     const moveit_msgs::PickupGoalConstPtr& goal, moveit_msgs::PickupResult& action_res)
 
  253   opt.
replan_ = goal->planning_options.replan;
 
  259     return planUsingPickPlacePickup(g, result_ptr, plan);
 
  261   if (goal->planning_options.look_around && context_->plan_with_sensing_)
 
  264                           attempts = goal->planning_options.look_around_attempts,
 
  265                           safe_execution_cost = goal->planning_options.max_safe_execution_cost](
 
  267       return plan_with_sensing->computePlan(plan, planner, attempts, safe_execution_cost);
 
  269     context_->plan_with_sensing_->setBeforeLookCallback([
this] { startPickupLookCallback(); });
 
  273   context_->plan_execution_->planAndExecute(plan, goal->planning_options.planning_scene_diff, opt);
 
  275   convertToMsg(plan.
plan_components_, action_res.trajectory_start, action_res.trajectory_stages);
 
  278     action_res.trajectory_descriptions[i] = plan.
plan_components_[i].description_;
 
  283                                                                               moveit_msgs::PlaceResult& action_res)
 
  287   opt.
replan_ = goal->planning_options.replan;
 
  292     return planUsingPickPlacePlace(g, result_ptr, plan);
 
  294   if (goal->planning_options.look_around && context_->plan_with_sensing_)
 
  297                           attempts = goal->planning_options.look_around_attempts,
 
  298                           safe_execution_cost = goal->planning_options.max_safe_execution_cost](
 
  300       return plan_with_sensing->computePlan(plan, planner, attempts, safe_execution_cost);
 
  302     context_->plan_with_sensing_->setBeforeLookCallback([
this] { startPlaceLookCallback(); });
 
  306   context_->plan_execution_->planAndExecute(plan, goal->planning_options.planning_scene_diff, opt);
 
  308   convertToMsg(plan.
plan_components_, action_res.trajectory_start, action_res.trajectory_stages);
 
  311     action_res.trajectory_descriptions[i] = plan.
plan_components_[i].description_;
 
  320   context_->planning_scene_monitor_->waitForCurrentRobotState(
ros::Time::now());
 
  321   context_->planning_scene_monitor_->updateFrameTransforms();
 
  323   moveit_msgs::PickupGoalConstPtr goal;
 
  324   if (input_goal->possible_grasps.empty())
 
  326     moveit_msgs::PickupGoal* copy(
new moveit_msgs::PickupGoal(*input_goal));
 
  333   moveit_msgs::PickupResult action_res;
 
  335   if (goal->planning_options.plan_only || !context_->allow_trajectory_execution_)
 
  337     if (!goal->planning_options.plan_only)
 
  338       ROS_WARN_NAMED(
"manipulation", 
"This instance of MoveGroup is not allowed to execute trajectories but the pick " 
  339                                      "goal request has plan_only set to false. Only a motion plan will be computed " 
  341     executePickupCallbackPlanOnly(goal, action_res);
 
  344     executePickupCallbackPlanAndExecute(goal, action_res);
 
  346   bool planned_trajectory_empty = action_res.trajectory_stages.empty();
 
  348       getActionResultString(action_res.error_code, planned_trajectory_empty, goal->planning_options.plan_only);
 
  349   if (action_res.error_code.val == moveit_msgs::MoveItErrorCodes::SUCCESS)
 
  350     pickup_action_server_->setSucceeded(action_res, 
response);
 
  353     if (action_res.error_code.val == moveit_msgs::MoveItErrorCodes::PREEMPTED)
 
  354       pickup_action_server_->setPreempted(action_res, 
response);
 
  356       pickup_action_server_->setAborted(action_res, 
response);
 
  359   setPickupState(
IDLE);
 
  367   context_->planning_scene_monitor_->waitForCurrentRobotState(
ros::Time::now());
 
  368   context_->planning_scene_monitor_->updateFrameTransforms();
 
  370   moveit_msgs::PlaceResult action_res;
 
  372   if (goal->planning_options.plan_only || !context_->allow_trajectory_execution_)
 
  374     if (!goal->planning_options.plan_only)
 
  375       ROS_WARN_NAMED(
"manipulation", 
"This instance of MoveGroup is not allowed to execute trajectories but the place " 
  376                                      "goal request has plan_only set to false. Only a motion plan will be computed " 
  378     executePlaceCallbackPlanOnly(goal, action_res);
 
  381     executePlaceCallbackPlanAndExecute(goal, action_res);
 
  383   bool planned_trajectory_empty = action_res.trajectory_stages.empty();
 
  385       getActionResultString(action_res.error_code, planned_trajectory_empty, goal->planning_options.plan_only);
 
  386   if (action_res.error_code.val == moveit_msgs::MoveItErrorCodes::SUCCESS)
 
  387     place_action_server_->setSucceeded(action_res, 
response);
 
  390     if (action_res.error_code.val == moveit_msgs::MoveItErrorCodes::PREEMPTED)
 
  391       place_action_server_->setPreempted(action_res, 
response);
 
  393       place_action_server_->setAborted(action_res, 
response);
 
  409   pickup_state_ = state;
 
  410   pickup_feedback_.state = stateToStr(state);
 
  411   pickup_action_server_->publishFeedback(pickup_feedback_);
 
  416   place_state_ = state;
 
  417   place_feedback_.state = stateToStr(state);
 
  418   place_action_server_->publishFeedback(place_feedback_);
 
  426   goal.minimize_object_distance = 
true;
 
  430   moveit_msgs::Grasp g;
 
  431   g.grasp_pose.header.frame_id = goal.target_name;
 
  432   g.grasp_pose.pose.position.x = -0.2;
 
  433   g.grasp_pose.pose.position.y = 0.0;
 
  434   g.grasp_pose.pose.position.z = 0.0;
 
  435   g.grasp_pose.pose.orientation.x = 0.0;
 
  436   g.grasp_pose.pose.orientation.y = 0.0;
 
  437   g.grasp_pose.pose.orientation.z = 0.0;
 
  438   g.grasp_pose.pose.orientation.w = 1.0;
 
  440   g.pre_grasp_approach.direction.header.frame_id = lscene->getPlanningFrame();
 
  441   g.pre_grasp_approach.direction.vector.x = 1.0;
 
  442   g.pre_grasp_approach.min_distance = 0.1;
 
  443   g.pre_grasp_approach.desired_distance = 0.2;
 
  445   g.post_grasp_retreat.direction.header.frame_id = lscene->getPlanningFrame();
 
  446   g.post_grasp_retreat.direction.vector.z = 1.0;
 
  447   g.post_grasp_retreat.min_distance = 0.1;
 
  448   g.post_grasp_retreat.desired_distance = 0.2;
 
  450   if (lscene->getRobotModel()->hasEndEffector(goal.end_effector))
 
  452     g.pre_grasp_posture.joint_names = lscene->getRobotModel()->getEndEffector(goal.end_effector)->getJointModelNames();
 
  453     g.pre_grasp_posture.points.resize(1);
 
  454     g.pre_grasp_posture.points[0].positions.resize(g.pre_grasp_posture.joint_names.size(),
 
  455                                                    std::numeric_limits<double>::max());
 
  457     g.grasp_posture.joint_names = g.pre_grasp_posture.joint_names;
 
  458     g.grasp_posture.points.resize(1);
 
  459     g.grasp_posture.points[0].positions.resize(g.grasp_posture.joint_names.size(), -std::numeric_limits<double>::max());
 
  461   goal.possible_grasps.push_back(g);