moveit2
The MoveIt Motion Planning Framework for ROS 2.
planner_logic_interface.h
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 
35 /* Author: Sebastian Jahr
36  Description: Defines an interface for a planner logic plugin for the hybrid planning manager component node.
37  */
38 
39 #pragma once
40 
41 #include <rclcpp/rclcpp.hpp>
42 #include <moveit_msgs/msg/move_it_error_codes.hpp>
45 
47 {
48 // Describes the outcome of a reaction to an event in the hybrid planning architecture
50 {
51  ReactionResult(const HybridPlanningEvent& planning_event, const std::string& error_msg, int error_code)
52  : error_message(error_msg), error_code(error_code)
53  {
54  switch (planning_event)
55  {
57  event = "Hybrid planning request received";
58  break;
60  event = "Global planning action successful";
61  break;
63  event = "Global planning action aborted";
64  break;
66  event = "Global planning action canceled";
67  break;
69  event = "Global solution available";
70  break;
72  event = "Local planning action successful";
73  break;
75  event = "Local planning action aborted";
76  break;
78  event = "Local planning action canceled";
79  break;
81  event = "Undefined event";
82  }
83  };
84  ReactionResult(const std::string& event, const std::string& error_msg, int error_code)
85  : event(event), error_message(error_msg), error_code(error_code){};
86 
87  // Event that triggered the reaction
88  std::string event;
89 
90  // Additional error description
91  std::string error_message;
92 
93  // Error code
95 };
96 
97 class HybridPlanningManager; // Forward declaration
98 
105 {
106 public:
112  virtual ~PlannerLogicInterface() = default;
113 
119  virtual bool initialize(const std::shared_ptr<HybridPlanningManager>& hybrid_planning_manager) = 0;
120 
126  virtual ReactionResult react(const HybridPlanningEvent& event) = 0;
127 
133  virtual ReactionResult react(const std::string& event) = 0;
134 
135 protected:
136  // The hybrid planning manager instance that runs this logic plugin
137  std::shared_ptr<HybridPlanningManager> hybrid_planning_manager_ = nullptr;
138 };
139 } // namespace moveit::hybrid_planning
virtual ReactionResult react(const std::string &event)=0
std::shared_ptr< HybridPlanningManager > hybrid_planning_manager_
PlannerLogicInterface & operator=(const PlannerLogicInterface &)=default
PlannerLogicInterface(const PlannerLogicInterface &)=default
PlannerLogicInterface & operator=(PlannerLogicInterface &&)=default
PlannerLogicInterface(PlannerLogicInterface &&)=default
virtual bool initialize(const std::shared_ptr< HybridPlanningManager > &hybrid_planning_manager)=0
virtual ReactionResult react(const HybridPlanningEvent &event)=0
ReactionResult(const HybridPlanningEvent &planning_event, const std::string &error_msg, int error_code)
ReactionResult(const std::string &event, const std::string &error_msg, int error_code)