Challenge 1
Add the running total: reset it to zero at the START of every Follow Line call, add the error to it each pass, and hold it at a cap you choose. Add Ki as a fourth input, set it to zero, and prove nothing changed.

EV3 Robotics›Level 4 · WRO Prep›Lesson 29
Level 4 · Lesson 29 · EV3-L04-2960 minutes · Block 4 of 6 · Mat: WRO 2024 — Earth Allies, Sustainable Farming
Close the gap that would not close — and learn the order the three gains must be tuned in.
Two lessons ago you found a gap on the curve that no gain could remove. Yesterday D let you raise the gain, which made the gap smaller without ever closing it. Today you add the term that closes it, and you leave with a tuning procedure you can apply to any controller, not just this one.
I is the term that misbehaves. P makes the robot weave, D makes it buzz, and I makes it wallow — or, if it goes wrong, throws the robot off the mat entirely. It is worth understanding before you type a number.
The marked curve on your fast leg is the whole test today. It is the only place the steady gap appears, and it is the only thing I is for.
Measure the gap once with yesterday’s best Kp and Kd before you change anything. That is today’s starting number, and it is probably a few millimetres.
Keep the straight marked too. You will need it to check that adding I has not spoiled anything that already worked.
The gap survives because proportional control needs an error to produce a correction. On a constant curve the robot needs a constant turn, so it settles wherever the error is just big enough to produce it, and stays there. Neither P nor D objects: P is producing exactly what it should, and D sees no change at all.
So add a term that objects to an error that lasts. Each pass round the loop, add the current error to a running total. If the error is small but never goes away, the total climbs and climbs, and eventually the correction it produces is enough to push the robot onto the line.
That is the I term — integral, meaning accumulated. Multiply the running total by its own gain Ki and add it in. Then the full controller is:
Steering = Kp × error + Ki × total + Kd × change
Three terms, three questions about the same error: how big is it, how long has it been there, and how fast is it changing. That is all PID is.
Windup is the failure to know about. If the robot loses the line, gets stuck against the greenhouses, or is lifted off the mat, the error stays large and the total keeps growing the whole time. Put it back down and it fires off a correction earned from ten seconds of being stuck. It looks like the robot has gone mad. It has simply remembered too well.
Two guards, both cheap:
And note the scale. The total grows every single pass, so it becomes a much larger number than the error itself. Ki is far smaller than Kp — start around a hundredth of it. A Ki that looks like a reasonable number next to Kp will send the robot off the mat on the first curve.
One more variable, and it needs the same care as yesterday’s.
Before the loop: set the total to zero, and set the previous error to zero.
Inside the loop, each pass:
Add Ki as a fourth input to Follow Line, alongside speed, Kp and Kd. Four numbers now describe a run completely, which is what makes the table worth keeping.
Set Ki to zero and run once. It must behave exactly as it did at the end of yesterday. If it does not, the arithmetic changed somewhere and that is the bug to find before any tuning starts.
Before tuning, learn to tell the three gains apart by how they fail. This is the difference between diagnosing and guessing, and it is the most portable thing in this block.
Learn these by causing them. Deliberately set each gain far too high, one at a time, and watch. Five minutes spent breaking it on purpose saves an hour of tuning by superstition — and in a competition, the ability to name a failure from across the table is worth more than any single set of numbers.
This is the procedure. It works on any PID controller, on any robot, and it is what you are really taking away from this block.
Change one gain at a time and run the leg after each change. Two changes at once and you have learned nothing about either.
Ki = 0 is a legitimate answer. If your gap is already down to a couple of millimetres after step three, adding I buys you very little and brings windup risk into a competition run. Plenty of good competition followers are PD, deliberately. Write down that you chose it, and why — that is a stronger journal entry than a Ki you cannot justify.
Run the marked leg twice with your final settings and record the three measurements: curve gap, swings, leg time. That row is what lesson 30 compares.
Then, if you used any I at all, test windup on purpose. Start the leg, hold the robot still against your hand for three seconds part-way along, and let go.
This is not a contrived test. A robot gets nudged, blocked or held up in real rounds, and a follower that goes wild afterwards will lose a mission you had already scored.
This is a keep-forever entry:
Bring three sets of numbers to lesson 30. The two-state follower from lesson 5, the proportional row you circled in lesson 27, and today’s PID row. Tomorrow puts all three over one leg and asks which one you should actually race — and the answer is not automatically today’s.
This model drives, so its challenges are run on a mat. Mats differ between branches — check you are looking at the one in your room.

WRO 2024 RoboMission Elementary — Earth Allies — Sustainable Farming · official WRO game mat, 2362 × 1143 mm
The challenges name these places rather than distances, so the same challenge works on any mat:
Switch mats above and every route below is redrawn on the mat you chose.
Work through the challenges in order — each is harder than the last. The mission comes after all three, and it is meant to make you plan before you build.
Add the running total: reset it to zero at the START of every Follow Line call, add the error to it each pass, and hold it at a cap you choose. Add Ki as a fourth input, set it to zero, and prove nothing changed.

Cause all three failures on purpose, one gain at a time set far too high, and write down what each looked like: P weaves fast, D buzzes, I wallows slowly. Naming a failure from across the table is worth more in a competition than any one set of numbers.

Tune in order and never two at once: P to the edge then back off, D until the weaving damps, P again, then I LAST and only if a steady gap remains — starting around a hundredth of Kp. Then hold the robot still for three seconds mid-leg and let go. If it lurches, the total wound up.

Record your final Kp, Ki and Kd with the speed they were tuned at, the gap and swings and time they produce, your I cap and what the windup test did — and write the tuning order out as four steps. Ki of zero is a legitimate answer if the gap is already small; say so and say why. The order is the part that transfers to every other controller you will ever tune.
