Back to Knowledge Hub
Technical Blog

Real-Time Control with ROS 2 on Constrained Hardware

November 18, 202510 min read
ROS 2Real-TimeRobotics

The Raspberry Pi 5 is a game-changer for robotics. With a quad-core Cortex-A76 at 2.4GHz and real PCIe lanes, it's the first Pi that can genuinely handle real-time control loops without constant corner-cutting. But "can handle" and "does handle" are different things — you need to configure it right.

Out of the box, the Pi 5 runs a standard Linux kernel with CFS (Completely Fair Scheduler). This is optimized for throughput, not latency. A control loop that needs to fire every 1ms will see jitter of 5-15ms under load — unacceptable for a robotic arm that could damage itself or its environment.

The fix: PREEMPT_RT kernel patches. These convert the Linux kernel into a fully preemptible real-time OS. Spinlocks become sleeping locks, interrupt handlers become kernel threads, and the scheduler guarantees bounded latency. On Pi 5, this brings worst-case jitter down to ~50 microseconds — well within our 1ms budget.

ROS 2 Humble's DDS (Data Distribution Service) middleware adds its own latency. The default DDS implementation (Fast-DDS) uses a thread pool for message processing. For real-time nodes, switch to Cyclone DDS with these tunings: dedicated receiver threads, zero-copy shared memory transport for intra-process communication, and pre-allocated message pools to eliminate runtime allocation.

The control architecture: a real-time executor runs the servo control loop at 1kHz on a CPU core isolated via `isolcpus=3`. Sensor fusion (IMU + encoder feedback) runs on core 2. High-level planning (trajectory generation, inverse kinematics) runs on cores 0-1 at a relaxed 50Hz. This core pinning prevents scheduling interference between control and planning.

Practical results on our 6-DoF robotic arm: position control accuracy improved from ±2.3mm (standard kernel) to ±0.4mm (PREEMPT_RT + DDS tuning). The arm can now reliably perform pick-and-place operations at 15 cycles/minute with 99.7% success rate.

All kernel configs, DDS tuning parameters, and launch files are documented in the project repository. The same approach works on Jetson Orin Nano with even better results due to dedicated real-time cores.

CK

Chetan Khapedia

AI & Data Science Engineer · Robotics · Edge AI · MLOps