Control · Robot club · about 15 min
The error and its sign, wrapping headings, bang-bang control, overshoot.
[1 mark]What does this program print?
def wrapped(h):
return (h + 180) % 360 - 180
print(wrapped(200))
print(wrapped(350))[1 mark]A controller uses error = target - measured. The target heading is 90 and the robot faces 60. What is the error? Give a whole number.
[1 mark]What is bang-bang control?
[1 mark]The bang-bang loop calls stop() when the error is under 2 degrees, but the robot ends further off. Why?
[1 mark]What does this program print?
for error in [30, -10]:
speed = 60 if abs(error) > 25 else 20
print(error, speed)[1 mark]What does break do inside while True:?
[1 mark]What is the problem with the crude fix: fast when far, then short slow bursts with a pause?
Spin until the robot faces 0 within 3 degrees, printing error: and the error every time round the loop. Do not drive anywhere.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
print("heading:", heading())Plan your program here, then type it in and press Run.
for over the targets.