15 #ifndef NAV2_SMAC_PLANNER__NODE_2D_HPP_
16 #define NAV2_SMAC_PLANNER__NODE_2D_HPP_
23 #include "nav2_smac_planner/types.hpp"
24 #include "nav2_smac_planner/constants.hpp"
25 #include "nav2_smac_planner/collision_checker.hpp"
26 #include "nav2_smac_planner/node_hybrid.hpp"
28 namespace nav2_smac_planner
39 typedef std::unique_ptr<std::vector<Node2D>> Graph;
40 typedef std::vector<NodePtr> NodeVector;
53 inline bool operator==(
const Coordinates & rhs)
const
55 return this->x == rhs.x && this->y == rhs.y;
58 inline bool operator!=(
const Coordinates & rhs)
const
60 return !(*
this == rhs);
65 typedef std::vector<Coordinates> CoordinateVector;
71 explicit Node2D(
const uint64_t index);
85 return this->_index == rhs._index;
107 return _accumulated_cost;
116 _accumulated_cost = cost_in;
204 const unsigned int & x,
const unsigned int & y,
const unsigned int & width)
206 return static_cast<uint64_t
>(x) +
static_cast<uint64_t
>(y) *
207 static_cast<uint64_t
>(width);
218 const uint64_t & index,
const unsigned int & width,
const unsigned int & angles)
221 throw std::runtime_error(
"Node type Node2D does not have a valid angle quantization.");
234 const unsigned int & size_x = _neighbors_grid_offsets[3];
235 return Coordinates(index % size_x, index / size_x);
245 const Coordinates & node_coords,
246 const CoordinateVector & goals_coords);
258 const MotionModel & motion_model,
259 unsigned int & size_x,
260 unsigned int & size_y,
261 unsigned int & num_angle_quantization,
272 std::function<
bool(
const uint64_t &,
275 const bool & traverse_unknown,
276 NodeVector & neighbors);
287 static float cost_travel_multiplier;
288 static std::vector<int> _neighbors_grid_offsets;
292 float _accumulated_cost;
296 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.
void setPose(const Coordinates &pose_in)
setting continuous coordinate search poses (in partial-cells)
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 float getHeuristicCost(const Coordinates &node_coords, const CoordinateVector &goals_coords)
Get cost of heuristic of node.
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.