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 <string>
20 #include <vector>
21 
22 #include "rclcpp/rclcpp.hpp"
23 #include "nav2_ros_common/lifecycle_node.hpp"
24 #include "nav2_core/goal_checker.hpp"
25 #include "rcl_interfaces/msg/set_parameters_result.hpp"
26 
27 namespace nav2_controller
28 {
29 
39 {
40 public:
45 
50 
51  // Standard GoalChecker Interface
58  void initialize(
59  const nav2::LifecycleNode::WeakPtr & parent,
60  const std::string & plugin_name,
61  const std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
62 
66  void reset() override;
67 
76  bool isGoalReached(
77  const geometry_msgs::msg::Pose & query_pose, const geometry_msgs::msg::Pose & goal_pose,
78  const geometry_msgs::msg::Twist & velocity,
79  const nav_msgs::msg::Path & transformed_global_plan) override;
80 
88  bool getTolerances(
89  geometry_msgs::msg::Pose & pose_tolerance,
90  geometry_msgs::msg::Twist & vel_tolerance,
91  double & path_length_tolerance) override;
92 
101  bool isGoalXYReached(
102  const geometry_msgs::msg::Pose & query_pose,
103  const geometry_msgs::msg::Pose & goal_pose,
104  const geometry_msgs::msg::Twist & velocity,
105  const nav_msgs::msg::Path & transformed_global_plan) override;
106 
107 protected:
108  double along_path_tolerance_;
109  double cross_track_tolerance_;
110  double path_length_tolerance_;
111  bool is_overshoot_valid_;
112  // Dynamic parameters handler
113  std::mutex mutex_;
114  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
115  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
116  std::string plugin_name_;
117  nav2::LifecycleNode::WeakPtr node_;
118  rclcpp::Logger logger_{rclcpp::get_logger("AxisGoalChecker")};
119 
128  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
129  const std::vector<rclcpp::Parameter> & parameters);
130 
137  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
138 };
139 
140 } // namespace nav2_controller
141 
142 #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.