How unknownfreeoccupied/ufomap works
Purpose and Top-Level Shape
UFOMap is a C++ probabilistic 3D volumetric mapping framework. Its core represents unknown, free, and occupied space in an octree-backed map; optional ROS packages expose mapping, serialization, visualization, and service interfaces. The standalone library is under ufomap/; ROS integration is under ufomap_ros/.
Core Map Model
The principal public API is the map subsystem, centered on octree storage and occupancy semantics:
• ufomap/include/ufo/map/octree.h
• ufomap/include/ufo/map/occupancy_map_base.h
• ufomap/include/ufo/map/occupancy_map.h
OccupancyMap builds on the generic octree/node model to store probabilistic occupancy while retaining explicit unknown regions. Colored occupancy is a specialization in ufomap/include/ufo/map/occupancy_map_color.h, implemented by ufomap/src/map/occupancy_map_color.cpp.
Spatial Encoding, Nodes, and Traversal
Spatial hierarchy and addressing are separate from occupancy policy:
• ufomap/include/ufo/map/code.h
• ufomap/include/ufo/map/key.h
• ufomap/include/ufo/map/octree_node.h
Keys/codes identify cells in the octree; node types carry tree state. Iterator families provide map/octree traversal, including nearest-oriented queries:
• ufomap/include/ufo/map/iterator/occupancy_map.h
• ufomap/include/ufo/map/iterator/octree.h
• ufomap/include/ufo/map/iterator/occupancy_map_nearest.h
This boundary lets planning or collision consumers query hierarchical map content without owning map-update mechanics.
Geometry and Collision Boundary
A geometry module supplies typed primitives, bounding-volume abstractions, and collision checks used to query map-adjacent spatial regions:
• ufomap/include/ufo/geometry/bounding_volume.h
• ufomap/include/ufo/geometry/collision_checks.h
• ufomap/src/geometry/collision_checks.cpp
Supported query shapes include AABBs, OBBs, rays, frusta, capsules, and others. Math primitives underpin both geometry and mapping:
• ufomap/include/ufo/math/vector3.h
• ufomap/include/ufo/math/quaternion.h
• ufomap/include/ufo/math/pose6.h
Map Input and Update Path
Point-cloud data is the main library-level mapping input:
• ufomap/include/ufo/map/point_cloud.h
• ufomap/include/ufo/map/occupancy_map.h
• ufomap/src/map/occupancy_map.cpp
The primary flow is point cloud plus sensor pose/ray information into occupancy updates, producing free/occupied voxel evidence and preserving unobserved cells as unknown. Consumers then traverse or spatially query the resulting hierarchy.
ROS Runtime Integration
ROS packages form an adapter layer around the C++ map rather than a separate mapping implementation. ufomap_mapping provides the operational server/node:
• ufomap_ros/ufomap_mapping/src/server_node.cpp
• ufomap_ros/ufomap_mapping/src/server.cpp
• ufomap_ros/ufomap_mapping/include/ufomap_mapping/server.h
It is launched through ufomap_ros/ufomap_mapping/launch/server.launch and has runtime-configurable server behavior in ufomap_ros/ufomap_mapping/cfg/Server.cfg. This is the primary ROS process entry point.
ROS Data, Services, and Visualization
ROS message definitions serialize maps and geometry across ROS topic boundaries:
• ufomap_ros/ufomap_msgs/msg/UFOMap.msg
• ufomap_ros/ufomap_msgs/msg/UFOMapStamped.msg
• ufomap_ros/ufomap_msgs/src/conversions.cpp
Service contracts support map retrieval, persistence, reset, and volume clearing:
• ufomap_ros/ufomap_srvs/srv/GetMap.srv
• ufomap_ros/ufomap_srvs/srv/SaveMap.srv
• ufomap_ros/ufomap_srvs/srv/ClearVolume.srv
RViz visualization is a plugin consuming the ROS-facing map representation:
• ufomap_ros/ufomap_rviz_plugins/src/ufomap_display.cpp
• ufomap_ros/ufomap_rviz_plugins/plugin_description.xml
Build and Packaging
The core library uses CMake and exports a package configuration through ufomap/CMakeLists.txt and ufomap/cmake/ufomapConfig.cmake.in. ROS components are separately packaged as catkin-style packages via their CMakeLists.txt and package.xml files. Material runtime dependencies are ROS (mapping server, messages, services, RViz) and RViz for visualization; no external hosted service is indicated.
Main entry points: occupancy_map.h Occupancy map · server_node.cpp Mapping server · octree.h Octree · vector3.h Math primitives
Components 15
C++ Core
Standalone probabilistic volumetric mapping library.
- Math primitives
ufomap/include/ufo/math/vector3.h - Geometry & collision · Bounding volumes and collision checks for map-adjacent regions.
ufomap/include/ufo/geometry/collision_checks.h - Cell keys & codes
ufomap/include/ufo/map/code.h - Octree nodes
ufomap/include/ufo/map/octree_node.h - Octree
ufomap/include/ufo/map/octree.h - Occupancy map base
ufomap/include/ufo/map/occupancy_map_base.h - Occupancy map · Stores probabilistic free and occupied evidence while retaining unknown space.
ufomap/include/ufo/map/occupancy_map.h - Colored occupancy map
ufomap/include/ufo/map/occupancy_map_color.h - Point cloud input
ufomap/include/ufo/map/point_cloud.h - Map traversal & nearest queries · Hierarchical and nearest-oriented occupancy queries.
ufomap/include/ufo/map/iterator/occupancy_map_nearest.h
ROS Integration
ROS adapters, runtime server, contracts, and visualization.
- ROS server launch
ufomap_ros/ufomap_mapping/launch/server.launch - Mapping server · Operational ROS adapter around the C++ occupancy map.
ufomap_ros/ufomap_mapping/src/server_node.cpp - Map ROS messages · Map and geometry representation crossing ROS topic boundaries.
ufomap_ros/ufomap_msgs/msg/UFOMap.msg - Map ROS services · Retrieve, save, reset, and clear map volumes.
ufomap_ros/ufomap_srvs/srv/GetMap.srv - RViz map display
ufomap_ros/ufomap_rviz_plugins/src/ufomap_display.cpp
Connections 15
- Math primitives → Geometry & collision: underpins
- Math primitives → Occupancy map: poses and vectors
- Cell keys & codes → Octree: addresses cells
- Octree nodes → Octree: stores tree state
- Octree → Occupancy map base: backs hierarchy
- Occupancy map base → Occupancy map: base policy
- Occupancy map → Colored occupancy map: specialized as
- Point cloud input → Occupancy map: ray-based updates · Sensor pose and point data produce free and occupied evidence.
- Occupancy map → Map traversal & nearest queries: queried through
- Geometry & collision → Map traversal & nearest queries: spatial query regions
- ROS server launch → Mapping server: starts
- Mapping server → Occupancy map: updates and serves
- Mapping server → Map ROS messages: publishes / serializes
- Map ROS services → Mapping server: controls and retrieves
- Map ROS messages → RViz map display: visualized by