Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
nav2_smac_planner::NodeLattice Class Reference

NodeLattice implementation for graph, Hybrid-A*. More...

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

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

Public Types

typedef NodeLatticeNodePtr
 
typedef std::unique_ptr< std::vector< NodeLattice > > Graph
 
typedef std::vector< NodePtrNodeVector
 
typedef NodeHybrid::Coordinates Coordinates
 
typedef NodeHybrid::CoordinateVector CoordinateVector
 

Public Member Functions

 NodeLattice (const unsigned int index)
 A constructor for nav2_smac_planner::NodeLattice. More...
 
 ~NodeLattice ()
 A destructor for nav2_smac_planner::NodeLattice.
 
bool operator== (const NodeLattice &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.
 
void setMotionPrimitive (MotionPrimitive *prim)
 Sets the motion primitive used to achieve node in search. More...
 
MotionPrimitive *& getMotionPrimitive ()
 Gets the motion primitive used to achieve node in search. More...
 
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...
 
bool & wasVisited ()
 Gets if cell has been visited in search. More...
 
void visited ()
 Sets if cell has been visited in search.
 
unsigned int & getIndex ()
 Gets cell index. More...
 
void backwards (bool back=true)
 Sets that this primitive is moving in reverse.
 
bool isBackward ()
 Gets if this primitive is moving in reverse. More...
 
bool isNodeValid (const bool &traverse_unknown, GridCollisionChecker *collision_checker, MotionPrimitive *primitive=nullptr, bool is_backwards=false)
 Check if this node is valid. More...
 
float getTraversalCost (const NodePtr &child)
 Get traversal cost of parent node to child node. More...
 
void getNeighbors (std::function< bool(const unsigned int &, nav2_smac_planner::NodeLattice *&)> &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...
 
void addNodeToPath (NodePtr current_node, CoordinateVector &path)
 add node to the path More...
 

Static Public Member Functions

static unsigned int getIndex (const unsigned int &x, const unsigned int &y, const unsigned int &angle)
 Get index at coordinates. More...
 
static Coordinates getCoords (const unsigned int &index, const unsigned int &width, const unsigned int &angle_quantization)
 Get coordinates at index. More...
 
static float getHeuristicCost (const Coordinates &node_coords, const Coordinates &goal_coordinates, const nav2_costmap_2d::Costmap2D *costmap)
 Get cost of heuristic of node. More...
 
static void initMotionModel (const MotionModel &motion_model, unsigned int &size_x, unsigned int &size_y, unsigned int &angle_quantization, SearchInfo &search_info)
 Initialize motion models. More...
 
static void precomputeDistanceHeuristic (const float &lookup_table_dim, const MotionModel &motion_model, const unsigned int &dim_3_size, const SearchInfo &search_info)
 Compute the SE2 distance heuristic. More...
 
static void resetObstacleHeuristic (nav2_costmap_2d::Costmap2D *costmap, const unsigned int &start_x, const unsigned int &start_y, const unsigned int &goal_x, const unsigned int &goal_y)
 Compute the wavefront heuristic. More...
 
static float getObstacleHeuristic (const Coordinates &node_coords, const Coordinates &goal_coords, const double &cost_penalty)
 Compute the Obstacle heuristic. More...
 
static float getDistanceHeuristic (const Coordinates &node_coords, const Coordinates &goal_coords, const float &obstacle_heuristic)
 Compute the Distance heuristic. More...
 

Public Attributes

NodeLatticeparent
 
Coordinates pose
 

Static Public Attributes

static LatticeMotionTable motion_table
 
static LookupTable dist_heuristic_lookup_table
 
static float size_lookup = 25
 

Detailed Description

NodeLattice implementation for graph, Hybrid-A*.

Definition at line 117 of file node_lattice.hpp.

Constructor & Destructor Documentation

◆ NodeLattice()

nav2_smac_planner::NodeLattice::NodeLattice ( const unsigned int  index)
explicit

A constructor for nav2_smac_planner::NodeLattice.

Parameters
indexThe index of this node for self-reference

Definition at line 175 of file node_lattice.cpp.

Member Function Documentation

◆ addNodeToPath()

void nav2_smac_planner::NodeLattice::addNodeToPath ( NodeLattice::NodePtr  current_node,
NodeLattice::CoordinateVector &  path 
)

add node to the path

Parameters
current_node

Definition at line 556 of file node_lattice.cpp.

References getMotionPrimitive(), and isBackward().

Referenced by backtracePath().

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

◆ backtracePath()

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

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

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

Definition at line 537 of file node_lattice.cpp.

References addNodeToPath().

Here is the call graph for this function:

◆ getAccumulatedCost()

float& nav2_smac_planner::NodeLattice::getAccumulatedCost ( )
inline

Gets the accumulated cost at this node.

Returns
accumulated cost

Definition at line 183 of file node_lattice.hpp.

◆ getCoords()

static Coordinates nav2_smac_planner::NodeLattice::getCoords ( const unsigned int &  index,
const unsigned int &  width,
const unsigned int &  angle_quantization 
)
inlinestatic

Get coordinates at index.

Parameters
indexIndex of point
widthWidth of costmap
angle_quantizationTheta size of costmap
Returns
Coordinates

Definition at line 295 of file node_lattice.hpp.

◆ getCost()

float& nav2_smac_planner::NodeLattice::getCost ( )
inline

Gets the costmap cost at this node.

Returns
costmap cost

Definition at line 201 of file node_lattice.hpp.

Referenced by getTraversalCost().

Here is the caller graph for this function:

◆ getDistanceHeuristic()

float nav2_smac_planner::NodeLattice::getDistanceHeuristic ( const Coordinates node_coords,
const Coordinates goal_coords,
const float &  obstacle_heuristic 
)
static

Compute the Distance heuristic.

Parameters
node_coordsCoordinates to get heuristic at
goal_coordsCoordinates to compute heuristic to
obstacle_heuristicValue of the obstacle heuristic to compute additional motion heuristics if required
Returns
heuristic Heuristic value

Definition at line 348 of file node_lattice.cpp.

References nav2_smac_planner::LatticeMotionTable::getAngleFromBin().

Referenced by getHeuristicCost().

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

◆ getHeuristicCost()

float nav2_smac_planner::NodeLattice::getHeuristicCost ( const Coordinates node_coords,
const Coordinates goal_coordinates,
const nav2_costmap_2d::Costmap2D costmap 
)
static

Get cost of heuristic of node.

Parameters
nodeNode index current
nodeNode index of new
costmapCostmap ptr to use
Returns
Heuristic cost between the nodes

Definition at line 319 of file node_lattice.cpp.

References getDistanceHeuristic(), and getObstacleHeuristic().

Here is the call graph for this function:

◆ getIndex() [1/2]

unsigned int& nav2_smac_planner::NodeLattice::getIndex ( )
inline

Gets cell index.

Returns
Reference to cell index

Definition at line 227 of file node_lattice.hpp.

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

Here is the caller graph for this function:

◆ getIndex() [2/2]

static unsigned int nav2_smac_planner::NodeLattice::getIndex ( const unsigned int &  x,
const unsigned int &  y,
const unsigned int &  angle 
)
inlinestatic

Get index at coordinates.

Parameters
xX coordinate of point
yY coordinate of point
angleTheta coordinate of point
Returns
Index

Definition at line 279 of file node_lattice.hpp.

References nav2_smac_planner::NodeHybrid::getIndex().

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

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

◆ getMotionPrimitive()

MotionPrimitive* & nav2_smac_planner::NodeLattice::getMotionPrimitive ( )
inline

Gets the motion primitive used to achieve node in search.

Returns
pointer to motion primitive

Definition at line 174 of file node_lattice.hpp.

Referenced by addNodeToPath(), and getTraversalCost().

Here is the caller graph for this function:

◆ getNeighbors()

void nav2_smac_planner::NodeLattice::getNeighbors ( std::function< bool(const unsigned int &, nav2_smac_planner::NodeLattice *&)> &  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 461 of file node_lattice.cpp.

References backwards(), getIndex(), nav2_smac_planner::LatticeMotionTable::getMotionPrimitives(), isNodeValid(), setMotionPrimitive(), setPose(), and wasVisited().

Here is the call graph for this function:

◆ getObstacleHeuristic()

static float nav2_smac_planner::NodeLattice::getObstacleHeuristic ( const Coordinates node_coords,
const Coordinates goal_coords,
const double &  cost_penalty 
)
inlinestatic

Compute the Obstacle heuristic.

Parameters
node_coordsCoordinates to get heuristic at
goal_coordsCoordinates to compute heuristic to
Returns
heuristic Heuristic value

Definition at line 367 of file node_lattice.hpp.

References nav2_smac_planner::NodeHybrid::getObstacleHeuristic().

Referenced by getHeuristicCost().

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

◆ getTraversalCost()

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

Get traversal cost of parent node to child node.

Parameters
childNode pointer to child
Returns
traversal cost

Definition at line 269 of file node_lattice.cpp.

References getCost(), getMotionPrimitive(), and isBackward().

Here is the call graph for this function:

◆ initMotionModel()

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

Initialize motion models.

Parameters
motion_modelMotion model enum to use
size_xSize of X of graph
size_ySize of y of graph
angle_quantizationSize of theta bins of graph
search_infoSearch info to use

Definition at line 332 of file node_lattice.cpp.

◆ isBackward()

bool nav2_smac_planner::NodeLattice::isBackward ( )
inline

Gets if this primitive is moving in reverse.

Returns
backwards If moving in reverse

Definition at line 244 of file node_lattice.hpp.

Referenced by addNodeToPath(), and getTraversalCost().

Here is the caller graph for this function:

◆ isNodeValid()

bool nav2_smac_planner::NodeLattice::isNodeValid ( const bool &  traverse_unknown,
GridCollisionChecker collision_checker,
MotionPrimitive primitive = nullptr,
bool  is_backwards = false 
)

Check if this node is valid.

Parameters
traverse_unknownIf we can explore unknown nodes on the graph
collision_checkerCollision checker object to aid in validity checking
primitiveOptional argument if needing to check over a primitive not only a terminal pose
is_backwardsOptional argument if needed to check if prim expansion is in reverse
Returns
whether this node is valid and collision free

Definition at line 205 of file node_lattice.cpp.

References nav2_smac_planner::LatticeMotionTable::getAngleFromBin(), nav2_smac_planner::GridCollisionChecker::getCost(), nav2_smac_planner::GridCollisionChecker::getPrecomputedAngles(), 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:

◆ operator==()

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

operator== for comparisons

Parameters
NodeLatticeright hand side node reference
Returns
If cell indicies are equal

Definition at line 142 of file node_lattice.hpp.

◆ precomputeDistanceHeuristic()

void nav2_smac_planner::NodeLattice::precomputeDistanceHeuristic ( const float &  lookup_table_dim,
const MotionModel &  motion_model,
const unsigned int &  dim_3_size,
const SearchInfo search_info 
)
static

Compute the SE2 distance heuristic.

Parameters
lookup_table_dimSize, in costmap pixels, of the each lookup table dimension to populate
motion_modelMotion model to use for state space
dim_3_sizeNumber of quantization bins for caching
search_infoInfo containing minimum radius to use

Definition at line 415 of file node_lattice.cpp.

References nav2_smac_planner::LatticeMotionTable::getAngleFromBin(), and nav2_smac_planner::LatticeMotionTable::getLatticeMetadata().

Here is the call graph for this function:

◆ resetObstacleHeuristic()

static void nav2_smac_planner::NodeLattice::resetObstacleHeuristic ( nav2_costmap_2d::Costmap2D costmap,
const unsigned int &  start_x,
const unsigned int &  start_y,
const unsigned int &  goal_x,
const unsigned int &  goal_y 
)
inlinestatic

Compute the wavefront heuristic.

Parameters
costmapCostmap to use
goal_coordsCoordinates to start heuristic expansion at

Definition at line 352 of file node_lattice.hpp.

References nav2_smac_planner::NodeHybrid::resetObstacleHeuristic().

Here is the call graph for this function:

◆ setAccumulatedCost()

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

Sets the accumulated cost at this node.

Parameters
referenceto accumulated cost

Definition at line 192 of file node_lattice.hpp.

◆ setMotionPrimitive()

void nav2_smac_planner::NodeLattice::setMotionPrimitive ( MotionPrimitive prim)
inline

Sets the motion primitive used to achieve node in search.

Parameters
pointerto motion primitive

Definition at line 165 of file node_lattice.hpp.

Referenced by getNeighbors().

Here is the caller graph for this function:

◆ setPose()

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

setting continuous coordinate search poses (in partial-cells)

Parameters
Posepose

Definition at line 151 of file node_lattice.hpp.

Referenced by getNeighbors().

Here is the caller graph for this function:

◆ wasVisited()

bool& nav2_smac_planner::NodeLattice::wasVisited ( )
inline

Gets if cell has been visited in search.

Parameters
Ifcell was visited

Definition at line 210 of file node_lattice.hpp.

Referenced by getNeighbors().

Here is the caller graph for this function:

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