Part I: Compile and Run a State Machine
It is possible to develop code entirely on the robot, but the small
screen and keyboard, combined with the slower processor relative to
the workstation, don't favor this approach. Therefore, for reasons of
both speed and convenience, you will edit and compile your code on the
workstation and only upload the executable to the robot.
Since we make frequent bug fixes and enhancements to Tekkotsu, at the
start of your day before you upload code to the robot you should
upload the latest version of the Tekkotsu library, libtekkotsu.so,
from the class directory. The sendtekkotsu
script does this.
Then, every time you recompile your code, you can send it to the robot
with the sendmycode
- Compile the shorthand form of the Bark/Howl/Blink state machine in the
by copying it to your ~/project directory, cd'ing to that directory,
and typing "make".
- Send the compiled code to the robot. To do this, use
"sendmycode" to copy your tekkotsu-CALLIOPE5KP
executable to the ~/project directory on the robot. Remember that for
the first run of the day you should use "sendtekkotsu" instead of
"sendmycode". The argument to either script is the robot name.
> sendmycode calliope1.rel CALLIOPE5KP
- Type control-shift-T in the terminal window to open a new tab.
Then ssh into the robot by typing, e.g., "ssh firstname.lastname@example.org".
Notice that the prompt on the robot is red, while the prompt on the
workstation is green. This helps you tell them apart: "red for robot".
- In a third tab, start a ControllerGUI by typing, e.g.,
"ControllerGUI calliope1.rel". Note that you can just type "Con" and
hit the [Tab] key and the shell will auto-complete.
- In the ControllerGUI, go to Root Control > User Behaviors >
BarkHowlBlink. Double click on the behavior to run it. Try pressing
the play button in response to the bark sound. Also try not pressing
it. What happens in each case? Click on the behavior name again to
- 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
Part II: Storyboard Tool
Read the Storyboard
Lab on the Tekkotsu wiki.
Remember that you must run the Storyboard tool on your workstation, not on
the robot! Follow the instructions in the lab, replacing Example2 with BarkHowlBlink, 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 lecture notes. 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
Run your state machine on the robot and generate an execution trace
using the Storyboard tool by following the directions in the lab.
Before leaving the lab today, hand in via email to Mark Perez at
email@example.com 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
Start on these problems after you've seen next week's "Behaviors and
What to hand in:
- Initializing a node's motion command. Write a simple state
machine that waits for a Play button press event. When the event
occurs, it should flash the Play 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 Play LED, look
in the file Tekkotsu/Shared/CommonCalliopeInfo.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
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: Power (red), Play, and Advance, for 1
second each, over and over. Asynchronously, your behavior should play
a series of three barks: barklow.wav, barkmed.wav, and yipper.wav,
over and over. In response to pressing the left bumper (LBump),
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 Power LED, you
would normally light the Play LED next, but if you get a button press
you immediately switch to the Advance LED and start running backwards;
the sound should immediately switch too. Another bumper 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
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: Power is howl.wav, Play is barklow.wav,
and Advance in ping.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 left bumper press
should reverse the sequence. Show your model and an execution trace.
your source code for the problems shown above,
plus screen captures of the Storyboard showing your model and its
exeuction trace for each of the problems where a trace was requested.
Please hand these in by Wednesday, January 30, 2013.