Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
StartupBehavior.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_StartupBehavior_h_ 00003 #define INCLUDED_StartupBehavior_h_ 00004 #include "Behaviors/BehaviorBase.h" 00005 #include "Motion/MotionManager.h" 00006 #include <vector> 00007 #include <stack> 00008 00009 class Controller; // defined in Controller.h, don't actually need header file yet 00010 class ControlBase; // defined in ControlBase.h, don't actually need header file yet 00011 00012 //! 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) 00013 00014 /*! This is done by assigning an instance of StartupBehavior to the 00015 * global ProjectInterface::startupBehavior variable. Note that 00016 * there's nothing special about the type of this class, it's just 00017 * another BehaviorBase - ProjectInterface::startupBehavior could be 00018 * any behavior. 00019 * 00020 * If you want some other behavior to handle the root initialization, 00021 * simply remove the assignment of ::theStartup to startupBehavior at 00022 * the beginning of StartupBehavior.cc. Then you can substitute your 00023 * own behavior instead. Probably a good way to distribute project 00024 * code when you're all done with development and want to ship a 00025 * single-purpose memory stick (assuming your users won't want to get 00026 * access to things like the Controller anymore... up to you.) 00027 * 00028 * If all you want to do is get your behavior to launch at startup, 00029 * you don't need to replace this. Just add a menu entry. (in say, 00030 * the Mode Switch menu, which is separated out into 00031 * StartupBehavior_SetupModeSwitch.cc for reduced recompilation after 00032 * header files are modified) If you use a BehaviorSwitchControl, you 00033 * can call its BehaviorSwitchControl::start() method to start the 00034 * behavior it controls as you add it to the menu. There are several 00035 * examples of this usage in the Background Behaviors menu 00036 * (StartupBehavior_SetupBackgroundBehaviors.cc) 00037 * 00038 * This behavior is similar in idea to the init process in 00039 * unix/linux. 00040 */ 00041 class StartupBehavior : public BehaviorBase { 00042 public: 00043 //! Constructor 00044 StartupBehavior(); 00045 //! Destructor 00046 virtual ~StartupBehavior(); 00047 00048 //! @name Inherited 00049 virtual void DoStart(); 00050 virtual void DoStop(); 00051 virtual void processEvent(const EventBase&); 00052 virtual std::string getName() const { return "StartupBehavior"; } 00053 static std::string getClassDescription() { return "The initial behavior, when run, sets up everything else"; } 00054 //@} 00055 protected: 00056 //! Initializes the Controller menu structure - calls each of the other Setup functions in turn 00057 /*! Also adds Shutdown and Help items at the end */ 00058 virtual ControlBase* SetupMenus(); 00059 00060 virtual ControlBase* SetupModeSwitch(); //!< sets up Mode Switch menu 00061 virtual ControlBase* SetupBackgroundBehaviors(); //!< sets up Background Behaviors menu 00062 virtual ControlBase* SetupTekkotsuMon(); //!< sets up TekkotsuMon menu 00063 virtual ControlBase* SetupStatusReports(); //!< sets up Status Reports menu 00064 virtual ControlBase* SetupFileAccess(); //!< sets up File Access menu 00065 virtual ControlBase* SetupWalkEdit(); //!< sets up Walk Editing menus (contributed by PGSS 2003 team project - see StartupBehavior_SetupWalkEdit.cc ) 00066 virtual ControlBase* SetupVision(); //!< sets up the Vision menu 00067 00068 virtual void initVision(); //!< Sets up the vision pipelines (held in StartupBehavior_SetupVision.cc) 00069 00070 virtual void startSubMenu(); //!< future calls to addItem() will be placed under the most recently added item 00071 virtual void addItem(ControlBase * control); //!< inserts a control at the end of the current menu 00072 virtual ControlBase* endSubMenu(); //!< closes out a submenu so that future calls to addItem() will be added to the enclosing menu, returns the menu being closed out 00073 00074 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) 00075 std::stack<ControlBase*> setup; //!< only used during setup - easier than passing it around all the functions 00076 MotionManager::MC_ID stop_id; //!< the main EmergencyStopMC 00077 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. 00078 }; 00079 00080 extern BehaviorBase& startupBehavior; 00081 00082 #endif |
Tekkotsu v2.1 |
Generated Tue Mar 16 23:19:15 2004 by Doxygen 1.3.5 |