UPennWalkControllerBehavior.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_UPennWalkControllerBehavior_h_
00003 #define INCLUDED_UPennWalkControllerBehavior_h_
00004
00005 #include <iostream>
00006 #include "Wireless/Wireless.h"
00007 #include "Behaviors/BehaviorBase.h"
00008 #include "Motion/MotionManager.h"
00009 #include "Motion/UPennWalkMC.h"
00010 #include "Motion/MMAccessor.h"
00011 #include "Events/EventRouter.h"
00012 #include "Events/EventBase.h"
00013 #include "Shared/Config.h"
00014 #include "IPC/SharedObject.h"
00015
00016
00017 class UPennWalkControllerBehavior : public BehaviorBase {
00018
00019 public:
00020
00021
00022
00023 static UPennWalkControllerBehavior * theOne;
00024 static int mechacmd_callback(char *buf, int bytes);
00025
00026 protected:
00027 SharedObject<UPennWalkMC> shared_walker;
00028
00029 private:
00030
00031 static const char CMD_fwd = 'f';
00032 static const char CMD_roto = 'r';
00033 static const char CMD_side = 's';
00034 static const char CMD_opt0 = '0';
00035 static const char CMD_opt1 = '1';
00036 static const char CMD_opt2 = '2';
00037 static const char CMD_opt3 = '3';
00038 static const char CMD_opt4 = '4';
00039 static const char CMD_opt5 = '5';
00040 static const char CMD_opt6 = '6';
00041 static const char CMD_opt7 = '7';
00042 static const char CMD_opt8 = '8';
00043 static const char CMD_opt9 = '9';
00044
00045
00046 float dx;
00047 float dy;
00048 float da;
00049
00050
00051
00052
00053
00054
00055 UPennWalkControllerBehavior *theLastOne;
00056
00057
00058 Socket *cmdsock;
00059
00060
00061 void runCommand(unsigned char *command);
00062
00063 UPennWalkControllerBehavior(const UPennWalkControllerBehavior&);
00064 UPennWalkControllerBehavior operator=(const UPennWalkControllerBehavior&);
00065
00066 public:
00067
00068 UPennWalkControllerBehavior() :
00069 BehaviorBase("UPennWalkControllerBehavior"),
00070 shared_walker(),
00071 dx(0), dy(0), da(0),
00072 theLastOne(theOne),
00073 cmdsock(NULL)
00074 {}
00075
00076 virtual ~UPennWalkControllerBehavior() { theOne = theLastOne; }
00077
00078 virtual void doStart();
00079
00080 virtual void doStop();
00081
00082 virtual UPennWalkMC * getWalkMC() { return &(*shared_walker); }
00083
00084 virtual MotionManager::MC_ID getWalkID() { return shared_walker->getID(); }
00085
00086
00087 virtual void doEvent() {
00088 MMAccessor<UPennWalkMC> walker(getWalkID());
00089 walker->setTargetVelocity(0,0,0);
00090 }
00091
00092 static std::string getClassDescription() {
00093 char tmp[20];
00094 sprintf(tmp,"%d",*config->main.walkControl_port);
00095 return std::string("Listens to walk control commands coming in from port ")+tmp;
00096 }
00097 virtual std::string getDescription() const { return getClassDescription(); }
00098 };
00099
00100
00101
00102
00103
00104
00105
00106
00107 #endif