Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
operations_manager.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 #include <unordered_map>
16 #include <vector>
17 #include <memory>
18 #include <string>
19 
20 #include "pluginlib/class_loader.hpp"
21 #include "pluginlib/class_list_macros.hpp"
22 #include "nav2_util/node_utils.hpp"
23 #include "nav2_core/route_exceptions.hpp"
24 #include "nav2_util/lifecycle_node.hpp"
25 #include "nav2_route/types.hpp"
26 #include "nav2_route/utils.hpp"
27 #include "nav2_route/interfaces/route_operation.hpp"
28 
29 #ifndef NAV2_ROUTE__OPERATIONS_MANAGER_HPP_
30 #define NAV2_ROUTE__OPERATIONS_MANAGER_HPP_
31 
32 namespace nav2_route
33 {
34 
40 {
41 public:
42  typedef std::vector<RouteOperation::Ptr>::const_iterator OperationsIter;
43 
47  explicit OperationsManager(
48  rclcpp_lifecycle::LifecycleNode::SharedPtr node,
49  std::shared_ptr<nav2_costmap_2d::CostmapSubscriber> costmap_subscriber);
50 
54  ~OperationsManager() = default;
55 
63  OperationPtrs findGraphOperations(
64  const NodePtr node, const EdgePtr edge_enter, const EdgePtr edge_exit);
65 
72  template<typename T>
74  T & obj,
75  const OperationTrigger & trigger,
76  OperationPtrs & operations);
77 
84  void updateResult(
85  const std::string & name, const OperationResult & op_result, OperationsResult & result);
86 
97  const bool status_change,
98  const RouteTrackingState & state,
99  const Route & route,
100  const geometry_msgs::msg::PoseStamped & pose,
101  const ReroutingState & rerouting_info);
102 
103 protected:
110  const std::vector<RouteOperation::Ptr> & operations, OperationsResult & result,
111  const NodePtr node,
112  const EdgePtr edge_entered,
113  const EdgePtr edge_exited,
114  const Route & route,
115  const geometry_msgs::msg::PoseStamped & pose);
116 
117  pluginlib::ClassLoader<RouteOperation> plugin_loader_;
118  std::unordered_map<std::string, RouteOperation::Ptr> graph_operations_;
119  std::vector<RouteOperation::Ptr> change_operations_;
120  std::vector<RouteOperation::Ptr> query_operations_;
121  rclcpp::Logger logger_{rclcpp::get_logger("OperationsManager")};
122 };
123 
124 } // namespace nav2_route
125 
126 #endif // NAV2_ROUTE__OPERATIONS_MANAGER_HPP_
Manages operations plugins to call on route tracking.
OperationsResult process(const bool status_change, const RouteTrackingState &state, const Route &route, const geometry_msgs::msg::PoseStamped &pose, const ReroutingState &rerouting_info)
Processes the operations at this tracker state.
void processOperationsPluginVector(const std::vector< RouteOperation::Ptr > &operations, OperationsResult &result, const NodePtr node, const EdgePtr edge_entered, const EdgePtr edge_exited, const Route &route, const geometry_msgs::msg::PoseStamped &pose)
Processes a vector of operations plugins, by trigger.
~OperationsManager()=default
A Destructor for nav2_route::OperationsManager.
OperationPtrs findGraphOperations(const NodePtr node, const EdgePtr edge_enter, const EdgePtr edge_exit)
Finds the set of operations stored in the graph to trigger at this transition.
OperationsManager(rclcpp_lifecycle::LifecycleNode::SharedPtr node, std::shared_ptr< nav2_costmap_2d::CostmapSubscriber > costmap_subscriber)
A constructor for nav2_route::OperationsManager.
void findGraphOperationsToProcess(T &obj, const OperationTrigger &trigger, OperationPtrs &operations)
Finds the set of operations stored in graph objects, by event.
void updateResult(const std::string &name, const OperationResult &op_result, OperationsResult &result)
Updates manager result state by an individual operation's result.
An object representing edges between nodes.
Definition: types.hpp:134
An object to store the nodes in the graph file.
Definition: types.hpp:183
a struct to hold return from an operation
Result information from the operations manager.
Definition: types.hpp:123
State shared to objects to communicate important rerouting data to avoid rerouting over blocked edges...
Definition: types.hpp:264
Current state management of route tracking class.
Definition: types.hpp:248
An ordered set of nodes and edges corresponding to the planned route.
Definition: types.hpp:211