Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
nav2_smac_planner::Node2D Class Reference

Node2D implementation for graph. More...

#include <nav2_smac_planner/include/nav2_smac_planner/node_2d.hpp>

Collaboration diagram for nav2_smac_planner::Node2D:
Collaboration graph
[legend]

Classes

class  Coordinates
 Node2D implementation of coordinate structure. More...
 

Public Types

typedef Node2DNodePtr
 
typedef std::unique_ptr< std::vector< Node2D > > Graph
 
typedef std::vector< NodePtrNodeVector
 
typedef std::vector< CoordinatesCoordinateVector
 

Public Member Functions

 Node2D (const uint64_t index)
 A constructor for nav2_smac_planner::Node2D. More...
 
 ~Node2D ()
 A destructor for nav2_smac_planner::Node2D.
 
bool operator== (const Node2D &rhs)
 operator== for comparisons More...
 
void setPose (const Coordinates &pose_in)
 setting continuous coordinate search poses (in partial-cells) More...
 
void reset ()
 Reset method for new search.
 
float getAccumulatedCost ()
 Gets the accumulated cost at this node. More...
 
void setAccumulatedCost (const float &cost_in)
 Sets the accumulated cost at this node. More...
 
float getCost ()
 Gets the costmap cost at this node. More...
 
void setCost (const float &cost)
 Gets the costmap cost at this node. More...
 
bool wasVisited ()
 Gets if cell has been visited in search. More...
 
void visited ()
 Sets if cell has been visited in search.
 
bool & isQueued ()
 Gets if cell is currently queued in search. More...
 
void queued ()
 Sets if cell is currently queued in search.
 
uint64_t getIndex ()
 Gets cell index. More...
 
bool isNodeValid (const bool &traverse_unknown, GridCollisionChecker *collision_checker)
 Check if this node is valid. More...
 
float getTraversalCost (const NodePtr &child)
 get traversal cost from this node to child node More...
 
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. More...
 
bool backtracePath (CoordinateVector &path)
 Set the starting pose for planning, as a node index. More...
 

Static Public Member Functions

static uint64_t getIndex (const unsigned int &x, const unsigned int &y, const unsigned int &width)
 Get index. More...
 
static Coordinates getCoords (const uint64_t &index, const unsigned int &width, const unsigned int &angles)
 Get index. More...
 
static Coordinates getCoords (const uint64_t &index)
 Get index. More...
 
static float getHeuristicCost (const Coordinates &node_coords, const CoordinateVector &goals_coords)
 Get cost of heuristic of node. More...
 
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) More...
 

Public Attributes

Node2Dparent
 
Coordinates pose
 

Static Public Attributes

static float cost_travel_multiplier = 2.0
 
static std::vector< int > _neighbors_grid_offsets
 

Detailed Description

Node2D implementation for graph.

Definition at line 35 of file node_2d.hpp.

Constructor & Destructor Documentation

◆ Node2D()

nav2_smac_planner::Node2D::Node2D ( const uint64_t  index)
explicit

A constructor for nav2_smac_planner::Node2D.

Parameters
indexThe index of this node for self-reference

Definition at line 28 of file node_2d.cpp.

Member Function Documentation

◆ backtracePath()

bool nav2_smac_planner::Node2D::backtracePath ( CoordinateVector &  path)

Set the starting pose for planning, as a node index.

Parameters
pathReference to a vector of indices of generated path
Returns
whether the path was able to be backtraced

Definition at line 155 of file node_2d.cpp.

References getCoords(), and getIndex().

Here is the call graph for this function:

◆ getAccumulatedCost()

float nav2_smac_planner::Node2D::getAccumulatedCost ( )
inline

Gets the accumulated cost at this node.

Returns
accumulated cost

Definition at line 105 of file node_2d.hpp.

◆ getCoords() [1/2]

static Coordinates nav2_smac_planner::Node2D::getCoords ( const uint64_t &  index)
inlinestatic

Get index.

Parameters
IndexIndex of point
Returns
coordinates of point

Definition at line 232 of file node_2d.hpp.

◆ getCoords() [2/2]

static Coordinates nav2_smac_planner::Node2D::getCoords ( const uint64_t &  index,
const unsigned int &  width,
const unsigned int &  angles 
)
inlinestatic

Get index.

Parameters
IndexIndex of point
widthwidth of costmap
anglesangle bins to use (must be 1 or throws exception)
Returns
coordinates of point

Definition at line 217 of file node_2d.hpp.

Referenced by backtracePath(), getNeighbors(), and getTraversalCost().

Here is the caller graph for this function:

◆ getCost()

float nav2_smac_planner::Node2D::getCost ( )
inline

Gets the costmap cost at this node.

Returns
costmap cost

Definition at line 123 of file node_2d.hpp.

Referenced by getTraversalCost().

Here is the caller graph for this function:

◆ getHeuristicCost()

float nav2_smac_planner::Node2D::getHeuristicCost ( const Coordinates node_coords,
const CoordinateVector &  goals_coords 
)
static

Get cost of heuristic of node.

Parameters
nodeNode index current
nodeNode index of new
Returns
Heuristic cost between the nodes

Definition at line 86 of file node_2d.cpp.

◆ getIndex() [1/2]

uint64_t nav2_smac_planner::Node2D::getIndex ( )
inline

Gets cell index.

Returns
Reference to cell index

Definition at line 176 of file node_2d.hpp.

Referenced by backtracePath(), nav2_simple_commander.costmap_2d.PyCostmap2D::getCostXY(), getNeighbors(), getTraversalCost(), isNodeValid(), and nav2_simple_commander.costmap_2d.PyCostmap2D::setCost().

Here is the caller graph for this function:

◆ getIndex() [2/2]

static uint64_t nav2_smac_planner::Node2D::getIndex ( const unsigned int &  x,
const unsigned int &  y,
const unsigned int &  width 
)
inlinestatic

Get index.

Parameters
xx coordinate of point to get index of
yy coordinate of point to get index of
widthwidth of costmap
Returns
index

Definition at line 203 of file node_2d.hpp.

Referenced by nav2_simple_commander.costmap_2d.PyCostmap2D::getCostXY(), and nav2_simple_commander.costmap_2d.PyCostmap2D::setCost().

Here is the caller graph for this function:

◆ getNeighbors()

void nav2_smac_planner::Node2D::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.

Parameters
validity_checkerFunctor for state validity checking
collision_checkerCollision checker to use
traverse_unknownIf unknown costs are valid to traverse
neighborsVector of neighbors to be filled

Definition at line 114 of file node_2d.cpp.

References getCoords(), getIndex(), isNodeValid(), and wasVisited().

Here is the call graph for this function:

◆ getTraversalCost()

float nav2_smac_planner::Node2D::getTraversalCost ( const NodePtr child)

get traversal cost from this node to child node

Parameters
childNode pointer to this node's child
Returns
traversal cost

Definition at line 68 of file node_2d.cpp.

References getCoords(), getCost(), and getIndex().

Here is the call graph for this function:

◆ initMotionModel()

void nav2_smac_planner::Node2D::initMotionModel ( const MotionModel &  motion_model,
unsigned int &  size_x,
unsigned int &  size_y,
unsigned int &  num_angle_quantization,
SearchInfo search_info 
)
static

Initialize the neighborhood to be used in A* We support 4-connect (VON_NEUMANN) and 8-connect (MOORE)

Parameters
neighborhoodThe desired neighborhood type
x_size_uintThe total x size to find neighbors
y_sizeThe total y size to find neighbors
num_angle_quantizationNumber of quantizations, must be 0
search_infoSearch parameters, unused by 2D node

Definition at line 97 of file node_2d.cpp.

◆ isNodeValid()

bool nav2_smac_planner::Node2D::isNodeValid ( const bool &  traverse_unknown,
GridCollisionChecker collision_checker 
)

Check if this node is valid.

Parameters
traverse_unknownIf we can explore unknown nodes on the graph
collision_checkerPointer to collision checker object
Returns
whether this node is valid and collision free

Definition at line 54 of file node_2d.cpp.

References nav2_smac_planner::GridCollisionChecker::getCost(), getIndex(), and nav2_smac_planner::GridCollisionChecker::inCollision().

Referenced by getNeighbors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isQueued()

bool& nav2_smac_planner::Node2D::isQueued ( )
inline

Gets if cell is currently queued in search.

Parameters
Ifcell was queued

Definition at line 159 of file node_2d.hpp.

◆ operator==()

bool nav2_smac_planner::Node2D::operator== ( const Node2D rhs)
inline

operator== for comparisons

Parameters
Node2Dright hand side node reference
Returns
If cell indices are equal

Definition at line 83 of file node_2d.hpp.

◆ setAccumulatedCost()

void nav2_smac_planner::Node2D::setAccumulatedCost ( const float &  cost_in)
inline

Sets the accumulated cost at this node.

Parameters
referenceto accumulated cost

Definition at line 114 of file node_2d.hpp.

◆ setCost()

void nav2_smac_planner::Node2D::setCost ( const float &  cost)
inline

Gets the costmap cost at this node.

Returns
costmap cost

Definition at line 132 of file node_2d.hpp.

◆ setPose()

void nav2_smac_planner::Node2D::setPose ( const Coordinates pose_in)
inline

setting continuous coordinate search poses (in partial-cells)

Parameters
Posepose

Definition at line 92 of file node_2d.hpp.

◆ wasVisited()

bool nav2_smac_planner::Node2D::wasVisited ( )
inline

Gets if cell has been visited in search.

Parameters
Ifcell was visited

Definition at line 141 of file node_2d.hpp.

Referenced by getNeighbors().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: