SLAM: Simultaneous Localization and Mapping
Imagine exploring a dark cave with no flashlight â you need to simultaneously figure out where you are AND build a map of the cave. This is exactly what SLAM does for drones. It's one of the most elegant and challenging problems in robotics.
The SLAM Problem
SLAM addresses a chicken-and-egg problem:
- To localize, you need a map of landmarks
- To build a map, you need to know where you are
The solution? Do both simultaneously using probabilistic estimation.
SLAM System Architecture
EKF-SLAM: Extended Kalman Filter SLAM
EKF-SLAM represents the robot's state and all landmark positions in a single large state vector, maintained with a covariance matrix.
State Representation
The state vector contains:
- Robot pose: Position (x, y, z) and orientation (roll, pitch, yaw)
- Landmark positions: 3D coordinates of all observed features
State: x = [x_r, y_r, z_r, Ī_r, θ_r, Ī_r, x_l1, y_l1, z_l1, x_l2, y_l2, z_l2, ...]
Map Building Process
EKF-SLAM Implementation
ORB-SLAM: Visual SLAM
ORB-SLAM is a state-of-the-art visual SLAM system that uses camera images to simultaneously track the camera pose and build a sparse 3D map.
ORB-SLAM Pipeline
- Feature Extraction: ORB features from each frame
- Tracking: Match features, estimate camera pose
- Local Mapping: Triangulate new points, bundle adjustment
- Loop Closure: Detect revisited places, optimize the graph
LiDAR SLAM
LiDAR SLAM uses 3D point clouds from laser scanners. It's particularly popular for outdoor drones due to LiDAR's accuracy and range.
ICP (Iterative Closest Point)
The core algorithm for scan matching:
Point Cloud Registration
Loop Closure Detection
Loop closure is critical for reducing drift in SLAM. When the drone revisits a previously mapped area, it must recognize this and correct accumulated errors.
Visual SLAM vs LiDAR SLAM Comparison
| Feature | Visual SLAM | LiDAR SLAM |
|---|---|---|
| Sensor Cost | Low (1000+) | |
| Range | Limited by lighting | Excellent (100m+) |
| Computational Cost | Medium | High |
| Accuracy | 1-5 cm | 1-10 cm |
| Texture Dependence | High | None |
| Weather Robustness | Low | High |
| 3D Mapping | Requires stereo/dual | Native 3D |
| Power Consumption | Low | Medium |
Hands-On Project: Complete SLAM System
Build a visual-inertial SLAM system for a simulated drone:
Key Takeaways
- SLAM solves the simultaneous localization and mapping problem through probabilistic estimation
- EKF-SLAM maintains a single state vector but scales quadratically with landmarks
- ORB-SLAM provides robust visual SLAM with loop closure capabilities
- LiDAR SLAM offers higher accuracy and range but at greater sensor cost
- Loop closure is essential for reducing long-term drift
- Visual-inertial fusion combines camera and IMU for robust state estimation