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 NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__PARAMETER_HANDLER_HPP_
16 #define NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__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/odometry_utils.hpp"
27 #include "nav2_util/geometry_utils.hpp"
28 #include "nav2_ros_common/node_utils.hpp"
29 
30 namespace nav2_regulated_pure_pursuit_controller
31 {
32 
33 struct Parameters
34 {
35  double desired_linear_vel, base_desired_linear_vel;
36  double lookahead_dist;
37  double rotate_to_heading_angular_vel;
38  double max_lookahead_dist;
39  double min_lookahead_dist;
40  double lookahead_time;
41  bool use_velocity_scaled_lookahead_dist;
42  double min_approach_linear_velocity;
43  double approach_velocity_scaling_dist;
44  double max_allowed_time_to_collision_up_to_carrot;
45  double min_distance_to_obstacle;
46  bool use_regulated_linear_velocity_scaling;
47  bool use_cost_regulated_linear_velocity_scaling;
48  double cost_scaling_dist;
49  double cost_scaling_gain;
50  double inflation_cost_scaling_factor;
51  double regulated_linear_scaling_min_radius;
52  double regulated_linear_scaling_min_speed;
53  bool use_fixed_curvature_lookahead;
54  double curvature_lookahead_dist;
55  bool use_rotate_to_heading;
56  double max_angular_accel;
57  bool use_cancel_deceleration;
58  double cancel_deceleration;
59  double rotate_to_heading_min_angle;
60  bool allow_reversing;
61  double max_robot_pose_search_dist;
62  bool interpolate_curvature_after_goal;
63  bool use_collision_detection;
64  double transform_tolerance;
65  bool stateful;
66 };
67 
73 {
74 public:
79  nav2::LifecycleNode::SharedPtr node,
80  std::string & plugin_name,
81  rclcpp::Logger & logger, const double costmap_size_x);
82 
87 
88  std::mutex & getMutex() {return mutex_;}
89 
90  Parameters * getParams() {return &params_;}
91 
95  void activate();
96 
100  void deactivate();
101 
102 protected:
103  nav2::LifecycleNode::WeakPtr node_;
104 
111  void
112  updateParametersCallback(std::vector<rclcpp::Parameter> parameters);
113 
122  rcl_interfaces::msg::SetParametersResult
123  validateParameterUpdatesCallback(std::vector<rclcpp::Parameter> parameters);
124 
125  // Dynamic parameters handler
126  std::mutex mutex_;
127  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
128  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
129  Parameters params_;
130  std::string plugin_name_;
131  rclcpp::Logger logger_ {rclcpp::get_logger("RegulatedPurePursuitController")};
132 };
133 
134 } // namespace nav2_regulated_pure_pursuit_controller
135 
136 #endif // NAV2_REGULATED_PURE_PURSUIT_CONTROLLER__PARAMETER_HANDLER_HPP_
Handles parameters and dynamic parameters for RPP.
~ParameterHandler()
Destrructor for nav2_regulated_pure_pursuit_controller::ParameterHandler.
void activate()
Registers callbacks for dynamic parameter handling.
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(std::vector< rclcpp::Parameter > parameters)
Validate incoming parameter updates before applying them. This callback is triggered when one or more...
ParameterHandler(nav2::LifecycleNode::SharedPtr node, std::string &plugin_name, rclcpp::Logger &logger, const double costmap_size_x)
Constructor for nav2_regulated_pure_pursuit_controller::ParameterHandler.
void deactivate()
Resets callbacks for dynamic parameter handling.
void updateParametersCallback(std::vector< rclcpp::Parameter > parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...