Driving · Robot club · about 15 min
Strafing: moving without turning, the thing wheels cannot do.
[1 mark]What is strafing?
[1 mark]What does this program make the robot do?
forward(60, distance=20) right(60, distance=20) backward(60, distance=20) left(60, distance=20)
[1 mark]Why is strafing useful? Choose all that apply.
Tick every answer that is true.
[1 mark]What does drive(60, -60, 0) do?
[1 mark]Why does drive need a wait and a stop around it?
drive is the raw command the others are built from. It starts the motors and returns, like forward(speed) with no distance.[1 mark]What does this program print?
p = (12.5, 30.0)
print("moved right to x =", p[0])moved right to x = 12.5
Like a list, [0] picks the first item, which for a position is x. [1] would be y.
[1 mark]What does drive(60, 0, 20) with a wait(3) make the robot do?
There is a wall between you and the green square. Get the robot into the square within 20 seconds without touching the wall. The wall is 20 cm wide and the square 20 cm beyond it. Forward, sideways, forward, sideways, and no turning needed. Remember the margin for coasting.
# 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) # your turn: go round the wall and into the square
The hint students can ask for: The wall is in the way. Drive round it, or use distance() to find it. The robot coasts a little after stop(), so leave a margin.
from bugbot import * connect() forward(60, distance=20) right(60, distance=25) forward(60, distance=45) left(60, distance=25)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.