Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
path_utils.hpp
1 // Copyright (c) 2025 Berkan Tali
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_UTIL__PATH_UTILS_HPP_
16 #define NAV2_UTIL__PATH_UTILS_HPP_
17 
18 #include <algorithm>
19 #include <cmath>
20 #include <limits>
21 #include <string>
22 
23 #include "geometry_msgs/msg/pose.hpp"
24 #include "geometry_msgs/msg/pose_stamped.hpp"
25 #include "geometry_msgs/msg/point.hpp"
26 #include "geometry_msgs/msg/quaternion.hpp"
27 #include "nav_msgs/msg/path.hpp"
28 #include "nav2_ros_common/tf2_factories.hpp"
29 #include "tf2/utils.hpp"
30 #include "angles/angles.h"
31 #include "nav2_util/geometry_utils.hpp"
32 #include "nav2_util/robot_utils.hpp"
33 namespace nav2_util
34 {
35 
40 {
41  double distance;
42  size_t closest_segment_index;
43 };
58 PathSearchResult distance_from_path(
59  const nav_msgs::msg::Path & path,
60  const geometry_msgs::msg::Pose & robot_pose,
61  const size_t start_index = 0,
62  const double search_window_length = std::numeric_limits<double>::max());
63 
73 bool transformPathInTargetFrame(
74  const nav_msgs::msg::Path & input_path,
75  nav_msgs::msg::Path & transformed_path,
76  nav2::TransformBuffer & tf_buffer, const std::string target_frame,
77  const double transform_timeout = 0.1);
78 
86 unsigned int findFirstPathConstraint(
87  nav_msgs::msg::Path & path,
88  bool enforce_path_inversion,
89  float rotation_threshold);
90 
98 unsigned int removePosesAfterFirstConstraint(
99  nav_msgs::msg::Path & path,
100  bool enforce_path_inversion,
101  float rotation_threshold);
102 
109 bool isPathUpdated(
110  nav_msgs::msg::Path & new_path,
111  nav_msgs::msg::Path & old_path);
112 
119 bool isGoalUpdated(
120  nav_msgs::msg::Path & new_path,
121  nav_msgs::msg::Path & old_path);
122 } // namespace nav2_util
123 
124 #endif // NAV2_UTIL__PATH_UTILS_HPP_
Result of searching for the closest segment on a path.
Definition: path_utils.hpp:40