Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MCNode.ccGo 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 HeadPointerNode to pass as template argument 00012 extern const char defHeadPointerNodeName[]="HeadPointerNode"; 00013 //! description for HeadPointerNode to pass as template argument 00014 extern const char defHeadPointerNodeDesc[]="Manages a HeadPointerMC to look in a given direction each time the node is activated"; 00015 //! name for TailWagNode to pass as template argument 00016 extern const char defTailWagNodeName[]="TailWagNode"; 00017 //! description for TailWagNode to pass as template argument 00018 extern const char defTailWagNodeDesc[]="Wags the tail for as long as the state is active"; 00019 //! name for PostureNode to pass as template argument 00020 extern const char defPostureNodeName[]="PostureNode"; 00021 //! description for PostureNode to pass as template argument 00022 extern const char defPostureNodeDesc[]="Moves the body to the specified posture"; 00023 //! name for WalkNode to pass as template argument 00024 extern const char defWalkNodeName[]="WalkNode"; 00025 //! description for WalkNode to pass as template argument 00026 extern const char defWalkNodeDesc[]="Manages a WalkMC node to walk in a direction each time the node is activated."; 00027 //! name for WaypointWalkNode to pass as template argument 00028 extern const char defWaypointWalkNodeName[]="WaypointWalkNode"; 00029 //! description for WaypointWalkNode to pass as template argument 00030 extern const char defWaypointWalkNodeDesc[]="Manages a WaypointWalkMC to perform a waypoint walk each time the node is activated."; 00031 00032 00033 void MCNodeBase::DoStart() { 00034 StateNode::DoStart(); // do this first (required) 00035 if(mc_id==MotionManager::invalid_MC_ID) 00036 mc_id = motman->addPersistentMotion(getPrivateMC()); 00037 else 00038 motman->setPriority(mc_id,MotionManager::kStdPriority); 00039 erouter->addListener(this,EventBase::motmanEGID,mc_id,EventBase::statusETID); 00040 } 00041 00042 void MCNodeBase::processEvent(const EventBase& /*e*/) { 00043 if(mcCompletes) 00044 postCompletionEvent(); 00045 } 00046 00047 void MCNodeBase::DoStop() { 00048 erouter->removeListener(this); //generally a good idea, unsubscribe all 00049 if(hasPrivateMC()) { 00050 motman->removeMotion(mc_id); 00051 mc_id=MotionManager::invalid_MC_ID; 00052 } else if(mc_id!=MotionManager::invalid_MC_ID) { 00053 motman->setPriority(mc_id,MotionManager::kIgnoredPriority); 00054 } 00055 StateNode::DoStop(); // do this last (required) 00056 } 00057 00058 void MCNodeBase::setMC(MotionManager::MC_ID mcid) { 00059 if(hasPrivateMC()) { 00060 if(mc_id!=MotionManager::invalid_MC_ID) 00061 motman->removeMotion(mc_id); 00062 delete mc; 00063 mc=NULL; 00064 } 00065 mc_id=mcid; 00066 } 00067 00068 00069 /*! @file 00070 * @brief Implement's MCNode's default name and description strings (the class is templated, so everything else has to go in the header) 00071 * @author Ethan Tira-Thompson (ejt) (Creator) 00072 * 00073 * $Author: dst $ 00074 * $Name: tekkotsu-4_0 $ 00075 * $Revision: 1.6 $ 00076 * $State: Exp $ 00077 * $Date: 2007/03/13 08:31:26 $ 00078 */ |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:53 2007 by Doxygen 1.5.4 |