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.h in your
~/project directory:
#ifndef INCLUDED_DstBehavior_h_
#define INCLUDED_DstBehavior_h_
#include "Behaviors/BehaviorBase.h"
class DstBehavior : public BehaviorBase {
public:
DstBehavior() : BehaviorBase("DstBehavior") {}
virtual void DoStart() {
BehaviorBase::DoStart();
std::cout << getName() << " is starting up." << std::endl;
}
virtual void DoStop() {
std::cout << getName() << " is shutting down." << std::endl;
BehaviorBase::DoStop();
}
};
#endif
|
In order to include your Behavior in the Tekkotsu system, you must add
it to the menu of behaviors in the file StartupBehavior_SetupModeSwitch.cc.
This requires inserting two lines into that file. First, insert the
following line in the list of #include statements at the
beginning:
Second, insert the following line just before the corresponding line
for SampleBehavior:
addItem(new BehaviorSwitchControl<DstBehavior>("DstBehavior",bg,false));
|
After completing these edits, 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 ControllerGUI is still running it should reconnect automatically;
otherwise, start it up again. Also open a telnet connection to the
AIBO on port 59000.
Now go to ControllerGUI and, from the Root Control menu, double click
on Mode Switch, then double click on DstBehavior to activate your
behavior. You should see the "starting up" message in the telnet
window. Click on DstBehavior again to deactivate it.
|