00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MovingLegs7_h_DEFINED
00013 #define MovingLegs7_h_DEFINED
00014
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include "def.h"
00019
00020 enum MovingLegs7State {
00021 MLS_IDLE,
00022 MLS_START,
00023 MLS_ADJUSTING_DIFF_JOINT_VALUE,
00024 MLS_MOVING_TO_BROADBASE,
00025 MLS_MOVING_TO_SLEEPING
00026 };
00027
00028 enum MovingResult {
00029 MOVING_CONT,
00030 MOVING_FINISH
00031 };
00032
00033 static const char* const JOINT_LOCATOR[] = {
00034 "PRM:/r4/c1-Joint2:41",
00035 "PRM:/r4/c1/c2-Joint2:42",
00036 "PRM:/r4/c1/c2/c3-Joint2:43",
00037
00038 "PRM:/r2/c1-Joint2:21",
00039 "PRM:/r2/c1/c2-Joint2:22",
00040 "PRM:/r2/c1/c2/c3-Joint2:23",
00041
00042 "PRM:/r5/c1-Joint2:51",
00043 "PRM:/r5/c1/c2-Joint2:52",
00044 "PRM:/r5/c1/c2/c3-Joint2:53",
00045
00046 "PRM:/r3/c1-Joint2:31",
00047 "PRM:/r3/c1/c2-Joint2:32",
00048 "PRM:/r3/c1/c2/c3-Joint2:33"
00049 };
00050
00051 const double BROADBASE_ANGLE[] = {
00052 120,
00053 90,
00054 30,
00055
00056 120,
00057 90,
00058 30,
00059
00060 -120,
00061 70,
00062 30,
00063
00064 -120,
00065 70,
00066 30
00067 };
00068
00069 const double SLEEPING_ANGLE[] = {
00070 59,
00071 0,
00072 30,
00073
00074 59,
00075 0,
00076 30,
00077
00078 -119,
00079 4,
00080 122,
00081
00082 -119,
00083 4,
00084 122
00085 };
00086
00087 class MovingLegs7 : public OObject {
00088 public:
00089 MovingLegs7();
00090 virtual ~MovingLegs7() {}
00091
00092 OSubject* subject[numOfSubject];
00093 OObserver* observer[numOfObserver];
00094
00095 virtual OStatus DoInit (const OSystemEvent& event);
00096 virtual OStatus DoStart (const OSystemEvent& event);
00097 virtual OStatus DoStop (const OSystemEvent& event);
00098 virtual OStatus DoDestroy(const OSystemEvent& event);
00099
00100 void Ready(const OReadyEvent& event);
00101
00102 private:
00103 void OpenPrimitives();
00104 void NewCommandVectorData();
00105 void SetJointGain();
00106 MovingResult AdjustDiffJointValue();
00107 MovingResult MoveToBroadBase();
00108 MovingResult MoveToSleeping();
00109
00110 RCRegion* FindFreeRegion();
00111 void SetJointValue(RCRegion* rgn, int idx, double start, double end);
00112
00113 static const size_t NUM_JOINTS = 12;
00114 static const size_t NUM_COMMAND_VECTOR = 2;
00115
00116 static const word J1_PGAIN = 0x0010;
00117 static const word J1_IGAIN = 0x0004;
00118 static const word J1_DGAIN = 0x0001;
00119
00120 static const word J2_PGAIN = 0x000a;
00121 static const word J2_IGAIN = 0x0004;
00122 static const word J2_DGAIN = 0x0001;
00123
00124 static const word J3_PGAIN = 0x0010;
00125 static const word J3_IGAIN = 0x0004;
00126 static const word J3_DGAIN = 0x0001;
00127
00128 static const word PSHIFT = 0x000e;
00129 static const word ISHIFT = 0x0002;
00130 static const word DSHIFT = 0x000f;
00131
00132 static const int BROADBASE_MAX_COUNTER = 24;
00133 static const int SLEEPING_MAX_COUNTER = 24;
00134
00135 MovingLegs7State movingLegsState;
00136 OPrimitiveID jointID[NUM_JOINTS];
00137 RCRegion* region[NUM_COMMAND_VECTOR];
00138 };
00139
00140 #endif // MovingLegs7_h_DEFINED