17 #ifndef NAV2_NAVFN_PLANNER__NAVFN_PLANNER_HPP_
18 #define NAV2_NAVFN_PLANNER__NAVFN_PLANNER_HPP_
25 #include "geometry_msgs/msg/point.hpp"
26 #include "geometry_msgs/msg/pose_stamped.hpp"
27 #include "nav2_core/global_planner.hpp"
28 #include "nav2_core/planner_exceptions.hpp"
29 #include "nav_msgs/msg/path.hpp"
30 #include "nav2_navfn_planner/navfn.hpp"
31 #include "nav2_navfn_planner/parameter_handler.hpp"
32 #include "nav2_util/robot_utils.hpp"
33 #include "nav2_ros_common/lifecycle_node.hpp"
34 #include "nav2_costmap_2d/costmap_2d_ros.hpp"
35 #include "nav2_util/geometry_utils.hpp"
36 #include "nav2_ros_common/tf2_factories.hpp"
38 namespace nav2_navfn_planner
62 const nav2::LifecycleNode::WeakPtr & parent,
63 std::string name, nav2::TransformBuffer::SharedPtr tf,
64 std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros)
override;
90 const geometry_msgs::msg::PoseStamped & start,
91 const geometry_msgs::msg::PoseStamped & goal,
92 const std::vector<geometry_msgs::msg::PoseStamped> & viapoints,
93 std::function<
bool()> cancel_checker)
override;
106 const geometry_msgs::msg::Pose & start,
107 const geometry_msgs::msg::Pose & goal,
double tolerance,
108 std::function<
bool()> cancel_checker,
109 nav_msgs::msg::Path & plan);
125 const geometry_msgs::msg::Pose & goal,
126 nav_msgs::msg::Path & plan);
134 const geometry_msgs::msg::Pose & goal,
135 nav_msgs::msg::Path & plan);
158 const geometry_msgs::msg::Pose & p1,
159 const geometry_msgs::msg::Pose & p2)
161 double dx = p1.position.x - p2.position.x;
162 double dy = p1.position.y - p2.position.y;
163 return dx * dx + dy * dy;
174 bool worldToMap(
double wx,
double wy,
unsigned int & mx,
unsigned int & my);
183 void mapToWorld(
double mx,
double my,
double & wx,
double & wy);
199 std::unique_ptr<NavFn> planner_;
202 nav2::TransformBuffer::SharedPtr tf_;
205 rclcpp::Clock::SharedPtr clock_;
208 rclcpp::Logger logger_{rclcpp::get_logger(
"NavfnPlanner")};
214 std::string global_frame_, name_;
217 nav2::LifecycleNode::WeakPtr node_;
219 Parameters * params_;
220 std::unique_ptr<nav2_navfn_planner::ParameterHandler> param_handler_;
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".
double squared_distance(const geometry_msgs::msg::Pose &p1, const geometry_msgs::msg::Pose &p2)
Compute the squared distance between two points.
~NavfnPlanner()
destructor
double getPointPotential(const geometry_msgs::msg::Point &world_point)
Compute the potential, or navigation cost, at a given point in the world must call computePotential f...
bool computePotential(const geometry_msgs::msg::Point &world_point)
Compute the navigation function given a seed point in the world to start from.
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 activate() override
Activate lifecycle node.
void mapToWorld(double mx, double my, double &wx, double &wy)
Transform a point from map to world frame.
bool makePlan(const geometry_msgs::msg::Pose &start, const geometry_msgs::msg::Pose &goal, double tolerance, std::function< bool()> cancel_checker, nav_msgs::msg::Path &plan)
Compute a plan given start and goal poses, provided in global world frame.
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my)
Transform a point from world to map frame.
bool isPlannerOutOfDate()
Determine if a new planner object should be made.
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 clearRobotCell(unsigned int mx, unsigned int my)
Set the corresponding cell cost to be free space.
void smoothApproachToGoal(const geometry_msgs::msg::Pose &goal, nav_msgs::msg::Path &plan)
Remove artifacts at the end of the path - originated from planning on a discretized world.
void cleanup() override
Cleanup lifecycle node.
void deactivate() override
Deactivate lifecycle node.
NavfnPlanner()
constructor
bool getPlanFromPotential(const geometry_msgs::msg::Pose &goal, nav_msgs::msg::Path &plan)
Compute a plan to a goal from a potential - must call computePotential first.