Nav2 Navigation Stack - rolling  main
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 namespace nav2_util
33 {
34 
39 {
40  double distance;
41  size_t closest_segment_index;
42 };
57 PathSearchResult distance_from_path(
58  const nav_msgs::msg::Path & path,
59  const geometry_msgs::msg::Pose & robot_pose,
60  const size_t start_index = 0,
61  const double search_window_length = std::numeric_limits<double>::max());
62 
72 bool transformPathInTargetFrame(
73  const nav_msgs::msg::Path & input_path,
74  nav_msgs::msg::Path & transformed_path,
75  nav2::TransformBuffer & tf_buffer, const std::string target_frame,
76  const double transform_timeout = 0.1);
77 
85 unsigned int findFirstPathConstraint(
86  nav_msgs::msg::Path & path,
87  bool enforce_path_inversion,
88  float rotation_threshold);
89 
97 unsigned int removePosesAfterFirstConstraint(
98  nav_msgs::msg::Path & path,
99  bool enforce_path_inversion,
100  float rotation_threshold);
101 
108 bool isPathUpdated(
109  nav_msgs::msg::Path & new_path,
110  nav_msgs::msg::Path & old_path);
111 
118 bool isGoalUpdated(
119  nav_msgs::msg::Path & new_path,
120  nav_msgs::msg::Path & old_path);
121 } // namespace nav2_util
122 
123 #endif // NAV2_UTIL__PATH_UTILS_HPP_
Result of searching for the closest segment on a path.
Definition: path_utils.hpp:39