Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RoverControllerBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_RoverControllerBehavior_h_
00003 #define INCLUDED_RoverControllerBehavior_h_
00004 
00005 #include "Shared/RobotInfo.h"
00006 #if !defined(TGT_HAS_ARMS) && !defined(TGT_HAS_LEGS) || !defined(TGT_HAS_HEAD)
00007 // no manipulator, but we can still compile, so it's only a warning
00008 #  warning RoverControllerBehavior can't find a manipulator, won't run
00009 #endif
00010 
00011 #include "Behaviors/BehaviorBase.h"
00012 #include "Behaviors/Controller.h"
00013 #include "Events/EventRouter.h"
00014 #include "Motion/PostureMC.h"
00015 #include "Motion/HeadPointerMC.h"
00016 
00017 //! DESCRIPTION
00018 class RoverControllerBehavior : public BehaviorBase {
00019 public:
00020   static const int PORT=10056; //!< port number to open up
00021   
00022   //! returns #theOne, initializing it if necessary
00023   static RoverControllerBehavior& getInstance() {
00024     if(theOne==NULL)
00025       theOne = new RoverControllerBehavior;
00026     return *theOne;
00027   }
00028   
00029   //! destructor
00030   virtual ~RoverControllerBehavior() {
00031     if(isActive())
00032       DoStop();
00033     theOne=NULL;
00034   }
00035   
00036   virtual void DoStart();
00037   virtual void DoStop();
00038 
00039   static std::string getClassDescription() { return "DESCRIPTION"; }
00040   virtual std::string getDescription() const { return getClassDescription(); }
00041   
00042 
00043 protected:
00044   //! constructor
00045   RoverControllerBehavior()
00046     : BehaviorBase("Rover Remote Control"),
00047     tgtScale(1), tgtXOff(0), tgtYOff(0), heightScale(1), heightOff(0), distanceScale(1),
00048     tgtX(0),tgtY(0),tgtZ(0), lookX(0),lookY(0),lookD(0),
00049     gripperAngle(0),perspective(0),
00050     autoGripperAngle(true),autoPerspective(true),autoTrackGripper(true),maxDist(true),
00051     cmdsock(NULL), head(MotionManager::invalid_MC_ID), arm(MotionManager::invalid_MC_ID)
00052   {
00053     initScale();
00054   }
00055   
00056   void initScale();
00057   
00058   //! called by wireless when there's new data, forwards call to theOne->update
00059   static int callback(char *buf, int bytes) { return theOne->update(buf,bytes); }
00060   //! called by wireless (via callback()) when there's new data
00061   int update(char *buf, int bytes);
00062   
00063   void updateArm();
00064   void updateHead();
00065   
00066   static RoverControllerBehavior * theOne;
00067   
00068   float tgtScale;
00069   float tgtXOff;
00070   float tgtYOff;
00071   float heightScale;
00072   float heightOff;
00073   float distanceScale;
00074   
00075   float tgtX;
00076   float tgtY;
00077   float tgtZ;
00078   float lookX;
00079   float lookY;
00080   float lookD;
00081   
00082   float gripperAngle;
00083   float perspective;
00084   
00085   bool autoGripperAngle;
00086   bool autoPerspective;
00087   bool autoTrackGripper;
00088   bool maxDist;
00089   
00090   Socket *cmdsock; //!< The input command stream socket
00091   
00092   MotionManager::MC_ID head;
00093   MotionManager::MC_ID arm;
00094   
00095 private:
00096   // Providing declarations for these functions will avoid a compiler warning if
00097   // you have any class members which are pointers.  However, as it is, an error
00098   // will result if you inadvertantly cause a call to either (which is probably
00099   // a good thing, unless you really intended to copy/assign a behavior, in
00100   // which case simply provide implementations for the functions)
00101   RoverControllerBehavior(const RoverControllerBehavior&); //!< don't call (copy constructor)
00102   RoverControllerBehavior& operator=(const RoverControllerBehavior&); //!< don't call (assignment operator)
00103 };
00104 
00105 /*! @file
00106  * @brief Defines RoverControllerBehavior, which DESCRIPTION
00107  * @author Ethan Tira-Thompson (ejt) (Creator)
00108  *
00109  * $Author: ejt $
00110  * $Name: tekkotsu-4_0 $
00111  * $Revision: 1.4 $
00112  * $State: Exp $
00113  * $Date: 2007/11/13 16:41:14 $
00114  */
00115 
00116 #endif

Tekkotsu v4.0
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4