Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RelaxBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_RelaxBehavior_h_
00003 #define INCLUDED_RelaxBehavior_h_
00004 
00005 #include <iostream>
00006 #include "Behaviors/BehaviorBase.h"
00007 #include "Motion/PIDMC.h"
00008 #include "IPC/SharedObject.h"
00009 #include "Motion/MotionManager.h"
00010 
00011 using namespace std;
00012 
00013 //! A behavior that sets all the pids to zero for the tail and legs servos.
00014 /*! This should hopefully make the robot quieter and consume less power. */
00015 class RelaxBehavior : public BehaviorBase {
00016 public:
00017   //! contstructor
00018   RelaxBehavior() : BehaviorBase("RelaxBehavior"), pidMCID(MotionManager::invalid_MC_ID) {}
00019   
00020   virtual void DoStart() {
00021     BehaviorBase::DoStart();
00022     SharedObject<PIDMC> pidMC(0);
00023     // if you want to keep some joints from being turned off, e.g.:
00024     //pidMC->setJointPowerLevel(HeadOffset+TiltOffset,1);
00025     // (or you could change the contructor too...)
00026     // http://www.tekkotsu.org/dox/classPIDMC.html
00027 
00028     // You could also change the priority level so that anytime
00029     // a joint is not in use it goes limp (try kBackgroundPriority)
00030     pidMCID=motman->addPersistentMotion(pidMC,MotionManager::kHighPriority);
00031     // the 'false' is to keep it from auto-pruning
00032   }
00033   virtual void DoStop() {
00034     motman->removeMotion(pidMCID);
00035     //this "one-shot" version of doing things will restore the PIDs
00036     motman->addPrunableMotion(SharedObject<PIDMC>(1));
00037     BehaviorBase::DoStop();
00038   }
00039   static std::string getClassDescription() { return "Sets PID parameters for all applicable joints to 0, allowing the joints to move freely, reducing noise and power consumption"; }
00040   virtual std::string getDescription() const { return getClassDescription(); }
00041 protected:
00042   MotionManager::MC_ID pidMCID; //!< the id for the pid motion command
00043 };
00044 
00045 #endif // INCLUDED_RelaxBehavior_h_
00046 
00047 /*! @file
00048  * @brief Describes RelaxBehavior, which sets all the pids to zero for the tail and legs servos.
00049  * @author Erik Berglund <tekkotsu.dev.spam.345@blog.no> (Creator)
00050  * @author ejt (Modifications)
00051  *
00052  * $Author: ejt $
00053  * $Name: tekkotsu-2_4_1 $
00054  * $Revision: 1.7 $
00055  * $State: Exp $
00056  * $Date: 2005/06/01 05:47:45 $
00057  */

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:48 2005 by Doxygen 1.4.4