The answersDownload the PDF
Worksheet

6.6 Bumps and stalls

Seeing more · Robot club · about 20 min

BugBotLab
NameClassDate

What this lesson is about

bumped(), stalls from velocity, back off and go round.

Questions 7 marks in all

  1. [1 mark]The robot drives into a 2 cm tall box, but distance() never saw it. Why?

    1. AThe depth sensor's level rows look straight over the top of it
    2. BThe box is the same colour as the mat
    3. Cdistance() only works when the robot is still
    4. DThe camera was switched to the line detector
  2. [1 mark]Which sensor does bumped() use?

    1. AThe accelerometer in the IMU, which feels the jolt
    2. BThe camera
    3. CThe distance sensor
    4. DThe optical-flow sensor
  3. [1 mark]How does the stall check know the robot is stuck?

    1. AIt compares the real speed from velocity() with the speed it asked for
    2. BIt waits for bumped()
    3. CIt checks whether distance() is under 5
    4. DIt counts how long the program has run
  4. [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
  5. [1 mark]Which of these can a stall check catch that bumped() might miss?

    Tick every answer that is true.

    1. AA slow push into a wall
    2. BDriving off the edge of a table onto nothing
    3. CA tag 30 cm ahead
    4. DAnother robot's LED changing colour
  6. [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.

    1. go: drive forward until `bumped()`
    2. back: drive backward for a few ticks
    3. side: slide right for a few more ticks
    4. go: carry on forward
  7. [1 mark]After a bump, a tag is right in front of you. What is the polite response?

    1. AIt is probably a robot, so wait rather than shove
    2. BIt is a wall, so back off and go round
    3. CDrive harder to push through
    4. DTurn the camera off

The task: bump and back

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.

QR code
Do it on the robot
www.bugbotlab.com/learn/6-6-bumps-and-stalls/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Count the bumps and print the total at the end.
  2. Use the stall check instead of bumped() and see which reacts first.
  3. After the bump, sidestep only until distance() in the level rows shows the way is clear.