Lab Partner Names: ________________________________________________
15-494/694 Cognitive Robotics: Lab 2
I. Software Setup
- 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".
- 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.
- Get a robot from the cabinet.
- Take a VEX AIM Odometry Test
Sheet and tape it down to the table you're working on.
- 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
- 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.
- Place the robot on the test sheet as indicated.
- Type
robot.set_pose(0,0,0,0) in simple_cli to zero everything out.
- Type
show pose to verify that the pose is reset.
- Tell the robot to drive forward 100 mm by typing:
Forward(100).now()
- Mark the robot's front ending position with your pen.
- Do
show pose again and enter the x coordinate in the table.
- 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.
- 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 | | | | |
- 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
- 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.
- 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 | | | | |
- 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
- Create a lab2 folder in your Cogrob folder. Do not put it
inside the vex-aim-tools folder.
- cd to your lab2 folder.
- 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")
}
- In the shell, type the command
genfsm Example1.fsm . The
should produce an Example1.py file.
- In the shell, run simple_cli.
- 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.
|