Velocity, acceleration and jerk can be computed using the Eular method from temporal and angular/spacial measurements, some effort is required to smooth these measurements and deal with error in the higher derivatives. Kalman or more specifically EKF will be used with a jerk as white noise model.
pip3 install git+https://github.com/kaepek/kalman.git
import CyKalman
filter1D = CyKalman.KalmanJerk1D(0.1, 1.0. 1.0, False, 2**14) # <alpha>, <x_error>, <jerk_constraint>, <time_is_relative>, <x_mod_limit>
t = 0
x = 0
filter1D.step(t, x)
kalman_state = filter1D.get_kalman_vector()
eular_state = filter1D.get_eular_vector()
p = filter1D.get_covariance_matrix()
Include kalman.cpp
and kalman.hpp
within your code. Use a symbolic link or a git-submodule to include this in your project.
#include "/somedir/lib/jerk/kalman_jerk.hpp"
#include "/somedir/lib/jerk/kalman_jerk.cpp"
double alpha = 0.1;
double x_resolution_error = 1.0;
double x_jerk_error = 0.1;
bool time_is_relative = false;
double x_mod_limit = 16384.0;
KalmanJerk1D k1 = kaepek::KalmanJerk1D(alpha, x_resolution_error, x_jerk_error, time_is_relative);
KalmanJerk1D k2 = kaepek::KalmanJerk1D(alpha, x_resolution_error, x_jerk_error, time_is_relative, x_mod_limit);
void loop() {
// get <value> somehow... not specified here
k1.step(seconds_since_last, value);
double *kalman_vec = k1.get_kalman_vector();
double *eular_vec = k1.get_eular_vector();
double *covar = k1.get_covariance_matrix();
}
Use Bash on Linux/Mac or GitBash on Windows.
npm run create:venv
Bash:
source env/bin/activate
Windows:
. env/Scripts/Activate
npm run install:venv
This must be done before running any local(to the repository) tests:
npm run create:wheel && npm run install:wheel
time npm run simulate:fixed-speed:1e6:abs --py_or_cy=cy
Set --py_or_cy
to cy
for cython and py
for native python
time npm run simulate:fixed-speed:1e6:rel --py_or_cy=cy
Set --py_or_cy
to cy
for cython and py
for native python
REQUIRES: Downloading the IBM double pendulum dataset first!
npm run download:ibm-double-pendulum
In the root project directory run this command to simulate the double pendulum...
npm run simulate:double-pendulum --py_or_cy=cy --dataset=6
Set --py_or_cy
to cy
for cython and py
for native python
Set --dataset=6
to change which dataset to graph post kalman filtering.
Note simulate:double-pendulum will automatically invoke npm run install:ibm-double-pendulum
for the given dataset.
In the root project directory run...
npm run simulate:bldc