Driving · Robot club · about 15 min
Tell the robot how far, not how long. Where it thinks it is.
[1 mark]What changes when you add distance=20 to forward(60)?
Tick every answer that is true.
[1 mark]How does the robot know how far it has gone?
[1 mark]The robot starts at (0, 0) facing forward, drives forward 30 cm, then backward 10 cm. Roughly what does position() say?
[1 mark]When is driving on, not waiting printed?
print("starting")
forward(60, distance=25)
print("arrived")
forward(60)
print("driving on, not waiting")
wait(1)
stop()[1 mark]forward(100, distance=20) usually lands further from 20 than forward(30, distance=20). Why?
[1 mark]The robot drives forward(60, distance=20) then forward(60, distance=40). Roughly how many centimetres forward of the start does it end? Give a whole number.
[1 mark]There is a line 30 cm ahead that the robot must stop before. Which is the safest plan?
forward(40, distance=27)forward(100, distance=30)forward(100) then wait(3) then stop()forward(40, distance=33)Drive 20 cm, print after 20: followed by position(), then drive 40 cm more and stop inside the green band 60 cm from the start.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# drive forward at 60 for 20 cm, then stop
forward(60, distance=20)
print("after 20:", position())Plan your program here, then type it in and press Run.
position() each time. How much does the error grow?forward(speed, distance=20) lands closest to 20.