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. Since you installed vex-aim-tools using git, just cd to that folder and do "git pull".

  2. Get a robot from the cabinet.

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

  4. Open a shell, activate your Python environment, 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 Pose Difference column of 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 in the Measured Distance 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 np.mean() and np.std() for this.

    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 the robot 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. This 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 "toc", and simultaneoulsy glows the robot's LEDs red for each "tick" and blue for each "toc", with a beat every 2 seconds. (Note: Google Text-to-Speech sometimes gets confused by "tock", which is why you should write "toc" instead, but you also need to write "tick" and not "tic".) To glow red, do Glow(vex.LightType.ALL_LEDS , vex.Color.RED). Colors are defined in vex/vex_types.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_LEDS, 250, 20, 0).

  • The VEX AIM robot can move in a direction other than the one in which it is pointing. Try this expression in simple_cli: MoveFor(100, 45).now(). Let's call this diagonal move a "sashay". MoveFor is defined in nodes.py.

    Copy the file Celeste.fsm into your lab2 directory and rename it Sashay_test.fsm. Open the file in an editor and change the name of the main class from Celeste to Sashay_test. Study the preamble string. Modify the preamble so that when you ask Celeste to sashay left or right by 100 mm, she outputs a string like "#sashay 45 100" or "#sashay -45 100".

    Following the examples in the file, write a CmdSashay() node using MoveFor.

    Add state machine logic to call CmdSashay at the appropriate time. Test your program by asking Celeste to sashay by various amounts.

Hand In

Collect your Metronome.fsm, Fanta.fsm, and Sashay_test.fsm programs into a zip archive and hand them in through Canvas by next Friday.


Course home page