Nav2 Navigation Stack - lyrical  lyrical
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_array.hpp"
31 #include "geometry_msgs/msg/pose_stamped.hpp"
32 #include "nav2_ros_common/lifecycle_node.hpp"
33 #include "nav2_ros_common/node_utils.hpp"
34 #include "tf2/utils.hpp"
35 #include "nav2_ros_common/tf2_factories.hpp"
36 
37 namespace nav2_smac_planner
38 {
39 
45 template<typename NodeT = NodeLattice>
47 {
48 public:
53 
58 
66  void configure(
67  const nav2::LifecycleNode::WeakPtr & parent,
68  std::string name, nav2::TransformBuffer::SharedPtr tf,
69  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
70 
74  void cleanup() override;
75 
79  void activate() override;
80 
84  void deactivate() override;
85 
93  nav_msgs::msg::Path createPlan(
94  const geometry_msgs::msg::PoseStamped & start,
95  const geometry_msgs::msg::PoseStamped & goal,
96  const std::vector<geometry_msgs::msg::PoseStamped> & viapoints,
97  std::function<bool()> cancel_checker) override;
98 
99 protected:
108  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
109  const std::vector<rclcpp::Parameter> & parameters);
110 
117  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
118 
119  std::unique_ptr<AStarAlgorithm<NodeT>> _a_star;
120  GridCollisionChecker _collision_checker;
121  std::unique_ptr<Smoother> _smoother;
122  rclcpp::Clock::SharedPtr _clock;
123  rclcpp::Logger _logger{rclcpp::get_logger("SmacPlannerLattice")};
124  nav2_costmap_2d::Costmap2D * _costmap;
125  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> _costmap_ros;
126  MotionModel _motion_model;
127  LatticeMetadata _metadata;
128  std::string _global_frame, _name;
129  SearchInfo _search_info;
130  bool _allow_unknown;
131  int _max_iterations;
132  int _max_on_approach_iterations;
133  int _terminal_checking_interval;
134  float _tolerance;
135  nav2::Publisher<nav_msgs::msg::Path>::SharedPtr _raw_plan_publisher;
136  double _max_planning_time;
137  double _lookup_table_size;
138  bool _debug_visualizations;
139  nav2::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr
140  _planned_footprints_publisher;
141  nav2::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr
142  _smoothed_footprints_publisher;
143  nav2::Publisher<geometry_msgs::msg::PoseArray>::SharedPtr
144  _expansions_publisher;
145  GoalHeadingMode _goal_heading_mode;
146  int _coarse_search_resolution;
147  std::mutex _mutex;
148  nav2::LifecycleNode::WeakPtr _node;
149 
150  // Dynamic parameters handler
151  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr _post_set_params_handler;
152  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr _on_set_params_handler;
153 };
154 
155 // Backward-compatible type alias
157 
158 } // namespace nav2_smac_planner
159 
160 #include "nav2_smac_planner/smac_planner_lattice_impl.hpp" // NOLINT
161 
162 #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:69
A costmap grid collision checker.
A templated state lattice planner that allows custom node types.
void cleanup() override
Cleanup 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 activate() override
Activate 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...
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...
void deactivate() override
Deactivate lifecycle node.
A struct of all lattice metadata.
Definition: types.hpp:155
Search properties and penalties.
Definition: types.hpp:38