16 #ifndef NAV2_SMAC_PLANNER__A_STAR_HPP_
17 #define NAV2_SMAC_PLANNER__A_STAR_HPP_
21 #include <unordered_map>
27 #include "nav2_costmap_2d/costmap_2d.hpp"
29 #include "nav2_smac_planner/thirdparty/robin_hood.h"
30 #include "nav2_smac_planner/analytic_expansion.hpp"
31 #include "nav2_smac_planner/node_2d.hpp"
32 #include "nav2_smac_planner/node_hybrid.hpp"
33 #include "nav2_smac_planner/node_lattice.hpp"
34 #include "nav2_smac_planner/node_basic.hpp"
35 #include "nav2_smac_planner/types.hpp"
36 #include "nav2_smac_planner/constants.hpp"
38 namespace nav2_smac_planner
45 template<
typename NodeT>
49 typedef NodeT * NodePtr;
51 typedef std::vector<NodePtr> NodeVector;
52 typedef std::pair<float, NodeBasic<NodeT>> NodeElement;
53 typedef typename NodeT::Coordinates Coordinates;
54 typedef typename NodeT::CoordinateVector CoordinateVector;
55 typedef typename NodeVector::iterator NeighborIterator;
56 typedef std::function<bool (
const unsigned int &, NodeT * &)> NodeGetter;
64 bool operator()(
const NodeElement & a,
const NodeElement & b)
const
66 return a.first > b.first;
70 typedef std::priority_queue<NodeElement, std::vector<NodeElement>,
NodeComparator> NodeQueue;
93 const bool & allow_unknown,
95 const int & max_on_approach_iterations,
96 const double & max_planning_time,
97 const float & lookup_table_size,
98 const unsigned int & dim_3_size);
107 bool createPath(CoordinateVector & path,
int & num_iterations,
const float & tolerance);
122 const unsigned int & mx,
123 const unsigned int & my,
124 const unsigned int & dim_3);
133 const unsigned int & mx,
134 const unsigned int & my,
135 const unsigned int & dim_3);
197 inline void addNode(
const float & cost, NodePtr & node);
203 inline NodePtr
addToGraph(
const unsigned int & index);
210 inline bool isGoal(NodePtr & node);
235 int _timing_interval = 5000;
237 bool _traverse_unknown;
238 bool _is_initialized;
240 int _max_on_approach_iterations;
241 double _max_planning_time;
243 unsigned int _x_size;
244 unsigned int _y_size;
245 unsigned int _dim3_size;
248 Coordinates _goal_coordinates;
255 MotionModel _motion_model;
256 NodeHeuristicPair _best_heuristic_node;
260 std::unique_ptr<AnalyticExpansion<NodeT>> _expander;
A 2D costmap provides a mapping between points in the world and their associated "costs".
An A* implementation for planning in a costmap. Templated based on the Node type.
~AStarAlgorithm()
A destructor for nav2_smac_planner::AStarAlgorithm.
unsigned int & getSizeDim3()
Get number of angle quantization bins (SE2) or Z coordinate (XYZ)
NodePtr addToGraph(const unsigned int &index)
Adds node to graph.
void initialize(const bool &allow_unknown, int &max_iterations, const int &max_on_approach_iterations, const double &max_planning_time, const float &lookup_table_size, const unsigned int &dim_3_size)
Initialization of the planner with defaults.
void setGoal(const unsigned int &mx, const unsigned int &my, const unsigned int &dim_3)
Set the goal for planning, as a node index.
int & getOnApproachMaxIterations()
Get maximum number of on-approach iterations after within threshold.
void setCollisionChecker(GridCollisionChecker *collision_checker)
Sets the collision checker to use.
NodePtr getNextNode()
Get pointer to next goal in open set.
bool areInputsValid()
Check if inputs to planner are valid.
void clearQueue()
Clear hueristic queue of nodes to search.
AStarAlgorithm(const MotionModel &motion_model, const SearchInfo &search_info)
A constructor for nav2_smac_planner::AStarAlgorithm.
int & getMaxIterations()
Get maximum number of iterations to plan.
void clearGraph()
Clear graph of nodes searched.
unsigned int & getSizeY()
Get size of graph in Y.
void setStart(const unsigned int &mx, const unsigned int &my, const unsigned int &dim_3)
Set the starting pose for planning, as a node index.
void addNode(const float &cost, NodePtr &node)
Add a node to the open set.
unsigned int & getSizeX()
Get size of graph in X.
NodePtr & getGoal()
Get pointer reference to goal node.
bool isGoal(NodePtr &node)
Check if this node is the goal node.
float getHeuristicCost(const NodePtr &node)
Get cost of heuristic of node.
float & getToleranceHeuristic()
Get tolerance, in node nodes.
NodePtr & getStart()
Get pointer reference to starting node.
bool createPath(CoordinateVector &path, int &num_iterations, const float &tolerance)
Creating path from given costmap, start, and goal.
A costmap grid collision checker.
Search properties and penalties.