#include <GloveData.h>
Inheritance diagram for gadget::GloveData:


Public Types | |
| enum | { NUM_JOINTS = 4, NUM_COMPONENTS = 6 } |
| enum | GloveJoint { MPJ = 0, PIJ = 1, DIJ = 2, ABDUCT = 3, YAW = 0, PITCH = 1 } |
| enum | GloveComponent { THUMB = 0, INDEX = 1, MIDDLE = 2, RING = 3, PINKY = 4, WRIST = 5 } |
Public Methods | |
| GloveData () | |
| GloveData (const GloveData &data) | |
| int | calcXforms () |
| Calulates all the xform matrices This is calculated based upon the mAngles in the data structure. More... | |
| gmtl::Matrix44f | getLocalTransformMatrix (GloveComponent component, GloveJoint joint) const |
| Returns the transform matrix of the specified joint. More... | |
| std::ostream & | outputAngles (std::ostream &out) const |
| Outputs the angles. More... | |
| std::istream & | inputAngles (std::istream &in) |
Public Attributes | |
| float | mAngles [NUM_COMPONENTS][NUM_JOINTS] |
| gmtl::Matrix44f | mTransforms [NUM_COMPONENTS][(NUM_JOINTS-1)] |
| These are the xforms from TO the coord system of the given joint. More... | |
The angles are the joint angles for all fingers and the wrist DIJ = Distal Interphalangeal Joint --- finger tip PIJ = Proximal " " --- Middle joint MPJ = Metacarpo " " --- closest to hand ABDUCT = spread of fingers
YAW and PITCH apply only to WRIST
xforms transfer you from one coord system to the other. If the xforms are tied together, then they can return complete transformations.
Definition at line 63 of file GloveData.h.
|
|
Definition at line 66 of file GloveData.h.
00066 { NUM_JOINTS = 4, NUM_COMPONENTS = 6 };
|
|
|
Definition at line 67 of file GloveData.h.
|
|
|
Definition at line 69 of file GloveData.h.
|
|
|
Definition at line 42 of file GloveData.cpp. References mAngles, NUM_COMPONENTS, and NUM_JOINTS.
00042 : gadget::InputData() 00043 { 00044 // Zero out the mAngles 00045 for(int i=0;i<NUM_COMPONENTS;i++) 00046 { 00047 for(int j=0;j<NUM_JOINTS;j++) 00048 { 00049 mAngles[i][j] = 0; 00050 } 00051 } 00052 00053 // Matrixes are already identities 00054 } |
|
|
Definition at line 56 of file GloveData.cpp. References mAngles, mTransforms, NUM_COMPONENTS, and NUM_JOINTS.
00056 : gadget::InputData(data) 00057 { 00058 int i; 00059 00060 for (i=0;i<NUM_COMPONENTS;i++) 00061 { 00062 for(int j=0;j<NUM_JOINTS;j++) 00063 { 00064 mAngles[i][j] = data.mAngles[i][j]; 00065 } 00066 } 00067 00068 for(i=0;i<NUM_COMPONENTS;i++) 00069 { 00070 for(int j=0;j<NUM_JOINTS-1;j++) 00071 { 00072 mTransforms[i][j] = data.mTransforms[i][j]; 00073 } 00074 } 00075 } |
|
|
Calulates all the xform matrices This is calculated based upon the mAngles in the data structure. I am just rotating around single axis for fingers, not taking abduct into account The thumb is a complete fudge. Wrist is not being done at all Definition at line 85 of file GloveData.cpp. References DIJ, INDEX, mAngles, MIDDLE, MPJ, mTransforms, NUM_COMPONENTS, NUM_JOINTS, PIJ, PINKY, RING, and THUMB.
00086 {
00087 gmtl::Vec3f xAxis(1.0f, 0.0f, 0.0f);
00088 gmtl::Vec3f yAxis(0.0f, 1.0f, 0.0f);
00089 gmtl::Vec3f zAxis(0.0f, 0.0f, 1.0f);
00090 const float toMeters(1.0f/PositionUnitConversion::ConvertToInches);
00091 gmtl::Vec3f dims[NUM_COMPONENTS][NUM_JOINTS];
00092
00093 // DIJ+1 = Length distal
00094 // DIJ = Length medial
00095 // PIJ = Length proximal
00096 // MPJ = Length to finger
00097
00098 // TODO: Do this once at startup, since it doesn't change.
00099 // And this really should be part of the Glove, so you can specify the dimension of a hand in the config file
00100
00101 dims[THUMB][DIJ+1] = yAxis * (toMeters * 0.5f);
00102 dims[THUMB][DIJ] = yAxis * (toMeters * 0.5f);
00103 dims[THUMB][PIJ] = yAxis * (toMeters * 0.5f);
00104 dims[THUMB][MPJ] = xAxis * (toMeters * -0.5f);
00105
00106 dims[INDEX][DIJ+1] = yAxis * (toMeters * 0.5f);
00107 dims[INDEX][DIJ] = yAxis * (toMeters * 1.0f);
00108 dims[INDEX][PIJ] = yAxis * (toMeters * 1.3f);
00109 dims[INDEX][MPJ] = (yAxis * (toMeters * 1.7f)) + (toMeters * xAxis * -0.4f);
00110
00111 dims[MIDDLE][DIJ+1] = yAxis * (toMeters * 0.5f);
00112 dims[MIDDLE][DIJ] = yAxis * (toMeters * 1.1f);
00113 dims[MIDDLE][PIJ] = yAxis * (toMeters * 1.4f);
00114 dims[MIDDLE][MPJ] = (yAxis * (toMeters * 1.8f)) + (toMeters * xAxis * 0.0f);
00115
00116 dims[RING][DIJ+1] = yAxis * (toMeters * 0.4f);
00117 dims[RING][DIJ] = yAxis * (toMeters * 1.0f);
00118 dims[RING][PIJ] = yAxis * (toMeters * 1.1f);
00119 dims[RING][MPJ] = (yAxis * (toMeters * 1.7f)) + (toMeters * xAxis * 0.4f);
00120
00121 dims[PINKY][DIJ+1] = yAxis * (toMeters * 0.3f);
00122 dims[PINKY][DIJ] = yAxis * (toMeters * 1.0f);
00123 dims[PINKY][PIJ] = yAxis * (toMeters * 0.85f);
00124 dims[PINKY][MPJ] = (yAxis * (toMeters * 1.6f)) + (toMeters * xAxis * 0.7f);
00125
00126 // ----------------------- //
00127 // ----- XFORMS ---------- //
00128 // ----------------------- //
00129
00130 // THUMB
00131 gmtl::setRot(mTransforms[THUMB][DIJ], gmtl::AxisAnglef( mAngles[THUMB][DIJ], xAxis ) );
00132 gmtl::preMult(mTransforms[THUMB][DIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[THUMB][DIJ]));
00133 gmtl::setRot(mTransforms[THUMB][PIJ], gmtl::AxisAnglef( mAngles[THUMB][PIJ], xAxis ) );
00134 gmtl::preMult(mTransforms[THUMB][PIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[THUMB][PIJ]));
00135 gmtl::setRot(mTransforms[THUMB][MPJ], gmtl::AxisAnglef( gmtl::Math::PI_OVER_4, zAxis ) );
00136 gmtl::preMult(mTransforms[THUMB][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[THUMB][MPJ]));
00137
00138 // Do we need to rotate this by the mAngles too?
00139 // gmtl::setRot(mTransforms[THUMB][MPJ], gmtl::AxisAnglef( mAngles[THUMB][MPJ], xAxis ) );
00140 // gmtl::preMult(mTransforms[THUMB][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[THUMB][MPJ]));
00141
00142 // INDEX
00143 gmtl::setRot(mTransforms[INDEX][DIJ], gmtl::AxisAnglef( mAngles[INDEX][DIJ], xAxis ) );
00144 gmtl::preMult(mTransforms[INDEX][DIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[INDEX][DIJ]));
00145 gmtl::setRot(mTransforms[INDEX][PIJ], gmtl::AxisAnglef( mAngles[INDEX][PIJ], xAxis ) );
00146 gmtl::preMult(mTransforms[INDEX][PIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[INDEX][PIJ]));
00147 gmtl::setRot(mTransforms[INDEX][MPJ], gmtl::AxisAnglef( mAngles[INDEX][MPJ], xAxis ) );
00148 gmtl::preMult(mTransforms[INDEX][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[INDEX][MPJ]));
00149
00150 // MIDDLE
00151 gmtl::setRot(mTransforms[MIDDLE][DIJ], gmtl::AxisAnglef( mAngles[MIDDLE][DIJ], xAxis ) );
00152 gmtl::preMult(mTransforms[MIDDLE][DIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[MIDDLE][DIJ]));
00153 gmtl::setRot(mTransforms[MIDDLE][PIJ], gmtl::AxisAnglef( mAngles[MIDDLE][PIJ], xAxis ) );
00154 gmtl::preMult(mTransforms[MIDDLE][PIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[MIDDLE][PIJ]));
00155 gmtl::setRot(mTransforms[MIDDLE][MPJ], gmtl::AxisAnglef( mAngles[MIDDLE][MPJ], xAxis ) );
00156 gmtl::preMult(mTransforms[MIDDLE][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[MIDDLE][MPJ]));
00157
00158 // RING
00159 gmtl::setRot(mTransforms[RING][DIJ], gmtl::AxisAnglef( mAngles[RING][DIJ], xAxis ) );
00160 gmtl::preMult(mTransforms[RING][DIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[RING][DIJ]));
00161 gmtl::setRot(mTransforms[RING][PIJ], gmtl::AxisAnglef( mAngles[RING][PIJ], xAxis ) );
00162 gmtl::preMult(mTransforms[RING][PIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[RING][PIJ]));
00163 gmtl::setRot(mTransforms[RING][MPJ], gmtl::AxisAnglef( mAngles[RING][MPJ], xAxis ) );
00164 gmtl::preMult(mTransforms[RING][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[RING][MPJ]));
00165
00166 // PINKY
00167 gmtl::setRot(mTransforms[PINKY][DIJ], gmtl::AxisAnglef( mAngles[PINKY][DIJ], xAxis ) );
00168 gmtl::preMult(mTransforms[PINKY][DIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[PINKY][DIJ]));
00169 gmtl::setRot(mTransforms[PINKY][PIJ], gmtl::AxisAnglef( mAngles[PINKY][PIJ], xAxis ) );
00170 gmtl::preMult(mTransforms[PINKY][PIJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[PINKY][PIJ]));
00171 gmtl::setRot(mTransforms[PINKY][MPJ], gmtl::AxisAnglef( mAngles[PINKY][MPJ], xAxis ) );
00172 gmtl::preMult(mTransforms[PINKY][MPJ], gmtl::makeTrans<gmtl::Matrix44f>(dims[PINKY][MPJ]));
00173
00174 return 1;
00175 }
|
|
||||||||||||
|
Returns the transform matrix of the specified joint.
Definition at line 85 of file GloveData.h.
00086 {
00087 return mTransforms[component][joint];
00088 }
|
|
|
Outputs the angles. TODO: Convert this to XML? Definition at line 178 of file GloveData.cpp. References mAngles, NUM_COMPONENTS, and NUM_JOINTS.
00179 {
00180 for(int i=0;i<NUM_COMPONENTS;i++)
00181 {
00182 for(int j=0;j<NUM_JOINTS;j++)
00183 {
00184 out << mAngles[i][j] << " ";
00185 }
00186 }
00187
00188 return out;
00189 }
|
|
|
Definition at line 192 of file GloveData.cpp. References mAngles, NUM_COMPONENTS, and NUM_JOINTS.
00193 {
00194 for(int i=0;i<NUM_COMPONENTS;i++)
00195 {
00196 for(int j=0;j<NUM_JOINTS;j++)
00197 {
00198 in >> mAngles[i][j];
00199 }
00200 }
00201
00202 return in;
00203 }
|
|
|
Definition at line 98 of file GloveData.h. Referenced by calcXforms, GloveData, inputAngles, and outputAngles. |
|
|
These are the xforms from TO the coord system of the given joint.
Ex: xforms[0] ==> Definition at line 105 of file GloveData.h. Referenced by calcXforms, and GloveData. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002