Control · Robot club · about 15 min
Speed from the remaining distance, the dead band, clamping.
[1 mark]The bang-bang park drives at 60 until distance() is 22 or less, then stops. Where does it end?
[1 mark]Target 22, gain 4, and distance() reads 32. What speed does speed = (distance() - target) * 4 ask for?
[1 mark]The plain proportional park stalls a little short of the target. Why?
[1 mark]What does this program print?
for value in [4, 30, 250]:
print(max(16, min(60, value)))[1 mark]In the clamped park, the robot overshoots and distance() reads 18. What does it do?
error = distance() - target
speed = max(16, min(60, abs(error) * 4))
if error > 0:
forward(speed)
else:
backward(speed)[1 mark]Put the three lines of every P controller in order.
Number the lines 1 to 3 to put them in the right order.
output = clamp(error * gain)apply(output)error = target - measuredStop with the front of the robot 20 to 24 cm from the wall, the green band, without touching the wall.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# as long as the thing ahead is further than 22 cm
while distance() > 22:
# drive forward at 60 (keeps going until the next command)
forward(60)
# pause 0.1 s (the robot keeps doing what it was told)
wait(0.1)
# all motors off
stop()Plan your program here, then type it in and press Run.
target.