16 #ifndef NAV2_COSTMAP_2D__INFLATION_LAYER_HPP_
17 #define NAV2_COSTMAP_2D__INFLATION_LAYER_HPP_
30 #include "rclcpp/rclcpp.hpp"
31 #include "nav2_costmap_2d/inflation_layer_interface.hpp"
32 #include "nav2_costmap_2d/layered_costmap.hpp"
33 #include "nav2_costmap_2d/distance_transform.hpp"
82 double robot_x,
double robot_y,
double robot_yaw,
double * min_x,
85 double * max_y)
override;
96 int min_i,
int min_j,
int max_i,
int max_j)
override;
115 need_reinflation_ =
true;
123 unsigned char cost = 0;
125 cost = LETHAL_OBSTACLE;
126 }
else if (distance * resolution_ <= inscribed_radius_) {
127 cost = INSCRIBED_INFLATED_OBSTACLE;
131 exp(-1.0 * cost_scaling_factor_ * (distance * resolution_ - inscribed_radius_));
132 cost =
static_cast<unsigned char>((INSCRIBED_INFLATED_OBSTACLE - 1) * factor);
147 return cost_scaling_factor_;
152 return inflation_radius_;
169 unsigned char * master_array,
171 int min_i,
int min_j,
int max_i,
int max_j,
172 int roi_min_i,
int roi_min_j,
173 unsigned int size_x);
208 const std::vector<rclcpp::Parameter> & parameters);
224 double inflation_radius_, inscribed_radius_, custom_inscribed_radius_, cost_scaling_factor_;
225 bool inflate_unknown_, inflate_around_unknown_;
226 unsigned int cell_inflation_radius_;
231 static constexpr
int COST_LUT_PRECISION = 100;
232 std::vector<unsigned char> cost_lut_;
233 double last_min_x_, last_min_y_, last_max_x_, last_max_y_;
236 bool need_reinflation_;
239 rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
240 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
A 2D costmap provides a mapping between points in the world and their associated "costs".
unsigned int cellDistance(double world_dist)
Given distance in the world... convert it to cells.
Abstract interface for inflation layers, providing common methods needed by navigation components reg...
Layer to convolve costmap by robot's radius or footprint using Eigen-based Felzenszwalb-Huttenlocher ...
double getCostScalingFactor() override
Get the cost scaling factor.
~InflationLayer()
A destructor.
void computeCaches()
Generate cost lookup table for distance to cost mapping.
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.
int getOptimalThreadCount()
Determine optimal thread count based on system resources.
unsigned int cellDistance(double world_dist)
Convert world distance to cell distance.
InflationLayer()
A constructor.
void deactivate() override
Deactivate the layer.
void onInitialize() override
Initialization process of layer on startup.
void reset() override
Reset this costmap.
double getInflationRadius() override
Get the inflation radius.
void matchSize() override
Match the size of the master costmap.
void onFootprintChanged() override
Process updates on footprint changes to the inflation layer.
bool isClearable() override
If clearing operations should be processed on this layer or not.
unsigned char computeCost(double distance) const override
Given a distance, compute a cost.
void updateParametersCallback(const std::vector< rclcpp::Parameter > ¶meters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
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.
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > ¶meters)
Validate incoming parameter updates before applying them. This callback is triggered when one or more...
void activate() override
Activate the layer.
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.
void updateInscribedRadius()
Update inscribed_radius_ from custom_inscribed_radius_ or the footprint, logging a warning when the c...
mutex_t * getMutex() override
Get the mutex of the inflation information.
void setCurrent(bool current)
Set whether the data in the layer is up to date.
Costmap2D * getCostmap()
Get the costmap pointer to the master costmap.
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixXfRM
Row-major float matrix type for efficient row-wise access.