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/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_following
31 {
32 
33 struct Parameters
34 {
35  // Frequency to run control loops
36  double controller_frequency;
37  // Timeout to detect the object
38  double detection_timeout;
39  // Timeout to detect the object while rotating to it
40  double rotate_to_object_timeout;
41  // Timeout after which a static object is considered as goal reached
42  double static_object_timeout;
43  // Tolerances for arriving at the safe_distance pose
44  double linear_tolerance, angular_tolerance;
45  // Maximum number of times the robot will retry to approach the object
46  int max_retries;
47  // This is the root frame of the robot - typically "base_link"
48  std::string base_frame;
49  // This is our fixed frame for controlling - typically "odom"
50  std::string fixed_frame;
51  // Maximum age of the base-to-fixed transform in seconds; non-positive disables the check
52  double transform_staleness_threshold{0.0};
53  // Desired distance to keep from the object
54  double desired_distance;
55  // Skip perception orientation
56  bool skip_orientation;
57  // Should the robot search for the object by rotating or go to last known heading
58  bool search_by_rotating;
59  // Search angle relative to current robot orientation when rotating to find objects
60  double search_angle;
61  // Tolerance for transforming coordinates
62  double transform_tolerance;
63  // Parameters for OdomSmoother
64  std::string odom_topic;
65  double odom_duration;
66  bool use_collision_detection;
67  double filter_coef;
68 };
69 
75 {
76 public:
81  const nav2::LifecycleNode::SharedPtr & node,
82  const rclcpp::Logger & logger);
83 
84 protected:
93  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
94  const std::vector<rclcpp::Parameter> & parameters) override;
95 
102  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters) override;
103 };
104 
105 } // namespace opennav_following
106 
107 #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...