model_test_ginac.cpp
Go to the documentation of this file.
1 // Copyright (C) 2007 Tinne De Laet <first dot last at mech dot kuleuven dot be>
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 
18 #include "model_test_ginac.hpp"
19 #include <cmath> // For sinus
20 #include <ginac/ginac.h>
21 
22 #define MU 0.0
23 #define SIGMA 0.5
24 
25 // Registers the fixture into the 'registry'
27 
28 using namespace BFL;
29 
30 void
32 {
33 }
34 
35 void
37 {
38 }
39 
40 void
42 {
43  GiNaC::symbol x0("x0"), x1("x1"), x2("x2"), x3("x3"), x4("x4"), x5("x5");
44  GiNaC::symbol u0("u0"), u1("u1");
45 
46  // *** FUNCTION ***
47  GiNaC::matrix f_sym(6,1);
48  f_sym(0,0) = x0*x1+sin(u0);
49  f_sym(1,0) = u1*x3*x2+u0*x0*x3;
50  f_sym(2,0) = 2;
51  f_sym(3,0) = x3*x3;
52  f_sym(4,0) = x1;
53  f_sym(5,0) = u0*x1;
54 
55  // *** STATE ***
56  vector<GiNaC::symbol> x_sym(6);
57  ColumnVector x_num(6);
58  x_num = 3;
59  x_sym[0] = x0;
60  x_sym[1] = x1;
61  x_sym[2] = x2;
62  x_sym[3] = x3;
63  x_sym[4] = x4;
64  x_sym[5] = x5;
65 
66  // *** INPUT ***
67  vector<GiNaC::symbol> u_sym(2);
68  ColumnVector u_num(2);
69  u_num = 3.4;
70  u_sym[0] = u0;
71  u_sym[1] = u1;
72 
73  // *** NOISE ON SYSTEM ***
74  ColumnVector mu(6); SymmetricMatrix sigma(6);
75  mu = MU;
76  for (int index_sigma_rows=0; index_sigma_rows < 6; index_sigma_rows++)
77  {
78  for (int index_sigma_cols=0; index_sigma_cols < 6; index_sigma_cols++)
79  {
80  if (index_sigma_cols == index_sigma_rows)
81  sigma(index_sigma_rows+1,index_sigma_cols+1)=SIGMA;
82  }
83  }
84  Gaussian My_Noise(mu,sigma);
85 
86  // *** SYSTEM MODEL ***
87 
88  NonLinearAnalyticConditionalGaussian_Ginac pdf(f_sym, u_sym, x_sym, My_Noise);
90 
91  /* FunctionGet */
92 // a_nonLinSysModel.FunctionGet();
93  //CPPUNIT_ASSERT_EQUAL(f_sym , a_nonLinSysModel.FunctionGet());
94  //vector<GiNaC::symbol> x_sym_val = a_nonLinSysModel.StateGet();
95  //CPPUNIT_ASSERT_EQUAL( x_sym.size() , x_sym_val.size());
96  // /* StateGet */
97  // for(int i = 0 ;i < x_sym.size() ; i++)
98  // {
99  // CPPUNIT_ASSERT_EQUAL(x_sym[i] ,x_sym_val[i]);
100  // }
101 
102  /* InputGet */
103  //CPPUNIT_ASSERT_EQUAL(u_sym , a_nonLinSysModel.InputGet());
104 
105  /* dfdxGet */
106 // CPPUNIT_ASSERT_EQUAL(pdf.dfGet(0) , a_nonLinSysModel.df_dxGet());
107 
108 
109  // test ExpectedValueGet()
110  // test CovarianceGet()
111  // test HGet()
112  //cout << "J = \n" << a_nonLinSysModel.PredictionGet(u_num, x_num) << endl;
113  //cout << "Q = \n" << a_nonLinSysModel.CovarianceGet(u_num, x_num) << endl;
114  //cout << "F = \n" << a_nonLinSysModel.df_dxGet(u_num, x_num);
115 }
116 
117 void
119 {
120 }
#define SIGMA
Class for nonlinear analytic systemmodels with additive gaussian noise.
void testNonLinearAnalyticMeasurementModelGaussianUncertaintyGinac()
Class representing Gaussian (or normal density)
Definition: gaussian.h:27
Conditional Gaussian for an analytic nonlinear system using Ginac:
void testNonLinearAnalyticSystemModelGaussianUncertaintyGinac()
#define MU
CPPUNIT_TEST_SUITE_REGISTRATION(ModelTestGinac)


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 Jun 10 2019 12:47:59