How We Solved an Intermittent FAST-LIO Startup Latency Bug
Understanding ROS 2 QoS · Livox Mid360 · FAST-LIO · ROS2 Humble
One of the most frustrating software bugs is one that cannot be reproduced consistently.
Recently, while developing an indoor SLAM drone platform based on Livox Mid360, FAST-LIO, ROS 2 Humble, and PX4, we encountered an intermittent startup problem. Most of the time the system worked perfectly, but occasionally FAST-LIO would start with a significant delay, causing poor localization performance and unstable downstream navigation.
• Jetson (Ubuntu 22.04)
• ROS 2 Humble
• Livox Mid360 LiDAR
• FAST-LIO
• PX4 Flight Controller
• MAVROS
• Custom ROS2 bridge
• FAST-LIO Odometry: 10 Hz
• End-to-end latency: approximately 30 ms
• Stable startup after every reboot
Most startups behaved normally. Occasionally, however, FAST-LIO would exhibit:
- Very slow initialization
- Delayed odometry output
- Poor synchronization between IMU and LiDAR
- Navigation instability
• Livox driver delay
• PX4 communication delay
• ROS2 executor scheduling
• DDS communication
• CPU performance
• Thread synchronization
• FAST-LIO mapping algorithm
• Timestamp synchronization
• Network latency
Instead of guessing, we decided to instrument the code.
• IMU callback age
• LiDAR callback age
• IMU minus LiDAR timestamp
• Mapping computation time
• Publishing latency
IMU callback age: 0.0002 seconds
IMU callback age: 1.3 seconds
ROS 2 communication is controlled by Quality of Service (QoS). QoS defines how messages are delivered between publishers and subscribers.
• Reliability
• History
• Queue depth
• Durability
Configuration data should never be lost.
Camera images, however, should always be the newest frame rather than an old frame that has been waiting in a queue.
High-rate sensors such as IMUs belong to the second category. Freshness is more important than perfect delivery.
The IMU subscriber originally used a generic queue depth:
The subscriber was changed to use the ROS 2 sensor profile:
• IMU
• LiDAR
• Camera
• Radar
"If old sensor data exists, discard it and process the newest data."
For localization systems, this behavior is almost always preferable.
After implementing the change, we performed extensive testing.
• Multiple software restarts
• Multiple complete system reboots
• Continuous runtime testing
• Odometry frequency monitoring
• End-to-end latency measurement
Odometry frequency: Approximately 10 Hz
End-to-end latency: Approximately 30–35 ms
• Do not only measure computation time.
• Also measure data age.
• These are completely different quantities.
Many localization problems are actually communication problems.
If you encounter intermittent startup delays in ROS 2 SLAM systems:
2. Measure callback latency.
3. Inspect QoS settings.
4. Compare message age instead of only message frequency.
5. Instrument every stage of the pipeline before changing algorithms.
(c) 卓博泰科技 · FAST-LIO Startup Latency Bug Fix