Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

StewartPlatformBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_StewartPlatformBehavior_h_
00003 #define INCLUDED_StewartPlatformBehavior_h_
00004 
00005 #include <iostream>
00006 #include "Behaviors/BehaviorBase.h"
00007 #include "Motion/MotionManager.h"
00008 #include "Shared/Config.h"
00009 
00010 class Socket;
00011 
00012 //*********** NOT DONE **********//
00013 
00014 //! moves the legs in synchrony to emulate the capabilities of a stewart platform
00015 class StewartPlatformBehavior : public BehaviorBase {
00016 
00017 public: 
00018   //! Points to the one StewartPlatformBehavior object that the input command stream is talking to.
00019   static StewartPlatformBehavior * theOne;
00020   static int callback(char *buf, int bytes); //!< called by wireless when there's new data
00021 
00022 public:
00023   //! constructor
00024   StewartPlatformBehavior()
00025     : BehaviorBase("StewartPlatformBehavior"),
00026       cmdsock(NULL), sock(-1), ctxt(NULL), docClosed(false),
00027       pose_id(MotionManager::invalid_MC_ID)
00028   {
00029     theOne=this;
00030   }
00031   //! destructor
00032   virtual ~StewartPlatformBehavior() {
00033     theOne=NULL;
00034   }
00035 
00036   virtual void DoStart();
00037 
00038   virtual void DoStop();
00039 
00040   virtual void processEvent(const EventBase &);
00041 
00042   static std::string getClassDescription() {
00043     char tmp[20];
00044     sprintf(tmp,"%d",*config->main.stewart_port);
00045     return std::string("moves the legs in synchrony to emulate the capabilities of a stewart platform, base on commands from port ")+tmp;
00046   }
00047   virtual std::string getDescription() const { return getClassDescription(); }
00048 
00049   virtual void setParam(const std::string& cmd, float value); //!< processes a string received from wireless
00050 
00051 protected:
00052   //! The input command stream socket
00053   Socket *cmdsock;
00054   int sock; //!< the socket number so we can test if #cmdsock is still valid
00055 
00056   //! contains parsing context regarding communication socket
00057   void* ctxt;
00058   //! set to true by sax routines if the socket should be closed
00059   bool docClosed;
00060 
00061   //! The estop to control
00062   MotionManager::MC_ID pose_id;
00063 
00064   //! fills out (and returns) a xmlSAXHandler structure to control parsing of the communication stream
00065   static void* getSAXHandler();
00066 
00067   //!@name SAX functions
00068   //! handles parsing of communications stream
00069   static void sax_start_element(StewartPlatformBehavior * inst, const char * name, const char ** attrs);
00070   static void sax_end_element(StewartPlatformBehavior * inst, const char * name);
00071   static void sax_end_doc(StewartPlatformBehavior * inst);
00072   static void sax_warning(StewartPlatformBehavior *inst, const char *msg, ...);
00073   static void sax_error(StewartPlatformBehavior *inst, const char *msg, ...);
00074   static void sax_fatal_error(StewartPlatformBehavior *inst, const char *msg, ...);
00075   //@}
00076 
00077   static bool isConnected(); //!< returns true if #theOne is connected
00078   void closeComm(); //!< closes communications socket
00079 
00080 private:
00081   StewartPlatformBehavior(const StewartPlatformBehavior&); //!< don't call
00082   StewartPlatformBehavior operator=(const StewartPlatformBehavior&); //!< don't call
00083 
00084 };
00085 
00086 /*! @file
00087  * @brief Describes StewartPlatformBehavior, moves the legs in synchrony to emulate the capabilities of a stewart platform
00088  * @author tss (Creator)
00089  * 
00090  * $Author: ejt $
00091  * $Name: tekkotsu-4_0 $
00092  * $Revision: 1.4 $
00093  * $State: Exp $
00094  * $Date: 2007/01/30 22:56:19 $
00095  */
00096 
00097 #endif 

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