15 #ifndef NAV2_SMAC_PLANNER__NODE_2D_HPP_
16 #define NAV2_SMAC_PLANNER__NODE_2D_HPP_
27 #include "nav2_smac_planner/types.hpp"
28 #include "nav2_smac_planner/constants.hpp"
29 #include "nav2_smac_planner/collision_checker.hpp"
30 #include "nav2_smac_planner/node_hybrid.hpp"
32 namespace nav2_smac_planner
43 typedef std::unique_ptr<std::vector<Node2D>> Graph;
44 typedef std::vector<NodePtr> NodeVector;
59 typedef std::vector<Coordinates> CoordinateVector;
65 explicit Node2D(
const uint64_t index);
79 return this->_index == rhs._index;
92 return _accumulated_cost;
101 _accumulated_cost = cost_in;
189 const unsigned int & x,
const unsigned int & y,
const unsigned int & width)
191 return static_cast<uint64_t
>(x) +
static_cast<uint64_t
>(y) *
192 static_cast<uint64_t
>(width);
203 const uint64_t & index,
const unsigned int & width,
const unsigned int & angles)
206 throw std::runtime_error(
"Node type Node2D does not have a valid angle quantization.");
219 const unsigned int & size_x = _neighbors_grid_offsets[3];
220 return Coordinates(index % size_x, index / size_x);
230 const Coordinates & node_coords,
231 const Coordinates & goal_coordinates);
243 const MotionModel & motion_model,
244 unsigned int & size_x,
245 unsigned int & size_y,
246 unsigned int & num_angle_quantization,
257 std::function<
bool(
const uint64_t &,
260 const bool & traverse_unknown,
261 NodeVector & neighbors);
271 static float cost_travel_multiplier;
272 static std::vector<int> _neighbors_grid_offsets;
276 float _accumulated_cost;
280 bool _in_collision{
false};
A costmap grid collision checker.
Node2D implementation for graph.
bool wasVisited()
Gets if cell has been visited in search.
bool & isQueued()
Gets if cell is currently queued in search.
Node2D(const uint64_t index)
A constructor for nav2_smac_planner::Node2D.
bool isNodeValid(const bool &traverse_unknown, GridCollisionChecker *collision_checker)
Check if this node is valid.
bool backtracePath(CoordinateVector &path)
Set the starting pose for planning, as a node index.
float getTraversalCost(const NodePtr &child)
get traversal cost from this node to child node
void setAccumulatedCost(const float &cost_in)
Sets the accumulated cost at this node.
void queued()
Sets if cell is currently queued in search.
static Coordinates getCoords(const uint64_t &index, const unsigned int &width, const unsigned int &angles)
Get index.
static Coordinates getCoords(const uint64_t &index)
Get index.
float getAccumulatedCost()
Gets the accumulated cost at this node.
static float getHeuristicCost(const Coordinates &node_coords, const Coordinates &goal_coordinates)
Get cost of heuristic of node.
uint64_t getIndex()
Gets cell index.
void getNeighbors(std::function< bool(const uint64_t &, nav2_smac_planner::Node2D *&)> &validity_checker, GridCollisionChecker *collision_checker, const bool &traverse_unknown, NodeVector &neighbors)
Retrieve all valid neighbors of a node.
~Node2D()
A destructor for nav2_smac_planner::Node2D.
void visited()
Sets if cell has been visited in search.
static uint64_t getIndex(const unsigned int &x, const unsigned int &y, const unsigned int &width)
Get index.
void setCost(const float &cost)
Gets the costmap cost at this node.
void reset()
Reset method for new search.
float getCost()
Gets the costmap cost at this node.
static void initMotionModel(const MotionModel &motion_model, unsigned int &size_x, unsigned int &size_y, unsigned int &num_angle_quantization, SearchInfo &search_info)
Initialize the neighborhood to be used in A* We support 4-connect (VON_NEUMANN) and 8-connect (MOORE)
bool operator==(const Node2D &rhs)
operator== for comparisons
Node2D implementation of coordinate structure.
Search properties and penalties.