Diagram of a policy evaluation loop with timing annotations
Architecture

Inside the Loop That Decides If a Robot Moves

A sub-millisecond evaluator is a real-time system, not a library call tucked into the command-processing thread. That shift ripples through the design: how rules sit in memory, how they are walked, how sensor data is fetched and cached, and how the evaluator is scheduled against the command loop. Teams that start with a synchronous function call in the controller's command thread tend to find the problem later, once the rule set passes a few dozen entries and command timing starts to wobble for reasons that trace back to evaluation.

Four Parts of the Loop

Command interception splits into four jobs:

  • Command intake: Accepts motion commands from the AI planner and queues them. At rates of 100 to 1000 Hz, intake must not block; the planner cannot stall until a verdict is ready before producing the next command.
  • Sensor input acquisition: Reads joint positions, TCP pose from forward kinematics, wrist force-torque, and workspace zone occupancy. Values have to be current at evaluation time; stale readings can let a bad command pass or reject one that current data would allow.
  • Rule evaluation engine: Tests the command against the rule set and current sensor state, returning pass or block plus the block response specification when the answer is block.
  • Command dispatch: Sends passed commands onward or carries out the block response, while keeping command order so the controller never sees out-of-sequence execution.

Safety performance depends on the span from intake to dispatch decision, meaning the time a command is held for evaluation. At 500 Hz, that window closes in 2 ms before the next command arrives.

Memory Layout That Keeps Reads Predictable

Rule evaluation is memory-heavy. A rule reads sensor values, compares them to stored thresholds, and evaluates a logical expression. With 100 rules and two sensor reads each, a full cycle is roughly 200 reads. At 500 Hz, that happens 500 times a second.

Whether those reads take nanoseconds or microseconds comes down to cache. An evaluator that reaches DRAM for most of its rule reads will not fit a 2 ms budget at 500 Hz. Rule data, including thresholds, operators, and response specifications, belongs in a compact sequential layout the engine can walk without pointer chasing. Current sensor state should be a small, frequently rewritten structure that stays in L1, kept separate from the historical buffer used for post-hoc work.

Branching and Worst-Case Time

Worst-case execution time (WCET) is the longest a code path can take, not the usual time. For an evaluator it means the slowest full pass over the rule set against a command, including the worst sensor acquisition. WCET is the number the safety case uses; average latency speaks to throughput.

Branches drive WCET spread in any non-trivial evaluator. Short-circuiting on the first violated rule improves the average, since one violation is often found early, but leaves WCET variable when every rule is checked and none fails. Certification tends to care about the worst case. Branch-free evaluation, where every rule runs and results are combined at the end, trades a higher average for a more predictable tail. Choosing between them depends on whether the safety case demands bounded WCET or bounded average latency.

Rule Count Against the Clock

With rules and sensor state in cache, well-structured engines scale roughly linearly with rule count. A tuned sequential evaluator on a modern core handles 50 to 100 rules per microsecond, which yields about 500 to 1000 rules in a 10 ms window, or 50 to 100 rules in 1 ms for high-rate systems.

Most single-arm production libraries hold 50 to 200 rules, comfortably inside 1 ms for a properly built evaluator. Trouble comes when task-specific rules push beyond that range, or when a rule needs data the local cache cannot supply. Any external fetch during evaluation, whether a database query or a call to a remote sensor, adds delay the evaluator cannot control and breaks a sub-millisecond budget. Either prefetch that data before evaluation begins or move the rule to the post-hoc layer, where real-time timing no longer applies.

Interrupts and Preemption

On a non-real-time operating system, anything higher priority can preempt the loop mid-pass. That produces latency spikes well above the nominal figure. A standard Linux host under load can see interrupt service latencies of 100 to 500 microseconds several times a second, enough to threaten a 1 ms budget even when the evaluator's own work fits.

Sub-millisecond evaluation on general-purpose hardware usually needs three platform settings: a real-time kernel (Linux with PREEMPT-RT for soft real-time, or a dedicated RTOS partition for hard real-time), isolated CPU cores removed from the scheduler pool, and interrupt affinity that steers hardware interrupts away from those cores. These are OS and platform choices rather than evaluator code, but the latency target cannot be met or measured without them.

What to Prioritize

Most deployments face the same trade-off first: predictable WCET versus average throughput. Branch-free evaluation is easier to analyze for certification but spends more time on average. Where a functional safety standard demands demonstrated WCET compliance, branch-free evaluation with a full WCET analysis simplifies the argument. Where average latency drives throughput and the worst case is already bounded by analysis, early termination with a documented bound is the usual pick. No approach wins everywhere; the deployment's safety requirements and certification context should make the call.

Back to The Safety Brief
Get Started

See the evaluator under your own command profile

Send a representative command stream through the evaluator and watch verdicts land before the actuator does.

Request Early Access