Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_smac_planner::CostmapDownsampler Class Reference

A costmap downsampler for more efficient path planning. More...

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

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

Public Member Functions

 CostmapDownsampler ()
 A constructor for CostmapDownsampler.
 
 ~CostmapDownsampler ()
 A destructor for CostmapDownsampler.
 
void on_configure (const nav2::LifecycleNode::WeakPtr &node, const std::string &global_frame, const std::string &topic_name, nav2_costmap_2d::Costmap2D *const costmap, const unsigned int &downsampling_factor, const bool &use_min_cost_neighbor=false)
 Configure the downsampled costmap object and the ROS publisher. More...
 
void on_activate ()
 Activate the publisher of the downsampled costmap.
 
void on_deactivate ()
 Deactivate the publisher of the downsampled costmap.
 
void on_cleanup ()
 Cleanup the publisher of the downsampled costmap.
 
nav2_costmap_2d::Costmap2Ddownsample (const unsigned int &downsampling_factor)
 Downsample the given costmap by the downsampling factor, and publish the downsampled costmap. More...
 
void resizeCostmap ()
 Resize the downsampled costmap. Used in case the costmap changes and we need to update the downsampled version.
 

Protected Member Functions

void updateCostmapSize ()
 Update the sizes X-Y of the costmap and its downsampled version.
 
void setCostOfCell (const unsigned int &new_mx, const unsigned int &new_my)
 Explore all subcells of the original costmap and assign the max cost to the new (downsampled) cell. More...
 

Protected Attributes

unsigned int _size_x
 
unsigned int _size_y
 
unsigned int _downsampled_size_x
 
unsigned int _downsampled_size_y
 
unsigned int _downsampling_factor
 
bool _use_min_cost_neighbor
 
float _downsampled_resolution
 
nav2_costmap_2d::Costmap2D_costmap
 
std::unique_ptr< nav2_costmap_2d::Costmap2D_downsampled_costmap
 
std::unique_ptr< nav2_costmap_2d::Costmap2DPublisher_downsampled_costmap_pub
 

Detailed Description

A costmap downsampler for more efficient path planning.

Definition at line 31 of file costmap_downsampler.hpp.

Member Function Documentation

◆ downsample()

nav2_costmap_2d::Costmap2D * nav2_smac_planner::CostmapDownsampler::downsample ( const unsigned int &  downsampling_factor)

Downsample the given costmap by the downsampling factor, and publish the downsampled costmap.

Parameters
downsampling_factorMultiplier for the costmap resolution
Returns
A ptr to the downsampled costmap

Definition at line 80 of file costmap_downsampler.cpp.

References resizeCostmap(), setCostOfCell(), and updateCostmapSize().

Here is the call graph for this function:

◆ on_configure()

void nav2_smac_planner::CostmapDownsampler::on_configure ( const nav2::LifecycleNode::WeakPtr &  node,
const std::string &  global_frame,
const std::string &  topic_name,
nav2_costmap_2d::Costmap2D *const  costmap,
const unsigned int &  downsampling_factor,
const bool &  use_min_cost_neighbor = false 
)

Configure the downsampled costmap object and the ROS publisher.

Parameters
nodeLifecycle node pointer
global_frameThe ID of the global frame used by the costmap
topic_nameThe name of the topic to publish the downsampled costmap
costmapThe costmap we want to downsample
downsampling_factorMultiplier for the costmap resolution
use_min_cost_neighborIf true, min function is used instead of max for downsampling

Definition at line 36 of file costmap_downsampler.cpp.

References nav2_costmap_2d::Costmap2D::getOriginX(), nav2_costmap_2d::Costmap2D::getOriginY(), and updateCostmapSize().

Here is the call graph for this function:

◆ setCostOfCell()

void nav2_smac_planner::CostmapDownsampler::setCostOfCell ( const unsigned int &  new_mx,
const unsigned int &  new_my 
)
protected

Explore all subcells of the original costmap and assign the max cost to the new (downsampled) cell.

Parameters
new_mxThe X-coordinate of the cell in the new costmap
new_myThe Y-coordinate of the cell in the new costmap

Definition at line 126 of file costmap_downsampler.cpp.

References nav2_costmap_2d::Costmap2D::getCost().

Referenced by downsample().

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

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