BallTrackingHead/MovingHead2/MovingHead.h

Go to the documentation of this file.
00001 //
00002 // Copyright 2002 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 MovingHead_h_DEFINED
00013 #define MovingHead_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 MovingHeadState {
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:j1",      // TILT
00035     "PRM:/r1/c1/c2-Joint2:j2",   // PAN
00036     "PRM:/r1/c1/c2/c3-Joint2:j3" // ROLL
00037 };
00038 
00039 class MovingHead : public OObject {
00040 public:
00041     MovingHead();
00042     virtual ~MovingHead() {}
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 NotifyCommand(const ONotifyEvent& event);
00053     void ReadyMove(const OReadyEvent& event);
00054 
00055 private:
00056     void          OpenPrimitives();
00057     void          NewCommandVectorData();
00058     void          SetJointGain();
00059     MovingResult  AdjustDiffJointValue();
00060     MovingResult  MoveToZeroPos();
00061     MovingResult  SwingHead();
00062 
00063     RCRegion* FindFreeRegion();
00064     void SetJointValue(RCRegion* rgn, int idx, double start, double end);
00065     void SetJointValue(RCRegion* rgn, int idx, int phase);
00066 
00067     static const size_t NUM_COMMAND_VECTOR = 2;
00068     static const size_t NUM_JOINTS         = 3;
00069     static const int    TILT_INDEX         = 0;
00070     static const int    PAN_INDEX          = 1;
00071     static const int    ROLL_INDEX         = 2;
00072 
00073     static const word   TILT_PGAIN         = 0x000a;
00074     static const word   TILT_IGAIN         = 0x0008;
00075     static const word   TILT_DGAIN         = 0x000c;
00076 
00077     static const word   PAN_PGAIN          = 0x000d;
00078     static const word   PAN_IGAIN          = 0x0008;
00079     static const word   PAN_DGAIN          = 0x000b;
00080 
00081     static const word   ROLL_PGAIN         = 0x000a;
00082     static const word   ROLL_IGAIN         = 0x0008;
00083     static const word   ROLL_DGAIN         = 0x000c;
00084 
00085     static const word   PSHIFT             = 0x000e;
00086     static const word   ISHIFT             = 0x0002;
00087     static const word   DSHIFT             = 0x000f;
00088 
00089     static const int ZERO_POS_MAX_COUNTER  =  16; // 128ms * 16 = 2048ms
00090     static const int MAX_PHASE             = 128; // phase [0:127]
00091 
00092     MovingHeadState  movingHeadState;
00093     OPrimitiveID     jointID[NUM_JOINTS];
00094     RCRegion*        region[NUM_COMMAND_VECTOR];
00095 };
00096 
00097 #endif // MovingHead_h_DEFINED

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