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)[1 mark]What does this program print?
speed = 60
y = 19.8
print(f"speed {speed}: asked 20, got {y}")[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()
Plan your program here, then type it in and press Run.
precise_forward(cm) that does the fast-then-slow trick for any distance.precise_turn(deg).