Architecture

Architecture

The processes, threads and crates of nao-rs, and how they map onto what Aldebaran's HAL and LoLA did.

Processes

computer (brain, tools)
   │ TCP 7700: robot API              UDP 7701: stop
   ▼                                   ▼
hulk ── links the nao-rs runtime    nao-rs-guard ── watches the runtime
   │  (one process, real-time cycle)    │  (takes the chest board over on a hang)
   │                                    │
   ├─ USB ─▶ chest board ─▶ 13 motor boards, 2 foot boards, IMU, sonar, battery, chest button
   ├─ I2C ─▶ head: 6 LED drivers, touch, power monitor, temperature
   └─ /dev/cgos ─▶ board controller: CPU temperature, head fan
            both map /run/nao-rs/deathswitch

On the original stack, HAL, LoLA and HULA are three processes linked by shared memory and two sockets. With nao-rs, hulk links the runtime as a library, so the controller and the drivers share one process. The only other process that touches the hardware is the guard, and it does so only after it has killed the runtime.

Threads of the runtime

ThreadPriority (SCHED_FIFO)PeriodJob
robot-cycle30, pinned to CPU 3, memory locked12 msChest board exchange in HAL's order, death switch check before each frame, triggers, heartbeat
robot-head2012 msOne I2C transaction per cycle: LEDs out, touch, power and temperature in (about 6 ms on the bus)
robot-fannormal10 sThe fan curve, the CPU alert and halt
guard (own process)402 ms pollHeartbeat check, UDP stop, takeover

The head runs on its own thread because one I2C transaction takes about 6 ms; the cycle thread only reads the latest head state from it (the three head pads feed the death switch triggers). The controller's commands and the head state reach the cycle thread through lock-free "latest value" slots, so reading them never blocks; the cycle publishes its state for the controller under a short lock.

One cycle

  1. Take the newest commands from the controller.
  2. Check the death switch, one atomic load. Tripped means the frame is all-off.
  3. Exchange the frame with the chest board and decode the answer (in HAL's order).
  4. Look at the triggers: chest button, the three head pads, joint temperatures. Trip the switch when one fires.
  5. Write the heartbeat for the guard and publish the state.

If the cycle falls more than three periods behind, the runtime trips the switch: the controller can't have seen the robot for that long.

State and commands

The runtime's state and commands use LoLA's layout: the same arrays, in the same order and units, as LoLA's RoboCup messages. Software written for LoLA, such as HULKs' hulk, keeps its conversions unchanged. The joint order is:

HeadYaw HeadPitch
LShoulderPitch LShoulderRoll LElbowYaw LElbowRoll LWristYaw
LHipYawPitch LHipRoll LHipPitch LKneePitch LAnklePitch LAnkleRoll
RHipRoll RHipPitch RKneePitch RAnklePitch RAnkleRoll
RShoulderPitch RShoulderRoll RElbowYaw RElbowRoll RWristYaw
LHand RHand

There is one hip yaw-pitch joint for both legs (LHipYawPitch): the NAO's two hips share one motor.

Crates

CrateWhat it does
usbfsLinux usbfs without libusb: configuration, claim, control and bulk transfers
chestlinkThe USB link to the chest board: start-up and the write, acknowledge, read exchange
chestboardChest board frames: messages, length table, CRC
chestprefsThe body preferences stored in the chest board: serial numbers, calibration
motorboardThe motor boards' configuration table
bodyHAL's body start-up, the motor board handshake, the cycle requests and the all-off frame
sensorsBody sensors from the chest board's answers, in LoLA's units and order
headThe head I2C bus: LED drivers, touch, power monitor, temperature
fanThe head fan through the board controller, and alfand's control law
deathswitchThe latched switch page, the guard's rules, the UDP stop
safetyHAL's safety rules as pure logic: controller lost, cycle stall, battery over-current, how the stiffness factors combine; applied to every frame by the runtime
chesttoolsThe chest board tools: version, mode, power-off
rtReal-time helpers: FIFO priority, locked memory, absolute-deadline ticker, lock-free latest value
robotThe runtime that ties them together, and the guard

Tools: naoctl (on the robot, see Command-line tools), and the recording, replay and comparison tools used for verification.

On this page