Homepage Demos Overview Downloads Tutorials Reference
Credits

StartupBehavior Class Reference

#include <StartupBehavior.h>

Inheritance diagram for StartupBehavior:

Inheritance graph
[legend]
List of all members.

Detailed Description

This is the default init behavior - it launches daemons, builds the Controller menu structure, does some nice things to fade the joints in to full power (reduces twitch).

This is done by assigning an instance of StartupBehavior to the global ProjectInterface::startupBehavior variable. Note that there's nothing special about the type of this class, it's just another BehaviorBase - ProjectInterface::startupBehavior could be any behavior.

If you want some other behavior to handle the root initialization, simply remove the assignment of theStartup to startupBehavior at the beginning of StartupBehavior.cc. Then you can substitute your own behavior instead. Probably a good way to distribute project code when you're all done with development and want to ship a single-purpose memory stick (assuming your users won't want to get access to things like the Controller anymore... up to you.)

If all you want to do is get your behavior to launch at startup, you don't need to replace this. Just add a menu entry. (in say, the Mode Switch menu, which is separated out into StartupBehavior_SetupModeSwitch.cc for reduced recompilation after header files are modified) If you use a BehaviorSwitchControl, you can call its BehaviorSwitchControl::start() method to start the behavior it controls as you add it to the menu. There are several examples of this usage in the Background Behaviors menu (StartupBehavior_SetupBackgroundBehaviors.cc)

This behavior is similar in idea to the init process in unix/linux.

Definition at line 41 of file StartupBehavior.h.

Inherited

virtual void DoStart ()
 By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.

virtual void DoStop ()
 By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).

virtual void processEvent (const EventBase &)
virtual std::string getName () const
 Identifies the behavior in menus and such.

std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).


Public Member Functions

 StartupBehavior ()
 Constructor.

virtual ~StartupBehavior ()
 Destructor.


Protected Member Functions

virtual ControlBaseSetupMenus ()
 Initializes the Controller menu structure - calls each of the other Setup functions in turn.

virtual ControlBaseSetupModeSwitch ()
 sets up Mode Switch menu

virtual ControlBaseSetupBackgroundBehaviors ()
 sets up Background Behaviors menu

virtual ControlBaseSetupTekkotsuMon ()
 sets up TekkotsuMon menu

virtual ControlBaseSetupStatusReports ()
 sets up Status Reports menu

virtual ControlBaseSetupFileAccess ()
 sets up File Access menu

virtual ControlBaseSetupWalkEdit ()
 sets up Walk Editing menus (contributed by PGSS 2003 team project - see StartupBehavior_SetupWalkEdit.cc )

virtual ControlBaseSetupVision ()
 sets up the Vision menu

virtual void initVision ()
 Sets up the vision pipelines (held in StartupBehavior_SetupVision.cc).

virtual void startSubMenu ()
 future calls to addItem() will be placed under the most recently added item

virtual void addItem (ControlBase *control)
 inserts a control at the end of the current menu

virtual ControlBaseendSubMenu ()
 closes out a submenu so that future calls to addItem() will be added to the enclosing menu, returns the menu being closed out


Protected Attributes

std::vector< BehaviorBase * > spawned
 Holds pointers to all the behaviors spawned from DoStart, so they can automatically be stopped on DoStop (should only happen on shutdown, but ensures cleanliness).

std::stack< ControlBase * > setup
 only used during setup - easier than passing it around all the functions

MotionManager::MC_ID stop_id
 the main EmergencyStopMC

MotionManager::MC_ID pid_id
 used to fade in the PIDs up to full strength (from initial zero) This is so the joints don't jerk on startup.


Constructor & Destructor Documentation

StartupBehavior::StartupBehavior  ) 
 

Constructor.

Definition at line 27 of file StartupBehavior.cc.

StartupBehavior::~StartupBehavior  )  [virtual]
 

Destructor.

Definition at line 35 of file StartupBehavior.cc.


Member Function Documentation

void StartupBehavior::addItem ControlBase control  )  [protected, virtual]
 

inserts a control at the end of the current menu

Definition at line 185 of file StartupBehavior.cc.

Referenced by SetupBackgroundBehaviors(), SetupFileAccess(), SetupMenus(), SetupModeSwitch(), SetupStatusReports(), SetupTekkotsuMon(), SetupVision(), and SetupWalkEdit().

void StartupBehavior::DoStart  )  [virtual]
 

By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.

Reimplemented from BehaviorBase.

Definition at line 37 of file StartupBehavior.cc.

void StartupBehavior::DoStop  )  [virtual]
 

By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).

Reimplemented from BehaviorBase.

Definition at line 99 of file StartupBehavior.cc.

ControlBase * StartupBehavior::endSubMenu  )  [protected, virtual]
 

closes out a submenu so that future calls to addItem() will be added to the enclosing menu, returns the menu being closed out

Definition at line 190 of file StartupBehavior.cc.

Referenced by SetupBackgroundBehaviors(), SetupFileAccess(), SetupMenus(), SetupModeSwitch(), SetupStatusReports(), SetupTekkotsuMon(), SetupVision(), and SetupWalkEdit().

std::string StartupBehavior::getClassDescription  )  [inline, static]
 

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

Reimplemented from BehaviorBase.

Definition at line 53 of file StartupBehavior.h.

virtual std::string StartupBehavior::getName  )  const [inline, virtual]
 

Identifies the behavior in menus and such.

Implements BehaviorBase.

Definition at line 52 of file StartupBehavior.h.

void StartupBehavior::initVision  )  [protected, virtual]
 

Sets up the vision pipelines (held in StartupBehavior_SetupVision.cc).

We set the default vision generators and source IDs here.

The vis*SID and def*Generator variables are defined in ProjectInterface. You can reassign their values as you see fit, which allows you to reorganize and adapt the vision pipeline, but still retain the ability of the included demo behaviors to access vision information.

Definition at line 32 of file StartupBehavior_SetupVision.cc.

Referenced by DoStart().

void StartupBehavior::processEvent const EventBase event  )  [virtual]
 

Uses a few timer events at the beginning to fade in the PID values, and closes the mouth too

Reimplemented from BehaviorBase.

Definition at line 109 of file StartupBehavior.cc.

ControlBase * StartupBehavior::SetupBackgroundBehaviors  )  [protected, virtual]
 

sets up Background Behaviors menu

Definition at line 20 of file StartupBehavior_SetupBackgroundBehaviors.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupFileAccess  )  [protected, virtual]
 

sets up File Access menu

Definition at line 12 of file StartupBehavior_SetupFileAccess.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupMenus  )  [protected, virtual]
 

Initializes the Controller menu structure - calls each of the other Setup functions in turn.

Also adds Shutdown and Help items at the end

Definition at line 148 of file StartupBehavior.cc.

Referenced by DoStart().

ControlBase * StartupBehavior::SetupModeSwitch  )  [protected, virtual]
 

sets up Mode Switch menu

Definition at line 20 of file StartupBehavior_SetupModeSwitch.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupStatusReports  )  [protected, virtual]
 

sets up Status Reports menu

Definition at line 12 of file StartupBehavior_SetupStatusReports.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupTekkotsuMon  )  [protected, virtual]
 

sets up TekkotsuMon menu

Definition at line 17 of file StartupBehavior_SetupTekkotsuMon.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupVision  )  [protected, virtual]
 

sets up the Vision menu

Definition at line 101 of file StartupBehavior_SetupVision.cc.

Referenced by SetupMenus().

ControlBase * StartupBehavior::SetupWalkEdit  )  [protected, virtual]
 

sets up Walk Editing menus (contributed by PGSS 2003 team project - see StartupBehavior_SetupWalkEdit.cc )

Definition at line 31 of file StartupBehavior_SetupWalkEdit.cc.

Referenced by SetupMenus().

void StartupBehavior::startSubMenu  )  [protected, virtual]
 

future calls to addItem() will be placed under the most recently added item

Definition at line 180 of file StartupBehavior.cc.

Referenced by SetupBackgroundBehaviors(), SetupFileAccess(), SetupMenus(), SetupModeSwitch(), SetupStatusReports(), SetupTekkotsuMon(), SetupVision(), and SetupWalkEdit().


Member Data Documentation

MotionManager::MC_ID StartupBehavior::pid_id [protected]
 

used to fade in the PIDs up to full strength (from initial zero) This is so the joints don't jerk on startup.

Definition at line 77 of file StartupBehavior.h.

Referenced by DoStart(), and processEvent().

std::stack<ControlBase*> StartupBehavior::setup [protected]
 

only used during setup - easier than passing it around all the functions

Definition at line 75 of file StartupBehavior.h.

Referenced by addItem(), endSubMenu(), SetupMenus(), and startSubMenu().

std::vector<BehaviorBase*> StartupBehavior::spawned [protected]
 

Holds pointers to all the behaviors spawned from DoStart, so they can automatically be stopped on DoStop (should only happen on shutdown, but ensures cleanliness).

Definition at line 74 of file StartupBehavior.h.

Referenced by DoStart(), and DoStop().

MotionManager::MC_ID StartupBehavior::stop_id [protected]
 

the main EmergencyStopMC

Definition at line 76 of file StartupBehavior.h.

Referenced by DoStart(), DoStop(), processEvent(), SetupFileAccess(), and SetupTekkotsuMon().


The documentation for this class was generated from the following files:

Tekkotsu v2.1
Generated Tue Mar 16 23:22:28 2004 by Doxygen 1.3.5