plot(): reading a control loop as a chart instead of a column of numbers.
[1 mark]Which three lines, plotted together, answer most questions about a feedback loop?
Tick every answer that is true.
- AThe measurement
- BThe error, target minus measurement
- CThe command you sent
- DThe battery voltage
- EThe loop period
Answer: A, B, C. The measurement says what the robot thinks is happening, the error says whether the loop is winning, and the command shows whether you are asking for more than the hardware can give.
[1 mark]The error stays large while the plotted command sits flat at 100. What is happening?
- AThe command is saturated, and no amount of extra gain will fix it
- BThe gain is too low and should be raised
- CThere is a steady state error, which needs an integral term
- DThere is too much delay in the loop
Answer: A. A command pinned at its limit means the hardware is already giving everything it has. More gain or an integral term only asks harder for what cannot be delivered.
[1 mark]The error settles smoothly, but to a steady value that is not zero. What does that shape mean?
- AA steady state error, which needs an integral term
- BUnder-damped: the gain is a little high
- CThe sign of the correction is wrong
- DSensor noise is reaching the motors
Answer: A. Settling somewhere other than zero is steady state error. The integral term in U5 is what removes it.
[1 mark]The error overshoots zero, comes back, and overshoots again by less each time. What does that shape mean?
- AUnder-damped: the gain is a little high, or there is some delay in the loop
- BThe correction has the wrong sign
- CA steady state error
- DThe loop is saturated
Answer: A. Decaying overshoot is under-damping. A wrong sign or far too much gain would make the error grow instead.
[1 mark]The plotted error gets bigger on every tick. What are the likely causes?
- AThe correction has the wrong sign, or the gain is far too high
- BA steady state error that needs an integral term
- CSensor noise reaching the motors
- DThe loop is running too fast
Answer: A. A growing error means the loop is making things worse: either it pushes the wrong way, or it pushes so hard it overshoots further each time.
[1 mark]A chart shows the error as a fuzzy band around zero, and the rotation command jitters along with it. What is reaching the motors?
Answer: sensor noise. Noise on the measurement passes straight through the gain into the command. Filtering it, in U4, is the fix.
[1 mark]A plot of believed y from odometry() and true y from position() shows two lines that start together and slowly separate. What does that picture show?
- ADead reckoning drifting away from the truth, which state estimation exists to prevent
- BA controller that is oscillating
- CA command that has saturated
- DThe lag of the drive after a step
Answer: A. The robot's belief accumulates error while the truth does not. Keeping those two lines together is the job of the estimators in U6 and U7.
Drive into the green zone under proportional control, plotting two lines as you go: error and rotation.
from bugbot import *
connect()
def wrapped(a):
return (a + 180) % 360 - 180The hint students can ask for: plot(name, value) once per loop, next to where you work the value out. Two names, two lines.
A solution
from bugbot import *
connect()
def wrapped(a):
return (a + 180) % 360 - 180
while position()[1] < 120:
error = wrapped(0 - heading())
rotation = error * 3
plot("error", error)
plot("rotation", rotation)
drive(70, 0, rotation)
wait(0.1)
stop()
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.