Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

robot/control/kinematics/OldIKOR.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002   Copyright (C)2002 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   
00018   $Id: OldIKOR.cpp 1036 2004-02-11 20:48:55Z jungd $
00019   $Revision: 1.5 $
00020   $Date: 2004-02-11 15:48:55 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
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 // globals needed by the old IKOR C code
00051 #ifdef BUILDOLDIKOR
00052 extern "C" {
00053 
00054   //extern FILE* gcheck;
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 /// \todo implement orientation components (convert to omega using euler_to_velocity() and fill out the mdx[3,4,5] components)
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 

Generated on Thu Jul 29 15:56:34 2004 for OpenSim by doxygen 1.3.6