Skip to main content
Robotics & Embodied AI

⏱ About 20 min20 XP

Real-Time Constraints

In most software, a program is correct if it produces the right output — timing is a matter of user experience, not correctness. In robotics, this is not true. A robot arm control loop that computes the right motor command but delivers it 50 ms late can overshoot its target, oscillate, or strike a human. Timing is a correctness requirement, not a performance metric. Understanding real-time constraints — where they come from, how to quantify them, and how to guarantee they are met — is a foundational skill for robot engineers.

What Makes a System Real-Time?

A real-time system is one in which the correctness of a computation depends not only on its logical result but also on the time at which that result is produced. Each computation has a deadline: a moment after which the result is too late to be useful or safe. Real-time requirements arise wherever a physical process evolves faster than the time budget allows for computation. A servo motor position controller must command current to the motor coils before the rotor overshoots its target — the physical dynamics of the motor set the deadline. A drone attitude controller must correct for wind gusts before the drone's attitude diverges unrecoverably — the aerodynamic dynamics set the deadline. A medical robot performing surgery must detect unexpected tissue contact and halt before force exceeds safe limits — the tissue response time sets the deadline. The deadline must be derived from a physical model, not guessed. An attitude controller for a drone with a time constant of 50 ms (the time for the attitude error to grow e-fold without correction) must run at least 10 times faster than the time constant — roughly every 5 ms. This is the rule of thumb: the control update rate must be at least 10x the closed-loop bandwidth to avoid degraded stability margins.

Timing Correctness Is a Safety Requirement

ISO 26262, the automotive functional safety standard, and IEC 62061, the industrial machinery safety standard, both require explicit analysis of timing requirements for safety-critical control functions. A robot certified to these standards must demonstrate that its real-time tasks meet their deadlines under worst-case conditions — not just on average.

Latency: Where Time Is Lost

Latency is the total elapsed time from when a physical event occurs to when the system responds to it. It is the sum of all delays in the pipeline: Sensor acquisition latency: the time from when the physical quantity changes until the sensor's digital output reflects the change. A camera with a 30 ms exposure time adds at least 30 ms of latency before an image is even available to process. Data transfer latency: the time to move data from the sensor to the processor. USB 3.0 transfer latency is microseconds; a long CAN bus with many nodes can add milliseconds of arbitration delay. Computation latency: the time for the algorithm to run. A deep neural network for object detection might take 10–50 ms on a mobile GPU. A simple PID controller takes microseconds on a microcontroller. Actuator response latency: the time from when the motor command is issued to when the actuator physically responds. A servo motor with a 10 ms current-control loop adds 10 ms; a hydraulic valve may add 5–20 ms of valve response time. The total end-to-end latency is the sum of all pipeline stages. A system with 30 ms camera latency, 2 ms transfer, 15 ms neural network, 5 ms planning, and 5 ms actuator response has 57 ms of end-to-end latency. For a robot arm moving at 2 m/s, 57 ms of latency means the robot is responding to a state that is 114 mm out of date.

Complete the statements about real-time system fundamentals.

A real-time system is correct only if its output is produced both with the right and within its . The total time from a physical event to the system's response is called .

Scheduling, Jitter, and Deadline Guarantees

Guaranteeing that a task meets its deadline requires controlling when it runs. The relevant parameters are: Period (T): how often a periodic task executes. A motor controller with a 1 ms period executes 1,000 times per second. Worst-case execution time (WCET): the maximum time the task can take to complete under any input and processor state. WCET analysis is a formal discipline; for safety-critical systems it involves static analysis of every code path or exhaustive measurement. Deadline (D): the time by which execution must complete after the task is triggered. For a task to be schedulable, it must satisfy D >= WCET and the processor must not be over-committed. If the sum of (WCET / Period) across all real-time tasks exceeds 1.0, the processor cannot guarantee all deadlines — a condition called CPU overload. Jitter is the variation in the actual start or completion time of a periodic task relative to its nominal schedule. A motor controller with a nominal 1 ms period might have 50 microsecond jitter — it sometimes runs at 0.95 ms, sometimes at 1.05 ms. Small jitter is usually acceptable; large jitter causes control performance degradation and must be bounded. Rate-monotonic scheduling (RMS) is a classical algorithm for assigning CPU priorities to periodic real-time tasks: shorter-period tasks get higher priority. Under RMS, a set of tasks is provably schedulable if the total CPU utilization does not exceed approximately 69% for many tasks.

Match each real-time scheduling concept to its precise definition.

Terms

Worst-case execution time (WCET)
Jitter
CPU overload
Rate-monotonic scheduling
End-to-end latency

Definitions

Condition where the sum of all tasks' WCET/Period ratios exceeds 1.0, making deadline guarantees impossible
Priority assignment rule where shorter-period tasks receive higher priority
Total elapsed time from a physical event to the system's physical response, summing all pipeline delays
Variation in a periodic task's actual execution time relative to its nominal schedule
The maximum time a task can take to complete under any input and processor state

Drag terms onto their definitions, or click a term then click a definition to match.

A robot control system has three periodic real-time tasks: Task A (period 1 ms, WCET 0.4 ms), Task B (period 5 ms, WCET 1.5 ms), and Task C (period 10 ms, WCET 2.0 ms). Is this task set schedulable on a single-core processor using rate-monotonic scheduling?

A camera-based obstacle avoidance system has 35 ms of total end-to-end latency. The robot drives at 1.5 m/s. How far does the robot travel during the latency period, and why does this matter for safety?

Analyze the Latency Budget of a Real Robot

  1. You are auditing the real-time performance of an autonomous robot's obstacle avoidance pipeline. The pipeline consists of these stages:
  2. 1. Depth camera: 33 ms exposure time, 2 ms USB transfer
  3. 2. Point cloud processing (CPU): 12 ms per frame
  4. 3. Obstacle detection algorithm: 8 ms
  5. 4. Path re-planning: 6 ms
  6. 5. Motor command transmission over CAN bus: 0.5 ms
  7. 6. Motor torque control loop: 2 ms
  8. Step 1: Compute the total end-to-end latency.
  9. Step 2: The robot's maximum safe operating speed is determined by the rule that it must be able to stop before hitting an obstacle detected at a minimum range of 0.5 m. Given your total latency, and a braking deceleration of 1.5 m/s^2, what is the maximum safe operating speed? (Hint: stopping distance = v^2 / (2a), total travel distance during latency plus stopping distance must be less than 0.5 m.)
  10. Step 3: Management wants to increase the robot's operating speed by 50%. Which pipeline stage would you optimize first, and what approach would you take?
  11. Step 4: The obstacle detection algorithm currently runs on a CPU. A GPU implementation would reduce it to 1 ms. Recompute the maximum safe speed with this optimization.
  12. Step 5: Describe one additional architectural change (hardware or software) that could further reduce latency.