Cartographer Overview

Cartographer is a system that provides real-time simultaneous localization and mapping (SLAM) in 2D and 3D across multiple platforms and sensor configurations. It is designed to build globally consistent maps from sensor data using a combination of local submap construction and global loop closure optimization.

Core Architecture

The library is organized into three main components:

1. Mapping (cartographer/mapping)

The mapping component implements the SLAM algorithm’s core logic:

  • MapBuilder — The top-level entry point that wires together trajectory builders (for local submaps) and a pose graph (for global loop closure).

  • TrajectoryBuilder — Constructs local submaps from sensor data using scan matching. Separate implementations exist for 2D and 3D.

  • PoseGraph — Maintains the global map by optimizing trajectory poses using constraints from loop closure detection and scan matching.

  • Submaps — Probabilistic grid representations (2D probability grids, 3D hybrid grids) that store local map data.

  • Scan Matching — Multiple algorithms: Ceres-based optimization, real-time correlative scan matching, and fast correlative scan matching (both 2D and 3D).

2. Sensor (cartographer/sensor)

The sensor component handles sensor data representation and processing:

  • Data Types — Range data (origin, returns, misses), point clouds, IMU data, odometry data, landmark data, and fixed-frame pose data.

  • Collation — Multi-queue and trajectory-based collation for synchronizing data from multiple sensors.

  • Filters — Voxel filtering for point cloud downsampling.

  • Range Data Transforms — Coordinate transformation and cropping utilities.

3. Common (cartographer/common)

Shared utilities and infrastructure:

  • Time — Universal Time Scale (UTS) timestamp representation with 100ns resolution.

  • Lua Parameter Dictionary — Configuration system using Lua scripts for hierarchical parameter management.

  • Thread Pool — Background thread management for computationally intensive tasks.

  • Math Utilities — Common mathematical functions and types.

  • Task System — Asynchronous task execution framework.

  • Configuration File Resolver — Loads and resolves Lua configuration files with includes.

Configuration System

Cartographer uses Lua configuration files for all tunable parameters. The configuration hierarchy:

map_builder.lua          # Top-level: selects 2D/3D, background threads, pose graph
├── trajectory_builder_2d.lua   # 2D local SLAM parameters
├── trajectory_builder_3d.lua   # 3D local SLAM parameters
├── pose_graph.lua              # Global optimization parameters
└── trajectory_builder.lua      # Shared trajectory builder settings

Key configuration areas:

  • Local SLAM: Voxel filtering, scan matching (Ceres, correlative), motion filtering, submap parameters

  • Global SLAM: Constraint builder (loop closure detection), optimization problem (Ceres), global sampling

Data Flow

Sensor Data → Collator → TrajectoryBuilder → Local Submaps
                                    ↓
                              PoseGraph ← Constraints (loop closure)
                                    ↓
                            Optimized Global Map

Supported Platforms

  • 2D SLAM: Planar laser scanners, possibly with IMU and odometry

  • 3D SLAM: 3D lidars (Velodyne, Ouster, etc.), possibly with IMU and odometry

  • Multi-session: Supports multiple trajectories, map merging, and serialization/deserialization

Key Design Principles

  1. Separation of local and global SLAM — Local trajectory builders operate independently; pose graph handles global consistency.

  2. Probabilistic submaps — Grids store occupancy probabilities, enabling robust scan matching.

  3. Configurable via Lua — All parameters exposed through hierarchical Lua configuration.

  4. Serialization support — Full state (submaps, trajectories, constraints) can be saved and loaded.

  5. Multi-threaded — Background threads for scan matching and optimization.

Cross-References

Contents

Cartographer Documentation