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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00041
00042 #ifndef ArmMC_h
00043 #define ArmMC_h
00044
00045
00046 #include "AbsPosMC.h"
00047 #include "ForwardKinematics/FKPosition.h"
00048 #include "ForwardKinematics/FKJacobian.h"
00049
00050
00051
00053 namespace OSCAR {
00054
00055 struct ControlParam
00056 {
00057 int joint, iter;
00058 double value, kp, kv, threshold;
00059
00060 };
00061
00066 class ArmMC : public AbsPosMC
00067 {
00068 public:
00069
00070 ArmMC(const int numberOfButtons,
00071 const int numberOfDeltas,
00072 const HandPose& startingHand,
00073 const Vector& scalingForces,
00074 const Vector& maximumForces,
00075 const String& nameOfDHFile,
00076 const String& nameOfMotorGainFile,
00077 const String& name,
00078 MC_TYPE type);
00079
00080 ArmMC(const int numberOfButtons,
00081 const int numberOfDeltas,
00082 const HandPose& startingHand,
00083 const Vector& scalingForces,
00084 const Vector& maximumForces,
00085 const String& nameOfDHFile,
00086 const String& name,
00087 MC_TYPE type);
00088
00089
00090 virtual ~ArmMC();
00091
00092
00093 void SetForces(Vector& forces);
00094 void SetTorques(Vector& torques);
00095 void SetScalingForces(Vector& scalingForces);
00096 void SetMaximumForces(Vector& maximumForces);
00097
00098 const void GetForces(Vector& forces);
00099 const void GetAngles(Vector& angles);
00100 const void GetScalingForces(Vector& scalingForces);
00101 const void GetMaximumForces(Vector& maximumForces);
00102 const void GetTorques(Vector&);
00103 const int GetPCSDeltas(Vector&);
00104
00105 int Initialize();
00106 int GetPacketFromMC();
00107 int SendPacketToMC();
00108 void SetArmPose(const Xform&);
00109 virtual void GetAnglesFromMC() {};
00110
00111
00112
00113
00114 double GetErrorRate(int joint);
00115 const void GetErrorRates(Vector& speeds);
00116 void UpdatePastErrorRates();
00117 ControlParam CParam;
00118 Vector *instErrorRates;
00119 Vector *prevErrors;
00120
00121
00122 int GetPacketFromServer();
00123 int SendVoltagesToServer();
00124 int Listen();
00125
00126 protected:
00127
00128 Vector *forces;
00129 Vector *scalingForces;
00130 Vector *maximumForces;
00131 Vector *torques;
00132 Vector *voltages;
00133 FKJacobian *jacobian;
00134 Xform handXform;
00135 Xform prevHandXform;
00136 Xform deltaXform;
00137 HandPose previousHand;
00138 HandPose deltaHand;
00139 Vector3 previousPosition;
00140
00141 Vector *angles;
00142 Vector *PCSdeltas;
00143 MatrixData *motorGainMD;
00144 Matrix *motorGainMat;
00145 Matrix *pastErrorRates;
00146 Vector *accumErrors;
00147 int filterLength;
00148
00149
00150
00151 void CalculateDeltas();
00152 void CalculateTorques();
00153 virtual void CalculateVoltages();
00154 void CheckRotDeltas();
00155 virtual void SendVoltagesToMC() {};
00156 void ScaleDeltas();
00157
00158 double CalcRate(int joint);
00159 double MaxVk(int joint);
00160 double MinVk(int joint);
00161 };
00162
00163 }
00164 #endif //ArmMC_h