MovingHead7.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2003 Sony Corporation 
00003 //
00004 // Permission to use, copy, modify, and redistribute this software for
00005 // non-commercial use is hereby granted.
00006 //
00007 // This software is provided "as is" without warranty of any kind,
00008 // either expressed or implied, including but not limited to the
00009 // implied warranties of fitness for a particular purpose.
00010 //
00011 
00012 #ifndef MovingHead7_h_DEFINED
00013 #define MovingHead7_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 MovingHead7State {
00021     MHS_IDLE,
00022     MHS_START,
00023     MHS_ADJUSTING_DIFF_JOINT_VALUE,
00024     MHS_MOVING_TO_ZERO_POS,
00025     MHS_SWING_HEAD
00026 };
00027 
00028 enum MovingResult {
00029     MOVING_CONT,
00030     MOVING_FINISH
00031 };
00032 
00033 static const char* const JOINT_LOCATOR[] = {
00034     "PRM:/r1/c1-Joint2:11",      // TILT1
00035     "PRM:/r1/c1/c2-Joint2:12",   // PAN
00036     "PRM:/r1/c1/c2/c3-Joint2:13" // TILT2
00037 };
00038 
00039 class MovingHead7 : public OObject {
00040 public:
00041     MovingHead7();
00042     virtual ~MovingHead7() {}
00043 
00044     OSubject*  subject[numOfSubject];
00045     OObserver* observer[numOfObserver];
00046 
00047     virtual OStatus DoInit   (const OSystemEvent& event);
00048     virtual OStatus DoStart  (const OSystemEvent& event);
00049     virtual OStatus DoStop   (const OSystemEvent& event);
00050     virtual OStatus DoDestroy(const OSystemEvent& event);
00051 
00052     void Ready(const OReadyEvent& event);
00053 
00054 private:
00055     void          OpenPrimitives();
00056     void          NewCommandVectorData();
00057     void          SetJointGain();
00058     MovingResult  AdjustDiffJointValue();
00059     MovingResult  MoveToZeroPos();
00060     MovingResult  SwingHead();
00061 
00062     RCRegion* FindFreeRegion();
00063     void SetJointValue(RCRegion* rgn, int idx, double start, double end);
00064     void SetJointValue(RCRegion* rgn, int idx, int phase);
00065 
00066     static const size_t NUM_COMMAND_VECTOR = 2;
00067     static const size_t NUM_JOINTS         = 3;
00068     static const int    TILT1_INDEX        = 0;
00069     static const int    PAN_INDEX          = 1;
00070     static const int    TILT2_INDEX        = 2;
00071 
00072     static const double TILT1_ZERO_POS     = 0.0;
00073     static const double PAN_ZERO_POS       = 0.0;
00074     static const double TILT2_ZERO_POS     = 0.0;
00075     static const double SWING_AMPLITUDE    = 80.0;
00076 
00077     static const word   TILT1_PGAIN        = 0x000a;
00078     static const word   TILT1_IGAIN        = 0x0004;
00079     static const word   TILT1_DGAIN        = 0x0002;
00080 
00081     static const word   PAN_PGAIN          = 0x0008;
00082     static const word   PAN_IGAIN          = 0x0002;
00083     static const word   PAN_DGAIN          = 0x0004;
00084 
00085     static const word   TILT2_PGAIN        = 0x0008;
00086     static const word   TILT2_IGAIN        = 0x0004;
00087     static const word   TILT2_DGAIN        = 0x0002;
00088 
00089     static const word   PSHIFT             = 0x000e;
00090     static const word   ISHIFT             = 0x0002;
00091     static const word   DSHIFT             = 0x000f;
00092 
00093     static const int ZERO_POS_MAX_COUNTER  =  16; // 128ms * 16 = 2048ms
00094     static const int MAX_PHASE             = 128; // phase [0:127]
00095     
00096     MovingHead7State  movingHeadState;
00097     OPrimitiveID      jointID[NUM_JOINTS];
00098     RCRegion*         region[NUM_COMMAND_VECTOR];
00099 };
00100 
00101 #endif // MovingHead7_h_DEFINED

Generated on Sun Dec 2 23:04:29 2007 for openSDK by  doxygen 1.3.9.1