Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
HeadPointControllerBehavior.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_HeadPointControllerBehavior_h_ 00003 #define INCLUDED_HeadPointControllerBehavior_h_ 00004 00005 #include <iostream> 00006 #include "Wireless/Wireless.h" 00007 #include "Behaviors/BehaviorBase.h" 00008 #include "Motion/MotionManager.h" 00009 #include "Events/EventRouter.h" 00010 #include "Events/EventBase.h" 00011 #include "Shared/Config.h" 00012 00013 //! Listens to control commands coming in from the command port for remotely controlling the head 00014 class HeadPointControllerBehavior : public BehaviorBase { 00015 00016 public: 00017 //! Points to the one HeadPointControllerBehavior object that the input 00018 //! command stream is talking to. A kludge. Dunno how you're gonna 00019 //! make sure you're not using this uninitialized. 00020 static HeadPointControllerBehavior * theOne; 00021 static int mechacmd_callback(char *buf, int bytes); //!< called by wireless when there's new data 00022 00023 protected: 00024 MotionManager::MC_ID head_id; //!< the HeadPointerMC to use 00025 00026 private: 00027 //!@name Command Bytes 00028 static const char CMD_tilt = 't'; //!< handy symbol for matching incoming communication 00029 static const char CMD_pan = 'p'; 00030 static const char CMD_roll = 'r'; 00031 //@} 00032 00033 float t; //!< head parameter 00034 float p; //!< head parameter 00035 float r; //!< head parameter 00036 00037 //! The last HPCB object that was theOne, so we can restore it 00038 //! to prominence when we die. This is a nice gesture, but it doesn't 00039 //! really make sense since we're all using the same port. But just 00040 //! in case something changes and we don't do that, this mechanism 00041 //! is in place. 00042 HeadPointControllerBehavior *theLastOne; 00043 00044 //! The input command stream socket 00045 Socket *cmdsock; 00046 00047 //! Executes a command. Called by mechacmd_callback. 00048 void runCommand(unsigned char *command); 00049 00050 HeadPointControllerBehavior(const HeadPointControllerBehavior&); //!< don't call 00051 HeadPointControllerBehavior operator=(const HeadPointControllerBehavior&); //!< don't call 00052 00053 public: 00054 //! constructor 00055 HeadPointControllerBehavior() : 00056 BehaviorBase("HeadPointControllerBehavior"), 00057 head_id(MotionManager::invalid_MC_ID), 00058 t(0), p(0), r(0), 00059 theLastOne(theOne), 00060 cmdsock(NULL) 00061 {} 00062 //! destructor 00063 virtual ~HeadPointControllerBehavior() { theOne = theLastOne; } 00064 00065 virtual void DoStart(); 00066 00067 virtual void DoStop(); 00068 00069 //! The only event we could possibly receive is the stop-if-no-heartbeat timer. 00070 virtual void processEvent(const EventBase &) {} 00071 00072 static std::string getClassDescription() { 00073 char tmp[20]; 00074 sprintf(tmp,"%d",config->main.headControl_port); 00075 return std::string("Listens to head control commands coming in from port ")+tmp; 00076 } 00077 virtual std::string getDescription() const { return getClassDescription(); } 00078 }; 00079 00080 /*! @file 00081 * @brief Describes HeadPointControllerBehavior, listens to control commands coming in from the command port for remotely controlling the head 00082 * @author tss (Creator) 00083 * 00084 * $Author: ejt $ 00085 * $Name: tekkotsu-2_2_1 $ 00086 * $Revision: 1.4 $ 00087 * $State: Exp $ 00088 * $Date: 2004/11/11 01:45:36 $ 00089 */ 00090 00091 #endif |
Tekkotsu v2.2.1 |
Generated Tue Nov 23 16:36:38 2004 by Doxygen 1.3.9.1 |