Homepage Demos Overview Downloads Tutorials Reference
Credits

HeadPointerNode.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_HeadPointerNode_h_
00003 #define INCLUDED_HeadPointerNode_h_
00004 
00005 #include "Behaviors/StateNode.h"
00006 #include "Events/EventRouter.h"
00007 #include "Motion/HeadPointerMC.h"
00008 
00009 //! A simple StateNode that executes a LedMC motion command and throws a status event upon completion
00010 class HeadPointerNode : public StateNode {
00011 protected:
00012   SharedObject<HeadPointerMC> head_mc;    //!< MotionCommand used by this node
00013   MotionManager::MC_ID head_id;  //!< id number for the MotionCommand
00014 
00015 public:
00016   //! constructor
00017   HeadPointerNode(std::string nodename="HeadPointerNode") : 
00018     StateNode("HeadPointerNode",nodename), head_mc(), head_id(MotionManager::invalid_MC_ID) {}
00019 
00020   //! activate the node
00021   virtual void DoStart() {
00022     head_id = motman->addPersistentMotion(head_mc);
00023     erouter->addListener(this,EventBase::motmanEGID,head_id,EventBase::statusETID);
00024     StateNode::DoStart();  // don't activate transitions until our listener has been added
00025   }
00026 
00027   //! deactivate the node
00028   virtual void DoStop() {
00029     motman->removeMotion(head_id);
00030     head_id = MotionManager::invalid_MC_ID;
00031     erouter->removeListener(this);
00032     StateNode::DoStop();
00033   }
00034 
00035   //! receive motmanEGID status event and throw stateMachineEGID status event
00036   virtual void processEvent(const EventBase&) {
00037     erouter->postEvent(EventBase::stateMachineEGID,reinterpret_cast<unsigned int>(this),EventBase::statusETID,0,getName(),1);
00038   }
00039 
00040   //! reveal the MotionCommand
00041   SharedObject<HeadPointerMC>& getMC() { return head_mc; }
00042 
00043   //! reveal the MC_ID
00044   MotionManager::MC_ID& getMC_ID() { return head_id; }
00045 
00046 protected:
00047   //! constructor
00048   HeadPointerNode(std::string &classname, std::string &nodename) : 
00049     StateNode(classname,nodename), head_mc(), head_id(MotionManager::invalid_MC_ID) {}
00050 
00051 
00052 };
00053 
00054 /*! @file
00055  * @brief Defines HeadPointerNode, a simple StateNode that runs a HeadPointerMC motion command and throws a status event upon completion
00056  * @author dst (Creator)
00057  *
00058  * $Author: dst $
00059  * $Name: tekkotsu-2_2_1 $
00060  * $Revision: 1.5 $
00061  * $State: Exp $
00062  * $Date: 2004/11/17 01:31:06 $
00063  */
00064 
00065 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:38 2004 by Doxygen 1.3.9.1