22 #define NUM_COND_ARGS 1 28 #define SIGMA_NOISE 0.0001 // Noise variance (constant for every input here) 29 #define CORRELATION_NOISE 0.0 // Correlation between different noise (idem) 31 #define LINEAR_SPEED 1.0 35 #define MEASUREMENT_SIZE 1 38 #define OFFSET_WALL 30 42 #define WALL_CT 1/(sqrt(pow(RICO_WALL,2) + 1)) 43 #define MU_MEAS_NOISE OFFSET_WALL*WALL_CT 44 #define SIGMA_MEAS_NOISE 0.5 64 int state_k;
int state_kMinusOne;
69 double prob_diag = 0.98;
70 double prob_nondiag = (1-prob_diag)/(
NUM_DS-1);
71 for (state_kMinusOne = 0 ; state_kMinusOne <
NUM_DS ; state_kMinusOne++)
73 cond_args[0] = state_kMinusOne;
74 for (state_k = 0 ; state_k <
NUM_DS ; state_k++)
76 if (state_kMinusOne == state_k) a_discretecondpdf.
ProbabilitySet(prob_diag,state_k,cond_args);
77 else a_discretecondpdf.
ProbabilitySet(prob_nondiag,state_k,cond_args);
85 CPPUNIT_ASSERT_EQUAL( NUM_DS , (
int)a_discreteSysModel.
NumStatesGet());
88 CPPUNIT_ASSERT_EQUAL( 1 , a_discreteSysModel.
StateSizeGet());
94 for (state_kMinusOne = 0 ; state_kMinusOne <
NUM_DS ; state_kMinusOne++)
96 cond_args[0] = state_kMinusOne;
97 for (state_k = 0 ; state_k <
NUM_DS ; state_k++)
99 CPPUNIT_ASSERT_EQUAL( (
double)a_discretecondpdf.
ProbabilityGet(state_k),(double)a_discreteSysModel.
ProbabilityGet(state_k,state_kMinusOne));
112 for (state_kMinusOne = 0 ; state_kMinusOne <
NUM_DS ; state_kMinusOne++)
114 cond_args[0] = state_kMinusOne;
115 for (state_k = 0 ; state_k <
NUM_DS ; state_k++)
117 CPPUNIT_ASSERT_EQUAL( (
double)a_discreteSysModel.
ProbabilityGet(state_k,state_kMinusOne),(double)b_discreteSysModel.ProbabilityGet(state_k,state_kMinusOne));
122 int num_cond_args_new = 2;
124 int cond_args_dims_new[num_cond_args_new];
125 cond_args_dims_new[0] =
NUM_DS; cond_args_dims_new[1] = size_input;
129 std::vector<int> cond_args_new(num_cond_args_new);
131 for (state_kMinusOne = 0 ; state_kMinusOne <
NUM_DS ; state_kMinusOne++)
133 cond_args_new[0] = state_kMinusOne;
134 for (input = 0 ; input < size_input ; input++)
136 cond_args_new[1] = input;
137 for (state_k = 0 ; state_k <
NUM_DS ; state_k++)
139 if (state_kMinusOne == state_k) c_discretecondpdf.
ProbabilitySet(prob_diag,state_k,cond_args_new);
140 else c_discretecondpdf.
ProbabilitySet(prob_nondiag,state_k,cond_args_new);
152 for (state_kMinusOne = 0 ; state_kMinusOne <
NUM_DS ; state_kMinusOne++)
154 cond_args[0] = state_kMinusOne;
155 for (input = 0 ; input < size_input ; input++)
157 cond_args_new[1] = input;
158 for (state_k = 0 ; state_k <
NUM_DS ; state_k++)
160 CPPUNIT_ASSERT_EQUAL( (
double)c_discretecondpdf.
ProbabilityGet(state_k),(double)c_discreteSysModel.
ProbabilityGet(state_k,state_kMinusOne,input));
174 ColumnVector initial_state(3);
175 initial_state(1) = 1.0;
176 initial_state(2) = 1.0;
177 initial_state(3) = 0.5;
179 ColumnVector initial_input(2);
180 initial_input(1) = 1.0;
181 initial_input(2) = 1.0;
183 for (
int i=1; i <
STATE_SIZE+1; i++){state(i) = initial_state(i);}
184 for (
int i=1; i <
INPUT_SIZE+1; i++){input(i) = initial_input(i);}
187 ColumnVector Noise_Mu(STATE_SIZE);
188 for (
int row=0; row <
STATE_SIZE; row++){Noise_Mu(row+1) = 0;}
189 SymmetricMatrix Noise_Cov(STATE_SIZE);
192 for (
int column=0; column <
STATE_SIZE; column++)
194 if (row == column) {Noise_Cov(row+1,column+1) =
SIGMA_NOISE;}
198 Gaussian System_Uncertainty(Noise_Mu,Noise_Cov);
203 for (
int column=0; column <
STATE_SIZE; column++)
205 if (row == column) A(row+1,column+1)=1;
206 else A(row+1,column+1)=0;
210 B(STATE_SIZE,1) = 0.0; B(1,INPUT_SIZE) = 0.0; B(2,INPUT_SIZE) = 0.0;
211 B(STATE_SIZE,INPUT_SIZE) = 1.0;
212 B(1,1) = cos(state(STATE_SIZE)) *
DELTA_T;
213 B(2,1) = sin(state(STATE_SIZE)) *
DELTA_T;
222 CPPUNIT_ASSERT_EQUAL( STATE_SIZE , a_linAnSysModel.
StateSizeGet());
228 CPPUNIT_ASSERT_EQUAL( A , a_linAnSysModel.
AGet());
229 CPPUNIT_ASSERT_EQUAL( B , a_linAnSysModel.
BGet());
232 CPPUNIT_ASSERT_EQUAL( A , a_linAnSysModel.
df_dxGet(input,state));
233 CPPUNIT_ASSERT_EQUAL( B , a_linAnSysModel.
BGet());
244 ColumnVector state_new(STATE_SIZE);
245 state_new = a_linAnSysModel.
Simulate(state, input);
253 B(1,1) = cos(state_new(STATE_SIZE)) *
DELTA_T;
254 B(2,1) = sin(state_new(STATE_SIZE)) *
DELTA_T;
257 a_linAnSysModel.
ASet(A);
258 a_linAnSysModel.
BSet(B);
259 CPPUNIT_ASSERT_EQUAL(A , a_linAnSysModel.
AGet());
260 CPPUNIT_ASSERT_EQUAL(B , a_linAnSysModel.
BGet());
271 ColumnVector initial_state(3);
272 initial_state(1) = 1.0;
273 initial_state(2) = 1.0;
274 initial_state(3) = 0.5;
275 for (
int i=1; i <
STATE_SIZE+1; i++){state(i) = initial_state(i);}
289 Gaussian Measurement_Uncertainty(MeasNoise_Mu,MeasNoise_Cov);
300 CPPUNIT_ASSERT_EQUAL( H , a_linAnMeasModel.
HGet());
304 CPPUNIT_ASSERT_EQUAL( H , a_linAnMeasModel.
df_dxGet(0,state));
315 meas_new = a_linAnMeasModel.
Simulate(state);
325 a_linAnMeasModel.
HSet(H);
326 CPPUNIT_ASSERT_EQUAL(H , a_linAnMeasModel.
HGet());
void ASet(const MatrixWrapper::Matrix &a)
Set Matrix A.
void testLinearAnalyticSystemModelGaussianUncertainty()
const MatrixWrapper::Matrix & HGet() const
Get Matrix H.
MatrixWrapper::ColumnVector PredictionGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Returns prediction of state.
MatrixWrapper::SymmetricMatrix CovarianceGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Covariance of system noise.
void testLinearAnalyticMeasurementModelGaussianUncertainty()
int MeasurementSizeGet() const
Get Measurement Size.
Class representing Gaussian (or normal density)
unsigned int NumStatesGet() const
Get the number of discrete states.
virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector &input) const
Get the probability of a certain argument.
bool SystemWithoutSensorParams() const
Number of Conditional Arguments.
void testDiscreteSystemModel()
MatrixWrapper::Matrix df_dxGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Returns F-matrix.
void SystemPdfSet(ConditionalPdf< T, T > *pdf)
Set the SystemPDF.
bool SystemWithoutInputs() const
Has the system inputs or not.
virtual void ConditionalArgumentSet(unsigned int n_argument, const CondArg &argument)
Set the n-th argument of the list.
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
Probability ProbabilityGet(const MeasVar &z, const StateVar &x, const StateVar &s)
Get the probability of a certain measurement.
int StateSizeGet() const
Get State Size.
virtual MatrixWrapper::ColumnVector PredictionGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Returns estimation of measurement.
MeasVar Simulate(const StateVar &x, const StateVar &s, int sampling_method=DEFAULT, void *sampling_args=NULL)
Simulate the Measurement, given a certain state, and an input.
Probability ProbabilityGet(const int &input) const
Get the probability of a certain argument.
void HSet(const MatrixWrapper::Matrix &h)
Set Matrix H.
CPPUNIT_TEST_SUITE_REGISTRATION(ModelTest)
virtual MatrixWrapper::Matrix df_dxGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Returns H-matrix.
#define CORRELATION_NOISE
Class for linear analytic systemmodels with additive gaussian noise.
Abstract Class representing all FULLY Discrete Conditional PDF's.
Class for linear analytic measurementmodels with additive gaussian noise.
Linear Conditional Gaussian.
Class for discrete System Models.
Probability ProbabilityGet(const T &x_k, const T &x_kminusone, const T &u)
Get the probability of arriving in a next state.
void BSet(const MatrixWrapper::Matrix &b)
Set Matrix B.
T Simulate(const T &x, const T &u, int sampling_method=DEFAULT, void *sampling_args=NULL)
Simulate the system.
const MatrixWrapper::Matrix & AGet() const
Get Matrix A.
virtual MatrixWrapper::SymmetricMatrix CovarianceGet(const MatrixWrapper::ColumnVector &u, const MatrixWrapper::ColumnVector &x)
Returns covariance on the measurement.
virtual MatrixWrapper::ColumnVector ExpectedValueGet() const
Get the expected value E[x] of the pdf.
void ProbabilitySet(const double &prob, const int &input, const std::vector< int > &condargs) const
Set the probability (Typical for discrete Pdf's)
const MatrixWrapper::Matrix & BGet() const
Get Matrix B.