plan_service_capability.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
40 
41 namespace move_group
42 {
43 MoveGroupPlanService::MoveGroupPlanService() : MoveGroupCapability("MotionPlanService")
44 {
45 }
46 
48 {
51 }
52 
53 bool MoveGroupPlanService::computePlanService(moveit_msgs::GetMotionPlan::Request& req,
54  moveit_msgs::GetMotionPlan::Response& res)
55 {
56  ROS_INFO_NAMED(getName(), "Received new planning service request...");
57  // before we start planning, ensure that we have the latest robot state received...
58  if (static_cast<bool>(req.motion_plan_request.start_state.is_diff))
59  context_->planning_scene_monitor_->waitForCurrentRobotState(ros::Time::now());
60  context_->planning_scene_monitor_->updateFrameTransforms();
61 
62  // Select planning_pipeline to handle request
63  const planning_pipeline::PlanningPipelinePtr planning_pipeline =
64  resolvePlanningPipeline(req.motion_plan_request.pipeline_id);
65  if (!planning_pipeline)
66  {
67  res.motion_plan_response.error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE;
68  return true;
69  }
70 
71  planning_scene_monitor::LockedPlanningSceneRO ps(context_->planning_scene_monitor_);
72  try
73  {
75  planning_pipeline->generatePlan(ps, req.motion_plan_request, mp_res);
76  mp_res.getMessage(res.motion_plan_response);
77  }
78  catch (std::exception& ex)
79  {
80  ROS_ERROR_NAMED(getName(), "Planning pipeline threw an exception: %s", ex.what());
81  res.motion_plan_response.error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE;
82  }
83 
84  return true;
85 }
86 } // namespace move_group
87 
planning_interface::MotionPlanResponse::getMessage
void getMessage(moveit_msgs::MotionPlanResponse &msg) const
move_group::MoveGroupCapability
Definition: move_group_capability.h:89
move_group::MoveGroupCapability::context_
MoveGroupContextPtr context_
Definition: move_group_capability.h:132
move_group::MoveGroupCapability::getName
const std::string & getName() const
Definition: move_group_capability.h:104
planning_interface::MotionPlanResponse
move_group::PLANNER_SERVICE_NAME
static const std::string PLANNER_SERVICE_NAME
Definition: capability_names.h:75
move_group::MoveGroupPlanService::initialize
void initialize() override
Definition: plan_service_capability.cpp:79
move_group::MoveGroupPlanService::plan_service_
ros::ServiceServer plan_service_
Definition: plan_service_capability.h:118
ros::NodeHandle::advertiseService
ServiceServer advertiseService(AdvertiseServiceOptions &ops)
ROS_ERROR_NAMED
#define ROS_ERROR_NAMED(name,...)
move_group::MoveGroupPlanService::computePlanService
bool computePlanService(moveit_msgs::GetMotionPlan::Request &req, moveit_msgs::GetMotionPlan::Response &res)
Definition: plan_service_capability.cpp:85
move_group::MoveGroupPlanService
Definition: plan_service_capability.h:76
move_group::MoveGroupPlanService::MoveGroupPlanService
MoveGroupPlanService()
Definition: plan_service_capability.cpp:75
ROS_INFO_NAMED
#define ROS_INFO_NAMED(name,...)
move_group::MoveGroupCapability::root_node_handle_
ros::NodeHandle root_node_handle_
Definition: move_group_capability.h:129
move_group::MoveGroupCapability::resolvePlanningPipeline
planning_pipeline::PlanningPipelinePtr resolvePlanningPipeline(const std::string &pipeline_id) const
Definition: move_group_capability.cpp:196
move_group
Definition: capability_names.h:41
class_loader.hpp
planning_pipeline.h
planning_pipeline
plan_service_capability.h
planning_scene_monitor::LockedPlanningSceneRO
CLASS_LOADER_REGISTER_CLASS
CLASS_LOADER_REGISTER_CLASS(default_planner_request_adapters::AddIterativeSplineParameterization, planning_request_adapter::PlanningRequestAdapter)
capability_names.h
ros::Time::now
static Time now()


move_group
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Thu Nov 21 2024 03:24:41