Part I: Compile and Run a State Machine
- Compile the shorthand form of the Bark/Howl/Blink state machine
in the file BarkHowlBlinkBehavior.h.fsm,
by copying it to your ~/project directory and adding the necessary
#include and MENUITEM entries to UserBehaviors.h. Then type
"make"
- Load the file
~/project/build/PLATFORM_LOCAL/TGT_CHIARA/BarkHowlBlinkBehavior.h into
a text editor and look at the code the stateparser generated from the
shorthand description.
- Run the behavior on the Chiara. To do this, log in to the robot and type
"getmycode your_andrew_id", then type ./tekkotsu-CHIARA.
- In the ControllerGUI, go to Root Control > Status Reports >
Event Logger and select buttonEGID, stateMachineEGID, and
stateTransitionEGID. Run the behavior and look on the Tekkotsu
console to see the events scroll by.
Part II: Storyboard Tool
Review the Storyboard
Tool chapter of the Tekkotsu tutorial, which you should have read
prior to this lab.
Remember that you must run the Storyboard on your workstation, not on
the robot! Follow the instructions in the Downloading
a state machine model section of the Storyboard chapter to
download the model of your Bark/Howl/Blink state machine and create an
appropriate layout. Edit the layout to make it look like the diagram
in the tutorial. Note: to move a link, click on it, and a tiny dot
will appear in the middle of the arrow shaft. Click and drag on the
dot to move the link. Save the layout when you're done editing
it.
Run your state machine on the Chiara and generate an execution trace
using the Storyboard tool.
Before leaving the lab today, hand in (via email to
ilenz@andrew.cmu.edu) a screen capture showing your layout and the
execution trace. Include the names of everyone in your group. Note:
you can get a screen capture by going to the Gnome pulldown menu and
clicking on Applications > Accessories > Take Screenshot. If
you just want to capture one window, you can run Gimp and click on
File > Acquire > Screen Shot, then save the file as a JPEG or
PNG image.
Part III: State Machine Programming
You should start this part in the lab, and finish it for homework.
Your answers should be turned in as Homework 1, due Friday, January
29.
- Initializing a node's motion command. Write a simple state
machine that waits for a green button press event. When the event
occurs, it should flash the green LED for 1 second. How are you going
to do that? First, look over the documentation for LedNode.
You'll notice that a LedNode contains a motion command inside it, of
type LedMC. Read the documentation on LedMC. The
real work of calculating LED states is done by a parent class called
LedEngine. Skim the documentation on LedEngine
and you will find the cycle() and set() methods that were used in the
Bark/Howl/Blink example. There are more. Find a method for flashing
an LED. To determine the bitmask to use to access the green LED, look
in the file Tekkotsu/Shared/ChiaraInfo.h. How will you get back from your
LedNode to the node that waits for a button press?
- Smooth movement. You can use a HeadPointerNode to move the
robot's camera to look at a specific point in space. It contains a
HeadPointerMC motion command inside it. By chaining together a series
of these you can produce a complex head movement that will look
roughly the same no matter what configuration of head and neck joints
your robot has. First you'll want to use HeadPointerMC's
setMaxSpeed() method to slow down the motion so it doesn't jerk the
robot's head around violently. (0.2 is a good setting) The first argument
should be a joint
number; set the max speed for both joint 0 (PanOffset) and joint 1
(TiltOffset). Then you can use the lookAtPoint method to point the
camera.
Write a behavior to make the robot nod its head "yes". On startup the
behavior should move the head to a neutral position by looking at the
point (5000, 0, 400). Then, after a 2 second pause, it should
smoothly move the head down to (500, 0, -100), then back up to
neutral, then down again, and then back up.
- Parallel programming. Write a behavior that flashes a
repeating sequence of LEDs, red-yellow-green-blue, for 1 second each,
over and over. Asynchronously, your behavior should play a series of
three barks: barklow.wav, barkmed.wav, and barkhigh.wav, over and
over. In response to a green button press, reverse both the sequence
of lights and the sequence of nodes, and do it without losing your
place in the sequence, e.g., if you're currently in the forward
sequence and lighting the green LED, you would normally light the blue
one next, but if you get a button press you immediately switch to the
yellow LED and start running backwards; the sound should immediately
switch too. Another green button press should switch the light and
sound sequences back to their original order. Note: don't do anything
weird like trying to dynamically change the structure of the state
machine. Just write separate parts for the forward and reverse
sequences and include appropriate transitions between them.
After you have your behavior running correctly, use the Storyboard
tool to generate a layout and an execution trace.
- Fork/join. Redo the sound and light sequence from the
previous problem as follows. Instead of running asynchronously, each
light has an associated sound: red is howl.wav, yellow is barklow.wav,
green in ping.wav, and blue is toc.wav. Each LED should come on as
the sound starts to play, and stay on until the sound finishes. As
soon as the sound is done, you proceed to the next LED/sound pair. A
green button press should reverse the sequence. Show your model and
an execution trace.
What to hand in: your source code for all homework problems,
plus a screen capture of the Storyboard showing your model and its
exeuction trace, where requested.
Dave Touretzky and
Ethan Tira-Thompson
|