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_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  // Desired distance to keep from the object
52  double desired_distance;
53  // Skip perception orientation
54  bool skip_orientation;
55  // Should the robot search for the object by rotating or go to last known heading
56  bool search_by_rotating;
57  // Search angle relative to current robot orientation when rotating to find objects
58  double search_angle;
59  // Tolerance for transforming coordinates
60  double transform_tolerance;
61  // Parameters for OdomSmoother
62  std::string odom_topic;
63  double odom_duration;
64  bool use_collision_detection;
65  double filter_coef;
66 };
67 
73 {
74 public:
79  const nav2::LifecycleNode::SharedPtr & node,
80  const rclcpp::Logger & logger);
81 
82 protected:
91  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
92  const std::vector<rclcpp::Parameter> & parameters) override;
93 
100  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters) override;
101 };
102 
103 } // namespace opennav_following
104 
105 #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...