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 #include <robot/control/kinematics/OldIKOR>
00026
00027 #ifdef BUILDOLDIKOR
00028 extern "C" {
00029 #include <robot/control/oldikor/IKOR/general.h>
00030 #include <robot/control/oldikor/IKOR/headers.h>
00031 }
00032 #endif
00033
00034
00035 using robot::control::kinematics::OldIKOR;
00036
00037 using base::Vector;
00038
00039
00040
00041 OldIKOR::OldIKOR(const robot::KinematicChain& chain, bool platformActive)
00042 : chain(chain), platformActive(platformActive)
00043 {
00044 #ifdef BUILDOLDIKOR
00045 Init_Globals();
00046 #endif
00047 }
00048
00049
00050
00051 #ifdef BUILDOLDIKOR
00052 extern "C" {
00053
00054
00055
00056 static MATRIX* staticJ;
00057 void GET_JACOB(MATRIX *Jacob, MATRIX *Qarray)
00058 {
00059 mat_cp(staticJ, Jacob);
00060 }
00061
00062 void GET_ACTUAL_X(MATRIX *Qarray, MATRIX *x_of_link)
00063 {
00064 abort();
00065 }
00066
00067 }
00068 #else
00069 extern "C" {
00070 void GET_JACOB(void*, void*) {}
00071 void GET_ACTUAL_X(void*,void*) {}
00072 }
00073 #endif
00074
00075
00076
00077 Vector OldIKOR::solve(const Vector& dx, const Vector& x, const Vector& q,
00078 const base::Matrix& J,
00079 OptimizationMethod optMethod,
00080 OptimizationCriterion optCriterion,
00081 OptimizationConstraints optConstraints,
00082 base::Orient::Representation orientationRepresentation)
00083 {
00084 Vector dq;
00085
00086 #ifdef BUILDOLDIKOR
00087
00088 const Int N=J.size1();
00089 const Int M=J.size2();
00090 ::N = N;
00091 ::M = M;
00092 Solutions *FSP_data = Solutions_init(M,N);
00093 Robot->Weights->rows = Robot->Weights->cols = M;
00094 MATRIX *mJacob = mat_malloc(N, M);
00095 staticJ = mat_malloc(N, M);
00096 for(Int r=0; r<N; r++)
00097 for(Int c=0; c<M; c++)
00098 staticJ->p[r][c] = J(r,c);
00099 GET_JACOBIAN(mJacob, FSP_data->Qarray);
00100 MATRIX *mdx = mat_malloc(N, 1);
00101 mdx->p[0][0] = dx[0];
00102 mdx->p[1][0] = dx[1];
00103 mdx->p[2][0] = dx[2];
00104 FSP_data->cn = 0;
00105 History Old_DQs;
00106 Old_DQs.whereami = -1;
00107 for (int i=0; i<HIST_SIZE; i++)
00108 Old_DQs.dq[i].DQ = mat_malloc( M , 1 );
00109 MATRIX *mdq = mat_malloc(M,1);
00110 int IKCriterion[5];
00111 IKCriterion[0]=0;
00112 int IKMethod[4];
00113 double spheredata[4][4];
00114 IKMethod[0]=0; IKMethod[1]=0; IKMethod[2]=0; IKMethod[3]=0;
00115 MATRIX *x_of_link = mat_malloc(M+1,N);
00116 printf("$$$$$$2 M=%d N=%d\n",M,N);
00117 mdq = FSP (FSP_data, &Old_DQs, mJacob, mdx, IKCriterion, IKMethod,
00118 LAGRANGIAN, 0, spheredata, x_of_link, datafp);
00119
00120 for(int j=0; j<mdq->rows; j++) {
00121 dq[j] = mdq->p[j][0];
00122 }
00123
00124 #else
00125 throw std::runtime_error(Exception("unimplemented. (Old IKOR code was not included in the build - #define BUILDOLDIKOR)"));
00126 #endif
00127
00128 return dq;
00129 }
00130
00131
00132
00133
00134
00135 void OldIKOR::setParameter(const String& name, Real value)
00136 {
00137 throw std::invalid_argument(Exception("unknown parameter name"));
00138 }
00139
00140