model_test_ginac.cpp
Go to the documentation of this file.
00001 // Copyright (C) 2007 Tinne De Laet <first dot last at mech dot kuleuven dot be>
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 //
00017 
00018 #include "model_test_ginac.hpp"
00019 #include <cmath> // For sinus
00020 #include <ginac/ginac.h>
00021 
00022 #define MU 0.0
00023 #define SIGMA 0.5
00024 
00025 // Registers the fixture into the 'registry'
00026 CPPUNIT_TEST_SUITE_REGISTRATION( ModelTestGinac );
00027 
00028 using namespace BFL;
00029 
00030 void
00031 ModelTestGinac::setUp()
00032 {
00033 }
00034 
00035 void
00036 ModelTestGinac::tearDown()
00037 {
00038 }
00039 
00040 void
00041 ModelTestGinac::testNonLinearAnalyticSystemModelGaussianUncertaintyGinac()
00042 {
00043   GiNaC::symbol x0("x0"), x1("x1"), x2("x2"), x3("x3"), x4("x4"), x5("x5");
00044   GiNaC::symbol u0("u0"), u1("u1");
00045 
00046   // *** FUNCTION ***
00047   GiNaC::matrix f_sym(6,1);
00048   f_sym(0,0) = x0*x1+sin(u0);
00049   f_sym(1,0) = u1*x3*x2+u0*x0*x3;
00050   f_sym(2,0) = 2;
00051   f_sym(3,0) = x3*x3;
00052   f_sym(4,0) = x1;
00053   f_sym(5,0) = u0*x1;
00054 
00055   // *** STATE ***
00056   vector<GiNaC::symbol> x_sym(6);
00057   ColumnVector x_num(6);
00058   x_num = 3;
00059   x_sym[0] = x0;
00060   x_sym[1] = x1;
00061   x_sym[2] = x2;
00062   x_sym[3] = x3;
00063   x_sym[4] = x4;
00064   x_sym[5] = x5;
00065 
00066   // *** INPUT ***
00067   vector<GiNaC::symbol> u_sym(2);
00068   ColumnVector u_num(2);
00069   u_num = 3.4;
00070   u_sym[0] = u0;
00071   u_sym[1] = u1;
00072 
00073   // *** NOISE ON SYSTEM ***
00074   ColumnVector mu(6);  SymmetricMatrix sigma(6);
00075   mu = MU;
00076   for (int index_sigma_rows=0; index_sigma_rows < 6; index_sigma_rows++)
00077   {
00078       for (int index_sigma_cols=0; index_sigma_cols < 6; index_sigma_cols++)
00079         {
00080           if (index_sigma_cols == index_sigma_rows)
00081             sigma(index_sigma_rows+1,index_sigma_cols+1)=SIGMA;
00082         }
00083   }
00084   Gaussian My_Noise(mu,sigma);
00085 
00086  // *** SYSTEM MODEL ***
00087 
00088   NonLinearAnalyticConditionalGaussian_Ginac pdf(f_sym, u_sym, x_sym, My_Noise);
00089   NonLinearAnalyticSystemModelGaussianUncertainty_Ginac a_nonLinSysModel(&pdf);
00090 
00091   /* FunctionGet */
00092 // a_nonLinSysModel.FunctionGet();
00093  //CPPUNIT_ASSERT_EQUAL(f_sym , a_nonLinSysModel.FunctionGet());
00094  //vector<GiNaC::symbol> x_sym_val = a_nonLinSysModel.StateGet();
00095  //CPPUNIT_ASSERT_EQUAL( x_sym.size() , x_sym_val.size());
00096  // /* StateGet */
00097  // for(int i = 0 ;i < x_sym.size() ; i++)
00098  // {
00099  //    CPPUNIT_ASSERT_EQUAL(x_sym[i] ,x_sym_val[i]);
00100  // }
00101 
00102   /* InputGet */
00103   //CPPUNIT_ASSERT_EQUAL(u_sym , a_nonLinSysModel.InputGet());
00104 
00105   /* dfdxGet */
00106 //  CPPUNIT_ASSERT_EQUAL(pdf.dfGet(0) , a_nonLinSysModel.df_dxGet());
00107 
00108 
00109   // test ExpectedValueGet()
00110   // test CovarianceGet()
00111   // test HGet()
00112   //cout << "J = \n" << a_nonLinSysModel.PredictionGet(u_num, x_num) << endl;
00113   //cout << "Q = \n" << a_nonLinSysModel.CovarianceGet(u_num, x_num) << endl;
00114   //cout << "F = \n" << a_nonLinSysModel.df_dxGet(u_num, x_num);
00115 }
00116 
00117 void
00118 ModelTestGinac::testNonLinearAnalyticMeasurementModelGaussianUncertaintyGinac()
00119 {
00120 }


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Feb 11 2019 03:45:12