The robot as a system · University · about 25 min
How often the loop runs, how late the answer arrives, and what both do to a controller.
[1 mark]This drive takes about a quarter of a second to get most of the way to a new speed. Which of the three times in the lesson is that?
[1 mark]The drive's time constant is about 0.25 s. Which loop rate does the lesson's rule of thumb favour?
[1 mark]Why can too much delay make a feedback loop unstable?
[1 mark]A loop oscillates because its information is late. Which of these are fixes from the lesson?
Tick every answer that is true.
[1 mark]A loop asks for wait(0.05), and each pass also spends 0.012 s in distance() and 0.018 s in scan(). What does this print?
work = 0.012 + 0.018
requested = 0.05
period = requested + work
print("period:", round(period, 3), "s")
print("rate:", round(1 / period, 1), "Hz")[1 mark]The heading-hold loop works out its error with wrapped(). With clockwise-positive heading, what does this print?
def wrapped(a):
return (a + 180) % 360 - 180
print(wrapped(0 - 350), wrapped(0 - 10), wrapped(190))Drive into the green zone, and from three seconds onwards stay within 8 degrees of heading 0. This robot pulls hard to one side, so the loop has to be doing real work all the way.
from bugbot import *
connect()
def wrapped(a):
return (a + 180) % 360 - 180
# drive, correcting as you go, and keep correcting once you are there
forward(70, distance=130)
stop()Plan your program here, then type it in and press Run.
wait(0.03) and with wait(0.07). The simulator gives exactly 0.03 and 0.07. Add a line inside the loop that works something out for a long time, such as sum(range(1000000)). Does the period change in the simulator? Would it on the robot?