Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
path_handler.hpp
1 // Copyright (c) 2025 Maurice Alexander Purnawan
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_CORE__PATH_HANDLER_HPP_
16 #define NAV2_CORE__PATH_HANDLER_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 #include <utility>
22 
23 #include "geometry_msgs/msg/pose.hpp"
24 #include "nav_msgs/msg/path.hpp"
25 #include "nav2_ros_common/lifecycle_node.hpp"
26 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
27 #include "nav2_ros_common/tf2_factories.hpp"
28 
29 namespace nav2_core
30 {
31 using PathIterator = std::vector<geometry_msgs::msg::PoseStamped>::iterator;
32 using PathSegment = std::pair<PathIterator, PathIterator>;
33 
44 {
45 public:
46  typedef std::shared_ptr<nav2_core::PathHandler> Ptr;
47 
48  virtual ~PathHandler() {}
49 
58  virtual void initialize(
59  const nav2::LifecycleNode::WeakPtr & parent,
60  const rclcpp::Logger & logger,
61  const std::string & plugin_name,
62  const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros,
63  nav2::TransformBuffer::SharedPtr tf) = 0;
64 
69  virtual void setPlan(const nav_msgs::msg::Path & path) = 0;
70 
79  virtual PathSegment findPlanSegment(
80  const geometry_msgs::msg::PoseStamped & pose) = 0;
81 
88  virtual nav_msgs::msg::Path transformLocalPlan(
89  const PathIterator & closest_point,
90  const PathIterator & pruned_plan_end) = 0;
91 
97  virtual geometry_msgs::msg::PoseStamped getTransformedGoal(
98  const builtin_interfaces::msg::Time & stamp) = 0;
99 };
100 
101 } // namespace nav2_core
102 
103 #endif // NAV2_CORE__PATH_HANDLER_HPP_
Function-object for handling the path from Planner Server.
virtual PathSegment findPlanSegment(const geometry_msgs::msg::PoseStamped &pose)=0
Determines the portion of the global plan to be used for local control. This function locates the sta...
virtual void initialize(const nav2::LifecycleNode::WeakPtr &parent, const rclcpp::Logger &logger, const std::string &plugin_name, const std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros, nav2::TransformBuffer::SharedPtr tf)=0
Initialize parameters.
virtual geometry_msgs::msg::PoseStamped getTransformedGoal(const builtin_interfaces::msg::Time &stamp)=0
Get the global goal pose transformed to the costmap global frame.
virtual void setPlan(const nav_msgs::msg::Path &path)=0
Set new reference plan.
virtual nav_msgs::msg::Path transformLocalPlan(const PathIterator &closest_point, const PathIterator &pruned_plan_end)=0
Transforms a predefined segment of the global plan into the costmap global frame.