Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
theta_star_planner.hpp
1 // Copyright 2020 Anshumaan Singh
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_THETA_STAR_PLANNER__THETA_STAR_PLANNER_HPP_
16 #define NAV2_THETA_STAR_PLANNER__THETA_STAR_PLANNER_HPP_
17 
18 #include <iostream>
19 #include <cmath>
20 #include <string>
21 #include <chrono>
22 #include <queue>
23 #include <algorithm>
24 #include <memory>
25 #include <vector>
26 #include "rclcpp/clock.hpp"
27 #include "rclcpp/logger.hpp"
28 #include "nav2_core/global_planner.hpp"
29 #include "nav2_core/planner_exceptions.hpp"
30 #include "nav_msgs/msg/path.hpp"
31 #include "nav2_util/robot_utils.hpp"
32 #include "nav2_ros_common/lifecycle_node.hpp"
33 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
34 #include "nav2_costmap_2d/cost_values.hpp"
35 #include "nav2_ros_common/node_utils.hpp"
36 #include "nav2_theta_star_planner/theta_star.hpp"
37 #include "nav2_theta_star_planner/parameter_handler.hpp"
38 #include "nav2_util/geometry_utils.hpp"
39 #include "nav2_ros_common/tf2_factories.hpp"
40 
41 using rcl_interfaces::msg::ParameterType;
42 
43 namespace nav2_theta_star_planner
44 {
45 
47 {
48 public:
49  void configure(
50  const nav2::LifecycleNode::WeakPtr & parent,
51  std::string name, nav2::TransformBuffer::SharedPtr tf,
52  std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros) override;
53 
54  void cleanup() override;
55 
56  void activate() override;
57 
58  void deactivate() override;
59 
67  nav_msgs::msg::Path createPlan(
68  const geometry_msgs::msg::PoseStamped & start,
69  const geometry_msgs::msg::PoseStamped & goal,
70  const std::vector<geometry_msgs::msg::PoseStamped> & viapoints,
71  std::function<bool()> cancel_checker) override;
72 
73 protected:
74  nav2::TransformBuffer::SharedPtr tf_;
75  rclcpp::Clock::SharedPtr clock_;
76  rclcpp::Logger logger_{rclcpp::get_logger("ThetaStarPlanner")};
77  std::string global_frame_, name_;
78 
79  // parent node weak ptr
80  nav2::LifecycleNode::WeakPtr parent_node_;
81 
82  std::unique_ptr<ThetaStar> planner_;
83 
84  Parameters * params_;
85  std::unique_ptr<nav2_theta_star_planner::ParameterHandler> param_handler_;
86 
92  void getPlan(nav_msgs::msg::Path & global_path, std::function<bool()> cancel_checker);
93 
100  static nav_msgs::msg::Path linearInterpolation(
101  const std::vector<coordsW> & raw_path,
102  const double & dist_bw_points);
103 };
104 } // namespace nav2_theta_star_planner
105 
106 #endif // NAV2_THETA_STAR_PLANNER__THETA_STAR_PLANNER_HPP_
Abstract interface for global planners to adhere to with pluginlib.
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 getPlan(nav_msgs::msg::Path &global_path, std::function< bool()> cancel_checker)
the function responsible for calling the algorithm and retrieving a path from it
void cleanup() override
Method to cleanup resources used on shutdown.
static nav_msgs::msg::Path linearInterpolation(const std::vector< coordsW > &raw_path, const double &dist_bw_points)
interpolates points between the consecutive waypoints of the path
void deactivate() override
Method to deactivate planner and any threads involved in execution.
void configure(const nav2::LifecycleNode::WeakPtr &parent, std::string name, nav2::TransformBuffer::SharedPtr tf, std::shared_ptr< nav2_costmap_2d::Costmap2DROS > costmap_ros) override
void activate() override
Method to active planner and any threads involved in execution.