Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MCNode.cc

Go to the documentation of this file.
00001 #include "MCNode.h"
00002 #include "Events/EventRouter.h"
00003 
00004 const char MCNodeBase::defName[]="MCNode";
00005 const char MCNodeBase::defDesc[]="A generic wrapper for any MotionCommand";
00006 
00007 // These externs are declared in their respective header files, but
00008 // defined here instead of corresponding .cc files to avoid file bloat
00009 // (there would be nothing else in their .cc files)
00010 
00011 //! name for TailWagNode to pass as template argument
00012 extern const char defTailWagNodeName[]="TailWagNode";
00013 //! description for TailWagNode to pass as template argument
00014 extern const char defTailWagNodeDesc[]="Wags the tail for as long as the state is active";
00015 //! name for HeadPointerNode to pass as template argument
00016 extern const char defHeadPointerNodeName[]="HeadPointerNode";
00017 //! description for HeadPointerNode to pass as template argument
00018 extern const char defHeadPointerNodeDesc[]="Manages a HeadPointerMC to look in a given direction each time the node is activated";
00019 //! name for WalkNode to pass as template argument
00020 extern const char defWalkNodeName[]="WalkNode";
00021 //! description for WalkNode to pass as template argument
00022 extern const char defWalkNodeDesc[]="Manages a WalkMC node to walk in a direction each time the node is activated.";
00023 
00024 
00025 void MCNodeBase::DoStart() {
00026   StateNode::DoStart(); // do this first (required)
00027   if(mc_id==MotionManager::invalid_MC_ID)
00028     mc_id = motman->addPersistentMotion(getPrivateMC());
00029   else
00030     motman->setPriority(mc_id,MotionManager::kStdPriority);
00031   erouter->addListener(this,EventBase::motmanEGID,mc_id,EventBase::statusETID);
00032 }
00033 
00034 void MCNodeBase::processEvent(const EventBase& /*e*/) {
00035   if(mcCompletes)
00036     postCompletionEvent();
00037 }
00038 
00039 void MCNodeBase::DoStop() {
00040   erouter->removeListener(this); //generally a good idea, unsubscribe all
00041   if(hasPrivateMC()) {
00042     motman->removeMotion(mc_id);
00043     mc_id=MotionManager::invalid_MC_ID;
00044   } else if(mc_id!=MotionManager::invalid_MC_ID) {
00045     motman->setPriority(mc_id,MotionManager::kIgnoredPriority);
00046   }
00047   StateNode::DoStop(); // do this last (required)
00048 }
00049 
00050 void MCNodeBase::setMC(MotionManager::MC_ID mcid) {
00051   if(hasPrivateMC()) {
00052     if(mc_id!=MotionManager::invalid_MC_ID)
00053       motman->removeMotion(mc_id);
00054     delete mc;
00055     mc=NULL;
00056   }
00057   mc_id=mcid;
00058 }
00059 
00060 
00061 /*! @file
00062  * @brief Implement's MCNode's default name and description strings (the class is templated, so everything else has to go in the header)
00063  * @author Ethan Tira-Thompson (ejt) (Creator)
00064  *
00065  * $Author: ejt $
00066  * $Name: tekkotsu-3_0 $
00067  * $Revision: 1.4 $
00068  * $State: Exp $
00069  * $Date: 2006/09/27 20:10:27 $
00070  */

Tekkotsu v3.0
Generated Wed Oct 4 00:03:44 2006 by Doxygen 1.4.7