Nav2 Navigation Stack - jazzy  jazzy
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 "rclcpp_lifecycle/lifecycle_node.hpp"
26 #include "nav2_util/odometry_utils.hpp"
27 #include "nav2_util/geometry_utils.hpp"
28 #include "nav2_util/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  bool use_regulated_linear_velocity_scaling;
46  bool use_cost_regulated_linear_velocity_scaling;
47  double cost_scaling_dist;
48  double cost_scaling_gain;
49  double inflation_cost_scaling_factor;
50  double regulated_linear_scaling_min_radius;
51  double regulated_linear_scaling_min_speed;
52  bool use_fixed_curvature_lookahead;
53  double curvature_lookahead_dist;
54  bool use_rotate_to_heading;
55  double max_angular_accel;
56  bool use_cancel_deceleration;
57  double cancel_deceleration;
58  double rotate_to_heading_min_angle;
59  bool allow_reversing;
60  double max_robot_pose_search_dist;
61  bool interpolate_curvature_after_goal;
62  bool use_collision_detection;
63  double transform_tolerance;
64  bool stateful;
65 };
66 
72 {
73 public:
78  rclcpp_lifecycle::LifecycleNode::SharedPtr node,
79  std::string & plugin_name,
80  rclcpp::Logger & logger, const double costmap_size_x);
81 
86 
87  std::mutex & getMutex() {return mutex_;}
88 
89  Parameters * getParams() {return &params_;}
90 
91 protected:
92  rclcpp_lifecycle::LifecycleNode::WeakPtr node_;
97  rcl_interfaces::msg::SetParametersResult
98  dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters);
99 
100  // Dynamic parameters handler
101  std::mutex mutex_;
102  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr dyn_params_handler_;
103  Parameters params_;
104  std::string plugin_name_;
105  rclcpp::Logger logger_ {rclcpp::get_logger("RegulatedPurePursuitController")};
106 };
107 
108 } // namespace nav2_regulated_pure_pursuit_controller
109 
110 #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.
rcl_interfaces::msg::SetParametersResult dynamicParametersCallback(std::vector< rclcpp::Parameter > parameters)
Callback executed when a parameter change is detected.
ParameterHandler(rclcpp_lifecycle::LifecycleNode::SharedPtr node, std::string &plugin_name, rclcpp::Logger &logger, const double costmap_size_x)
Constructor for nav2_regulated_pure_pursuit_controller::ParameterHandler.