Function navmap_ros::to_occupancy_grid
Defined in File conversions.hpp
Function Documentation
-
nav_msgs::msg::OccupancyGrid navmap_ros::to_occupancy_grid(const navmap::NavMap &nm)
Convert a
navmap::NavMapback tonav_msgs::msg::OccupancyGrid.Two paths are considered:
Fast exact path: If the first surface encodes valid grid metadata (GridMeta) and there is a per-NavCel
"occupancy"layer of type U8 with size2 * W * H, the function reconstructs anOccupancyGridexactly (linear inverse mapping0..254 → 0..100,255 → -1).Generic fallback: If the exact path is not applicable, the function samples cell centers via a navcel-locator (e.g.,
locate_navcel) and reads"occupancy"values to populate the grid.
Note
The fallback path assumes the presence of an
"occupancy"layer. The precise sampling strategy (bounds, resolution, and handling of cells without a containing navcel) is implementation-defined.Warning
If the map does not carry grid metadata or the
"occupancy"layer is missing, the result may be incomplete or implementation-defined.- Parameters:
nm – [in] Core NavMap to be rasterized as an occupancy grid.
- Returns:
A ROS
OccupancyGridpopulated fromnm.