Skip to content

With Block Predictor

Run the With Block Predictor MicroSim Fullscreen

You can include this MicroSim on your website using the following iframe:

<iframe src="https://dmccreary.github.io/robot-arm/sims/with-block-predictor/main.html"
        height="664px" width="100%" scrolling="no"></iframe>

Description

Step through six short Python programs that use a fake robot arm and watch what happens to the error and to the torque. Then predict the outcome of each program before it is run. Used in Chapter 10.

Each program fails in some way: a target beyond a joint limit, a read before connect(), or a write that the fake arm was told to refuse. The lamp shows whether the torque is on, and the line under it shows whether the error was raised, caught, or is continuing upward.

The programs are illustrative. They use the Arm class and the FakeArm of the Chapter 10 lab, where with arm: calls connect() at the start of the block and disconnect() at the end, even when an error is raised.

Lesson Plan

Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.

  1. Predict first. Read program 1. Before you press Step, say what will happen to the error and to the torque.
  2. Step through. Press Step and watch each event: the connect, the limit check, the error, the cleanup. Was your prediction right?
  3. Compare programs 1, 2 and 3. They make the same bad move. Which lines decide whether the torque is still on at the end?
  4. Six programs. Switch to Six programs. Choose an outcome by its letter before the program is run. You get one try for each.
  5. Think about it. A with block does not hide an error. Why is that the safe choice for a robot arm?

Specification

The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 10: A Python Hardware Library for Robot Arms.