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(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,(unsigned int)this,EventBase::statusETID,0);
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 
00047 };
00048 
00049 /*! @file
00050  * @brief Defines HeadPointerNode, a simple StateNode that runs a HeadPointerMC motion command and throws a status event upon completion
00051  * @author dst (Creator)
00052  *
00053  * $Author: ejt $
00054  * $Name: tekkotsu-2_2 $
00055  * $Revision: 1.2 $
00056  * $State: Exp $
00057  * $Date: 2004/10/17 01:16:10 $
00058  */
00059 
00060 #endif

Tekkotsu v2.2
Generated Tue Oct 19 14:19:14 2004 by Doxygen 1.3.9.1