38 #ifndef NAV2_COSTMAP_2D__LAYERED_COSTMAP_HPP_
39 #define NAV2_COSTMAP_2D__LAYERED_COSTMAP_HPP_
45 #include "nav2_costmap_2d/cost_values.hpp"
46 #include "nav2_costmap_2d/layer.hpp"
47 #include "nav2_costmap_2d/costmap_2d.hpp"
63 LayeredCostmap(std::string global_frame,
bool rolling_window,
bool track_unknown);
74 void updateMap(
double robot_x,
double robot_y,
double robot_yaw);
76 std::string getGlobalFrameID()
const
85 unsigned int size_x,
unsigned int size_y,
double resolution,
double origin_x,
87 bool size_locked =
false);
111 return &combined_costmap_;
119 return rolling_window_;
127 return combined_costmap_.
getDefaultValue() == nav2_costmap_2d::NO_INFORMATION;
149 void addPlugin(std::shared_ptr<Layer> plugin);
155 void addFilter(std::shared_ptr<Layer> filter);
169 void getBounds(
unsigned int * x0,
unsigned int * xn,
unsigned int * y0,
unsigned int * yn)
188 void setFootprint(
const std::vector<geometry_msgs::msg::Point> & footprint_spec);
191 const std::vector<geometry_msgs::msg::Point> &
getFootprint() {
return footprint_;}
217 Costmap2D primary_costmap_, combined_costmap_;
218 std::string global_frame_;
220 bool rolling_window_;
223 double minx_, miny_, maxx_, maxy_;
224 unsigned int bx0_, bxn_, by0_, byn_;
226 std::vector<std::shared_ptr<Layer>> plugins_;
227 std::vector<std::shared_ptr<Layer>> filters_;
231 double circumscribed_radius_, inscribed_radius_;
232 std::vector<geometry_msgs::msg::Point> footprint_;
A 2D costmap provides a mapping between points in the world and their associated "costs".
unsigned char getDefaultValue()
Get the default background value of the costmap.
Instantiates different layer plugins and aggregates them into one score.
std::vector< std::shared_ptr< Layer > > * getPlugins()
Get the vector of pointers to the costmap plugins.
std::vector< std::shared_ptr< Layer > > * getFilters()
Get the vector of pointers to the costmap filters.
bool isRolling()
If this costmap is rolling or not.
void addPlugin(std::shared_ptr< Layer > plugin)
Add a new plugin to the plugins vector to process.
Costmap2D * getCostmap()
Get the costmap pointer to the master costmap.
~LayeredCostmap()
Destructor.
void addFilter(std::shared_ptr< Layer > filter)
Add a new costmap filter plugin to the filters vector to process.
void resizeMap(unsigned int size_x, unsigned int size_y, double resolution, double origin_x, double origin_y, bool size_locked=false)
Resize the map to a new size, resolution, or origin.
void getBounds(unsigned int *x0, unsigned int *xn, unsigned int *y0, unsigned int *yn)
Get the bounds of the costmap.
double getCircumscribedRadius()
The radius of a circle centered at the origin of the robot which just surrounds all points on the rob...
bool isInitialized()
if the costmap is initialized
bool isOutofBounds(double robot_x, double robot_y)
Checks if the robot is outside the bounds of its costmap in the case of poorly configured setups.
void updateMap(double robot_x, double robot_y, double robot_yaw)
Update the underlying costmap with new data. If you want to update the map outside of the update loop...
LayeredCostmap(std::string global_frame, bool rolling_window, bool track_unknown)
Constructor for a costmap.
void getUpdatedBounds(double &minx, double &miny, double &maxx, double &maxy)
Get the size of the bounds for update.
bool isSizeLocked()
Get if the size of the costmap is locked.
bool isTrackingUnknown()
If this costmap is tracking unknown space or not.
void setFootprint(const std::vector< geometry_msgs::msg::Point > &footprint_spec)
Updates the stored footprint, updates the circumscribed and inscribed radii, and calls onFootprintCha...
double getInscribedRadius()
The radius of a circle centered at the origin of the robot which is just within all points and edges ...
bool isCurrent()
If the costmap is current, e.g. are all the layers processing recent data and not stale information f...
const std::vector< geometry_msgs::msg::Point > & getFootprint()
Returns the latest footprint stored with setFootprint().