Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
parameter_handler.hpp
1 // Copyright (c) 2022 Samsung Research America
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 OPENNAV_DOCKING__PARAMETER_HANDLER_HPP_
16 #define OPENNAV_DOCKING__PARAMETER_HANDLER_HPP_
17 
18 #include <string>
19 #include <vector>
20 #include <memory>
21 #include <algorithm>
22 #include <mutex>
23 
24 #include "rclcpp/logger.hpp"
25 #include "rclcpp/parameter.hpp"
26 #include "nav2_ros_common/lifecycle_node.hpp"
27 #include "nav2_util/parameter_handler.hpp"
28 #include "nav2_ros_common/node_utils.hpp"
29 
30 namespace opennav_docking
31 {
32 
33 struct Parameters
34 {
35  // Frequency to run control loops
36  double controller_frequency;
37  // Timeout for initially detecting the charge dock
38  double initial_perception_timeout;
39  // Timeout after making contact with dock for charging to start
40  // If this is exceeded, the robot returns to the staging pose and retries
41  double wait_charge_timeout;
42  // Timeout to approach into the dock and reset its approach is retrying
43  double dock_approach_timeout;
44  // Timeout to rotate to the dock
45  double rotate_to_dock_timeout;
46  // When undocking, these are the tolerances for arriving at the staging pose
47  double undock_linear_tolerance, undock_angular_tolerance;
48  // Maximum number of times the robot will return to staging pose and retry docking
49  int max_retries;
50  // This is the root frame of the robot - typically "base_link"
51  std::string base_frame;
52  // This is our fixed frame for controlling - typically "odom"
53  std::string fixed_frame;
54  // The tolerance to the dock's staging pose not requiring navigation
55  double dock_prestaging_tolerance;
56  // Angular tolerance to exit the rotation loop when rotate_to_dock is enabled
57  double rotation_angular_tolerance;
58  // Does the robot drive backwards onto the dock? Default is forwards
59  std::optional<bool> dock_backwards;
60  // Parameters for OdomSmoother
61  std::string odom_topic;
62  double odom_duration;
63 };
64 
70 {
71 public:
76  const nav2::LifecycleNode::SharedPtr & node,
77  const rclcpp::Logger & logger);
78 
79 protected:
88  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
89  const std::vector<rclcpp::Parameter> & parameters) override;
90 
97  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters) override;
98 };
99 
100 } // namespace opennav_docking
101 
102 #endif // OPENNAV_DOCKING__PARAMETER_HANDLER_HPP_
Handles parameters and dynamic parameters for Controller Server.
ParameterHandler(const nav2::LifecycleNode::SharedPtr &node, const rclcpp::Logger &logger)
Constructor for opennav_docking::ParameterHandler.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters) override
Apply parameter updates after validation This callback is executed when parameters have been successf...
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > &parameters) override
Validate incoming parameter updates before applying them. This callback is triggered when one or more...