Lite / Intelligent Robotic Systems / Week 28
Fast loops inside slow ones
A balancing robot corrects its motors a thousand times a second but decides where to go only once a second. Why not do everything at 1 kHz?
Why should I care?
Computing time is a budget. Spend it where the physics is fast (currents, wheel speeds, balance) and save it where the world changes slowly (goals, routes). Getting this split wrong gives either a sluggish robot or an overloaded processor.
- Explain why low-level control loops run faster than planning loops.
- Choose an update rate from how quickly the controlled quantity can change.
- Calculate how many inner-loop updates happen per outer-loop decision.
Predict
A wheel's speed can change noticeably in 5 ms. Roughly how often should its speed controller run?
- Once a second
- About every 50 ms
- About every 1 ms or faster
Guess first, then reveal
Several times faster than the thing it controls can change: around 1 ms. A loop slower than the dynamics it controls cannot react in time and may go unstable.
Discover
Open the Robotics Workbench and run a motion with the default controller. Find the controller's update period, then make it ten times slower and run again. Describe what changes in the tracking and why.
What the interactive shows (text version)
In the Robotics Workbench, slowing the controller update period by ten times makes the tracked motion lag and overshoot the target path, because corrections arrive too late for the arm's dynamics.
Watch (optional)
Watch for: Notice which parts of the car's software react within milliseconds and which plan seconds ahead.
A university lab shows an autonomous car's layered system, where perception, planning and low-level control each play their part.
“Controlling Self Driving Cars” by AerospaceControlsLab (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
Rates follow the physics
Each loop should run several times faster than the quantity it controls can change. Motor current changes in microseconds to milliseconds, so current loops run at 10–20 kHz. Wheel speed changes in milliseconds (1 kHz). A robot's position on a map changes over tenths of a second (10–100 Hz). Goals change over seconds (1 Hz or less).
Cascaded loops
Layers are usually cascaded: the planner sends a path, a position loop turns it into speed targets, and a speed loop turns those into motor commands. Each inner loop treats its setpoint as constant between outer updates, which only works if the inner loop is much faster.
The cost of running fast
Running everything at the highest rate wastes processor time and energy, and heavy jobs such as vision may simply not finish in 1 ms. Splitting rates lets each job get the time it needs, often on different processors: a microcontroller for fast loops, a larger computer for perception and planning.
Explain it another way
Intuitive
Driving a car: your hands make tiny steering corrections all the time, your eyes check the lane every moment, and you decide which road to take only at junctions.
Technical
For a cascade to behave, each inner loop's closed-loop bandwidth should be roughly 5–10 times that of the loop around it. Sample rates are then chosen around 10–20 times each loop's bandwidth.
Mathematical
Updates per decision = inner rate ÷ outer rate. A 1 kHz speed loop under a 10 Hz planner runs 1000 ÷ 10 = 100 times per planning step. Its period is 1/1000 s = 1 ms.
Applied
Drone flight controllers typically run attitude loops at hundreds of hertz to a few kilohertz on a microcontroller, while a companion computer handles mapping and route planning far more slowly.
Worked example 1
A planner runs at 5 Hz and a position loop at 200 Hz. How many position updates per plan, and what is the position loop's period?
200 ÷ 5 = 40 position updates per plan. Period = 1/200 s = 5 ms.
Common mix-ups
Faster is always better, so run every loop as fast as possible.
✓ Each loop needs a rate matched to its dynamics. Over-fast loops waste computing; heavy jobs may not even finish in time.The update rate is a software detail you can choose later.
✓ Rates decide processors, buses and stability, so they belong on the block diagram from the start.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
For a line-following robot, list four loops (motor current, wheel speed, line tracking, lap strategy). Give each a rate with a one-line justification based on how fast its quantity changes, and calculate the updates per decision between each pair.
Reflect
Where in your own day do you make fast corrections inside a slow plan?
Write your answer on paper or in your own notes. Lite never stores what you write.