00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MoNetAgentManager_h_DEFINED
00013 #define MoNetAgentManager_h_DEFINED
00014
00015 #include <list>
00016 using namespace std;
00017
00018 #include <OPENR/OSubject.h>
00019 #include <OPENR/OObserver.h>
00020 #include <MoNetData.h>
00021 #include <ODA.h>
00022
00023 const int HEAD_TILT = 0;
00024 const int HEAD_TILT1 = 0;
00025 const int HEAD_PAN = 1;
00026 const int HEAD_ROLL = 2;
00027 const int HEAD_TILT2 = 2;
00028 const int RFLEG_J1 = 3;
00029 const int RFLEG_J2 = 4;
00030 const int RFLEG_J3 = 5;
00031 const int LFLEG_J1 = 6;
00032 const int LFLEG_J2 = 7;
00033 const int LFLEG_J3 = 8;
00034 const int RRLEG_J1 = 9;
00035 const int RRLEG_J2 = 10;
00036 const int RRLEG_J3 = 11;
00037 const int LRLEG_J1 = 12;
00038 const int LRLEG_J2 = 13;
00039 const int LRLEG_J3 = 14;
00040 const int TAIL_TILT = 15;
00041 const int TAIL_PAN = 16;
00042 const int MOUTH = 17;
00043 const int LEFT_EAR = 18;
00044 const int RIGHT_EAR = 19;
00045
00046 const int DRX900_NUM_JOINTS = 15;
00047 static const char* const DRX900_JOINT_LOCATOR[] = {
00048 "PRM:/r1/c1-Joint2:j1",
00049 "PRM:/r1/c1/c2-Joint2:j2",
00050 "PRM:/r1/c1/c2/c3-Joint2:j3",
00051 "PRM:/r4/c1-Joint2:j1",
00052 "PRM:/r4/c1/c2-Joint2:j2",
00053 "PRM:/r4/c1/c2/c3-Joint2:j3",
00054 "PRM:/r2/c1-Joint2:j1",
00055 "PRM:/r2/c1/c2-Joint2:j2",
00056 "PRM:/r2/c1/c2/c3-Joint2:j3",
00057 "PRM:/r5/c1-Joint2:j1",
00058 "PRM:/r5/c1/c2-Joint2:j2",
00059 "PRM:/r5/c1/c2/c3-Joint2:j3",
00060 "PRM:/r3/c1-Joint2:j1",
00061 "PRM:/r3/c1/c2-Joint2:j2",
00062 "PRM:/r3/c1/c2/c3-Joint2:j3",
00063 };
00064
00065 const int DRX1000_NUM_JOINT2 = 18;
00066 const int DRX1000_NUM_JOINT4 = 2;
00067 const int DRX1000_NUM_JOINTS = DRX1000_NUM_JOINT2 + DRX1000_NUM_JOINT4;
00068 static const char* const DRX1000_JOINT_LOCATOR[] = {
00069 "PRM:/r1/c1-Joint2:11",
00070 "PRM:/r1/c1/c2-Joint2:12",
00071 "PRM:/r1/c1/c2/c3-Joint2:13",
00072 "PRM:/r4/c1-Joint2:41",
00073 "PRM:/r4/c1/c2-Joint2:42",
00074 "PRM:/r4/c1/c2/c3-Joint2:43",
00075 "PRM:/r2/c1-Joint2:21",
00076 "PRM:/r2/c1/c2-Joint2:22",
00077 "PRM:/r2/c1/c2/c3-Joint2:23",
00078 "PRM:/r5/c1-Joint2:51",
00079 "PRM:/r5/c1/c2-Joint2:52",
00080 "PRM:/r5/c1/c2/c3-Joint2:53",
00081 "PRM:/r3/c1-Joint2:31",
00082 "PRM:/r3/c1/c2-Joint2:32",
00083 "PRM:/r3/c1/c2/c3-Joint2:33",
00084 "PRM:/r6/c1-Joint2:61",
00085 "PRM:/r6/c2-Joint2:62",
00086 "PRM:/r1/c1/c2/c3/c4-Joint2:14",
00087 "PRM:/r1/c1/c2/c3/e5-Joint4:15",
00088 "PRM:/r1/c1/c2/c3/e6-Joint4:16"
00089 };
00090
00091 const int MAX_NUM_JOINTS = DRX1000_NUM_JOINTS;
00092 const int NUM_FRAMES = 4;
00093
00094 class MoNetAgent;
00095
00096 class MoNetAgentManager {
00097 public:
00098 MoNetAgentManager();
00099 ~MoNetAgentManager() {}
00100
00101 void InitDRX900();
00102 void InitDRX1000();
00103 void Start(OSubject* effector);
00104
00105 void RegisterMoNetAgent(MoNetAgent* m);
00106
00107 void NotifyCommand(const ONotifyEvent& event, MoNetAgentResult* result);
00108 void ReadyEffector(const OReadyEvent& event, MoNetAgentResult* result);
00109
00110 OPrimitiveID PrimitiveID(int idx) { return primitiveID[idx]; }
00111 OSubject* Effector() { return effectorSubject; }
00112 RCRegion* FindFreeCommandRegion();
00113
00114 private:
00115 void OpenPrimitivesDRX900();
00116 void NewCommandVectorDataDRX900();
00117
00118 void OpenPrimitivesDRX1000();
00119 void NewCommandVectorDataDRX1000();
00120
00121 void LoadMotionODA();
00122
00123 static const size_t NUM_COMMAND_VECTOR = 4;
00124
00125 MoNetAgent* prevMoNetAgent;
00126 MoNetAgent* activeMoNetAgent;
00127 MoNetAgentCommand activeAgentCommand;
00128 list<MoNetAgent*> moNetAgentList;
00129
00130 OSubject* effectorSubject;
00131 OPrimitiveID primitiveID[MAX_NUM_JOINTS];
00132
00133 RCRegion* commandRegions[NUM_COMMAND_VECTOR];
00134
00135 ODesignDataID motionDataID;
00136 ODA motionODA;
00137 };
00138
00139 #endif // MoNetAgentManager_h_DEFINED