moveit2
The MoveIt Motion Planning Framework for ROS 2.
single_plan_execution.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020, PickNik 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 PickNik Inc. 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 
36 
38 {
40 {
41  switch (event)
42  {
44  // Reset local planner started flag
45  local_planner_started_ = false;
46  // Handle new hybrid planning request
47  return ReactionResult(event, "", moveit_msgs::msg::MoveItErrorCodes::SUCCESS,
50  // Do nothing since we wait for the global planning action to finish
51  return ReactionResult(event, "Do nothing", moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
53  // Activate local planner once global solution is available
54  if (!local_planner_started_)
55  { // ensure the local planner is not started twice
56  local_planner_started_ = true;
57  return ReactionResult(event, "", moveit_msgs::msg::MoveItErrorCodes::SUCCESS,
59  }
60  return ReactionResult(event, "", moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
62  // Abort hybrid planning if no global solution is found
63  return ReactionResult(event, "Global planner failed to find a solution",
64  moveit_msgs::msg::MoveItErrorCodes::PLANNING_FAILED);
66  // Finish hybrid planning action successfully because local planning action succeeded
67  return ReactionResult(event, "", moveit_msgs::msg::MoveItErrorCodes::SUCCESS,
70  // Local planning failed so abort hybrid planning
71  return ReactionResult(event, "Local planner failed to find a solution",
72  moveit_msgs::msg::MoveItErrorCodes::PLANNING_FAILED);
73  default:
74  // Unknown event, abort hybrid planning
75  return ReactionResult(event, "Unknown event", moveit_msgs::msg::MoveItErrorCodes::FAILURE,
77  }
78 }
79 
80 ReactionResult SinglePlanExecution::react(const std::string& event)
81 {
82  return ReactionResult(event, "'Single-Plan-Execution' plugin cannot handle events given as string.",
83  moveit_msgs::msg::MoveItErrorCodes::FAILURE);
84 };
85 } // namespace moveit::hybrid_planning
86 
87 #include <pluginlib/class_list_macros.hpp>
88 
PLUGINLIB_EXPORT_CLASS(cached_ik_kinematics_plugin::CachedIKKinematicsPlugin< kdl_kinematics_plugin::KDLKinematicsPlugin >, kinematics::KinematicsBase)
ReactionResult react(const HybridPlanningEvent &event) override