Driving · Robot club · about 15 min
Coasting, overshoot, and why fast and accurate pull in different directions.
[1 mark]The robot drives by time at speeds 30, 60 and 100, then stop(). Which slides furthest after the motors switch off?
[1 mark]How does distance= allow for coasting?
[1 mark]Why drive forward(100, distance=15) and then forward(25, distance=5), instead of 20 cm at 100?
[1 mark]You want to stop 50 cm ahead, with the last 8 cm at a slow speed. What distance should the fast forward be? Give a whole number of centimetres.
[1 mark]What does this program print?
errors = []
for y in [20.1, 20.3, 19.6]:
errors.append(round(y - 20, 1))
print("errors:", errors)errors: [0.1, 0.3, -0.4]
Each error is where the robot got to minus 20. A negative error, like -0.4, means it stopped short.
[1 mark]What does this program print?
speed = 60
y = 19.8
print(f"speed {speed}: asked 20, got {y}")speed 60: asked 20, got 19.8
In an f-string the names inside curly brackets are replaced by their values.
[1 mark]A fast turn overshoots by about a degree. Why does that matter?
Stop with the robot's centre within 2 cm of the small square 50 cm ahead, having driven at least 40 cm. The starter times the drive; timing is never that accurate.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() # drive forward at 100 (keeps going until the next command) forward(100) # pause 2.5 s (the robot keeps doing what it was told) wait(2.5) # all motors off stop()
The hint students can ask for: Stop with the robot's centre within 2 cm of the small square 50 cm ahead. Timing a drive is never that accurate: measure it.
from bugbot import * connect() forward(100, distance=44) forward(25, distance=6)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.