Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbagd/rust-linearkalman
Kalman filtering and smoothing in Rust
https://github.com/rbagd/rust-linearkalman
kalman-filter kalman-filtering rust smoothing
Last synced: about 1 month ago
JSON representation
Kalman filtering and smoothing in Rust
- Host: GitHub
- URL: https://github.com/rbagd/rust-linearkalman
- Owner: rbagd
- License: gpl-3.0
- Created: 2017-01-19T18:01:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-08T18:16:55.000Z (about 8 years ago)
- Last Synced: 2024-12-14T03:09:47.943Z (2 months ago)
- Topics: kalman-filter, kalman-filtering, rust, smoothing
- Language: Rust
- Size: 1.23 MB
- Stars: 40
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-list - rbagd/rust-linearkalman - linearkalman?style=social"/> : Kalman filtering and smoothing in Rust. (Signal Processing)
- awesome-rust-list - rbagd/rust-linearkalman - linearkalman?style=social"/> : Kalman filtering and smoothing in Rust. (Signal Processing)
README
# Kalman filtering and smoothing library written in Rust
[](https://travis-ci.org/rbagd/rust-linearkalman)
[](http://www.gnu.org/licenses/gpl-3.0)Access documentation for the library [here](http://rbagd.eu/rust-linearkalman/linearkalman/index.html). Library is also referenced in [Cargo][cargo] index.
Currently, library provides only time-invariant linear Kalman filtering and smoothing technique is known as fixed-interval smoothing (Rauch-Tung-Striebel smoother) which relies on Kalman filter estimates for the entire dataset. `linearkalman` relies on [rulinalg] library to implement linear algebra structures and operations and so input data is expected to be a `std::vec::Vec` of [Vector] objects, i.e. a vector of vectors.
In order to use this library, make sure your `Cargo.toml` file contains the following:
```toml
[dependencies]
linearkalman = "0.1.3"
```Library can then be imported using:
```rust
extern crate linearkalman;
```## Example
Below example assumes 3-dimensional measurement data with an underlying 2-dimensional state space model. With the help of a few macros from [rulinalg], a simple attempt to use the library to run Kalman filter and smoother would be as follows.
```rust
#[macro_use]
extern crate rulinalg;
extern crate linearkalman;use rulinalg::vector::Vector;
use linearkalman::KalmanFilter;fn main() {
let kalman_filter = KalmanFilter {
// Process noise covariance
q: matrix![1.0, 0.1;
0.1, 1.0],
// Measurement noise matrix
r: matrix![1.0, 0.2, 0.1;
0.2, 0.8, 0.5;
0.1, 0.5, 1.2],
// Observation matrix
h: matrix![1.0, 0.7;
0.5, 0.7;
0.8, 0.1],
// State transition matrix
f: matrix![0.6, 0.2;
0.1, 0.3],
// Initial guess for state mean at time 1
x0: vector![1.0, 1.0],
// Initial guess for state covariance at time 1
p0: matrix![1.0, 0.0;
0.0, 1.0],
};let data: Vec> = vec![vector![1.04, 2.20, 3.12],
vector![1.11, 2.33, 3.34],
vector![1.23, 2.21, 3.45]];let run_filter = kalman_filter.filter(&data);
let run_smooth = kalman_filter.smooth(&run_filter.0, &run_filter.1);// Print filtered and smoothened state variable coordinates
println!("filtered.1,filtered.2,smoothed.1,smoothed.2");
for k in 0..3 {
println!("{:.6},{:.6},{:.6},{:.6}",
&run_filter.0[k].x[0], &run_filter.0[k].x[1],
&run_smooth[k].x[0], &run_smooth[k].x[1])
}
}
````examples` directory contains code sample which allows to import data from a CSV file and returns filtered and smoothed data to `stdout`.
## License
This project is licensed under GPL3.
[rulinalg]: https://github.com/AtheMathmo/rulinalg
[Vector]: https://athemathmo.github.io/rulinalg/doc/rulinalg/vector/struct.Vector.html
[cargo]: https://crates.io/crates/linearkalman