SensorObserver.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 SensorObserver_h_DEFINED
00013 #define SensorObserver_h_DEFINED
00014 
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h> 
00017 #include <OPENR/OObserver.h>
00018 #include "def.h"
00019 
00020 const int NUM_COMMON_SENSORS = 28;
00021 const int NUM_ERS210_SENSORS = 3;
00022 const int NUM_ERS220_SENSORS = 3;
00023 
00024 const int ACC_Y      =  0;
00025 const int ACC_X      =  1;
00026 const int ACC_Z      =  2; 
00027 const int TACT_R     =  3;
00028 const int TACT_F     =  4;
00029 const int TIN_SW     =  5;
00030 const int PSD        =  6;
00031 const int HEAD_TILT  =  7;
00032 const int HEAD_PAN   =  8;
00033 const int HEAD_ROLL  =  9;
00034 const int RFLEG_J1   = 10;
00035 const int RFLEG_J2   = 11;
00036 const int RFLEG_J3   = 12;
00037 const int RFLEG_SW   = 13;
00038 const int LFLEG_J1   = 14;
00039 const int LFLEG_J2   = 15;
00040 const int LFLEG_J3   = 16;
00041 const int LFLEG_SW   = 17;
00042 const int RRLEG_J1   = 18;
00043 const int RRLEG_J2   = 19;
00044 const int RRLEG_J3   = 20;
00045 const int RRLEG_SW   = 21;
00046 const int LRLEG_J1   = 22;
00047 const int LRLEG_J2   = 23;
00048 const int LRLEG_J3   = 24;
00049 const int LRLEG_SW   = 25;
00050 const int BACK_SW    = 26;
00051 const int THERMO     = 27;
00052 
00053 const int MOUTH      =  0;
00054 const int TAIL_PAN   =  1;
00055 const int TAIL_TILT  =  2;
00056 
00057 const int TAIL_SW_L  =  0;
00058 const int TAIL_SW_M  =  1;
00059 const int TAIL_SW_R  =  2;
00060 
00061 static const char* const COMMON_SENSOR_LOCATOR[] = {
00062     // BODY CPC
00063     "PRM:/a1-Sensor:a1",                // ACCELEROMETER Y
00064     "PRM:/a2-Sensor:a2",                // ACCELEROMETER X
00065     "PRM:/a3-Sensor:a3",                // ACCELEROMETER Z
00066 
00067     // HEAD CPC
00068     "PRM:/r1/c1/c2/c3/f1-Sensor:f1",    // HEAD TACTILE SENSOR (REAR)
00069     "PRM:/r1/c1/c2/c3/f2-Sensor:f2",    // HEAD TACTILE SENSOR (FRONT)
00070     "PRM:/r1/c1/c2/c3/c4/s5-Sensor:s5", // TIN SWITCH
00071     "PRM:/r1/c1/c2/c3/p1-Sensor:p1",    // PSD
00072     "PRM:/r1/c1-Joint2:j1",             // HEAD TILT
00073     "PRM:/r1/c1/c2-Joint2:j2",          // HEAD PAN
00074     "PRM:/r1/c1/c2/c3-Joint2:j3",       // HEAD ROLL
00075 
00076     // RFLEG CPC
00077     "PRM:/r4/c1-Joint2:j1",             // RFLEG J1 (Right Front Leg)
00078     "PRM:/r4/c1/c2-Joint2:j2",          // RFLEG J2
00079     "PRM:/r4/c1/c2/c3-Joint2:j3",       // RFLEG J3
00080     "PRM:/r4/c1/c2/c3/c4-Sensor:s4",    // RFLEG SW
00081 
00082     // LFLEG CPC
00083     "PRM:/r2/c1-Joint2:j1",             // LFLEG J1 (Left Front Leg)
00084     "PRM:/r2/c1/c2-Joint2:j2",          // LFLEG J2
00085     "PRM:/r2/c1/c2/c3-Joint2:j3",       // LFLEG J3
00086     "PRM:/r2/c1/c2/c3/c4-Sensor:s4",    // LFLEG SW 
00087 
00088     // RRLEG CPC
00089     "PRM:/r5/c1-Joint2:j1",             // RRLEG J1 (Right Rear Leg)
00090     "PRM:/r5/c1/c2-Joint2:j2",          // RRLEG J2
00091     "PRM:/r5/c1/c2/c3-Joint2:j3",       // RRLEG J3
00092     "PRM:/r5/c1/c2/c3/c4-Sensor:s4",    // RRLEG SW
00093 
00094     // LRLEG CPC
00095     "PRM:/r3/c1-Joint2:j1",             // LRLEG J1 (Left Rear Leg)
00096     "PRM:/r3/c1/c2-Joint2:j2",          // LRLEG J2
00097     "PRM:/r3/c1/c2/c3-Joint2:j3",       // LRLEG J3
00098     "PRM:/r3/c1/c2/c3/c4-Sensor:s4",    // LRLEG SW
00099 
00100     // TAIL CPC
00101     "PRM:/r6/s1-Sensor:s1",             // BACK SWITCH
00102     "PRM:/r6/t1-Sensor:t1"              // THERMOMETER
00103 };
00104 
00105 static const char* const ERS210_SENSOR_LOCATOR[] = {
00106     // HEAD CPC
00107     "PRM:/r1/c1/c2/c3/c4-Joint2:j4",    // MOUTH 
00108     
00109     // TAIL CPC
00110     "PRM:/r6/c1-Joint2:j1",             // TAIL PAN
00111     "PRM:/r6/c2-Joint2:j2"              // TAIL TILT
00112 };
00113 
00114 static const char* const ERS220_SENSOR_LOCATOR[] = {
00115     // TAIL CPC
00116     "PRM:/r6/s2-Sensor:s2",             // TAIL SWITCH (LEFT)
00117     "PRM:/r6/s3-Sensor:s3",             // TAIL SWITCH (MID)
00118     "PRM:/r6/s4-Sensor:s4"              // TAIL SWITCH (RIGHT)
00119 };
00120 
00121 class SensorObserver : public OObject {
00122 public:  
00123     SensorObserver();
00124     virtual ~SensorObserver() {}
00125   
00126     OSubject*    subject[numOfSubject];
00127     OObserver*   observer[numOfObserver];
00128 
00129     virtual OStatus DoInit   (const OSystemEvent& event);
00130     virtual OStatus DoStart  (const OSystemEvent& event);
00131     virtual OStatus DoStop   (const OSystemEvent& event);
00132     virtual OStatus DoDestroy(const OSystemEvent& event);
00133     
00134     void NotifyERS210(const ONotifyEvent& event);
00135     void NotifyERS220(const ONotifyEvent& event);
00136 
00137 private:
00138     void InitCommonSensorIndex(OSensorFrameVectorData* sensorVec);
00139     void InitERS210SensorIndex(OSensorFrameVectorData* sensorVec);
00140     void InitERS220SensorIndex(OSensorFrameVectorData* sensorVec);
00141     void PrintCommonSensor(OSensorFrameVectorData* sensorVec);
00142     void PrintERS210Sensor(OSensorFrameVectorData* sensorVec);
00143     void PrintERS220Sensor(OSensorFrameVectorData* sensorVec);
00144     void PrintSensorValue(OSensorFrameVectorData* sensorVec, int index);
00145     void PrintJointValue(OSensorFrameVectorData* sensorVec, int index);
00146     void PrintSeparator();
00147     void WaitReturnKey();
00148 
00149     bool initSensorIndex;
00150     int  commonidx[NUM_COMMON_SENSORS];
00151     int  ers210idx[NUM_ERS210_SENSORS];
00152     int  ers220idx[NUM_ERS220_SENSORS];
00153 };
00154 
00155 #endif // SensorObserver_h_DEFINED

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