Control · Robot club · about 20 min
Sluggish, good, oscillating. Loop speed and driving speed.
[1 mark]With a gain of 1 on the curving robot, what happens?
[1 mark]With a gain of 40, the robot snakes. What is that called?
[1 mark]Rotation is capped at 100. With a gain of 40, above what heading error is the controller just bang-bang again? Give the number of degrees.
[1 mark]What does this program print?
errors = [5, 2, -1, -3, 1, 4, -2]
worst, flips, last = 0, 0, 0
for error in errors:
worst = max(worst, abs(error))
if error * last < 0:
flips += 1
last = error
print("worst", worst, "and", flips, "sign changes")[1 mark]Why is a high gain with a slow loop the worst combination?
[1 mark]In a sweep of gains, where is the good gain?
[1 mark]A gain works well at speed 50. What might happen at speed 100?
The zone is narrower and you have six seconds. The starter's gain of 40 wobbles and wastes time, and its speed is too low. Tune both.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
def wrapped(h):
return (h + 180) % 360 - 180
while position()[1] < 72:
error = wrapped(0 - heading())
# forward, sideways, rotation: -100 to 100 each, until the next command
drive(60, 0, error * 40)
# pause 0.05 s (the robot keeps doing what it was told)
wait(0.05)
# all motors off
stop()Plan your program here, then type it in and press Run.
gain = 4 * speed / 70.