mherb / kalman

Header-only C++11 Kalman Filtering Library (EKF, UKF) based on Eigen3
MIT License
1.31k stars 382 forks source link

Use actual position measurements, as Eigen::Vector3f? #15

Open antithing opened 7 years ago

antithing commented 7 years ago

Hi, and thank you for making this code available. I have a real time datastream, consisting of position (Eigen::Vector3d) and orientation(Eigen::Quaternion3d). This data comes in at 10Hz, and I need to 'upsample' it to 100Hz, by running a kalman with 10 predicted samples between each measured one. Can this be done with your code? Is it fairly simple to change the model to a Vector3f for rotation?

Thanks!

mherb commented 7 years ago

Can this be done with your code?

Yep, jut run the predict step on the filter instance as often as you need to, i.e.

for(size_t i = 0; i < 10; ++i) { ekf.predict(sys, u); }

Is it fairly simple to change the model to a Vector3f for rotation?

The lib does not make any assumption about the state space of the system, i.e. you need to define your own system model with corresponding state space. While planned, it is currently not possible to use an Eigen::Vector3d directly as state type, but you would need to inherit from Kalman::Vector (which itself inherits from Eigen::Matrix/Vector). Please have a look at the example(s) and let me know if this answers your questions.

antithing commented 7 years ago

Thanks for getting back to me. I am actually seeing a lot of build errors in visual studio, and cannot compile.

Severity    Code    Description Project File    Line
Error   C2664   'KalmanExamples::Robot1::OrientationMeasurement<T> KalmanExamples::Robot1::OrientationMeasurementModel<T,Kalman::StandardBase>::h(const int) const': cannot convert argument 1 from 'State' to 'const int'  example_robot1  D:\filters\kalman-master\examples\Robot1\main.cpp   91

Severity    Code    Description Project File    Line
Error   C2259   'KalmanExamples::Robot1::OrientationMeasurementModel<T,Kalman::StandardBase>': cannot instantiate abstract class    example_robot1  D:\filters\kalman-master\examples\Robot1\main.cpp   40

Severity    Code    Description Project File    Line
Error   C4430   missing type specifier - int assumed. Note: C++ does not support default-int    example_robot1  d:\filters\kalman-master\examples\robot1\SystemModel.hpp    138

..and more. Am I missing something? Windows, visual studio 2015. thank you!

mherb commented 7 years ago

I have never tried to compile using MSVC as I develop primarily on OS X. VS2015 should support most or all required C++11 features but might be a bit picky about some nonstandard details. Support for VS2015 should therefore be somewhat easy to integrate, pull requests with this regard are highly appreciated!