Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
route_operation.hpp
1 // Copyright (c) 2025 Open Navigation LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_ROUTE__INTERFACES__ROUTE_OPERATION_HPP_
16 #define NAV2_ROUTE__INTERFACES__ROUTE_OPERATION_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "nav2_ros_common/lifecycle_node.hpp"
23 #include "pluginlib/class_loader.hpp"
24 #include "nav2_route/types.hpp"
25 #include "geometry_msgs/msg/pose_stamped.hpp"
26 #include "nav2_costmap_2d/costmap_subscriber.hpp"
27 
28 namespace nav2_route
29 {
30 
36 {
37  bool reroute{false};
38  std::vector<unsigned int> blocked_ids;
39 };
40 
45 enum class RouteOperationType
46 {
47  ON_GRAPH = 0,
48  ON_STATUS_CHANGE = 1,
49  ON_QUERY = 2
50 };
51 
66 {
67 public:
68  using Ptr = std::shared_ptr<nav2_route::RouteOperation>;
69 
73  RouteOperation() = default;
74 
78  virtual ~RouteOperation() = default;
79 
86  virtual void configure(
87  const nav2::LifecycleNode::SharedPtr node,
88  std::shared_ptr<nav2_costmap_2d::CostmapSubscriber> costmap_subscriber,
89  const std::string & name) = 0;
90 
96  virtual std::string getName() = 0;
97 
107  virtual RouteOperationType processType() {return RouteOperationType::ON_GRAPH;}
108 
127  NodePtr node_achieved,
128  EdgePtr edge_entered,
129  EdgePtr edge_exited,
130  const Route & route,
131  const geometry_msgs::msg::PoseStamped & curr_pose,
132  const Metadata * mdata = nullptr) = 0;
133 };
134 
135 } // namespace nav2_route
136 
137 #endif // NAV2_ROUTE__INTERFACES__ROUTE_OPERATION_HPP_
A plugin interface to perform an operation while tracking the route such as triggered from the graph ...
virtual ~RouteOperation()=default
Destructor.
virtual void configure(const nav2::LifecycleNode::SharedPtr node, std::shared_ptr< nav2_costmap_2d::CostmapSubscriber > costmap_subscriber, const std::string &name)=0
Configure the operation plugin (get params, create interfaces, etc)
virtual std::string getName()=0
An API to get the name of a particular operation for triggering, query or logging.
virtual RouteOperationType processType()
Indication of which type of route operation this plugin is. Whether it is be called by the graph's no...
RouteOperation()=default
Constructor.
virtual OperationResult perform(NodePtr node_achieved, EdgePtr edge_entered, EdgePtr edge_exited, const Route &route, const geometry_msgs::msg::PoseStamped &curr_pose, const Metadata *mdata=nullptr)=0
The main route operation API to perform an operation when triggered. The return value indicates if th...
An object representing edges between nodes.
Definition: types.hpp:134
An object to store arbitrary metadata regarding nodes from the graph file.
Definition: types.hpp:35
An object to store the nodes in the graph file.
Definition: types.hpp:183
a struct to hold return from an operation
An ordered set of nodes and edges corresponding to the planned route.
Definition: types.hpp:211