Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
simple_progress_checker.hpp
1 // Copyright (c) 2019 Intel Corporation
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__SIMPLE_PROGRESS_CHECKER_HPP_
16 #define NAV2_CONTROLLER__PLUGINS__SIMPLE_PROGRESS_CHECKER_HPP_
17 
18 #include <string>
19 #include <vector>
20 #include "rclcpp/rclcpp.hpp"
21 #include "nav2_ros_common/lifecycle_node.hpp"
22 #include "nav2_core/progress_checker.hpp"
23 #include "geometry_msgs/msg/pose_stamped.hpp"
24 #include "geometry_msgs/msg/pose.hpp"
25 
26 namespace nav2_controller
27 {
35 {
36 public:
40  SimpleProgressChecker() = 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 
66  void reset() override;
67 
68 protected:
74  bool isRobotMovedEnough(const geometry_msgs::msg::Pose & pose);
79  void resetBaselinePose(const geometry_msgs::msg::Pose & pose);
80 
87  static double pose_distance(
88  const geometry_msgs::msg::Pose &,
89  const geometry_msgs::msg::Pose &);
90 
91  nav2::LifecycleNode::WeakPtr node_;
92  rclcpp::Clock::SharedPtr clock_;
93  rclcpp::Logger logger_{rclcpp::get_logger("simple_progress_checker")};
94 
95  double radius_;
96  rclcpp::Duration time_allowance_{0, 0};
97 
98  geometry_msgs::msg::Pose baseline_pose_;
99  rclcpp::Time baseline_time_;
100 
101  bool baseline_pose_set_{false};
102  // Dynamic parameters handler
103  std::mutex mutex_;
104  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
105  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
106  std::string plugin_name_;
107 
116  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
117  const std::vector<rclcpp::Parameter> & parameters);
118 
125  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
126 };
127 } // namespace nav2_controller
128 
129 #endif // NAV2_CONTROLLER__PLUGINS__SIMPLE_PROGRESS_CHECKER_HPP_
This plugin is used to check the position of the robot to make sure that it is actually progressing t...
bool check(geometry_msgs::msg::PoseStamped &current_pose) override
Checks if the robot has moved compare to previous.
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...
static double pose_distance(const geometry_msgs::msg::Pose &, const geometry_msgs::msg::Pose &)
Calculates distance between two poses.
void resetBaselinePose(const geometry_msgs::msg::Pose &pose)
Resets baseline pose with the current pose of the robot.
void initialize(const nav2::LifecycleNode::WeakPtr &parent, const std::string &plugin_name) override
Initialize the goal checker.
bool isRobotMovedEnough(const geometry_msgs::msg::Pose &pose)
Calculates robots movement from baseline pose.
void reset() override
Reset the progress checker state.
~SimpleProgressChecker()
Destroy the Simple 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...
SimpleProgressChecker()=default
Construct a new Simple Progress Checker object.
This class defines the plugin interface used to check the position of the robot to make sure that it ...