Google Cartographer
An open-source real-time SLAM library enabling mobile robots to generate high-fidelity 2D and 3D maps. Cartographer solves the complex problem of mapping dynamic environments while simultaneously tracking the robot's precise location.
Core Concepts
Real-Time SLAM
Simultaneous Localization and Mapping allows AGVs to map unknown environments while keeping track of their trajectory without GPS.
Loop Closure
Detects when the robot returns to a previously visited location and corrects accumulated drift in the map for global consistency.
Submaps
Maps are built as a collection of small local submaps. This allows the system to optimize recent data quickly without re-processing the entire world.
Multi-Sensor Fusion
Seamlessly fuses data from LiDAR (Light Detection and Ranging), IMUs (Inertial Measurement Units), and wheel odometry for robust tracking.
Pose Graph Optimization
Utilizes the Ceres Solver to optimize the pose graph, minimizing errors across the entire trajectory to create a geometrically accurate floor plan.
Distributed Architecture
Designed to run on limited compute resources on the robot, while offloading heavy visualization and map saving to remote workstations.
How It Works
Google Cartographer operates by ingesting raw sensor data, primarily from LiDAR scanners and Inertial Measurement Units (IMU). As the robot moves, Cartographer builds "Submaps"—small, locally consistent maps of the immediate surroundings.
The magic happens in the background via "Global SLAM." The system constantly matches current scans against previous submaps. If a match is found (a loop closure), the software adjusts the positions of all submaps to fix drift errors.
This results in a robust, globally consistent map (typically an occupancy grid) that can be used for path planning and navigation, even in environments with dynamic obstacles like walking humans or moving forklifts.
Real-World Applications
Warehouse Automation
Used in Automated Guided Vehicles (AGVs) and Autonomous Mobile Robots (AMRs) to navigate massive fulfillment centers without magnetic tape or QR codes.
Industrial Cleaning
Powers commercial floor scrubbers, allowing them to map lobbies and hallways to ensure 100% surface coverage during cleaning cycles.
Hospital Logistics
Enables delivery robots to transport linens, medicine, and lab samples through complex, multi-floor hospital environments safely.
Digital Twin Creation
Backpack-mounted or robot-mounted mapping systems use Cartographer to generate precise "as-built" diagrams of construction sites and factories.
Frequently Asked Questions
What hardware does Google Cartographer require?
At a minimum, Cartographer requires a LiDAR sensor (2D or 3D). An IMU (Inertial Measurement Unit) is highly recommended for 2D mapping to provide rotational velocity and acceleration data, and it is mandatory for 3D mapping to determine the gravity vector.
Does Cartographer support ROS (Robot Operating System)?
Yes, Cartographer is fully integrated with ROS 1 and ROS 2. It provides the `cartographer_ros` package, which handles the subscription to sensor topics (LaserScan, PointCloud2, Imu, Odometry) and publishes the map and robot pose (tf).
How does Cartographer handle "Loop Closure"?
It uses a branch-and-bound scan matching approach. When the robot revisits an area, Cartographer attempts to match the current scan against all nearby submaps. If a match is found with high confidence, the pose graph is optimized to pull the trajectory together, eliminating accumulated drift.
What is the difference between Local SLAM and Global SLAM?
Local SLAM builds submaps by inserting scans into a small occupancy grid, optimizing for immediate consistency. Global SLAM runs in the background, rearranging these submaps to ensure the whole map is consistent, specifically handling loop closures and long-term drift.
Can Cartographer run on a Raspberry Pi?
It can run on a Raspberry Pi 4, but performance may be limited for high-resolution mapping or high-speed movement. For industrial AGVs, an Intel NUC, NVIDIA Jetson, or similar industrial PC is recommended to handle the optimization threads efficiently.
Is it suitable for outdoor environments?
Yes, especially when using 3D LiDAR. However, large open spaces with few features (geometric structures) can be challenging for SLAM. In these cases, integrating GPS/GNSS data into the pose graph is recommended to assist with localization.
How does it compare to GMapping or Hector SLAM?
Cartographer is generally more robust and accurate for large-scale mapping than GMapping or Hector, thanks to its sophisticated loop closure and submap architecture. However, it is also more computationally intensive and has a steeper configuration learning curve.
How do I configure Cartographer?
Configuration is done via Lua scripts. These scripts control parameters like the size of submaps, the resolution of the grid, weights for the optimization problem, and sensor inputs. Tuning these parameters is critical for optimal performance in specific environments.
Can I save and reuse the map?
Yes. Cartographer saves the state in a `.pbstream` file. This file contains the compressed map data and the pose graph. It can be converted to standard `.pgm` and `.yaml` map files for use with the ROS navigation stack (AMCL).
What is "Pure Localization" mode?
In pure localization mode, Cartographer stops adding new data to the map and instead focuses solely on determining the robot's position within a pre-existing `.pbstream` map. This requires significantly less CPU power than full mapping mode.
Does it work with wheel odometry?
Yes, and it is highly recommended. While Cartographer can work without it, providing wheel odometry helps the Local SLAM algorithm estimate initial motion, making scan matching much faster and more reliable, especially in repetitive corridors.
Is Google Cartographer free for commercial use?
Yes, it is released under the Apache 2.0 license. This allows for commercial usage, modification, and distribution without requiring you to open-source your own proprietary application code.