Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
PostureNode.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_TailWagNode_h_ 00003 #define INCLUDED_TailWagNode_h_ 00004 00005 #include "MCNode.h" 00006 #include "Events/EventRouter.h" 00007 #include "Motion/PostureMC.h" 00008 00009 //!default name for PostureNode's (have to instantiate a variable in order to use as a template argument) 00010 /*! instantiation will be placed in MCNode.cc to avoid file bloat */ 00011 extern const char defPostureNodeName[]; 00012 //!default description for PostureNode's (have to instantiate a variable in order to use as a template argument) 00013 /*! instantiation will be placed in MCNode.cc to avoid file bloat */ 00014 extern const char defPostureNodeDesc[]; 00015 00016 //! A simple StateNode that executes a PostureMC motion command 00017 /*! Caches the posture file in a private PostureEngine because the 00018 * motion command might be shared with other functions that are 00019 * using it for other purposes */ 00020 class PostureNode : public MCNode<PostureMC,defPostureNodeName,defPostureNodeDesc,true> { 00021 public: 00022 00023 //! Constructor: takes optional instance name and filename. 00024 /*! Caches the posture file in a private PostureEngine because the 00025 motion command might be shared with other functions that are 00026 using it for other purposes */ 00027 PostureNode(const std::string &nodename=defPostureNodeName, const std::string &filename=std::string()) 00028 : MCNode<PostureMC,defPostureNodeName,defPostureNodeDesc,true>(nodename), posture() 00029 { 00030 if ( filename.size() > 0 ) 00031 posture.loadFile(filename.c_str()); 00032 } 00033 00034 virtual void DoStart() { 00035 getMC()->setAverage(posture,1); // copy cached posture into the motion command 00036 MCNode<PostureMC,defPostureNodeName,defPostureNodeDesc,true>::DoStart(); 00037 } 00038 00039 //! loads the specified file into #posture, note this @em doesn't affect the current PostureMC, just the cached one which will be loaded into it on next activation. See getPosture(), getMC_ID() 00040 virtual void loadFile(const std::string &filename) { 00041 posture.loadFile(filename.c_str()); 00042 getMC()->setAverage(posture,1); 00043 } 00044 00045 //! accessor for #posture, note this @em doesn't affect the current PostureMC, just the cached one which will be loaded into it on next activation. See getMC_ID() 00046 virtual PostureEngine& getPosture() { return posture; } 00047 //! accessor for #posture, note this @em doesn't return the current PostureMC, just the cached one which will be loaded into it on next activation. See getMC_ID() 00048 virtual const PostureEngine& getPosture() const { return posture; } 00049 00050 protected: 00051 //! The internal cache of joint positions, copied to the motion command when activated. 00052 /*! This allows the motion command to be shared by other nodes/behaviors, which might modify 00053 * the posture on an ongoing basis. */ 00054 PostureEngine posture; 00055 }; 00056 00057 /*! @file 00058 * @brief Defines PostureNode, a simple StateNode that runs a PostureMC motion command 00059 * @author dst 00060 * 00061 * $Author: ejt $ 00062 * $Name: tekkotsu-4_0 $ 00063 * $Revision: 1.5 $ 00064 * $State: Exp $ 00065 * $Date: 2007/11/11 23:57:19 $ 00066 */ 00067 00068 #endif |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4 |