Inspiration

This robot head came as a kit meant to recognize faces through its camera: a shell with a face, five hobby servos, a USB eye camera and an Arduino Mega, sold with the promise of step-by-step tutorials. The company behind it has since disappeared, and the tutorials never came. The head sat on a shelf.

When we picked it up again for this hackathon, we wanted more than a head that turns. Robots that work beside people, at a bedside, in a clinic or at home, now run AI right next to their motors. The AI is the newest and least predictable part of such a system: it can crash, stall or slow down. So we asked one question: when the AI fails, what do the motors do?

QNX's design has an answer. On a microkernel, drivers and services are ordinary processes that can fail and be restarted without taking the system down. We rebuilt the head from scratch on QNX 8.0 to make that answer visible: when the AI crashes, the robot doesn't.

What it does

It is a face-tracking robot head on a Raspberry Pi 5 running QNX 8.0, built so that a failing AI cannot make it move badly.

  • It sees you and follows you. A neural network (UltraFace on ONNX Runtime) finds faces in the eye camera's frames on the device, in 26 ms per frame at the camera's 29 fps. The neck turns and the face tilts to keep you in the centre.
  • It knows who you are. The kit was meant to recognize faces, and now it does: a second network (SFace) compares a new face with the enrolled ones, on the device. People it knows get a two-nod greeting; strangers are watched, not greeted.
  • It behaves like a product. One command starts everything. It slowly looks around when nobody is there.
  • It fails safe. Vision and motion are separate QNX processes, and the vision never touches the motors. It writes target positions to /dev/servo, served by servod, a resource manager that owns the servos, clamps every command, moves smoothly and watches for silence. Kill the vision process mid-track and within 0.3 s servod turns the head back home. QNX's System Launch and Monitor restarts the vision at once; it sees its first frame about 0.6 s after starting, and tracking resumes. There is no reboot and no runaway motor. Freeze the vision instead and servod still brings the head home; send it a wild angle and servod holds the head at the joint limit.
  • It measures itself. Every frame is timestamped from the camera to the servo command. The same code builds for Linux, so we compared QNX 8.0 with stock Linux and Linux PREEMPT_RT on the same Pi.

How we built it

  • Hardware. We kept the kit's shell, servos and eye camera, and replaced its Arduino Mega and servo/power board with a Raspberry Pi 5 (8 GB) and an Adafruit CRICKIT HAT. The CRICKIT drives the servos over I2C and has its own 5 V supply, so three jumper wires (SDA, SCL, GND) connect it to the Pi.
  • QNX 8.0 on the Pi. The QNX Software Development Platform (SDP) 8.0.5 toolchain (qcc) cross-compiles everything, written in C. ONNX Runtime 1.24.4 comes from the QNX open-source package repository (apk add onnxruntime).
  • Three processes.
    • tracker receives camera frames through the QNX camera API, runs the face detector inside the camera callback and computes the next servo targets. It runs at SCHED_FIFO priority 60 pinned to CPU 3, which QNX allows without root.
    • servod registers /dev/servo/pan, /dev/servo/tilt and /dev/servo/face; each write is a QNX message. It clamps targets to each joint's measured limits, moves every joint along a 50 Hz trapezoidal profile, and sends the head home after 300 ms without a command. It needs root only to register its paths, then becomes an ordinary user and locks itself out of setuid.
    • SLM, QNX's System Launch and Monitor, runs the other two from tools/nova.slm. It starts the camera setup and servod, holds the tracker back until servod's resource manager has registered /dev/servo/pan, and restarts the tracker the moment it exits; the tracker's wrapper restarts the camera service first if frames had stopped. nova_start.sh launches this SLM instance, and with nova_autostart.sh the head is tracking 14 s after power-on.
  • One codebase, two OSes. A V4L2 back end runs the same tracker on Raspberry Pi OS. The benchmark tools (a 1 ms real-time loop, memory and IPC load generators, a memory-bandwidth probe) build for both.

Where to look in the code.

  • Resource manager and message passing: main() in src/servod/servod.c registers /dev/servo/{pan,tilt,face} with resmgr_attach(). io_write() receives each write as a message, served at the sender's priority, and clamps it; the motion() thread sends the head home after 300 ms without one.
  • System Launch and Monitor: tools/nova.slm (waitfor on /dev/servo/pan, depend), run by tools/nova_start.sh as its own SLM instance.
  • Camera API: src/tracker/cam_qnx.c (camera_open(), the viewfinder callback, frametimestamp).
  • I2C resource manager: i2c_write() in src/tracker/servo.c drives the CRICKIT with devctl(DCMD_I2C_SEND) on /dev/i2c1.
  • Least privilege: drop_privileges() in servod.c gives up root and locks PROCMGR_AID_SETUID with procmgr_ability().

Challenges we ran into

  • Booting at all. The QNX image for the Pi 5 stopped at a black screen on a current bootloader. A bootloader change (2026-06-17) now honours kernel_address literally, so the image was loaded at an address it was not linked for. Setting kernel_address=0x80000 fixed it, and we documented the constraint upstream (BSP pull request #4).
  • A camera QNX could not read. The kit's camera offers MJPEG first, so the QNX camera service reported an unknown frame format, and asking for YUYV failed. Restarting the service with a configuration that makes YUYV 640x480 the camera's default fixed it. The service also stops delivering frames now and then, so the tracker exits when frames stop and the supervisor restarts the service.
  • Servos with no feedback. Hobby servos jump to the first pulse they receive, and the neck carries the weight of the head. We mapped every joint by hand (direction, limits, how far it moves the camera image) and held the neck up before moving anything else. The CRICKIT addresses servos by PWM index, not pin number, and silently ignores the wrong one. Rewriting the PWM frequency on every step made the servos shudder, and linear ramps looked robotic, so servod writes the frequency once and accelerates and brakes smoothly.
  • A fair benchmark. QNX has no CPU frequency driver, so the firmware ran it at 2.4 GHz for a minute after boot and 1.5 GHz after that; we fixed both OSes at 1.5 GHz. Our first memory-load result flattered QNX because the same copy loop moved half as much data there, so we capped the load at 600 MB/s per core on both.

Accomplishments that we're proud of

  • The crash demo works on the real robot. We send SIGKILL to the vision process mid-track: the head turns back home, the vision restarts, and the head is tracking again with no reboot. In the recorded run, the restarted tracker found the face in all 324 frames.
  • Steady on-device AI. On QNX the face detector took 26.0 ms per frame on average and 26.4 ms at the 99th percentile, over 5,247 frames.
  • The shortest worst case. We ran a 1 ms SCHED_FIFO loop for 5 minutes, 3 times per load, on the same Pi at 1.5 GHz. QNX's worst wake-up was 5 µs idle (Linux 10 to 13 µs), 59 to 63 µs under memory load (Linux 61 to 102 µs), 8 to 11 µs under pipe IPC (Linux 13 to 16 µs) and 6 to 8 µs under UDP traffic (Linux 9 to 15 µs).
  • A fix shared upstream. The boot problem and its fix are documented in a pull request to the QNX Raspberry Pi 5 BSP.
  • An honest negative result. On the whole robot loop under the same memory load, QNX's detector slows from 26 to 79 ms per frame (12 fps) while Linux keeps 29 fps. We traced part of it to the graphics stack scanning out a 1080p frame buffer even with no monitor attached, ruled out five other causes, and published the method and the data.

What we learned

  • Real-time guarantees are about time, not throughput. QNX kept the tightest worst case under every load, yet the detector slowed under memory traffic. A robot's safety has to come from its structure: motion that never waits for the AI.
  • A resource manager makes a safety boundary simple. To the tracker the servos are just files (/dev/servo/pan). All the rules live in one process the vision cannot bypass, and the same interface works from a shell: echo 1500 > /dev/servo/pan.
  • Measure before you claim. Two of our early results, a QNX lead under load and a CPU running at an unexpected clock, came from unequal conditions, not from the OS. Fixing the clock and the load changed the conclusions.
  • Hardware rewards patience. With no position feedback, a heavy head and a camera cable that can pull loose, we brought up each servo one at a time, with the head supported by hand.

What's next

  • Keep the vision fast under memory pressure. Find the rest of the DRAM write gap on this board with the BSP maintainers, switch the display off when no monitor is attached, and try a quantized model that moves less data.
  • Bound the AI's share of the machine. Use QNX's scheduling and resource controls so that a misbehaving vision process cannot starve anything else on the Pi.
  • Grow the tutorial this kit never got. Extend the step-by-step guide from one robot head to other servo kits and boards.
  • Take the pattern to robots that work beside people. Telepresence and rehabilitation devices need the same split between an AI that may fail and motion that must not.

Built With

  • adafruit-crickit
  • c
  • i2c
  • linux
  • onnx
  • onnx-runtime
  • preempt-rt
  • python
  • qnx
  • qnx-camera-api
  • qnx-resource-manager
  • qnx-sdp-8.0
  • raspberry-pi-5
  • servo
  • sface
  • ultraface
  • uvc-camera
Share this project:

Updates

Submission history