Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
smac_planner_2d.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_2D_HPP_
16 #define NAV2_SMAC_PLANNER__SMAC_PLANNER_2D_HPP_
17 
18 #include <memory>
19 #include <vector>
20 #include <string>
21 #include <mutex>
22 
23 #include "nav2_smac_planner/a_star.hpp"
24 #include "nav2_smac_planner/smoother.hpp"
25 #include "nav2_smac_planner/utils.hpp"
26 #include "nav2_smac_planner/costmap_downsampler.hpp"
27 #include "nav_msgs/msg/occupancy_grid.hpp"
28 #include "nav2_core/global_planner.hpp"
29 #include "nav_msgs/msg/path.hpp"
30 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
31 #include "nav2_costmap_2d/costmap_2d.hpp"
32 #include "geometry_msgs/msg/pose_stamped.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 #include "rcl_interfaces/msg/set_parameters_result.hpp"
38 
39 namespace nav2_smac_planner
40 {
41 
47 template<typename NodeT = Node2D>
49 {
50 public:
55 
60 
68  void configure(
69  const nav2::LifecycleNode::WeakPtr & parent,
70  std::string name, nav2::TransformBuffer::SharedPtr tf,
71  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
72 
76  void cleanup() override;
77 
81  void activate() override;
82 
86  void deactivate() override;
87 
95  nav_msgs::msg::Path createPlan(
96  const geometry_msgs::msg::PoseStamped & start,
97  const geometry_msgs::msg::PoseStamped & goal,
98  const std::vector<geometry_msgs::msg::PoseStamped> & viapoints,
99  std::function<bool()> cancel_checker) override;
100 
101 protected:
110  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
111  const std::vector<rclcpp::Parameter> & parameters);
112 
119  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
120 
121  std::unique_ptr<AStarAlgorithm<NodeT>> _a_star;
122  GridCollisionChecker _collision_checker;
123  std::unique_ptr<Smoother> _smoother;
124  nav2_costmap_2d::Costmap2D * _costmap;
125  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> _costmap_ros;
126  std::unique_ptr<CostmapDownsampler> _costmap_downsampler;
127  rclcpp::Clock::SharedPtr _clock;
128  rclcpp::Logger _logger{rclcpp::get_logger("SmacPlanner2D")};
129  std::string _global_frame, _name;
130  float _tolerance;
131  int _downsampling_factor;
132  bool _downsample_costmap;
133  nav2::Publisher<nav_msgs::msg::Path>::SharedPtr _raw_plan_publisher;
134  double _max_planning_time;
135  bool _allow_unknown;
136  int _max_iterations;
137  int _max_on_approach_iterations;
138  int _terminal_checking_interval;
139  bool _use_final_approach_orientation;
140  SearchInfo _search_info;
141  std::string _motion_model_for_search;
142  MotionModel _motion_model;
143  std::mutex _mutex;
144  nav2::LifecycleNode::WeakPtr _node;
145 
146  // Dynamic parameters handler
147  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr _post_set_params_handler;
148  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr _on_set_params_handler;
149 };
150 
151 // Backward-compatible type alias
153 
154 } // namespace nav2_smac_planner
155 
156 #include "nav2_smac_planner/smac_planner_2d_impl.hpp" // NOLINT
157 
158 #endif // NAV2_SMAC_PLANNER__SMAC_PLANNER_2D_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 2D planner that allows custom node types.
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 activate() override
Activate lifecycle node.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
void deactivate() override
Deactivate lifecycle node.
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.
void cleanup() override
Cleanup lifecycle node.
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.
Search properties and penalties.
Definition: types.hpp:38