Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
nav2_costmap_2d::InflationLayer Class Reference

Layer to convolve costmap by robot's radius or footprint using Eigen-based Felzenszwalb-Huttenlocher O(n) distance transform for improved performance. More...

#include <nav2_costmap_2d/include/nav2_costmap_2d/inflation_layer.hpp>

Inheritance diagram for nav2_costmap_2d::InflationLayer:
Inheritance graph
[legend]
Collaboration diagram for nav2_costmap_2d::InflationLayer:
Collaboration graph
[legend]

Public Member Functions

 InflationLayer ()
 A constructor.
 
 ~InflationLayer ()
 A destructor.
 
void onInitialize () override
 Initialization process of layer on startup.
 
void deactivate () override
 Deactivate the layer.
 
void activate () override
 Activate the layer.
 
void updateBounds (double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y) override
 Update the bounds of the master costmap by this layer's update dimensions. More...
 
void updateCosts (nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j) override
 Update the costs in the master costmap in the window. More...
 
void matchSize () override
 Match the size of the master costmap.
 
bool isClearable () override
 If clearing operations should be processed on this layer or not.
 
void reset () override
 Reset this costmap.
 
unsigned char computeCost (double distance) const override
 Given a distance, compute a cost. More...
 
mutex_t * getMutex () override
 Get the mutex of the inflation information.
 
double getCostScalingFactor () override
 Get the cost scaling factor. More...
 
double getInflationRadius () override
 Get the inflation radius. More...
 
- Public Member Functions inherited from nav2_costmap_2d::Layer
 Layer ()
 A constructor.
 
virtual ~Layer ()
 A destructor.
 
void initialize (LayeredCostmap *parent, std::string name, nav2::TransformBuffer *tf, const nav2::LifecycleNode::WeakPtr &node, rclcpp::CallbackGroup::SharedPtr callback_group)
 Initialization process of layer on startup.
 
std::string getName () const
 Get the name of the costmap layer.
 
bool isCurrent () const
 Check to make sure all the data in the layer is up to date. If the layer is not up to date, then it may be unsafe to plan using the data from this layer, and the planner may need to know. More...
 
void setCurrent (bool current)
 Set whether the data in the layer is up to date. More...
 
bool isEnabled () const
 Gets whether the layer is enabled.
 
const std::vector< geometry_msgs::msg::Point > & getFootprint () const
 Convenience function for layered_costmap_->getFootprint().
 
std::string getFullName (const std::string &param_name)
 Convenience functions for declaring ROS parameters.
 
std::string joinWithParentNamespace (const std::string &topic)
 

Protected Member Functions

void applyInflation (unsigned char *master_array, const MatrixXfRM &distance_map, int min_i, int min_j, int max_i, int max_j, int roi_min_i, int roi_min_j, unsigned int size_x)
 Apply inflation costs from distance map to costmap. More...
 
void onFootprintChanged () override
 Process updates on footprint changes to the inflation layer.
 
unsigned int cellDistance (double world_dist)
 Convert world distance to cell distance.
 
void computeCaches ()
 Generate cost lookup table for distance to cost mapping.
 
int getOptimalThreadCount ()
 Determine optimal thread count based on system resources. More...
 
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback (const std::vector< rclcpp::Parameter > &parameters)
 Validate incoming parameter updates before applying them. This callback is triggered when one or more parameters are about to be updated. It checks the validity of parameter values and rejects updates that would lead to invalid or inconsistent configurations. More...
 
void updateParametersCallback (const std::vector< rclcpp::Parameter > &parameters)
 Apply parameter updates after validation This callback is executed when parameters have been successfully updated. It updates the internal configuration of the node with the new parameter values. More...
 
void updateInscribedRadius ()
 Update inscribed_radius_ from custom_inscribed_radius_ or the footprint, logging a warning when the custom value is in use.
 

Protected Attributes

double inflation_radius_
 
double inscribed_radius_
 
double custom_inscribed_radius_
 
double cost_scaling_factor_
 
bool inflate_unknown_
 
bool inflate_around_unknown_
 
unsigned int cell_inflation_radius_
 
int num_threads_
 
double resolution_
 
std::vector< unsigned char > cost_lut_
 
double last_min_x_
 
double last_min_y_
 
double last_max_x_
 
double last_max_y_
 
bool need_reinflation_
 
mutex_t * access_
 
rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_
 
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_
 
- Protected Attributes inherited from nav2_costmap_2d::Layer
LayeredCostmaplayered_costmap_
 
std::string name_
 
nav2::TransformBuffer * tf_
 
rclcpp::CallbackGroup::SharedPtr callback_group_
 
nav2::LifecycleNode::WeakPtr node_
 
rclcpp::Clock::SharedPtr clock_
 
rclcpp::Logger logger_ {rclcpp::get_logger("nav2_costmap_2d")}
 
std::atomic_bool current_
 
bool enabled_
 

Static Protected Attributes

static constexpr int COST_LUT_PRECISION = 100
 

Additional Inherited Members

- Public Types inherited from nav2_costmap_2d::InflationLayerInterface
typedef std::recursive_mutex mutex_t
 
- Static Public Member Functions inherited from nav2_costmap_2d::InflationLayerInterface
static std::shared_ptr< InflationLayerInterfacegetInflationLayer (std::shared_ptr< nav2_costmap_2d::Costmap2DROS > &costmap_ros, const std::string layer_name="")
 Get the inflation layer from a costmap, checking for both InflationLayer and LegacyInflationLayer implementations. More...
 

Detailed Description

Layer to convolve costmap by robot's radius or footprint using Eigen-based Felzenszwalb-Huttenlocher O(n) distance transform for improved performance.

Definition at line 43 of file inflation_layer.hpp.

Member Function Documentation

◆ applyInflation()

void nav2_costmap_2d::InflationLayer::applyInflation ( unsigned char *  master_array,
const MatrixXfRM distance_map,
int  min_i,
int  min_j,
int  max_i,
int  max_j,
int  roi_min_i,
int  roi_min_j,
unsigned int  size_x 
)
protected

Apply inflation costs from distance map to costmap.

Parameters
master_arrayPointer to the costmap data
distance_mapDistance transform result
min_iMinimum x index of update region
min_jMinimum y index of update region
max_iMaximum x index of update region
max_jMaximum y index of update region
roi_min_iROI minimum x offset
roi_min_jROI minimum y offset
size_xWidth of the costmap

Definition at line 237 of file inflation_layer.cpp.

References getOptimalThreadCount().

Referenced by updateCosts().

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

◆ computeCost()

unsigned char nav2_costmap_2d::InflationLayer::computeCost ( double  distance) const
inlineoverridevirtual

Given a distance, compute a cost.

Parameters
distanceThe distance from an obstacle in cells.
Returns
A cost value for the distance

Implements nav2_costmap_2d::InflationLayerInterface.

Definition at line 121 of file inflation_layer.hpp.

Referenced by computeCaches().

Here is the caller graph for this function:

◆ getCostScalingFactor()

double nav2_costmap_2d::InflationLayer::getCostScalingFactor ( )
inlineoverridevirtual

Get the cost scaling factor.

Returns
The cost scaling factor

Implements nav2_costmap_2d::InflationLayerInterface.

Definition at line 145 of file inflation_layer.hpp.

Referenced by updateParametersCallback().

Here is the caller graph for this function:

◆ getInflationRadius()

double nav2_costmap_2d::InflationLayer::getInflationRadius ( )
inlineoverridevirtual

Get the inflation radius.

Returns
The inflation radius in meters

Implements nav2_costmap_2d::InflationLayerInterface.

Definition at line 150 of file inflation_layer.hpp.

◆ getOptimalThreadCount()

int nav2_costmap_2d::InflationLayer::getOptimalThreadCount ( )
protected

Determine optimal thread count based on system resources.

Returns
Optimal number of OpenMP threads to use

Definition at line 182 of file inflation_layer.cpp.

Referenced by applyInflation(), and updateCosts().

Here is the caller graph for this function:

◆ updateBounds()

void nav2_costmap_2d::InflationLayer::updateBounds ( double  robot_x,
double  robot_y,
double  robot_yaw,
double *  min_x,
double *  min_y,
double *  max_x,
double *  max_y 
)
overridevirtual

Update the bounds of the master costmap by this layer's update dimensions.

Parameters
robot_xX pose of robot
robot_yY pose of robot
robot_yawRobot orientation
min_xX min map coord of the window to update
min_yY min map coord of the window to update
max_xX max map coord of the window to update
max_yY max map coord of the window to update

Implements nav2_costmap_2d::Layer.

Definition at line 149 of file inflation_layer.cpp.

References getMutex().

Here is the call graph for this function:

◆ updateCosts()

void nav2_costmap_2d::InflationLayer::updateCosts ( nav2_costmap_2d::Costmap2D master_grid,
int  min_i,
int  min_j,
int  max_i,
int  max_j 
)
overridevirtual

Update the costs in the master costmap in the window.

Parameters
master_gridThe master costmap grid to update
min_xX min map coord of the window to update
min_yY min map coord of the window to update
max_xX max map coord of the window to update
max_yY max map coord of the window to update

Implements nav2_costmap_2d::Layer.

Definition at line 283 of file inflation_layer.cpp.

References applyInflation(), nav2_costmap_2d::DistanceTransform::distanceTransform2D(), nav2_costmap_2d::DistanceTransform::DT_INF, nav2_costmap_2d::Costmap2D::getCharMap(), getMutex(), getOptimalThreadCount(), nav2_costmap_2d::Costmap2D::getSizeInCellsX(), nav2_costmap_2d::Costmap2D::getSizeInCellsY(), and nav2_costmap_2d::Layer::setCurrent().

Here is the call graph for this function:

◆ updateParametersCallback()

void nav2_costmap_2d::InflationLayer::updateParametersCallback ( const std::vector< rclcpp::Parameter > &  parameters)
protected

Apply parameter updates after validation This callback is executed when parameters have been successfully updated. It updates the internal configuration of the node with the new parameter values.

Parameters
parametersList of parameters that have been updated.

Definition at line 396 of file inflation_layer.cpp.

References getCostScalingFactor(), getMutex(), matchSize(), nav2_costmap_2d::Layer::setCurrent(), and updateInscribedRadius().

Referenced by activate().

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

◆ validateParameterUpdatesCallback()

rcl_interfaces::msg::SetParametersResult nav2_costmap_2d::InflationLayer::validateParameterUpdatesCallback ( const std::vector< rclcpp::Parameter > &  parameters)
protected

Validate incoming parameter updates before applying them. This callback is triggered when one or more parameters are about to be updated. It checks the validity of parameter values and rejects updates that would lead to invalid or inconsistent configurations.

Parameters
parametersList of parameters that are being updated.
Returns
rcl_interfaces::msg::SetParametersResult Result indicating whether the update is accepted.

Definition at line 369 of file inflation_layer.cpp.

Referenced by activate().

Here is the caller graph for this function:

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