-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b35ee
commit 007377c
Showing
17 changed files
with
343 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: CI_UKF | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Eigen | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libeigen3-dev | ||
- name: Configure and build | ||
run: | | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
- name: Run tests | ||
run: | | ||
cd build -DBUILD_TEST_UKF=ON | ||
ctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,42 @@ | ||
# Eigen_UKF | ||
|
||
A C++ implementation of the Unscented Kalman Filter (UKF) using Eigen. For the implementation I took inspiration from https://github.com/CoffeeKumazaki/kalman_filters. | ||
A C++ implementation of the Unscented Kalman Filter (UKF) using Eigen. The UKF uses a deterministic sampling technique known as the unscented transformation to calculate statistics around the mean. This technique does not require differentiability of the models. | ||
|
||
The UKF uses a deterministic sampling technique known as the unscented transformation to calculate statistics around the mean. This technique does not require differentiability of the models. | ||
See also https://groups.seas.harvard.edu/courses/cs281/papers/unscented.pdf for more details. | ||
|
||
## Installation | ||
For the implementation I took inspiration from https://github.com/CoffeeKumazaki/kalman_filters. | ||
|
||
## Installation and usage | ||
|
||
**Tested only on Ubuntu 20.04 LTS** | ||
|
||
### Dependencies | ||
|
||
- [Eigen3](https://eigen.tuxfamily.org/index.php?title=Main_Page) library. | ||
|
||
### Tested only on Ubuntu 20.04 LTS | ||
### Compilation | ||
|
||
Clone the repo on your PC. Then, enter the folder where you downloaded the repo, open a terminal and run: | ||
|
||
``` | ||
mkdir build && cd build | ||
cmake ../ | ||
make | ||
cmake .. -DCMAKE_INSTALL_PREFIX="/path/to/desired/install/dir" | ||
make install | ||
``` | ||
|
||
The executable of the c++ code will be available in the `build/` folder. | ||
The UKF library will be available in the `install/lib` folder. The library is composed of two classes: | ||
|
||
- [SystemModel](lib/src/SystemModel.cpp): template class used to construct the state and observation models. Create a child class from this parent class, then edit it to add your models. | ||
- [UnscentedKF](lib/src/UnscentedKF.cpp): the class implementing the UKF algorithm. | ||
|
||
### Example | ||
|
||
An example of usage of the library is available in the [example](example) folder. The filter is used to estimate the thrust provided by a jet engine and its rate of change, given the measured thrust data. | ||
|
||
### Test | ||
|
||
A simple test to verify library integrity is provided in the [test](test) folder. The test uses [Catch2](https://github.com/catchorg/Catch2.git) library and can be run with the `ctest` command from the `build` directory. | ||
|
||
## Maintainer | ||
|
||
Gabriele Nava, @gabrielenava |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Author: Gabriele Nava | ||
# Date: Ott. 2023 | ||
|
||
# Configure the executable | ||
set(SRCS src/ThrustEstimationUKF.cpp src/JetSystemModel.cpp) | ||
add_executable(${PROJECT_NAME}_example ${SRCS}) | ||
|
||
target_include_directories(${PROJECT_NAME}_example PUBLIC include) | ||
target_link_libraries(${PROJECT_NAME}_example ${PROJECT_NAME}) | ||
|
||
# Copy the example data in the build folder | ||
configure_file("${CMAKE_SOURCE_DIR}/example/data/jetData.txt" "${CMAKE_BINARY_DIR}/example/jetData.txt" COPYONLY) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef JET_SYSTEM_MODEL_H | ||
#define JET_SYSTEM_MODEL_H | ||
|
||
#include "SystemModel.h" | ||
|
||
class JetSystemModel : public SystemModel | ||
{ | ||
public: | ||
// overwrite constructor for the child class | ||
JetSystemModel(int _nMeasures, double _dt); | ||
|
||
// initialize variables of the child class | ||
double dt = 0.01; | ||
int nMeasures = 1; | ||
|
||
// state model parameters | ||
static Eigen::Matrix2d A; | ||
static Eigen::Vector2d B; | ||
|
||
// measurement model parameters | ||
static Eigen::Vector2d h; | ||
|
||
// add additional methods and override existing methods | ||
void configureModelParameters(); | ||
Eigen::VectorXd dynamicsModel(const Eigen::VectorXd &x, const Eigen::VectorXd &u) override; | ||
Eigen::VectorXd observationModel(const Eigen::VectorXd &x) override; | ||
}; | ||
|
||
#endif /* end of include guard JET_SYSTEM_MODEL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file JetSystemModel.cpp | ||
* @author Gabriele Nava | ||
* @date 2023 | ||
*/ | ||
#include <JetSystemModel.h> | ||
|
||
// definition of the new constructor; initialize model parameters | ||
JetSystemModel::JetSystemModel(int _nMeasures, double _dt) : nMeasures(_nMeasures), dt(_dt) {} | ||
Eigen::Matrix2d JetSystemModel::A = Eigen::Matrix2d::Zero(); | ||
Eigen::Vector2d JetSystemModel::B = Eigen::Vector2d::Zero(); | ||
Eigen::Vector2d JetSystemModel::h = Eigen::Vector2d::Zero(); | ||
|
||
// definition of the child class methods | ||
void JetSystemModel::configureModelParameters() | ||
{ | ||
// for jet engines, implemented a simple kinematic model | ||
this->A << 1.0, dt, 0.0, 1.0; | ||
this->B << std::pow(dt, 2) / 2, dt; | ||
|
||
// measurements are the observed thrusts | ||
this->h << 1.0, 0.0; | ||
} | ||
|
||
// overwrite the dynamicsModel class | ||
Eigen::VectorXd JetSystemModel::dynamicsModel(const Eigen::VectorXd &x, const Eigen::VectorXd &u) | ||
{ | ||
return (this->A * x + this->B * u); | ||
} | ||
|
||
// overwrite the observationModel class | ||
Eigen::VectorXd JetSystemModel::observationModel(const Eigen::VectorXd &x) | ||
{ | ||
return this->h.transpose() * x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Author: Gabriele Nava | ||
# Date: Ott. 2023 | ||
|
||
# Configure and install the library | ||
add_library(${PROJECT_NAME} src/UnscentedKF.cpp src/SystemModel.cpp) | ||
target_include_directories(${PROJECT_NAME} PUBLIC include) | ||
install(TARGETS ${PROJECT_NAME} DESTINATION lib) |
Oops, something went wrong.