The robot as a system · University · about 20 min
The control loop, its period, and the deadman that stops a robot whose program has gone quiet.
[1 mark]Put the body of the control loop in order, as it runs on every pass.
Number the lines 1 to 4 to put them in the right order.
act(command)wait(period)command = decide(measurement)measurement = sense()[1 mark]A loop ends each pass with wait(0.1) and does nothing else that takes noticeable time. How often does it run, and roughly what is the fastest disturbance its measurements can represent properly?
[1 mark]A loop has a period of 0.04 s. What is its rate in Hz?
[1 mark]A loop calls wait(0.1), and the sensor reads and arithmetic in each pass take a further 0.03 s. This works out the rate it really runs at. What does it print?
work = 0.03
period = 0.1 + work
print("rate:", round(1 / period, 1), "Hz")[1 mark]A program calls forward(60) once and then wait(2), with no other commands. What does the robot do?
[1 mark]Why does every controller in the course use forward(60) followed by wait(0.1), rather than forward(60, distance=40)?
[1 mark]Which of these are set directly by the loop's period?
Tick every answer that is true.
Without driving, read the depth sensor thirty times at ten times a second, print each reading, and print how long the loop actually took on average, as period: 0.1.
from bugbot import * connect() # clock() is the seconds since the program started start = clock()
Plan your program here, then type it in and press Run.
clock() inside the loop. Is the spacing exactly 0.1 s?forward(60) in a loop of thirty with no wait at all in it. Why does the robot not move in the simulator, and what would a real BugBot do?