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/rclcpp.hpp"
25 #include "nav2_ros_common/lifecycle_node.hpp"
26 #include "nav2_util/parameter_handler.hpp"
27 #include "nav2_ros_common/node_utils.hpp"
28 
29 namespace opennav_docking
30 {
31 
32 struct Parameters
33 {
34  // Frequency to run control loops
35  double controller_frequency;
36  // Timeout for initially detecting the charge dock
37  double initial_perception_timeout;
38  // Timeout after making contact with dock for charging to start
39  // If this is exceeded, the robot returns to the staging pose and retries
40  double wait_charge_timeout;
41  // Timeout to approach into the dock and reset its approach is retrying
42  double dock_approach_timeout;
43  // Timeout to rotate to the dock
44  double rotate_to_dock_timeout;
45  // When undocking, these are the tolerances for arriving at the staging pose
46  double undock_linear_tolerance, undock_angular_tolerance;
47  // Maximum number of times the robot will return to staging pose and retry docking
48  int max_retries;
49  // This is the root frame of the robot - typically "base_link"
50  std::string base_frame;
51  // This is our fixed frame for controlling - typically "odom"
52  std::string fixed_frame;
53  // The tolerance to the dock's staging pose not requiring navigation
54  double dock_prestaging_tolerance;
55  // Angular tolerance to exit the rotation loop when rotate_to_dock is enabled
56  double rotation_angular_tolerance;
57  // Does the robot drive backwards onto the dock? Default is forwards
58  std::optional<bool> dock_backwards;
59  // Parameters for OdomSmoother
60  std::string odom_topic;
61  double odom_duration;
62 };
63 
69 {
70 public:
75  const nav2::LifecycleNode::SharedPtr & node,
76  const rclcpp::Logger & logger);
77 
78 protected:
87  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
88  const std::vector<rclcpp::Parameter> & parameters) override;
89 
96  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters) override;
97 };
98 
99 } // namespace opennav_docking
100 
101 #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...