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

robot/control/kinematics/IKORFullSpaceSolverTest.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: IKORFullSpaceSolverTest.cpp 1079 2004-07-28 19:35:26Z jungd $
00019   $Revision: 1.4 $
00020   $Date: 2004-07-28 15:35:26 -0400 (Wed, 28 Jul 2004) $
00021   $Author: jungd $
00022 
00023 ****************************************************************************/
00024 
00025 #include <robot/control/kinematics/IKORFullSpaceSolverTest>
00026 
00027 using robot::control::kinematics::IKORFullSpaceSolverTest;
00028 
00029 
00030 
00031 using base::equals;
00032 using robot::control::kinematics::IKORFullSpaceSolver;
00033 
00034 
00035 IKORFullSpaceSolverTest::IKORFullSpaceSolverTest()
00036 {
00037 }
00038 
00039 
00040 void IKORFullSpaceSolverTest::setUp()
00041 {
00042 
00043   fsp = ref<IKORFullSpaceSolver>(NewObj IKORFullSpaceSolver());
00044 }
00045 
00046 
00047 void IKORFullSpaceSolverTest::tearDown()
00048 {
00049 }
00050 
00051 
00052 void IKORFullSpaceSolverTest::testByHandCase1()
00053 {
00054 return;//!!!!
00055   // This is from a case worked out by hand by Lonnie Love
00056   Matrix A( zeroMatrix(3,6) );
00057                 A(0,1)=-0.325l;
00058   A(1,0)=2.064;                                            A(1,4)=0.54;
00059                 A(2,1)=1.943;  A(2,2)=1.156; A(2,3)=0.674;
00060 
00061   Vector b(3);
00062   b[0]=0; b[1]=0; b[2]=1;
00063 
00064   array<Int> dependentRowsEliminated;
00065 
00066   Matrix gi = fsp->solve(A,b,dependentRowsEliminated);
00067 
00068 //  Debugln(DJ,"gi=\n" << gi);
00069 //abort();//!!!!!
00070 }
00071 
00072 
00073 void IKORFullSpaceSolverTest::testSpecialCase1()
00074 {
00075 return;//!!!!
00076   // This is the example of special case 1 from the
00077   // paper FSP (Full Space Parameterization), Version 2.0
00078   //  Fries, Hacker & Pin
00079   // ORNL/TM-13021
00080 
00081   Matrix A( zeroMatrix(3,9) );
00082   A(0,6)=1; A(0,8)=-0.61;
00083   A(1,0)=-1.236; A(1,1)=0.635; A(1,2)=0.88; A(1,5)=0.343; A(1,7)=1; A(1,8)=-0.893;
00084   A(2,3)=-0.851; A(2,4)=-0.343;
00085 
00086   Vector b( zeroVector(3) );
00087   b(0)=-0.0101;
00088 
00089   array<Int> dependentRowsEliminated;
00090 
00091   Matrix gi = fsp->solve(A,b,dependentRowsEliminated);
00092 
00093   // now construct the solution given in the paper and compare
00094   Matrix gi2( zeroMatrix(7,9) );
00095   gi2(0,6)=-0.0101;
00096   gi2(1,0)=-0.012; gi2(1,8)=0.0166;
00097   gi2(2,1)=0.0233; gi2(2,8)=0.0166;
00098   gi2(3,2)=0.0168; gi2(3,8)=0.0166;
00099   gi2(4,5)=0.0431; gi2(4,8)=0.0166;
00100   gi2(5,7)=0.0148; gi2(5,8)=0.0166;
00101   gi2(6,3)=0.3738; gi2(6,4)=-0.9275; gi2(6,6)=-0.0101;
00102 
00103   gi2.transpose(); // transpose from row vectors to column vectors
00104 
00105   CPPUNIT_ASSERT( gi.equals(gi2, 0.0001) );
00106 
00107 }
00108 
00109 
00110 
00111 void IKORFullSpaceSolverTest::testSpecialCase2()
00112 {
00113 return;//!!!!
00114   // This is the example of special case 2 from the
00115   // paper FSP (Full Space Parameterization), Version 2.0
00116   //  Fries, Hacker & Pin
00117   // ORNL/TM-13021
00118 
00119   Matrix A(3,6);
00120   A(0,0)=1; A(0,1)=1; A(0,2)=2; A(0,3)=2; A(0,4)=4; A(0,5)=3;
00121   A(1,0)=2; A(1,1)=5; A(1,2)=4; A(1,3)=0; A(1,4)=9; A(1,5)=6;
00122   A(2,0)=3; A(2,1)=2; A(2,2)=6; A(2,3)=4; A(2,4)=8; A(2,5)=9;
00123 
00124   Vector b(3);
00125   b(0)=3; b(1)=7; b(2)=6;
00126 
00127   array<Int> dependentRowsEliminated;
00128 
00129   Matrix gi = fsp->solve(A,b,dependentRowsEliminated);
00130 
00131 
00132   // now construct the solution given in the paper and compare
00133   Matrix gi2( zeroMatrix(4,6) );
00134   gi2(0,1)=1.4; gi2(0,3)=0.8;
00135   gi2(1,3)=-0.0556; gi2(1,4)=0.778;
00136   gi2(2,1)=1.4; gi2(2,2)=-0.8321; gi2(2,3)=0.8; gi2(2,5)=0.5547;
00137   gi2(3,0)=0.9636; gi2(3,1)=1.4; gi2(3,2)=-0.1482; gi2(3,3)=0.8; gi2(3,5)=-0.2224;
00138   gi2.transpose(); // transpose from row vectors to column vectors
00139 
00140   Debugln(DJ,"gi (from FSP)=\n" << gi);
00141   Debugln(DJ,"gi2 (from paper)=\n" << gi2);
00142 
00143   CPPUNIT_ASSERT( gi.equals(gi2, 0.0001) );
00144 
00145 }
00146 
00147 
00148 
00149 void IKORFullSpaceSolverTest::testEnduranceExample()
00150 {
00151   // This is the example of an endurance test from the
00152   // paper FSP (Full Space Parameterization), Version 2.0
00153   //  Fries, Hacker & Pin
00154   // ORNL/TM-13021
00155 
00156   Matrix A(4,8);
00157   A(0,0)=1; A(0,1)=0; A(0,2)=0; A(0,3)=0; A(0,4)=0; A(0,5)=1; A(0,6)=0; A(0,7)=0;
00158   A(1,0)=0; A(1,1)=3; A(1,2)=1; A(1,3)=0; A(1,4)=2; A(1,5)=0; A(1,6)=1; A(1,7)=4;
00159   A(2,0)=0; A(2,1)=6; A(2,2)=0; A(2,3)=0; A(2,4)=4; A(2,5)=0; A(2,6)=0; A(2,7)=8;
00160   A(3,0)=0; A(3,1)=5; A(3,2)=6; A(3,3)=0; A(3,4)=0; A(3,5)=0; A(3,6)=6; A(3,7)=0;
00161 
00162   Vector b(4);
00163   b[0]=0; b[1]=1; b[2]=2; b[3]=3;
00164 
00165   array<Int> dependentRowsEliminated;
00166 
00167   Matrix gi = fsp->solve(A,b,dependentRowsEliminated);
00168 
00169   Debugln(DJ,"gi=\n" << gi);
00170 }
00171 
00172 
00173 #ifdef DEBUG
00174 CPPUNIT_TEST_SUITE_REGISTRATION( IKORFullSpaceSolverTest );
00175 #endif
00176 

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