Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
axis_goal_checker.hpp
1 // Copyright (c) 2025 Dexory
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_CONTROLLER__PLUGINS__AXIS_GOAL_CHECKER_HPP_
16 #define NAV2_CONTROLLER__PLUGINS__AXIS_GOAL_CHECKER_HPP_
17 
18 #include <memory>
19 #include <optional>
20 #include <string>
21 #include <vector>
22 
23 #include "rclcpp/logger.hpp"
24 #include "rclcpp/node_interfaces/node_parameters_interface.hpp"
25 #include "rclcpp/parameter.hpp"
26 #include "nav2_ros_common/lifecycle_node.hpp"
27 #include "nav2_core/goal_checker.hpp"
28 #include "rcl_interfaces/msg/set_parameters_result.hpp"
29 
30 namespace nav2_controller
31 {
32 
42 {
43 public:
48 
53 
54  // Standard GoalChecker Interface
61  void initialize(
62  const nav2::LifecycleNode::WeakPtr & parent,
63  const std::string & plugin_name,
64  const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
65 
69  void reset() override;
70 
79  bool isGoalReached(
80  const geometry_msgs::msg::Pose & query_pose, const geometry_msgs::msg::Pose & goal_pose,
81  const geometry_msgs::msg::Twist & velocity,
82  const nav_msgs::msg::Path & transformed_global_plan) override;
83 
91  bool getTolerances(
92  geometry_msgs::msg::Pose & pose_tolerance,
93  geometry_msgs::msg::Twist & vel_tolerance,
94  double & path_length_tolerance) override;
95 
104  bool isGoalXYReached(
105  const geometry_msgs::msg::Pose & query_pose,
106  const geometry_msgs::msg::Pose & goal_pose,
107  const geometry_msgs::msg::Twist & velocity,
108  const nav_msgs::msg::Path & transformed_global_plan) override;
109 
110 protected:
111  double along_path_tolerance_;
112  double cross_track_tolerance_;
113  double fallback_radial_goal_tolerance_;
114  double path_length_tolerance_;
115  double direction_estimation_distance_;
116  bool is_overshoot_valid_;
117  std::optional<double> cached_end_of_path_yaw_;
118  // Dynamic parameters handler
119  std::mutex mutex_;
120  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
121  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
122  std::string plugin_name_;
123  nav2::LifecycleNode::WeakPtr node_;
124  rclcpp::Logger logger_{rclcpp::get_logger("AxisGoalChecker")};
125 
134  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
135  const std::vector<rclcpp::Parameter> & parameters);
136 
143  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
144 };
145 
146 } // namespace nav2_controller
147 
148 #endif // NAV2_CONTROLLER__PLUGINS__AXIS_GOAL_CHECKER_HPP_
Goal Checker plugin that checks progress along the axis defined by the last segment of the path to th...
bool getTolerances(geometry_msgs::msg::Pose &pose_tolerance, geometry_msgs::msg::Twist &vel_tolerance, double &path_length_tolerance) override
Get the position and velocity tolerances.
~AxisGoalChecker()
Destroy the Axis Goal Checker object.
bool isGoalXYReached(const geometry_msgs::msg::Pose &query_pose, const geometry_msgs::msg::Pose &goal_pose, const geometry_msgs::msg::Twist &velocity, const nav_msgs::msg::Path &transformed_global_plan) override
Check if XY goal position has been reached (without considering yaw)
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > &parameters)
Validate incoming parameter updates before applying them. This callback is triggered when one or more...
void reset() override
Reset the goal checker state.
void initialize(const nav2::LifecycleNode::WeakPtr &parent, const std::string &plugin_name, const std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros) override
Initialize the goal checker.
bool isGoalReached(const geometry_msgs::msg::Pose &query_pose, const geometry_msgs::msg::Pose &goal_pose, const geometry_msgs::msg::Twist &velocity, const nav_msgs::msg::Path &transformed_global_plan) override
Check if the goal is reached.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
AxisGoalChecker()
Construct a new Axis Goal Checker object.
Function-object for checking whether a goal has been reached.