Achieving Real-Time Performance in ROS 2 with RedHawk Linux
As robotic systems advance in complexity, the need for deterministic real-time performance becomes more critical especially in safety and mission-critical environments. ROS 2, the widely adopted middleware framework for robotic applications, provides a modular, scalable foundation for building next-generation systems. However, its out-of-the-box performance on standard Linux distributions may not meet the stringent timing guarantees required for real-time applications.
That’s where RedHawk Linux comes in. Engineered for real-time performance, RedHawk enables ROS 2 developers to meet deadlines with nanosecond-level precision while maintaining full compatibility with Ubuntu and Red Hat Enterprise Linux user-space tools.
Why ROS 2 Needs Real-Time Support
ROS 2 improves upon its predecessor by supporting multi-threading, DDS-based communication, and real-time scheduling essential for time-sensitive tasks like sensor fusion, trajectory planning, and feedback control. But leveraging these features requires a kernel and system configuration that minimizes latency and jitter. Standard Linux distributions, even with PREEMPT-RT patches, often fall short when subjected to unpredictable workloads or insufficient resource isolation.
RedHawk Linux addresses these limitations by providing:
- A hardened real-time kernel with low latency and jitter,
- Core shielding and CPU affinity tools,
- Priority management and resource locking capabilities.
Together, these enhancements enable ROS 2 applications to meet the strict timing constraints often encountered in aerospace, defense, and industrial automation.
Building and Running ROS 2 on RedHawk
Installing ROS 2 Humble on RedHawk Linux involves building from source, primarily to integrate required patches and tune the system for real-time operation. The process is straightforward for engineers familiar with Linux build environments:
- Configure the system to emulate Ubuntu 20.04 (Focal) via
ROS_OS_OVERRIDE. - Install development dependencies and clone the ROS 2 source.
- Use
colconto build the workspace with symlink install for easier development.
Once installed, developers can verify functionality using standard ROS 2 demos like the talker and listener nodes, ensuring both C++ and Python interfaces are operational.
Benchmarking with the Pendulum Demo
To evaluate real-time performance, the RedHawk team used ROS 2’s pendulum control demo an inverted pendulum simulation that stresses latency-sensitive control loops. The benchmark compared performance on a stock Ubuntu 20.04 kernel versus RedHawk 8.4.
Key findings:
- Ubuntu (stock kernel): Ubuntu’s worst-case latency reached to about 3500 microseconds.
- RedHawk (optimized): Worst-case latency dropped below 52 microseconds, with negligible jitter and consistent mean latency around 2.2 microseconds.
These results illustrate the importance of real-time kernel tuning and CPU isolation in minimizing latency and jitter.
Real-Time Tuning with RedHawk Tools
To reach optimal performance, RedHawk provides system-level tools for fine-grained control:
- Shielding: Using the
shieldutility, entire CPU cores (or sockets) can be reserved exclusively for real-time tasks. - Binding and Priority Boosting: Critical processes can be bound to isolated cores and assigned real-time priorities using the
runcommand and FIFO scheduling. - NightStar Tools: Developers can use NightView for source-level debugging, NightTrace for system-wide tracing, and NightTune for live performance tuning.
These tools allow developers to inspect and tune thread behavior, memory usage, and interrupt handling with minimal overhead.
Enhancing ROS 2 Performance with Patches
One notable improvement came from addressing first run latency outliers in the pendulum demo. By applying a patch developed by Concurrent Real-Time, engineers could clear statistics after initial cache warm-up and improve initial iteration performance.
Post-patch benchmarks showed:
- Ubuntu: Max latency improved by over 3,000 microseconds.
- RedHawk: Worst-case latency dropped to ~14 microseconds, with a mean of 1.8 microseconds almost indistinguishable from its best-case scenario.
This demonstrates the effectiveness of combining kernel-level optimizations with ROS-specific patches for maximum determinism.
Final Thoughts
For engineers deploying ROS 2 in environments where timing predictability is paramount, RedHawk Linux offers a proven path to real-time performance. With comprehensive tooling, compatibility with industry standards, and support for advanced debugging and tracing, RedHawk enables developers to unlock the full potential of ROS 2 in mission-critical systems.
Related Articles



