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