00001 #ifndef VR_HAPTIC_HDSPIDARMOTOR_H
00002 #define VR_HAPTIC_HDSPIDARMOTOR_H
00003
00004 #include "Base/Affine.h"
00005 #include "Device/DVDaBase.h"
00006 #include "Device/DVAdBase.h"
00007 #include "Device/DVCounterBase.h"
00008
00009 namespace Spr {
00010
00011 class SPR_DLL HISpidarMotor{
00012 public:
00013
00014
00015
00016 float maxForce;
00017
00018 float minForce;
00019
00020 float voltPerNewton;
00021
00022 float currentPerVolt;
00023
00024 float lengthPerPulse;
00025
00026 Vec3f pos;
00027
00028 Vec3f jointPos;
00029
00030
00031
00032
00033
00034 DVDaBase* da;
00035
00036 DVCounterBase* counter;
00037
00038 DVAdBase* ad;
00039
00040
00041 float force;
00042
00043
00044 float voltageInt;
00045 float currentInt;
00046 float timeInt;
00047 float currentLast;
00048 float lengthLast;
00049 float vdd;
00050 PTM::VMatrixCol<float> calibMat;
00051
00052 PTM::VVector<float> calibVec;
00053
00054 Vec4f calibResult;
00055
00056 public:
00057
00058 HISpidarMotor();
00059
00060 virtual ~HISpidarMotor(){}
00061
00062 void SetForce(float f){
00063 if(f < minForce) f = minForce;
00064 if(f > maxForce) f = maxForce;
00065 if(da) da->Voltage(f * voltPerNewton);
00066 force = f;
00067 }
00068
00069 float GetForce(){
00070 return force;
00071 }
00072
00073 float GetCurrent(){
00074 return force * voltPerNewton * currentPerVolt;
00075 }
00076
00077 void SetLength(float l){ if(counter) counter->Count(long(l / lengthPerPulse)); }
00078
00079 float GetLength(){
00080 if(counter) return counter->Count() * lengthPerPulse;
00081 else return 0;
00082 }
00083
00084 float GetVelocity();
00085
00086 void GetCalibrationData(float dt);
00087
00088 void Calibrate(bool bUpdate);
00089
00090 void GetVdd();
00091 };
00092
00093 }
00094 #endif