Lab Partner Names: ________________________________________________
15-494/694 Cognitive Robotics: Lab 2
I. Software Update and Initial Setup
- You should update your copy of the cozmo-tools package at the
start of every lab. Do this:
$ cd ~/cozmo-tools
$ git pull
- Get a robot, a charger, and a Kindle from the cabinet. You will
not need light cubes for this lab, and in fact you do not want Cozmo
to see any light cubes while you're testing his odometry.
- Log in to the workstation.
- Raise and lower Cozmo's lift to reveal the robot's network name
and WiFi password.
- Connect the Kindle to the robot's WiFi network. The Kindle's
WiFi Settings page will tell you "Internet service not working".
That's because you're connected to a robot, not the Internet. It's
normal.
- Connect the Kindle to the workstation via its USB cable.
- Run the Cozmo app and put it into SDK mode.
- Open a shell on the workstation and type "simple_cli".
- Take a Cozmo Odometry Test Sheet
and tape it down to the table you'll be working on.
II. Investigate Cozmo's 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.
- Place Cozmo on the test sheet as indicated. If you use a pen to mark his lift position,
the mark should end up right on top of the thick black line.
- Type
robot.pose and enter Cozmo's initial x coordinate in the table below.
- Tell Cozmo to drive forward 100 mm by typing:
Forward(100).now()
- Mark his ending position with your pen.
- Look at
robot.pose and enter the x coordinate in the table.
- Measure the location of your pen mark (eyeball it using the reference lines) and enter
that in 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 Cozmo'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. Test of DriveForward
- Forward() uses the
robot.drive_straight() action.
Now we're going to repeat the test using the DriveForward() node,
which uses robot.drive_wheels() to move the wheels and does
its own check (in Python) of distance traveled.
- Follow the same steps as before, but using
DriveForward(100).now() , and fill in the table below.
Test of DriveForward(100) |
Trial |
Initial pose x |
Final pose x |
Pose Difference |
Measured Difference |
1 | | | | |
2 | | | | |
3 | | | | |
4 | | | | |
5 | | | | |
- How accurate is DriveForward? Compare Calculate the mean and
standard deviation of the Pose Difference and Measured Difference
values.
Pose Difference Mean: __________ Std. Dev: __________
Measured Difference Mean: __________ Std. Dev: __________
- The reason DriveForward is less accurate is that when the robot
reaches the desired distance, it doesn't stop immediately. The code
for DriveForward sets the wheel speeds to 0, but the implementation of
this operation uses a gradual deceleration rather than a sudden stop,
so the robot moves a little further than intended.
IV. Investigate Cozmo's Odometry: Rotation
- We want to perform a similar test of Cozmo's rotation accuracy.
The Turn() node uses
robot.turn_in_place() , which is a
Cozmo action. Let's use 90 degrees for our tests.
- Have Cozmo make 90 degree turns using
Turn(90).now()
and record the results. Use degrees, not radians, in your
measurements. Estimate the turn angle visually.
Test of Turn(90) |
Trial |
Initial angle_z |
Final angle_z |
Angle Difference |
Measured Difference |
1 | | | | |
2 | | | | |
3 | | | | |
4 | | | | |
5 | | | | |
- How accurate is Turn? Calculate the mean and standard deviation
of the Angle Difference and Measured Difference values.
Angle Difference Mean: __________ Std. Dev: __________
Measured Difference Mean: __________ Std. Dev: __________
V. Test of DriveTurn
- Like DriveForward, DriveTurn sets Cozmo's wheel speeds directly
and is not an action, so it does not lock an action track. Perform
an experiment to measure the accuracy of DriveTurn.
Test of DriveTurn(90) |
Trial |
Initial angle_z |
Final angle_z |
Angle Difference |
Measured Difference |
1 | | | | |
2 | | | | |
3 | | | | |
4 | | | | |
5 | | | | |
- How accurate is DriveTurn? Calculate the mean and standard deviation
of the Angle Difference and Measured Difference values.
Angle Difference Mean: __________ Std. Dev: __________
Measured Difference Mean: __________ Std. Dev: __________
- DriveTurn is less accurate than Turn for the same reason that
DriveForward is less accurate than Forward. But DriveTurn has some
advantages over Turn: (1) it accepts an optional speed argument, and
(2) it can turn by any amount rather than being limited to angles less
than 180 degrees.
- Write down the number of your robot (there's a sticker on the bottom).
Robot number: _______________
- Hand in this sheet to your lab instructor. Make sure your names are on it.
VI. 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 and the
examples in cozmo_fsm/examples first. Write the following programs
using the state machine shorthand notation we covered in class:
- Square.fsm: make the robot move along a square 100 mm on a
side. After it finishes moving it should say "Cozmo squared".
- LoveHate.fsm: make the robot react to the cubes. If
cube1.is_visible is True, the robot should turn to face
that cube. If the robot sees cube2 it should turn its back to it,
i.e., turn so that cube2 is directly behind it. In either case,
simultaneously with turning, the robot should say "love it" or "hate
it". If the robot doesn't see any cubes, it shouldn't turn or say
anything.
The behavior should loop so that the robot constantly looks for cubes,
and you can move the cubes and watch the robot react. Test your
behavior by placing cubes at various locations within the robot's
field of view.
Hint: the bearing of a cube in radians (in the world reference frame)
is equal to atan2(ydiff,xdiff), where the cube's x and y can be
extracted from cube.pose.position.x, and similarly for the
robot's x and y. atan2 is part of the math package, which you'll need
to import. Remember to convert to degrees before turning. Also, you
must subtract the robot's current heading from the bearing to get the
turn angle.
- LightCycle.fsm: When this behavior starts, cube 1 should
glow red, cube 2 should glow green, and cube 3 should go blue.
Then, any time a cube is tapped, all three cubes should shift
colors: the red cube should glow green, the green clube should glow
blue, and the blue cube should glow red. You can use the SetLights
node to change a cube's color. Read the SDK documentation for
"Light" to understand how lights work. Use the state machine
formalism's fork/join mechanism to perform all three color changes
at once; that is the main point of this exercise.
Hand In
Collect yourSquare.fsm, LoveHate.fsm, and LightCycle.fsm files into a
zip file called handin.zip.
Hand in your work through AutoLab by next Friday.
|