00001 #ifndef HDSPIDAR_H
00002 #define HDSPIDAR_H
00003
00004 #include "HIHapticDevice.h"
00005 #include "HISpidarMotorAngle.h"
00006 #include "Device/DVDeviceManager.h"
00007 #include <vector>
00008 #include <Base/TMatrix.h>
00009
00010 using namespace PTM;
00011 namespace Spr {
00012
00013 class SPR_DLL HISpidar4Angle: public HIForceDevice6D{
00014 public:
00015
00016 typedef HIForceDevice6D superclass;
00017 protected:
00018 Vec3f initPos[5];
00019 Vec3f pos[5];
00020
00021 Vec3f posSqrConst;
00022
00023 Matrix3f matPos;
00024 Vec3f phi[4];
00025 float realtens[4];
00026 float tension[4];
00027
00028 protected:
00029
00030 HISpidarMotorAngle motor[4];
00031
00032
00033
00034
00035
00036
00037
00038 float AvailableForce(int disable, Vec3f& f, Vec3f* v3Str);
00039
00040 void InitMat();
00041
00042 public:
00043
00044 HISpidar4Angle();
00045
00046 virtual ~HISpidar4Angle();
00047
00048 virtual bool Init(DVDeviceManager& dev);
00049
00050 virtual bool Init(DVDeviceManager& dev, Vec3f* motorPos, Vec3f* iPos, float vpn, float lpp, float app, float minF, float maxF);
00051
00052 virtual bool BeforeCalib(){ SetMinForce(); return true; }
00053
00054 bool Calib();
00055
00056 void SetMinForce();
00057
00058 virtual void SetForce(const Vec3f& f){ SetForce(f, 0.1f); }
00059 virtual void SetForce(const Vec3f& f,float eff){ SetForce(f, eff, 0.0f); }
00060 virtual void SetForce(const Vec3f& f, float eff, float cont);
00061
00062 virtual void Update(float dt);
00063 virtual Vec3f GetForce();
00064 virtual Vec3f GetPos(){return Vec3f();}
00065
00066 virtual Vec3f GetPos(int i){return pos[i];}
00067
00068 HISpidarMotor* Motor(){
00069 return motor;
00070 }
00071
00072
00073 float l1, l2, l3, l4, a1, a2, a3, a4;
00074 float Len[4],Ang[4];
00075 float l1old, l2old, l3old, l4old, a1old, a2old, a3old, a4old;
00076 float l1new, l2new, l3new, l4new, a1new, a2new, a3new, a4new;
00077
00078 float X, Y, Z, X1, Y1, Z1, X2, Y2, Z2;
00079 float Xnew, Ynew, Znew, X1new, Y1new, Z1new, X2new, Y2new, Z2new;
00080 float deltaX, deltaY, deltaZ, deltaX1, deltaY1, deltaZ1, deltaX2, deltaY2, deltaZ2;
00081
00082 float vec1[2], vec2[3],vec3[3];
00083
00084 TMatrixRow<11,9,float> matA;
00085 TMatrixRow<9,9,float> ATA;
00086 TVector<9,float> deltaL;
00087 TVector<9,float> LdeltaL;
00088 TVector<11,float> lengthDiff;
00089 TVector<9,float> postureDiff;
00090 float sigma;
00091 float errorLen;
00092 float errorAng;
00093
00094 Vec3f rot;
00095
00096 void CholeskyFacToGetSolution(TMatrixRow<9,9,float> Q, TVector<9,float> s);
00097 void SetMat(float x,float y, float z, float x1,float y1, float z1, float x2,float y2, float z2);
00098 bool Pos_6dof();
00099 Vec3f GetRot(){return rot;}
00100 void CalcRot();
00101 bool flag;
00102
00103
00104 };
00105
00106
00107 }
00108 #endif
00109