Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
TailWagMC.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_TailWagMC_h 00003 #define INCLUDED_TailWagMC_h 00004 00005 #include "Motion/MotionCommand.h" 00006 #include "Motion/MotionManager.h" 00007 #include "Shared/get_time.h" 00008 #include "math.h" 00009 #include "Shared/ERS210Info.h" 00010 00011 //! A simple motion command for wagging the tail - you can specify period, magnitude, and tilt 00012 class TailWagMC : public MotionCommand { 00013 public: 00014 //!constructor 00015 TailWagMC() : period(500), magnitude(22*3.141592/180), active(false), tilt() { } 00016 //!destructor 00017 virtual ~TailWagMC() {} 00018 virtual int updateOutputs() { 00019 if(active && state->robotDesign&WorldState::ERS210Mask) { 00020 for(unsigned int i=0; i<NumFrames; i++) 00021 pans[i].set(sin((2*M_PI*(get_time()+i*FrameTime))/period)*magnitude); //bug fix thanks L.A.Olsson@herts.ac.uk 00022 motman->setOutput(this,ERS210Info::TailOffset+PanOffset,pans); 00023 motman->setOutput(this,ERS210Info::TailOffset+TiltOffset,tilt); 00024 return 1; 00025 } else 00026 return 0; 00027 } 00028 virtual int isDirty() { return active; } 00029 virtual int isAlive() { return true; } 00030 00031 void setPeriod(unsigned int p) { period=p; } //!< sets the period of time between swings, in milliseconds 00032 unsigned int getPeriod() { return period; } //!< gets the period of time between swings, in milliseconds 00033 void setMagnitude(double mag) { magnitude=mag; } //!< sets the magnitude of swings, in radians 00034 double getMagnitude() { return magnitude; } //!< gets the magnitude of swings, in radians 00035 void setTilt(double r) { tilt.set(r,1); } //!< sets the tilt of the tail while wagging, in radians 00036 void unsetTilt() { tilt.unset(); } //!< makes the tilt control unspecified, will let something else control tilt 00037 double getTilt() { return tilt.value; } //!< sets the tilt of the tail while wagging, in radians 00038 void setActive(bool a) { active=a; } //!< turns the tail wagger on or off 00039 bool getActive() { return active; } //!< returns true if this is currently trying to wag the tail 00040 00041 protected: 00042 unsigned int period; //!< period of time between swings, in milliseconds 00043 double magnitude; //!< magnitude of swings, in radians 00044 bool active; //!< true if this is currently trying to wag the tail 00045 OutputCmd tilt; //!< holds current setting for the tilt joint 00046 OutputCmd pans[NumFrames]; //!< holds commands for planning ahead the wagging 00047 }; 00048 00049 /*! @file 00050 * @brief Defines TailWagMC, which will wag the tail on a ERS-210 robot. 00051 * @author ejt (Creator) 00052 * 00053 * $Author: ejt $ 00054 * $Name: tekkotsu-2_2 $ 00055 * $Revision: 1.5 $ 00056 * $State: Rel $ 00057 * $Date: 2003/09/25 15:27:23 $ 00058 */ 00059 00060 #endif 00061 |
Tekkotsu v2.2 |
Generated Tue Oct 19 14:19:16 2004 by Doxygen 1.3.9.1 |