Nav2 Navigation Stack - rolling  main
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_FOLLOWING__PARAMETER_HANDLER_HPP_
16 #define OPENNAV_FOLLOWING__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_following
30 {
31 
32 struct Parameters
33 {
34  // Frequency to run control loops
35  double controller_frequency;
36  // Timeout to detect the object
37  double detection_timeout;
38  // Timeout to detect the object while rotating to it
39  double rotate_to_object_timeout;
40  // Timeout after which a static object is considered as goal reached
41  double static_object_timeout;
42  // Tolerances for arriving at the safe_distance pose
43  double linear_tolerance, angular_tolerance;
44  // Maximum number of times the robot will retry to approach the object
45  int max_retries;
46  // This is the root frame of the robot - typically "base_link"
47  std::string base_frame;
48  // This is our fixed frame for controlling - typically "odom"
49  std::string fixed_frame;
50  // Desired distance to keep from the object
51  double desired_distance;
52  // Skip perception orientation
53  bool skip_orientation;
54  // Should the robot search for the object by rotating or go to last known heading
55  bool search_by_rotating;
56  // Search angle relative to current robot orientation when rotating to find objects
57  double search_angle;
58  // Tolerance for transforming coordinates
59  double transform_tolerance;
60  // Parameters for OdomSmoother
61  std::string odom_topic;
62  double odom_duration;
63  bool use_collision_detection;
64  double filter_coef;
65 };
66 
72 {
73 public:
78  const nav2::LifecycleNode::SharedPtr & node,
79  const rclcpp::Logger & logger);
80 
81 protected:
90  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
91  const std::vector<rclcpp::Parameter> & parameters) override;
92 
99  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters) override;
100 };
101 
102 } // namespace opennav_following
103 
104 #endif // OPENNAV_FOLLOWING__PARAMETER_HANDLER_HPP_
Handles parameters and dynamic parameters for Planner Server.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters) override
Apply parameter updates after validation This callback is executed when parameters have been successf...
ParameterHandler(const nav2::LifecycleNode::SharedPtr &node, const rclcpp::Logger &logger)
Constructor for opennav_following::ParameterHandler.
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...