Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
smac_planner_hybrid.hpp
1 // Copyright (c) 2020, 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. Reserved.
14 
15 #ifndef NAV2_SMAC_PLANNER__SMAC_PLANNER_HYBRID_HPP_
16 #define NAV2_SMAC_PLANNER__SMAC_PLANNER_HYBRID_HPP_
17 
18 #include <memory>
19 #include <vector>
20 #include <string>
21 
22 #include "nav2_smac_planner/a_star.hpp"
23 #include "nav2_smac_planner/smoother.hpp"
24 #include "nav2_smac_planner/utils.hpp"
25 #include "nav2_smac_planner/costmap_downsampler.hpp"
26 #include "nav_msgs/msg/occupancy_grid.hpp"
27 #include "nav2_core/global_planner.hpp"
28 #include "nav_msgs/msg/path.hpp"
29 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
30 #include "nav2_costmap_2d/costmap_2d.hpp"
31 #include "geometry_msgs/msg/pose_stamped.hpp"
32 #include "geometry_msgs/msg/pose_array.hpp"
33 #include "nav2_ros_common/lifecycle_node.hpp"
34 #include "nav2_ros_common/node_utils.hpp"
35 #include "tf2/utils.hpp"
36 #include "nav2_ros_common/tf2_factories.hpp"
37 
38 namespace nav2_smac_planner
39 {
40 
46 template<typename NodeT = NodeHybrid>
48 {
49 public:
54 
59 
67  void configure(
68  const nav2::LifecycleNode::WeakPtr & parent,
69  std::string name, nav2::TransformBuffer::SharedPtr tf,
70  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
71 
75  void cleanup() override;
76 
80  void activate() override;
81 
85  void deactivate() override;
86 
94  nav_msgs::msg::Path createPlan(
95  const geometry_msgs::msg::PoseStamped & start,
96  const geometry_msgs::msg::PoseStamped & goal,
97  const std::vector<geometry_msgs::msg::PoseStamped> & viapoints,
98  std::function<bool()> cancel_checker) override;
99 
100 protected:
109  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
110  const std::vector<rclcpp::Parameter> & parameters);
111 
118  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
119 
120  std::unique_ptr<AStarAlgorithm<NodeT>> _a_star;
121  GridCollisionChecker _collision_checker;
122  std::unique_ptr<Smoother> _smoother;
123  rclcpp::Clock::SharedPtr _clock;
124  rclcpp::Logger _logger{rclcpp::get_logger("SmacPlannerHybrid")};
125  nav2_costmap_2d::Costmap2D * _costmap;
126  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> _costmap_ros;
127  std::unique_ptr<CostmapDownsampler> _costmap_downsampler;
128  std::string _global_frame, _name;
129  float _lookup_table_dim;
130  float _tolerance;
131  bool _downsample_costmap;
132  int _downsampling_factor;
133  double _angle_bin_size;
134  unsigned int _angle_quantizations;
135  bool _allow_unknown;
136  int _max_iterations;
137  int _max_on_approach_iterations;
138  int _terminal_checking_interval;
139  SearchInfo _search_info;
140  double _max_planning_time;
141  double _lookup_table_size;
142  double _minimum_turning_radius_global_coords;
143  bool _debug_visualizations;
144  std::string _motion_model_for_search;
145  MotionModel _motion_model;
146  GoalHeadingMode _goal_heading_mode;
147  int _coarse_search_resolution;
148  nav2::Publisher<nav_msgs::msg::Path>::SharedPtr _raw_plan_publisher;
149  nav2::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr
150  _planned_footprints_publisher;
151  nav2::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr
152  _smoothed_footprints_publisher;
153  nav2::Publisher<geometry_msgs::msg::PoseArray>::SharedPtr
154  _expansions_publisher;
155  std::mutex _mutex;
156  nav2::LifecycleNode::WeakPtr _node;
157 
158  // Dynamic parameters handler
159  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr _post_set_params_handler;
160  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr _on_set_params_handler;
161  std::shared_ptr<rclcpp::ParameterEventHandler> _remote_param_subscriber;
162  std::shared_ptr<rclcpp::ParameterCallbackHandle> _remote_resolution_handler;
163 };
164 
165 // Backward-compatible type alias
167 
168 } // namespace nav2_smac_planner
169 
170 #include "nav2_smac_planner/smac_planner_hybrid_impl.hpp" // NOLINT
171 
172 #endif // NAV2_SMAC_PLANNER__SMAC_PLANNER_HYBRID_HPP_
Abstract interface for global planners to adhere to with pluginlib.
A 2D costmap provides a mapping between points in the world and their associated "costs".
Definition: costmap_2d.hpp:69
A costmap grid collision checker.
A templated hybrid-A* planner that allows custom node types.
void activate() override
Activate lifecycle node.
void deactivate() override
Deactivate lifecycle node.
void cleanup() override
Cleanup lifecycle node.
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > &parameters)
Validate incoming parameter updates before applying them. This callback is triggered when one or more...
void configure(const nav2::LifecycleNode::WeakPtr &parent, std::string name, nav2::TransformBuffer::SharedPtr tf, std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros) override
Configuring plugin.
nav_msgs::msg::Path createPlan(const geometry_msgs::msg::PoseStamped &start, const geometry_msgs::msg::PoseStamped &goal, const std::vector< geometry_msgs::msg::PoseStamped > &viapoints, std::function< bool()> cancel_checker) override
Creating a plan from start and goal poses.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
Search properties and penalties.
Definition: types.hpp:38