Activity: First Law

Code Materials


In this exercise, students will be exploring Cozmo's visual perception/recognition and the First Law of Calypso.


Part 1: Basic Vision

  1. Run Calypso. Start out with an empty program.

  2. Make the camera viewer as big as possible (size 2X) and move it to a convenient location. (To adjust the camera viewer, use the mouse to put the cursor into the camera viewer window to make the title bar appear; then click and drag on the title bar. See video.)

  3. Show the robot one cube and note its presence in the camera viewer.

  4. If you cover part of the cube with your finger, Cozmo can no longer recognize it: the yellow outline disappears. How much of the cube can you cover before Cozmo can't recognize it? Do some parts matter more than others?

  5. Cozmo is a bit near-sighted. If the cube is too far away, he won't recognize it. Try moving the cube back until Cozmo can no longer see it. If you move it a little closer, he should be able to see it again.

    Using a ruler or tape measure, figure out how far the cube can be before Cozmo loses sight of it.

Part 2: The World Map

  1. Enter execution mode (press the Back button on the controller).

  2. Show Cozmo a cube and notice that it appears on the world map.

  3. Slide the cube around and note how it moves on the world map. Make sure your fingers don't cover the front of the cube; you want Cozmo to always be able to see it.

  4. Rotate the cube and note how it rotates on the world map.

  5. Put your hand in front of Cozmo's face to block his view. Notice that the cube goes gray, indicating that he cannot see it. But he still knows it's there, because it's on his map.

  6. Gently move or rotate the cube slightly while the robot's view is blocked. Then remove your hand and notice that the world map updates automatically.

  7. Tap on a cube and notice that it "bounces" in the world map.

  8. Pick up the cube and put it down outside of Cozmo's field of view. Notice that the cube disappears from the world map and goes into the "dock" in the top right corner of the screen.

  9. Put the cube back in front of Cozmo and it will reappear on the world map.

Part 3: Seeing Cubes

  1. Set up the two FirstLaw pages as shown in the figure and tape them to the table.

    Put Cozmo on his charger.

  2. Run the FirstLaw demo. (If you are reading this page in a web browser and have Calypso running, you can click on the FirstLaw.calypso link and the program will be automatically be loaded into Calypso.) The program starts out with a single rule: "WHEN see cube DO".

  3. Put a cube in square A.

    In the world map you will see a red line called an Line of Sight (LOS) indicator. It shows you which cube Cozmo is paying attention to.

  4. Put another cube in square E.

    The "WHEN see cube DO" rule will pick one of the cubes, so only one cube will have the LOS indicator pointing to it. Which one? Have students discuss this.

    • The rule sticks with whichever cube it saw first.
    • The rule always picks the rightmost cube.
    • The rule always picks the closest cube.
    • The rule picks a cube at random, but sticks with it.

  5. Try moving the cubes to different squares and see what the LOS indicator does. For example, if you have cubes in squares A and E, and you move the square A cube to square H, the LOS indicator will switch to the other cube.

    You've just discovered the First Law of Calypso: each rule picks the closest matching object. What if we have more than one rule?

  6. Add a second rule to the program, so it looks like this:

  7. Run the program, and put a cube in square A. Remove any other cubes. The first rule can run, and it has an LOS indicator pointing to the cube. The second rule cannot run because the cube is not red.
  8. With the FirstLaw program, tapping on cubes changes their color.

    Tap on the cube to turn it red.

    Now both rules can run, and you should see two LOS indicators pointing to the same cube.

  9. Place a second cube in square E.

    Cozmo sees both cubes, but both rules still choose the cube in square A.

  10. If you tap on the cube in square A so it changes to some color other than red, what will happen? Try it. You should see the second rule go gray again.

  11. If you now tap on the cube in square E so it turns red, what will the LOS indicators look like? Try it and see. The first rule will pick the cube in square A, but the second rule will pick the cube in square E, so both cubes will have LOS indicators pointing to them.

  12. Now tap on the cube A until it's red again. Now both cubes are red. What do the LOS indicators do?

  13. In-class exercise: write down some combination of "WHEN see" rules, give students a configuration of cube positions and colors (red, blue, green, or none), and ask them to predict the LOS indicators.

Part 4: Finding the Limits of Cozmo's Visual Field

  1. Using a magic marker and keeping an eye on Cozmo's camera view, draw a series of dots on the printed pages at the edges of his sight (ie. where he can just barely see the marker).

  2. Connect the dots to form two diagonal lines spreading out from Cozmo. These lines show Cozmo's field of view, meaning that a cube must lie within these lines in order for him to see it.

  3. If you remove the charger, you can extend the two lines until they cross. Students can then use a protractor to measure the angle between the two lines to estimate Cozmo's field of view in degrees. (You should get a value around 60 degrees.)

Back to top of page
Back to New Brighton Curriculum