Lab Partner Names: ________________________________________________

15-494/694 Cognitive Robotics: Lab 2

I. Software Setup

  1. Our software is changing rapidly, so at the start of every lab you should update your copy. If you installed vex-aim-tools using git, just cd to that folder and do "git pull".

  2. If you're using Virtual Andrew and installed vex-aim-tools from a zip file, cd to your CogRob folder, delete your entire vex-aim-tools folder, download the latest zip file, move it to your CogRob folder, and extract the files.

  3. Get a robot from the cabinet.

  4. Take a VEX AIM Odometry Test Sheet and tape it down to the table you're working on.

  5. Open a shell, activate your Python environment (or run setup.ps1 on Virtual Andrew; see the updated install instructions), and then run simple_cli.

II. Investigate VEX AIM Odometry: Translation

  1. You can do this part of the lab in teams of 2. Write both your names on the sheet. You only need to turn in one sheet at the end of the lab.
  2. Place the robot on the test sheet as indicated.
  3. Type robot.set_pose(0,0,0,0) in simple_cli to zero everything out.
  4. Type show pose to verify that the pose is reset.
  5. Tell the robot to drive forward 100 mm by typing: Forward(100).now()
  6. Mark the robot's front ending position with your pen.
  7. Do show pose again and enter the x coordinate in the table.
  8. Measure the distance from the front edge starting mark to your pen mark (eyeball it using the 5 mm reference lines) and enter that distance the last column of the table.
  9. Repeat the above steps to complete the table.

    Test of Forward(100)
    Trial Initial pose x Final pose x Pose Difference Measured Difference

    1


    2


    3


    4


    5

  10. How good is the robot's odometry? Calculate the mean and standard deviation of the Pose Difference and Measured Difference values. You can use numpy.mean() and numpy.std() for this. (You'll need to import numpy first.)

    Pose Difference Mean: __________       Std. Dev: __________

    Measured Difference Mean: __________       Std. Dev: __________

III. Investigate VEX AIM Odometry: Rotation

  1. We want to perform a similar test of the robot's rotation accuracy. The Turn() node causes the robot to rotate about its center, which is also its origin. Let's use 180 degree turns for our tests.
  2. Zero the pose and have Cozmo make 180 degree turns using Turn(180).now() and record the results. Use degrees, not radians, in your measurements. Estimate the turn angle visually.

    Test of Turn(180)
    Trial Initial heading Final heading Heading Difference Measured Difference

    1


    2


    3


    4


    5

  3. How accurate is Turn()? Calculate the mean and standard deviation of the Heading Difference and Measured Difference values.

    Heading Difference Mean: __________       Std. Dev: __________

    Measured Difference Mean: __________       Std. Dev: __________

IV. Write Your First State Machine

  1. Create a lab2 folder in your Cogrob folder. Do not put it inside the vex-aim-tools folder.

  2. cd to your lab2 folder.

  3. Using your favorite text editor, create a file called Example1.fsm in your lab2 folder with the following content:
        from aim_fsm import *
    
        class Example1(StateMachineProgram):
          $setup{
            Forward(50) =C=> Say("Hello there")    
          }
    
  4. In the shell, type the command genfsm Example1.fsm. The should produce an Example1.py file.

  5. In the shell, run simple_cli.

  6. In simple_cli, type the command runfsm("Example1") to run your example.

Pro tip: never edit the .py file. Only edit the .fsm file and then use genfsm to regenerate the .py file.

V. State Machine Programming (Homework)

Do this portion on your own, not with a partner, for homework. You may want to review the Finite State Machine lecture notes first. Write the following programs using the state machine shorthand notation we covered in class:
  • Write a version of the Metronome program (see lecture 3 slides) that alternately says "tick" and then "tock", and simultaneoulsy glows the robot's LEDs red for each "tick" and blue for each "tock", with a beat every 2 seconds. To glow red, do Glow(vex.LightType.ALL, vex.Color.RED). Colors are defined in vex.py.

  • Write a program Fanta.fsm that makes the robot glow orange whenever an orange barrel is visible. See the lecture 3 slides. When no orange barrel is visible the LEDs should turn off. You can get a nice shade of orange using Glow(vex.LightType.ALL, 250, 20, 0).

  • Run GPT_test and ask Celeste to tell you the RGB code for "teal". Then ask for the RGB code for "forest green".

  • Copy the file GPT_test.fsm into your lab2 directory and rename it Glow_test.fsm. Open the file in an editor and change the name of the main class from GPT_test to Glow_test. Study the preamble string. Modify the preamble so that when you ask Celeste to glow a color, she looks up the rgb code for that color and then outputs the string "#glow R G B".

  • Following the examples in the file, write a CmdGlow() node and add state machine logic to perform the #glow action.

  • Test your program by asking Celeste to glow "lime green", "goldenrod", and "navy blue".

Hand In

Collect your Metronome.fsm, Fanta.fsm, and Glow_test.fsm files hand them in through Canvas by next Friday.


Course home page