Skip to content

Commit

Permalink
Added further documentation for generating-docs/compiling/testing and…
Browse files Browse the repository at this point in the history
… fixed test
  • Loading branch information
mannyray committed Mar 27, 2020
1 parent ccd2ed4 commit 8f729bf
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 41 deletions.
2 changes: 2 additions & 0 deletions c++_implementation/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Kalman Filter

To generate doxygen run `doxygen` in this directory. Copy `png`s from `assets/` into `html/`.


3 changes: 3 additions & 0 deletions c++_implementation/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
##

`cd` into this directory and `g++ <file>` such as `g++ basicExample.cpp` to compile.
18 changes: 18 additions & 0 deletions c++_implementation/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Tests
To compile tests you need GTest. Run

```
$ mkdir build
$ cd build
$ cmake ..
$ make
$./runTests
$./runTests2
$./runTests3
$./runTests4
```

- `runTests` tests continuos solvers
- `runTests2` tests `predict` method of discrete Kalman filter and then the update phase method
- `runTests3` compare the output of discrete Kalman filter using three different types for template. Results should all be the same.
- `runTests4` tests 'randomVector' functions
9 changes: 0 additions & 9 deletions c++_implementation/tests/test.txt

This file was deleted.

6 changes: 0 additions & 6 deletions c++_implementation/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ TEST(continuousSolverRK4, RK4Test){
ASSERT_THROW(testModelSolver.solve(-1),std::out_of_range);
}




//CUSTOM VECTOR CLASS
class customVector{
private:
Expand Down Expand Up @@ -85,8 +82,6 @@ class customVector{
}
entries = std::vector<double>(size);
}


};


Expand Down Expand Up @@ -186,7 +181,6 @@ TEST(continuousSolverRK4,differentLibraryTest){
ASSERT_NEAR(testModelSolver.getCurrentState().getValueAtIndex(1),tmp4,1e-9);
}
ASSERT_THROW(testModelSolver.solve(-1),std::out_of_range);

}

int main(int argc, char **argv){
Expand Down
7 changes: 0 additions & 7 deletions c++_implementation/tests/tests2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/operators.hpp>


#include <iostream>


Expand Down Expand Up @@ -89,24 +87,19 @@ TEST(discreteDiscreteKalmanFilter, test){
filter.predict(1);
}



for(int i = 0; i < 10; i++){
vectorDouble measurement(i);

double sk = 1*filter.getCurrentCovariance().getSystemValue()*1 + 0.01;
double kk = filter.getCurrentCovariance().getSystemValue()*(1.0/sk);
double curEst = filter.getCurrentEstimate().getSystemValue();


filter.update(measurement);


ASSERT_NEAR(filter.getCurrentEstimate().getSystemValue(),curEst+kk*(double(i) - curEst),1e-9);
//ASSERT_NEAR(filter.getCurrentCovariance().getSystemValue(),1+0.01*i,1e-9);
//ASSERT_NEAR(filter.getCurrentTime(),i,1e-9);
}

}

int main(int argc, char **argv){
Expand Down
9 changes: 0 additions & 9 deletions c++_implementation/tests/tests3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
#include "../include/mathWrapper/boost.h"
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>



#include <math.h>
#include "../include/Eigen.h"


#include <iostream>


TEST(discreteDiscreteKalmanFilter, test){

int stateCount = 1;
Expand All @@ -38,9 +32,6 @@ TEST(discreteDiscreteKalmanFilter, test){
Eigen::VectorXd initialEstimateEigenSimple(1);initialEstimateEigenSimple<<1;
Eigen::MatrixXd initialCovarianceEigenSimple(1,1);initialCovarianceEigenSimple<<1;




class stateModel: public discreteModel<vectorDouble>{
public:
vectorDouble function(const vectorDouble & val, const int time) const override{
Expand Down
14 changes: 4 additions & 10 deletions c++_implementation/tests/tests4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
#include "../include/mathWrapper/boost.h"
#include "../include/Eigen.h"
#include "../include/mathWrapper/eigen.h"

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>


#include <iostream>

TEST(discreteDiscreteKalmanFilter, test){
Expand All @@ -27,16 +25,16 @@ TEST(discreteDiscreteKalmanFilter, test){
cholCov2(0,0)=1;cholCov2(0,1)=0.2;cholCov2(1,0)=0.0;cholCov2(1,1)=1.4;
matrixEigen cholCov3(cholCov);vectorEigen mean3(mean1);
for(int i = 0; i < totalCount; i++){
vectorDouble vdR = vectorDouble::randomVector(1);
vectorDouble vdR = vectorDouble::randomVector(1,i*i);
vdR_arr[i] = vdR*matrixDouble(0.1) + vectorDouble(5.0);

Eigen::VectorXd vesR = Eigen::VectorXd::randomVector(2);
Eigen::VectorXd vesR = Eigen::VectorXd::randomVector(2,i*i);
vesR_arr[i] = cholCov*vesR + mean1;

vectorBoost vbR = vectorBoost::randomVector(2);
vectorBoost vbR = vectorBoost::randomVector(2,i*i);
vbR_arr[i] = matrixBoost(cholCov2)*vbR + mean2;

vectorEigen veR = vectorEigen::randomVector(2);
vectorEigen veR = vectorEigen::randomVector(2,i*i);
veR_arr[i] = cholCov3*veR + mean3;
}

Expand All @@ -61,10 +59,6 @@ TEST(discreteDiscreteKalmanFilter, test){
}
vdCovariance = vdCovariance/totalCount;
ASSERT_NEAR(vdCovariance/0.01,1,0.01);




}

int main(int argc, char **argv){
Expand Down
2 changes: 2 additions & 0 deletions matlab_implementation/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Matlab Kalman Filter

To generate doxygen run `doxygen` in this directory. Copy from all Kalman filter subdirectories `kalman_subdirectory/examples/*.png` into `Doc/html/assets/kalman_subdirectory/examples/*.png`.

0 comments on commit 8f729bf

Please sign in to comment.