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 #include "Shared/MarkScope.h" 00004 00005 #include "Shared/RobotInfo.h" 00006 #ifdef TGT_HAS_TAIL 00007 #include "TailWagNode.h" 00008 REGISTER_BEHAVIOR_MENU_OPT(TailWagNode,DEFAULT_TK_MENU,BEH_NONEXCLUSIVE); 00009 #endif 00010 00011 const char MCNodeBase::defName[]="MCNode"; 00012 const char MCNodeBase::defDesc[]="A generic wrapper for any MotionCommand"; 00013 00014 // These externs are declared in their respective header files, but 00015 // defined here instead of corresponding .cc files to avoid file bloat 00016 // (there would be nothing else in their .cc files) 00017 00018 //! name for HeadPointerNode to pass as template argument 00019 extern const char defHeadPointerNodeName[]="HeadPointerNode"; 00020 //! description for HeadPointerNode to pass as template argument 00021 extern const char defHeadPointerNodeDesc[]="Manages a HeadPointerMC to look in a given direction each time the node is activated"; 00022 00023 //! name for PIDNode to pass as template argument 00024 extern const char defPIDNodeName[]="PIDNode"; 00025 //! description for PIDNode to pass as template argument 00026 extern const char defPIDNodeDesc[]="Manages a PIDMC to set joint power levels when the node is activated"; 00027 00028 //! name for CrabArmNode to pass as template argument 00029 extern const char defCrabArmNodeName[]="CrabArmNode"; 00030 //! description for CrabArmNode to pass as template argument 00031 extern const char defCrabArmNodeDesc[]="Manages a CrabArmMC to reach in a given direction each time the node is activated"; 00032 00033 //! name for ArmNode to pass as template argument 00034 extern const char defArmNodeName[]="ArmNode"; 00035 //! description for ArmNode to pass as template argument 00036 extern const char defArmNodeDesc[]="Manages an ArmMC to reach in a given direction each time the node is activated"; 00037 00038 //! name for TailWagNode to pass as template argument 00039 extern const char defTailWagNodeName[]="TailWagNode"; 00040 //! description for TailWagNode to pass as template argument 00041 extern const char defTailWagNodeDesc[]="Wags the tail for as long as the state is active"; 00042 00043 //! name for PostureNode to pass as template argument 00044 extern const char defPostureNodeName[]="PostureNode"; 00045 //! description for PostureNode to pass as template argument 00046 extern const char defPostureNodeDesc[]="Moves the body to the specified posture"; 00047 00048 //! name for MotionSequenceNode to pass as template argument 00049 extern const char defMotionSequenceNodeName[]="MotionSequenceNode"; 00050 //! description for MotionSequenceNode to pass as template argument 00051 extern const char defMotionSequenceNodeDesc[]="Moves the body through the specified motion sequence"; 00052 00053 //! name for DynamicMotionSequenceNode to pass as template argument 00054 extern const char defDynamicMotionSequenceNodeName[]="DynamicMotionSequenceNode"; 00055 //! description for DynamicMotionSequenceNode to pass as template argument 00056 extern const char defDynamicMotionSequenceNodeDesc[]="Moves the body through the specified dynamic motion sequence"; 00057 00058 //! name for WalkNode to pass as template argument 00059 extern const char defWalkNodeName[]="WalkNode"; 00060 //! description for WalkNode to pass as template argument 00061 extern const char defWalkNodeDesc[]="Manages a WalkMC node to walk in a direction each time the node is activated."; 00062 00063 //! name for WaypointWalkNode to pass as template argument 00064 extern const char defWaypointWalkNodeName[]="WaypointWalkNode"; 00065 //! description for WaypointWalkNode to pass as template argument 00066 extern const char defWaypointWalkNodeDesc[]="Manages a WaypointWalkMC to perform a waypoint walk each time the node is activated."; 00067 00068 00069 void MCNodeBase::doEvent() { 00070 if(mcCompletes && event->getGeneratorID()==EventBase::motmanEGID && event->getSourceID()==mc_id) 00071 postStateCompletion(); 00072 else 00073 StateNode::doEvent(); 00074 } 00075 00076 void MCNodeBase::stop() { 00077 if(hasPrivateMC()) { 00078 motman->removeMotion(mc_id); 00079 mc_id=MotionManager::invalid_MC_ID; 00080 } 00081 StateNode::stop(); // do this last (required) 00082 } 00083 00084 void MCNodeBase::setMC(MotionManager::MC_ID new_mc_id) { 00085 if ( new_mc_id != MotionManager::invalid_MC_ID ) { 00086 erouter->removeListener(this,EventBase::motmanEGID, mc_id); 00087 if( mc != NULL ) { 00088 if ( mc_id != MotionManager::invalid_MC_ID ) 00089 motman->removeMotion(mc_id); 00090 delete mc; 00091 mc=NULL; 00092 } 00093 mc_id = new_mc_id; 00094 if ( isActive() ) 00095 erouter->addListener(this,EventBase::motmanEGID,mc_id,EventBase::statusETID); 00096 } 00097 } 00098 00099 void MCNodeBase::setPriority(const float p) { 00100 priority = p; 00101 if ( mc_id != MotionManager::invalid_MC_ID ) 00102 motman->setPriority(mc_id, priority); 00103 } 00104 00105 void MCNodeBase::motionFails() { 00106 // Shut down the motion command: copied from stop() because we don't 00107 // want to call StateNode::stop() here; that would deactivate any 00108 // outgoing failure transition 00109 if(hasPrivateMC()) { 00110 motman->removeMotion(mc_id); 00111 mc_id=MotionManager::invalid_MC_ID; 00112 } else if(mc_id!=MotionManager::invalid_MC_ID) { 00113 motman->setPriority(mc_id,MotionManager::kIgnoredPriority); 00114 } 00115 postStateFailure(); 00116 } 00117 00118 /*! @file 00119 * @brief Implement's MCNode's default name and description strings (the class is templated, so everything else has to go in the header) 00120 * @author Ethan Tira-Thompson (ejt) (Creator) 00121 */ |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:44 2016 by Doxygen 1.6.3 |