Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
pose_progress_checker.hpp
1 // Copyright (c) 2023 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__POSE_PROGRESS_CHECKER_HPP_
16 #define NAV2_CONTROLLER__PLUGINS__POSE_PROGRESS_CHECKER_HPP_
17 
18 #include <string>
19 #include <vector>
20 #include "rclcpp/logger.hpp"
21 #include "rclcpp/node_interfaces/node_parameters_interface.hpp"
22 #include "rclcpp/parameter.hpp"
23 #include "nav2_controller/plugins/simple_progress_checker.hpp"
24 #include "nav2_ros_common/lifecycle_node.hpp"
25 
26 namespace nav2_controller
27 {
35 {
36 public:
40  PoseProgressChecker() = default;
41 
46 
52  void initialize(
53  const nav2::LifecycleNode::WeakPtr & parent,
54  const std::string & plugin_name) override;
55 
61  bool check(geometry_msgs::msg::PoseStamped & current_pose) override;
62 
63 protected:
69  bool isRobotMovedEnough(const geometry_msgs::msg::Pose & pose);
70 
77  static double poseAngleDistance(
78  const geometry_msgs::msg::Pose &,
79  const geometry_msgs::msg::Pose &);
80 
81  double required_movement_angle_;
82 
83  // Dynamic parameters handler
84  std::mutex mutex_;
85  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
86  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
87  std::string plugin_name_;
88  nav2::LifecycleNode::WeakPtr node_;
89  rclcpp::Logger logger_{rclcpp::get_logger("pose_progress_checker")};
90 
99  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
100  const std::vector<rclcpp::Parameter> & parameters);
101 
108  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
109 };
110 } // namespace nav2_controller
111 
112 #endif // NAV2_CONTROLLER__PLUGINS__POSE_PROGRESS_CHECKER_HPP_
This plugin is used to check the position and the angle of the robot to make sure that it is actually...
PoseProgressChecker()=default
Construct a new Pose Progress Checker object.
static double poseAngleDistance(const geometry_msgs::msg::Pose &, const geometry_msgs::msg::Pose &)
Calculates angle difference between two poses.
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...
bool isRobotMovedEnough(const geometry_msgs::msg::Pose &pose)
Calculates robots movement from baseline pose.
~PoseProgressChecker()
Destroy the Pose Progress Checker object.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
void initialize(const nav2::LifecycleNode::WeakPtr &parent, const std::string &plugin_name) override
Initialize the goal checker.
bool check(geometry_msgs::msg::PoseStamped &current_pose) override
Checks if the robot has moved compare to previous.
This plugin is used to check the position of the robot to make sure that it is actually progressing t...