Seeing more · Robot club · about 20 min
bumped(), stalls from velocity, back off and go round.
[1 mark]The robot drives into a 2 cm tall box, but distance() never saw it. Why?
distance() only works when the robot is still[1 mark]Which sensor does bumped() use?
[1 mark]How does the stall check know the robot is stuck?
velocity() with the speed it asked forbumped()distance() is under 5[1 mark]What does this program print?
speeds = [0, 10, 25, 30, 29, 28, 1, 0]
for tick, vy in enumerate(speeds):
if tick > 5 and vy < 2:
print("stalled at tick", tick)
break[1 mark]Which of these can a stall check catch that bumped() might miss?
Tick every answer that is true.
[1 mark]Put the states of the bump and back behaviour in the order they run after a bump.
Number the lines 1 to 4 to put them in the right order.
go: drive forward until `bumped()`back: drive backward for a few ticksside: slide right for a few more ticksgo: carry on forward[1 mark]After a bump, a tag is right in front of you. What is the polite response?
Reach the green zone past a box the depth sensor cannot see, printing bumped when you hit it.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
while position()[1] < 80:
# drive forward at 60 (keeps going until the next command)
forward(60)
# pause 0.1 s (the robot keeps doing what it was told)
wait(0.1)
# all motors off
stop()Plan your program here, then type it in and press Run.
bumped() and see which reacts first.distance() in the level rows shows the way is clear.