Exploring Tekkotsu Programming on Mobile Robots:


Prev: Robot safety
Up: Contents
Next: Events

The applications that users create, called Behaviors, are implemented as classes that inherit from the base class BehaviorBase. Tekkotsu instantiates the class when the behavior is to be activated, and normally destroys the instance when the behavior is deactivated. There are quite a few behaviors already built in to Tekkotsu. You can start and stop them using a tool called the ControllerGUI.

The way you interact with Tekkotsu depends on the kind of robot you're using. For robotic devices such as the Tekkotsu planar hand-eye system that attach to a PC, the PC is the robot, so you run Tekkotsu directly, e.g., cd ~/project followed by ./tekkotsu-HANDEYE. For autonomous robots such as the Chiara or the Create/ASUS, the computer is on board the robot. You ssh into the robot from your PC, and then start Tekkotsu on the robot, e.g., cd ~/project followed by typing, e.g., ./tekkotsu-CHIARA. (On the Sony AIBO, Tekkotsu runs automatically when you boot the robot from your memory stick. The AIBO runs its own operating system called Aperios. You cannot ssh into an AIBO, but you can telnet to it to receive console output.)

Exercise: Running a Behavior

If you haven't already started Tekkotsu, start it now. If you're using an AIBO, read the section below on "Talking to the AIBO" before proceeding further.

Start the ControllerGUI by typing "ControllerGUI hostname". If you're running Tekkotsu on your PC, you can use "localhost" as the hostname. (Note: if your search path is not set up to find ControllerGUI, you may have to type something like /usr/local/Tekkotsu/tools/mon/ControllerGUI.) Once the ControllerGUI window comes up, click on the "Raw Cam" button to call up a viewer for the robot's camera image.

Double click on "Background Behaviors" and then "StareAtBallBehavior", and activate it by double clicking. The name will change to #StareAtBallBehavior and its color will change to red, indicating that the behavior is active. Un-pause the robot by clicking on the Stop/Go icon. Now, move the pink ball back and forth in front of the robot and it should move its camera to keep the ball centered in the image.

Talking to the AIBO

Boot the AIBO using the standard Tekkotsu memory stick and then open a telnet connection to it on port 59000 to monitor the Aperios console output. For example, if your AIBO is named fido, you would type "telnet fido 59000". When the connection is made you will see some startup messages that were generated by Aperios and then later some from Tekkotsu.

Behaviors provide four essential member functions: a constructor, doStart(), doStop(), and doEvent(). doStart() is called when the Behavior is activated; its job is to allocate and initialize whatever structures the Behavior requires, and to subscribe the Behavior instance to whichever event streams the Behavior cares about. doStop() is called when the Behavior is deactivated, and is expected to undo whatever was done in doStart(). The doEvent() method handles event notifications as they are received; this is where much of the real work of the Behavior gets done. Behaviors also require at least one constructor function, and in the most general case they have three constructors.

Exercise: Writing Your First Behavior

Name your first behavior using your initials, to keep it distinct from behaviors others in your work group may write. If your initials are dst, copy the code below into the file DstBehavior.cc in your ~/project directory:

#include "Behaviors/BehaviorBase.h"

class DstBehavior : public BehaviorBase {
  DstBehavior() : BehaviorBase("DstBehavior") {}
  virtual void doStart() {
    std::cout << getName() << " is starting up." << std::endl;
  virtual void doStop() {
    std::cout << getName() << " is shutting down." << std::endl;



In order to include your Behavior in the Tekkotsu system, you must add it to the "User Behaviors" menu. The REGISTER_BEHAVIOR macro takes care of this for you.

After creating your source file, type "make" in your project directory. Once compilation completes successfully, run Tekkotsu again. (For the AIBO, put the memory stick in the writer and type "make update". Once compilation completes and the memory stick has been succesfully updated, place it back in the AIBO and reboot.) If the ControllerGUI is still running it should reconnect to the robot automatically. Otherwise, start it up again. On the AIBO you should also open a telnet connection to port 59000.

Now go to ControllerGUI and, from the Root Control menu, double click on User Behaviors, then double click on DstBehavior to activate your behavior. You should see the "starting up" message in the console window. Click on DstBehavior again to deactivate it.

Explore more:

  1. Skim the documentation for BehaviorBase, which is a subclass of EventListener. What else is it a subclass of? What other member functions does it provide?

  2. Look up the source code for BehaviorBase::start() and BehaviorBase::stop(). What do these functions do? What about BehaviorBase::doStart()? A link to the source for each function can be found in the "Member Function Documentation" section of the BehaviorBase documentation.

Prev: Robot safety
Up: Contents
Next: Events

Last modified: Thu Jun 17 21:00:24 EDT 2010