Control · Robot club · about 15 min
Correct in proportion to the error. Gain, sign, feedback.
[1 mark]What does a proportional controller do?
[1 mark]The gain is 4 and the heading error is 7.5 degrees. What rotation does drive(70, 0, error * 4) ask for?
[1 mark]What does this program print?
def wrapped(h):
return (h + 180) % 360 - 180
for heading in [10, 350]:
error = wrapped(0 - heading)
print(heading, error * 4)10 -40 350 40
Facing 10, the robot is right of the target, so the rotation is negative and turns it back left. Facing 350, it is left of the target, so it turns right.
[1 mark]You write drive(70, 0, -error * 4) by mistake. What happens?
[1 mark]Why is it called a feedback loop?
for loop[1 mark]Why does the P controller not need bursts and settling like the crude fix?
Drive into the green zone and finish still facing 0, within 6 degrees, on the curving robot.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() # drive forward at 70 for 70 cm, then stop forward(70, distance=70)
The hint students can ask for: This robot curves to the right whenever it drives. Steer against the heading error while driving, and finish in the green zone still facing 0.
from bugbot import *
connect()
def wrapped(h):
return (h + 180) % 360 - 180
while position()[1] < 65:
error = wrapped(heading())
drive(70, 0, -error * 4)
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.