Getting Started
UFO (Unknown Free Occupied) is a high-performance 3D mapping framework that explicitly represents free, occupied, and unknown space. This guide will help you get started with the core concepts and basic usage.
Basic Concepts
Section titled “Basic Concepts”- Spatial Containers: UFO provides various tree-based structures like
OctreeMap,QuadtreeMap, andHextreeMapto represent space at different resolutions and dimensions. - Probabilistic Representation: Each cell in a map can store occupancy information, confidence, semantics, and more.
- Efficient Queries: The framework is optimized for fast spatial queries, such as nearest neighbor searches and intersections.
Basic Usage
Section titled “Basic Usage”Here is a simple example of how to use an OctreeMap to store and query 3D points.
Code Example
Section titled “Code Example”#include <ufo/container/octree_map.hpp>#include <iostream>
int main() { // 1. Initialize an OctreeMap with 'int' as the data type ufo::OctreeMap<int> map;
// 2. Insert data at specific 3D coordinates (x, y, z) map.insert({{0.0, 0.0, 0.0}, 42}); map.insert({{1.0, 2.0, 3.0}, 100});
// 3. Perform a nearest neighbor search ufo::Vec3f query_point(0.1, 0.1, 0.1); auto nearest = map.nearest(query_point);
if (!nearest.empty()) { auto [pos, value] = *nearest.begin(); std::cout << "Nearest point at " << pos << " has value: " << value << std::endl; }
// 4. Iterate over all elements in the map std::cout << "All elements in map:" << std::endl; for (auto [pos, value] : map) { std::cout << pos << ": " << value << std::endl; }
return 0;}Building a Simple App
Section titled “Building a Simple App”To use UFO in your own project, you can find it via CMake.
CMakeLists.txt
Section titled “CMakeLists.txt”cmake_minimum_required(VERSION 3.23)project(MyUfoApp)
# Set C++23 standardset(CMAKE_CXX_STANDARD 23)set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Find UFO packagefind_package(UFO REQUIRED)
# Add your executableadd_executable(my_app main.cpp)
# Link against UFOtarget_link_libraries(my_app PRIVATE UFO::UFO)Build Instructions
Section titled “Build Instructions”cmake -B buildcmake --build build./build/my_app