Chapter 03 · Dynamics and feedback
Today in the field story
One problem, then the next
The simulated door behaves well at one update rate, then oscillates when sensor messages arrive late and noisy. For the Cold-Storage Door Tuning, preserve source time, arrival time, actual interval, data age, and derivative contribution. Compare fixed rate, added delay, jitter, and noise without changing gains, and explain why a faster requested loop is not proof of fresher decisions.
- Why now
Digital feedback acts on sampled, delayed evidence, so timing can invalidate otherwise sensible gains.
- Ignore today
Ignore operating-system real-time scheduling until Chapter 4; measure the current runtime honestly.
- Unlocks next
Deadline, jitter, and stale-data requirements for production control software.
Understand
Build the physical picture first
A digital controller sees the robot through a flip-book delivered late and with smudges. Faster pages can help, but delay, uneven timing, and noisy differences can still make the correction wrong.
Sampling converts continuous motion into measurements at separate instants. A rate f in hertz means f samples each second, and its ideal period is Δt=1/f. The controller calculation must use the real or configured period consistently; assuming 0.05 s while updates arrive irregularly changes derivative and integral calculations.
Latency is elapsed time from the physical event to the command that responds to it. Sensor exposure, filtering, transport, scheduling, calculation, and actuator response all contribute. Delay means the controller corrects an older state, so high gain can push the robot past the target before the measurement reveals what happened.
Noise is unwanted variation in a measurement. Differencing two noisy samples to estimate a derivative can amplify that variation, especially when divided by a small time step. Filtering may help but usually adds its own delay, so the engineering question is not “filter or no filter” but the measured tradeoff for the task.
Jitter is variation in update timing. Average frequency alone can hide occasional long gaps that matter to a fast mechanism. Logs should therefore retain sensor timestamp, receipt time, controller-start time, command-send time, and the age of data used for each command.
Words you need
Name each idea precisely
- Sampling rate
The number of updates or measurements per second, measured in hertz.
Physical example:20 Hz means one intended update every 0.05 s.
- Latency
Delay from an event or measurement to the resulting useful response.
Physical example:A camera frame is 100 ms old when an arm command uses it.
- Noise
Measurement variation that is not the physical change being estimated.
Physical example:A stationary encoder angle jumps slightly between adjacent readings.
- Jitter
Variation in the time between updates.
Physical example:A nominal 20 ms loop sometimes takes 45 ms.
- Data age
How old a measurement is at the moment it is used.
Physical example:now minus sensor timestamp equals 80 ms.
Math, one line at a time
Work through today’s relationship
Prerequisite rescue · optionalChange over time and feedback
Velocity, acceleration, and control error explain whether a robot settles, overshoots, or becomes unsafe.
- Δx/Δt
- change in position divided by elapsed timeUnit: metres per second (m/s)
- e = target − measured
- control errorUnit: same unit as the target
- u
- bounded actuator commandUnit: device-specific
A wheel moves from 1 m to 1.6 m in 0.2 s, so Δx = 0.6 m.
Average velocity is 0.6/0.2 = 3 m/s.
If the target is 2 m and measured position is 1.6 m, error e = 0.4 m; a controller converts that error into a limited command.
A feedback loop resembles an event loop that checks state repeatedly, but a missed deadline changes physical motion, not just screen responsiveness.
Position changes by 0.5 m in 0.25 s. What is average velocity?
0.5/0.25 = 2 m/s.
The sampling period is
A noise jump of error units produces the derivative estimate
Translate rate, delay, and noise into controller numbers
A loop is configured for 20 Hz. Measurement latency is 100 ms. Two consecutive noisy error samples differ by 0.02 units.
Convert rate to period: Δt=1/20=0.05 s=50 ms.
Express latency in periods: 100 ms/50 ms=2 sample intervals.
Interpret this carefully: the controller can be reacting to a state about two intended updates old.
Estimate the discrete error-rate contribution: 0.02/0.05=0.4 units/s.
Repeat mentally at 100 Hz: the same 0.02 difference divided by 0.01 s becomes 2 units/s.
Conclude that increasing rate does not by itself remove noise or latency and can magnify an unfiltered difference term.
The 20 Hz loop has a 50 ms period, sees roughly two periods of latency, and turns 0.02 sample noise into a 0.4 units/s derivative estimate.
Always convert timing into the same units and compare data age and worst-case delay with the mechanism's response time.
Physical examples
Where this appears in real life
Delayed shower
Hot water reaches the shower some time after the tap is turned. Turning again before the previous change arrives creates alternating too-hot and too-cold corrections.
The person is acting on an old temperature, just as a controller can act on stale state.
Choppy video call
A call may report a good average frame rate while occasional freezes make conversation difficult.
Average rate hides jitter and data age; the longest gaps can matter more than the mean.
Hands-on exercise
Make the idea observable
Reuse the Day 18 bounded simulation; do not connect it to powered hardware.
Run a fixed P controller with no added delay and save the response.
Insert a one-sample measurement delay, rerun with the same gain, and compare overshoot.
Insert a two-sample delay and record whether oscillation grows.
Add a repeating small measurement disturbance such as +0.01, -0.01.
Enable the same D term from Day 18 and inspect its contribution.
Log configured period, actual step time, measurement age, and maximum absolute command for every trial.
Delay shifts correction later; noise can make the derivative contribution alternate even while the true simulated state changes smoothly.
A comparison table connects each timing or noise change to overshoot, settling, command activity, and one design decision.
Build today
Control a simulated pendulum or cart-pole; log setpoint, error, command, saturation, and settling time.
Evidence to save
DONE when a comparison table for “Sampling rate, latency, noise, and stability” contains the test condition, metric, result, and justified engineering decision.
Common mistakes
Catch the wrong mental model
Reporting only average loop frequency.
Also report worst-case period, jitter distribution, deadline misses, and data age.
Using arrival time as if it were measurement time.
Preserve the sensor timestamp and calculate how old the physical observation is when used.
Increasing sample rate while reusing gains and derivative code unchanged.
Keep the actual Δt in discrete calculations and revalidate noise, delay, and stability.
Job connection
How this becomes employable evidence
Design stale-state indicators and a fault test that injects delayed telemetry, uneven update intervals, and noisy measurements while verifying bounded safe behaviour.
Relevant target roles
- Robot HMI / Control & Monitoring Engineer
- Robotics Deployment, Integration & Validation Engineer
Chapter 03 interview drill
Interview questions: Sampling rate, latency, noise, and stability
Practise a 60–90 second answer: define the idea, connect it to a physical robot, state assumptions, frames, and units when relevant, then finish with the failure signal or evidence you would inspect.
Primary interview scenario
A dashboard shows 20 Hz telemetry, but the robot still responds late. Which timestamps and worst-case timing measures distinguish low rate, latency, and jitter?
Answer shape: clarify the situation → trace the physical and software path → test the most likely boundaries → name the evidence that would confirm the result.
Technical follow-up questions
Q1What is the ideal period of a 50 Hz loop?
1/50 s = 0.02 s = 20 ms.
Q2Why can delay cause overshoot?
The controller keeps correcting an older state and may not see that the mechanism has already passed the target.
Q3Why is a timestamp inside the sensor message useful?
It lets the consumer compute measurement age instead of confusing transport arrival with physical observation time.