LiDAR Odometry in CARLA: Restructuring FLOAM for ROS 2
After my previous CARLA experiment with camera-based object detection, I wanted to push further — this time focusing on LiDAR and localization.
In the video you can observe:
- The system performing LiDAR odometry in CARLA
- Map misalignment during sharp turns — expected without loop closure, and likely addressable by integrating a loop closure module
Restructuring FLOAM for ROS 2
The original FLOAM implementation does not support ROS 2. I restructured it into a cleaner, more modular architecture:
floam_core: a pure C++ library containing the core algorithm — no ROS dependencyfloam: a ROS 2 node wrapping aroundfloam_core
This separation makes the system modular and reusable — the core algorithm can be tested and developed independently of the middleware layer. On top of that:
- Message synchronization is handled using ROS 2
message_filters - Subscribers and publishers are implemented in a multi-threaded design to maximize throughput
The performance improvement was noticeable:
| Implementation | Odometry Update Time |
|---|---|
| Original FLOAM | ~70–80 ms |
| My ROS 2 implementation | ~30–40 ms |
Simulating a Realistic LiDAR
To make the simulation more realistic, I reconfigured CARLA's LiDAR model based on the Velodyne HDL-64E user manual. The resulting point clouds look surprisingly close to real sensor data — though visible discrepancies between simulated and real-world LiDAR remain.
I'm currently unsure about the best approach for a proper sim-to-real analysis for LiDAR. If anyone has experience or suggestions, I'd really appreciate the insights — feel free to reach out or leave a comment.
Takeaway
This is another small but meaningful experiment showing that CARLA can be a practical tool for validating perception and localization pipelines before moving to real-world data. Between this and the camera-based detection experiment, CARLA is proving to be a genuinely useful sandbox for early-stage development.
The sim-to-real gap for LiDAR remains an open question for me — curious to hear how others are approaching it.
