Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
smac_planner_lattice.hpp
1 // Copyright (c) 2021, 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_LATTICE_HPP_
16 #define NAV2_SMAC_PLANNER__SMAC_PLANNER_LATTICE_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 "nav_msgs/msg/occupancy_grid.hpp"
26 #include "nav2_core/global_planner.hpp"
27 #include "nav_msgs/msg/path.hpp"
28 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
29 #include "nav2_costmap_2d/costmap_2d.hpp"
30 #include "geometry_msgs/msg/pose_stamped.hpp"
31 #include "nav2_util/lifecycle_node.hpp"
32 #include "nav2_util/node_utils.hpp"
33 #include "tf2/utils.h"
34 
35 namespace nav2_smac_planner
36 {
37 
39 {
40 public:
45 
50 
58  void configure(
59  const rclcpp_lifecycle::LifecycleNode::WeakPtr & parent,
60  std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
61  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
62 
66  void cleanup() override;
67 
71  void activate() override;
72 
76  void deactivate() override;
77 
84  nav_msgs::msg::Path createPlan(
85  const geometry_msgs::msg::PoseStamped & start,
86  const geometry_msgs::msg::PoseStamped & goal) override;
87 
88 protected:
93  rcl_interfaces::msg::SetParametersResult
94  dynamicParametersCallback(std::vector<rclcpp::Parameter> parameters);
95 
96  std::unique_ptr<AStarAlgorithm<NodeLattice>> _a_star;
97  GridCollisionChecker _collision_checker;
98  std::unique_ptr<Smoother> _smoother;
99  rclcpp::Clock::SharedPtr _clock;
100  rclcpp::Logger _logger{rclcpp::get_logger("SmacPlannerLattice")};
101  nav2_costmap_2d::Costmap2D * _costmap;
102  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> _costmap_ros;
103  MotionModel _motion_model;
104  LatticeMetadata _metadata;
105  std::string _global_frame, _name;
106  SearchInfo _search_info;
107  bool _allow_unknown;
108  int _max_iterations;
109  int _max_on_approach_iterations;
110  float _tolerance;
111  rclcpp_lifecycle::LifecyclePublisher<nav_msgs::msg::Path>::SharedPtr _raw_plan_publisher;
112  double _max_planning_time;
113  double _lookup_table_size;
114  std::mutex _mutex;
115  rclcpp_lifecycle::LifecycleNode::WeakPtr _node;
116 
117  // Dynamic parameters handler
118  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr _dyn_params_handler;
119 };
120 
121 } // namespace nav2_smac_planner
122 
123 #endif // NAV2_SMAC_PLANNER__SMAC_PLANNER_LATTICE_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:68
A costmap grid collision checker.
void deactivate() override
Deactivate lifecycle node.
void configure(const rclcpp_lifecycle::LifecycleNode::WeakPtr &parent, std::string name, std::shared_ptr< tf2_ros::Buffer > 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) override
Creating a plan from start and goal poses.
rcl_interfaces::msg::SetParametersResult dynamicParametersCallback(std::vector< rclcpp::Parameter > parameters)
Callback executed when a paramter change is detected.
void cleanup() override
Cleanup lifecycle node.
void activate() override
Activate lifecycle node.
A struct of all lattice metadata.
Definition: types.hpp:138
Search properties and penalties.
Definition: types.hpp:36