Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_LedMC_h 00003 #define INCLUDED_LedMC_h 00004 00005 #include "MotionCommand.h" 00006 #include "LedEngine.h" 00007 #include "OutputCmd.h" 00008 #include "MotionManager.h" 00009 00010 //! This is just a simple wrapper - you probably want to be looking at LedEngine.h 00011 /*! This is handy if all you want to do is control the LED's, but since other 00012 * MotionCommands will probably also want to make use of the LEDs, they can 00013 * just use the engine component to do all the work. */ 00014 class LedMC : public MotionCommand, public LedEngine { 00015 public: 00016 //! constructor 00017 LedMC() : MotionCommand(), LedEngine() { setWeights(AllLEDMask,1); } 00018 //! destructor 00019 virtual ~LedMC() {} 00020 00021 //! updates the cmds from LedEngine::updateLEDs() 00022 virtual int updateOutputs() { 00023 updateLEDFrames(cmds); 00024 for(unsigned int i=0; i<NumLEDs; i++) 00025 if(cmds[i][0].weight!=0) 00026 motman->setOutput(this,i+LEDOffset,cmds[i]); 00027 return NumLEDs; 00028 } 00029 virtual int isDirty() { return LedEngine::isDirty(); } 00030 virtual int isAlive() { return true; } //!< @todo let's make this smarter so you can flash the LED's and have it autoprune 00031 00032 //! Sets the JointCmd::weight of the LEDs specified by @a leds to @a weight 00033 void setWeights(LEDBitMask_t leds, float weight) { 00034 for(unsigned int i=0; i<NumLEDs; i++) 00035 if((leds>>i)&1) 00036 for(unsigned int f=0; f<NumFrames; f++) 00037 cmds[i][f].weight=weight; 00038 } 00039 00040 protected: 00041 OutputCmd cmds[NumLEDs][NumFrames]; //!< needed to store weight values of LEDs (useful to mark LEDs as unused) 00042 }; 00043 00044 /*!@file 00045 * @brief Defines LedMC, which provides a basic MotionCommand wrapper to LedEngine 00046 * @author ejt (Creator) 00047 * 00048 * $Author: ejt $ 00049 * $Name: tekkotsu-2_0 $ 00050 * $Revision: 1.6 $ 00051 * $State: Rel $ 00052 * $Date: 2003/09/25 15:27:23 $ 00053 */ 00054 00055 #endif 00056 00057 // Another way of doing things (this style for everyone else, look at EmergencyStopMC for instance 00058 // But for the main LedMC, this gets out of sync when i change the engine, so i just use inheritance 00059 /* 00060 class LedMC : public MotionCommand, public LedEngine { 00061 public: 00062 LedMC() : MotionCommand() {MCInit(); setPriority(kLowPriority); setWeight(~0,1); } 00063 virtual int updateJointCmds() { return engine.updateLEDs(cmds); } 00064 virtual inline const JointCmd& getJointCmd(unsigned int i) { return (i>=LEDOffset && i<LEDOffset+NumLEDs)?cmds[i-LEDOffset]:unusedJoint; } 00065 virtual int isDirty() { return engine.isDirty(); } 00066 virtual int isAlive() { return true; } 00067 00068 void invert(LEDBitMask_t leds) { engine.invert(leds); } 00069 void cset(LEDBitMask_t leds, float value) { engine.cset(leds,value); } 00070 void set(LEDBitMask_t leds, float value) { engine.set(leds,value); } 00071 void cflash(LEDBitMask_t leds, unsigned int ms=500) { engine.cflash(leds,ms); } 00072 void flash(LEDBitMask_t leds, unsigned int ms=500) { engine.flash(leds,ms); } 00073 void ccycle(LEDBitMask_t leds, unsigned int period, float amp, int offset=0) { engine.ccycle(leds,period,amp,offset); } 00074 void cycle(LEDBitMask_t leds, unsigned int period, float amp, int offset=0) { engine.cycle(leds,period,amp,offset); } 00075 void clear() { engine.clear(); } 00076 void setWeight(LEDBitMask_t leds, float weight) { 00077 for(unsigned int i=0; i<NumLEDs; i++) 00078 if((leds>>i)&1) 00079 cmds[i].weight=weight; 00080 } 00081 00082 float getSetting(LEDOffset_t led_id) { return engine.getSetting(led_id); } 00083 float getValue(LEDOffset_t led_id) { return engine.getValue(led_id); } 00084 00085 protected: 00086 static unsigned int crID; 00087 virtual void setClassRegistrationID(unsigned int id) { crID=id; } 00088 virtual unsigned int getClassRegistrationID() const { return crID; } 00089 00090 LedEngine engine; 00091 00092 JointCmd cmds[NumLEDs]; 00093 }; 00094 */
Tekkotsu v2.0 |
Generated Wed Jan 21 03:20:29 2004 by Doxygen 1.3.4 |