Function navmap_ros::from_occupancy_grid

Function Documentation

navmap::NavMap navmap_ros::from_occupancy_grid(const nav_msgs::msg::OccupancyGrid &grid)

Build a navmap::NavMap from a nav_msgs::msg::OccupancyGrid using a regular triangular surface with shared vertices.

  • Vertex layout follows the grid indexation with shared vertices across adjacent cells.

  • Triangle winding and diagonal split are deterministic (pattern = 0).

  • If width == 0 or height == 0, the returned map contains no triangles.

Note

The grid origin pose may contain a rotation. The vertex Z is taken from the origin Z; handling of non-zero yaw/roll/pitch (if any) is implementation-defined in the builder.

Parameters:

grid[in] Input ROS OccupancyGrid (row-major, width×height, resolution and origin).

Returns:

A core navmap::NavMap with:

  • Vertices: (W+1) * (H+1) laid on the grid plane, with Z = grid.info.origin.position.z.

  • Triangles: 2 * W * H (two per cell), using diagonal pattern = 0.

  • One surface whose frame matches grid.header.frame_id, and grid metadata filled.

  • A per-NavCel layer named "occupancy" of type uint8, with values mapped as: -1 255 (unknown), 0..100 0..254 (linear scaling).