GestureSensors.h

Go to the documentation of this file.
00001 //
00002 //  GestureSensors.h -- interface code for using CSL with gesture sensors that send out OSC
00003 //  See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00004 //      Controller interfaces by Satoshi Morita, Bo Bell, Lance Putnam, and Stephen Pope
00005 //
00006 
00007 #ifndef INCLUDE_GestureSensors_H
00008 #define INCLUDE_GestureSensors_H
00009 
00010 #include "CSL_Includes.h"
00011 #include "OSC_cpp.h"
00012 
00013 // Prototype for the OSC "glue" code
00014 
00015 extern "C" void add_OSC_Method2(char * name, OSC_CALL_BACK function, void * user_data );
00016 
00017 namespace csl {
00018 
00019 // Abstract class for all gesture sensors -- this does most of the work
00020 
00021 class GestureSensor {
00022 
00023 public: 
00024     void * mData;                   // my data array (typically a float *)
00025     char * mCmd;                    // my OSC command name (without the '/')
00026     char * mTypeString;             // my OSC type string, e.g., "ffff"
00027 //  OSC_CALL_BACK * mReaderFcn;     // my OSC call-back function (NB: not a class method)
00028     
00029                                     // Constructors
00030     GestureSensor(char * name, OSC_CALL_BACK * callback);
00031     GestureSensor(char * name, char * types, OSC_CALL_BACK * callback);
00032     virtual ~GestureSensor();
00033     
00034                                     // get my data
00035     virtual void * get_data() { return mData; };
00036     
00037                                     // parse an OSC packet into my data array according to my type string
00038     virtual status parse_OSC_packet(char * typeString, void * args);
00039 };
00040 
00042 
00043 // Concrete class for the 5DT Data Glove 5
00044 //
00045 // packet looks like "/Glove, fffffff, thumb, index, middle, ring, little, roll, pitch 
00046 //  mData is a float arrary  -- 0: thumb, 1: index, 2: middle, 3: ring, 4: little, 5: roll, 6: pitch
00047 
00048 // OSC callback function -- not part of the class
00049 
00050 extern "C" void glove_input(void *inst, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr ra);
00051 
00052 class Glove : public GestureSensor {
00053 
00054 public:                 // Constructor
00055     Glove(char * name) : GestureSensor(name, "fffffff", & glove_input) { };
00056     ~Glove() { };
00057 
00058 };
00059 
00060 // Concrete class for the EBeam whiteboard
00061 //
00062 // Ebeam data packet format: address ,ffff x y status color
00063 //      address - "/EB",        pen message
00064 //                "/EBStart",   eBeam app started
00065 //                "/EBStop",    eBeam app stopped
00066 //      x       - 0 = left, ~3670 = right
00067 //      y       - 0 = top, ~1700 = bottom
00068 //      status  - 0 = pen up, 1 = pen down
00069 //      color   - 0 = black, 1 = red, 2 = green, 3 = blue, 4 = eraser
00070 
00071 // OSC callback function -- not part of the class
00072 
00073 extern "C" void ebeam_input(void *inst, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr ra);
00074 
00075 class EBeam : public GestureSensor {
00076 
00077 public:                 // Constructor
00078     EBeam(char * name) : GestureSensor(name, "ffff", & ebeam_input) { };
00079     ~EBeam() { };
00080                         // data accessors
00081     float get_x() { return ((float * ) mData)[0]; }
00082     float get_y() { return ((float * ) mData)[1]; }
00083 
00084 };
00085 
00086 // Concrete class for the flock of birds magnetic trackers
00087 //
00088 // packet is "/Flock, ffffff, x, y, z, azimuth, elevation, roll
00089 
00090 // OSC callback function -- not part of the class
00091 
00092 extern "C" void bird_input(void *inst, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr ra);
00093 
00094 class Bird : public GestureSensor {
00095 
00096 public:
00097     float mFlockDataOld[6];     // Flock of Birds past data 
00098 
00099                         // Constructor
00100     Bird(char * name) : GestureSensor(name, "ffffff", & bird_input) { };
00101     ~Bird() { };
00102                         // get my data
00103     float get_x() { return ((float * ) mData)[0]; }
00104     float get_y() { return ((float * ) mData)[1]; }
00105     float get_z() { return ((float * ) mData)[2]; }
00106     float get_az() { return ((float * ) mData)[3]; }
00107     float get_el() { return ((float * ) mData)[4]; }
00108     float get_roll() { return ((float * ) mData)[5]; }
00109     
00110     float get_delta_x() { return ((float * ) mData)[0] - mFlockDataOld[0]; }
00111     float get_delta_y() { return ((float * ) mData)[1] - mFlockDataOld[1]; }
00112     float get_delta_z() { return ((float * ) mData)[2] - mFlockDataOld[2]; }
00113     float get_delta_az() { return ((float * ) mData)[3] - mFlockDataOld[3]; }
00114     float get_delta_el() { return ((float * ) mData)[4] - mFlockDataOld[4]; }
00115     float get_delta_roll() { return ((float * ) mData)[5] - mFlockDataOld[5]; }
00116     
00117     void dump();
00118 };
00119 
00120 // Concrete class for DanO's Matrix controller
00121 // Since the packet has a variable-length format, we can't use all of the inherited code
00122 
00123 // OSC callback function -- not part of the class
00124 
00125 extern "C" void matrix_input(void *inst, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr ra);
00126 
00127 class Matrix : public GestureSensor {
00128 
00129 public:                 // Matrix data structure (fixed 12 * 12)
00130     float theMatrix[12][12];        // 12 * 12 floats
00131     float redMatrix[4][4];          // reduced to 4 * 4 averages
00132     
00133                         // Constructor
00134     Matrix(char * name);            // use the basic constructor
00135     ~Matrix() {};
00136                         // get my data
00137     void * get_data() { return ((void *) theMatrix); }
00138     
00139     float get_avg(int top, int left, int height, int width);
00140     void compute_reduction();
00141     void dump_matrix();
00142     void dump_reduced_matrix();
00143 };
00144 
00145 // Concrete class for the Essential Reality P5 Data Glove
00146 //
00147 // packet looks like "/p5glove_data, iiiiiiiiiii, ButtA, ButtB, ButtC, thumb, index, middle, ring, little, x, y, z 
00148 //  mData is a float arrary  -- 0: thumb, 1: index, 2: middle, 3: ring, 4: little, 5: x, 6: y, 7: z, ABC
00149 
00150 // OSC callback function -- not part of the class
00151 
00152 extern "C" void p5_input(void *inst, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr ra);
00153 
00154 class P5Glove : public GestureSensor {
00155 
00156 public:                 // Constructor
00157     P5Glove(char * name) : GestureSensor(name, "iiiiiiiiiii", & p5_input) { };
00158     ~P5Glove() { };
00159 
00160 };
00161 
00162 
00163 }
00164 
00165 #endif
00166 

Generated on Fri Apr 6 20:18:13 2007 for CSL by  doxygen 1.4.5-20051010