TL;DR
Veloxity is the first open-source, memory-safe UAV autopilot written in Rust that is fully integrated into a modern autonomy ecosystem (ROS 2). By leveraging Rust’s ownership model, it eliminates common memory-related crashes while actually outperforming its C++ counterparts in communication latency and maintaining a smaller binary footprint.
What Problem Does This Paper Address?
In the world of Unmanned Aerial Vehicles (UAVs), the low-level firmware is the "last line of defense." If the firmware crashes, the drone falls. Historically, this firmware is written in C or C++, languages that prioritize performance but rely heavily on "programmer discipline" to avoid memory errors like out-of-bounds accesses, use-after-free bugs, and data races. These errors are notoriously difficult to debug because their effects often manifest far from the original defect.
While high-assurance languages like Ada/SPARK exist, they often come with steep learning curves and specialized toolchains that hinder rapid development. The authors address this by introducing Veloxity, a Rust-based autopilot. Rust offers the performance of C++ but uses a strict compiler to enforce memory safety, effectively "baking in" safety without the overhead of a garbage collector.
Methods
Veloxity was modeled after the established ROSflight (C++) ecosystem but re-engineered to utilize Rust’s unique safety features:
- The
WorldStructure and Contexts: Unlike C++ architectures where subsystems often have broad, persistent access to shared resources, Veloxity uses aWorldstructure that owns all long-lived resources. It uses "Contexts"—short-lived structures—to temporarily borrow only the specific data a subsystem needs for a single operation. This is illustrated in the architectural comparison below: Shared access in ROSflight versus context-based access in Veloxity.
- Compile-Time Compatibility: The authors used Rust’s trait system to ensure that subsystems (like estimators and controllers) are mathematically compatible at compile time. You literally cannot compile a version of the firmware where a mixer receives the wrong type of control output. Compile-time compatibility enforced through associated types in the control pipeline.
- Lifetime Enforcement: Rust’s compiler tracks how long references are valid. This prevents "dangling pointers"—a common C++ bug where a program tries to access memory that has already been deleted. Rust’s lifetime system prevents dangling references.
- Integration: Veloxity integrates with ROS 2 via a MAVLink bridge, allowing it to work seamlessly with existing autonomy stacks and simulators. Veloxity firmware within the ROSflight 2.0 ecosystem.
Datasets
The authors evaluated Veloxity using three primary methods:
- Numerical Comparison Harness: A host-only test running 10,000 independent firmware instances to check for mathematical agreement between Rust and C++ implementations.
- Software-in-the-Loop (SIL): Full-stack simulations using matched sensor-noise seeds to compare tracking accuracy in a controlled environment.
- Outdoor Flight Tests: Real-world waypoint-following missions using a Holybro X650 quadrotor equipped with a Pixracer Pro flight controller and a Raspberry Pi 5 companion computer.
Key Insights and Ideas
- Safety is "Zero-Cost": A common myth is that safety languages are slower. Veloxity proves that Rust’s compile-time checks provide safety without the runtime "tax" of a garbage collector, making it ideal for resource-constrained microcontrollers.
- Improved Determinism: In communication tests, Veloxity showed significantly more consistent timing than the C++ baseline. While the C++ firmware occasionally produced duplicate or missing echoes, Veloxity handled every command exactly once with lower jitter.
- Ownership as Architecture: The move from a "shared parent" object (C++) to a "borrowed context" (Rust) isn't just a syntax change; it's a fundamental shift that forces developers to design cleaner, more modular data flows.
Key Results
The empirical comparison between Veloxity (Rust) and ROSflight (C++) yielded impressive results:
- Binary Size: Veloxity’s raw flash image was 0.79% smaller (3,288 bytes) than the C++ version, debunking the idea that Rust produces "bloated" binaries.
- Latency: In a 400 Hz command-echo test, Veloxity reduced the mean round-trip time by 24% (from 0.974 ms to 0.738 ms).
- Reliability: During the echo test, Veloxity had zero missing or duplicate responses, whereas the C++ baseline failed to echo five commands and produced 417 duplicates.
- Flight Performance: In outdoor tests, Veloxity achieved a lower total Root Mean Square Error (RMSE) of 0.252 m compared to ROSflight’s 0.517 m, even when flying at a higher speed (4 m/s vs 3 m/s).
Limitations and Future Work
While Veloxity demonstrates the viability of Rust for UAVs, the authors note a few areas for growth:
- Hardware Support: Currently, the implementation is focused on the STM32H743II microcontroller. Future work aims to extend support to more flight controllers.
- Vehicle Types: The current evaluation focused on quadrotors; the team plans to expand to fixed-wing vehicles.
- Full-Stack Safety: While the firmware is now memory-safe, the "companion computer" (running the high-level autonomy stack) still relies on various languages. The authors suggest moving more of the autonomy stack into Rust to achieve end-to-end safety.
Summary updated