00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __GLOVE_CYBERGLOVE_HPP_
00028 #define __GLOVE_CYBERGLOVE_HPP_
00029
00030 #include "../config.hpp"
00031
00032 #include <string>
00033 #include <vector>
00034 #include <bitset>
00035
00036 #include "Device.hpp"
00037
00038 namespace glove {
00039 namespace devices {
00040
00047 class API CyberGlove: public virtual Device {
00048
00049 public:
00051 enum Finger {
00052 THUMB = 0, INDEX, MIDDLE, RING, PINKY
00053 };
00054
00056 enum Joint {
00057 METACARPAL = 0, PROXIMAL, DISTAL, ABDUCTION
00058 };
00059
00064 enum Sensor {
00065 THUMB_METACARPAL = 0,
00066 THUMB_ROTATION = THUMB_METACARPAL,
00067 THUMB_OPPOSE = THUMB_METACARPAL,
00068 THUMB_PROXIMAL,
00069 THUMB_DISTAL,
00070 THUMB_ABDUCTION,
00071 INDEX_METACARPAL = 4,
00072 INDEX_PROXIMAL,
00073 INDEX_DISTAL,
00074 INDEX_ABDUCTION,
00075 MIDDLE_METACARPAL = 8,
00076 MIDDLE_PROXIMAL,
00077 MIDDLE_DISTAL,
00078 MIDDLE_ABDUCTION,
00079 RING_METACARPAL = 12,
00080 RING_PROXIMAL,
00081 RING_DISTAL,
00082 RING_ABDUCTION,
00083 PINKY_METACARPAL = 16,
00084 PINKY_PROXIMAL,
00085 PINKY_DISTAL,
00086 PINKY_ABDUCTION,
00087 PALM_ARCH = 20,
00088 WRIST_PITCH,
00089 WRIST_YAW
00090 };
00091
00093 static const unsigned int numFingers;
00098 static const unsigned int maxNumberOfJointsPerFinger;
00100 static const unsigned int maxNumberOfSensorValues;
00104 static const unsigned int sensorRecordSize;
00105
00113 class API Calibration {
00114 public:
00118 Calibration();
00122 virtual ~Calibration();
00123
00133 virtual double map(const Finger f, const Joint j, const double value);
00134
00143 virtual double map(const Sensor s, const double value);
00150 virtual void map(std::vector<double>& values);
00151 };
00152
00154 static const std::string DEVICE_ID;
00155
00164 class sensor_iterator {
00165 CyberGlove& glove;
00166 int sensorId;
00167
00168 public:
00173 sensor_iterator(CyberGlove& glove);
00177 virtual ~sensor_iterator();
00178
00185 sensor_iterator& operator=(const Sensor s);
00186
00190 sensor_iterator& operator++();
00195 sensor_iterator operator++(int unused);
00199 sensor_iterator& operator+=(const unsigned int i);
00200
00205 unsigned int operator*() const;
00206
00213 bool operator==(sensor_iterator& itr);
00220 bool operator!=(sensor_iterator& itr);
00221 };
00222
00223 private:
00224 static CyberGlove::Calibration defaultCalib;
00225
00226 protected:
00228 CyberGlove::Calibration* calib;
00229
00230 public:
00232 static CyberGlove::Calibration* DEFAULT_CALIB;
00233
00237 CyberGlove();
00241 virtual ~CyberGlove();
00242
00248 virtual const std::bitset<24> getEnabledSensors() = 0;
00249
00254 virtual unsigned int numSensors() = 0;
00259 virtual bool isTipless();
00260
00265 virtual bool isRightHanded() = 0;
00270 virtual bool isLeftHanded() = 0;
00271
00276 virtual bool isStreaming() = 0;
00277
00283 virtual void setCalibration(CyberGlove::Calibration* c);
00284
00299 virtual const std::vector<double> getValues() = 0;
00306 virtual double getValue(const Sensor s) = 0;
00318 virtual double getValue(const Finger f, const Joint j);
00319
00328 virtual const std::vector<double> getAngles(const bool degree = false);
00337 virtual double getAngle(const Sensor s, const bool degree = false);
00351 virtual double getAngle(const Finger f, const Joint j, const bool degree = false);
00352
00360 static Sensor toSensorId(const Finger f, const Joint j);
00372 virtual Sensor getSensorId(const Finger f, const Joint j);
00373
00378 virtual std::string info() = 0;
00383 virtual std::pair<int, int> version() = 0;
00384
00389 virtual const std::string& getTypeIdentifier() const;
00394 static std::string toString(const Finger f, const Joint j);
00395 };
00396
00397 }
00398 }
00399
00400 #endif