00001
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
00015 class HeadPointControllerBehavior : public BehaviorBase {
00016
00017 public:
00018
00019
00020
00021 static HeadPointControllerBehavior * theOne;
00022 static int mechacmd_callback(char *buf, int bytes);
00023
00024 protected:
00025 MotionManager::MC_ID head_id;
00026
00027 private:
00028
00029 static const char CMD_tilt = 't';
00030 static const char CMD_pan = 'p';
00031 static const char CMD_roll = 'r';
00032
00033
00034 float t;
00035 float p;
00036 float r;
00037
00038
00039
00040
00041
00042
00043 HeadPointControllerBehavior *theLastOne;
00044
00045
00046 Socket *cmdsock;
00047
00048
00049 void runCommand(unsigned char *command);
00050
00051 HeadPointControllerBehavior(const HeadPointControllerBehavior&);
00052 HeadPointControllerBehavior operator=(const HeadPointControllerBehavior&);
00053
00054 public:
00055
00056 HeadPointControllerBehavior() :
00057 BehaviorBase(),
00058 head_id(MotionManager::invalid_MC_ID),
00059 t(0), p(0), r(0),
00060 theLastOne(theOne),
00061 cmdsock(wireless->socket(SocketNS::SOCK_STREAM, 2048, 2048))
00062 { theOne = this; }
00063
00064 virtual ~HeadPointControllerBehavior() { theOne = theLastOne; }
00065
00066 virtual void DoStart();
00067
00068 virtual void DoStop();
00069
00070
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
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #endif