Nav2 Navigation Stack - kilted  kilted
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  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  rclcpp_lifecycle::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 
92 protected:
93  rclcpp_lifecycle::LifecycleNode::WeakPtr node_;
98  void
99  updateParametersCallback(std::vector<rclcpp::Parameter> parameters);
100  rcl_interfaces::msg::SetParametersResult
101  validateParameterUpdatesCallback(std::vector<rclcpp::Parameter> parameters);
102  // Dynamic parameters handler
103  std::mutex mutex_;
104  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
105  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
106  Parameters params_;
107  std::string plugin_name_;
108  rclcpp::Logger logger_ {rclcpp::get_logger("RegulatedPurePursuitController")};
109 };
110 
111 } // namespace nav2_regulated_pure_pursuit_controller
112 
113 #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.
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.
void updateParametersCallback(std::vector< rclcpp::Parameter > parameters)
Callback executed when a parameter change is detected.