I am stuck at modeling a system model, i.e. getting my state vector and input vector. My guess is that position and velocity are state vector and acceleration is input vector. My 2nd guess is that all three quantities are in state vector and none in input vector.
So... what is state vector and what is input vector in my case?
--
Additional info:
I get measurements from position sensor and acceleration sensor. Everything is happening in 1D, for example on a straight line. I want to merge these readings (and remove the noise) to get an estimation of velocity for each timestep.
These equations describe the system; I am not sure if they're modeled right though. If I understand correctly it's safe to predict that acceleration is constant (even though in reality it changes) - because process covariance matrix fixes this assumption (right?).
I have also some sample data to work with (input values aren't noised here for simplicity):
time pos acc what I should get as output (velocity)
[0.0s] 0.000, -0.000 | 18.850
[0.1s] 1.885, -0.113 | 18.850
[0.2s] 3.768, -0.227 | 18.839
[0.3s] 5.650, -0.340 | 18.816
[0.4s] 7.528, -0.452 | 18.782
[0.5s] 9.401, -0.565 | 18.737
ADDITION 2:
For better communication I'm creating a new answer but should be treated as a comment to the first answer. Jason you've already helped me tremendously and I really am grateful for your time. I still have problems with this though - the results from Kalman Filter are not as expected. May you find the time please review the following, thanks. I already owe you a beer or two (or coffies if you like) - if you have paypal contact me on primoz[a t]codehunter.eu :)
I've implemented the model Jason had proposed in first answer. I added the jerk as 4th state variable. After hours of reviewing I decided to come back here for help. The values I get out of KF aren't as expected. Table below represents the data from first 10 iterations of algorithm. Notice how jerk is increasing each time step thus making other estimates wrong. After one second the difference between real acceleration and estimated is more than 1m/s² (see table, last row)!
real measured estimated real
time pos acc pos acc pos acc jerk vel[!] velocity
0.0 0.000 -0.000 -0.040 0.030 | -0.300 -0.060 0.000 18.850 <--> 18.850
0.1 1.885 -0.113 1.965 -0.153 | 1.585 -0.061 -0.006 18.844 <--> 18.844
0.2 3.768 -0.227 3.778 -0.247 | 3.469 -0.066 -0.035 18.835 <--> 18.827
0.3 5.650 -0.340 5.750 -0.370 | 5.351 -0.090 -0.122 18.815 <--> 18.799
0.4 7.528 -0.452 7.358 -0.452 | 7.228 -0.152 -0.291 18.769 <--> 18.759
0.5 9.401 -0.565 9.251 -0.555 | 9.094 -0.282 -0.574 18.673 <--> 18.708
0.6 11.269 -0.677 11.309 -0.717 | 10.938 -0.518 -1.006 18.494 <--> 18.646
0.7 13.130 -0.788 13.260 -0.758 | 12.752 -0.840 -1.490 18.233 <--> 18.573
0.8 14.983 -0.899 15.043 -0.949 | 14.520 -1.286 -2.096 17.854 <--> 18.488
0.9 16.827 -1.009 16.977 -1.089 | 16.235 -1.838 -2.770 17.362 <--> 18.393
1.0 18.661 -1.118 18.831 -1.168 | 17.890 -2.477 -3.476 16.762 <--> 18.287
My matrices are here:
What is causing this addition in each timestep for jerk? Is any of my matrices wrong?
The same goes with the first solution (only 3 state model) - the acceleration isn't changing as it should.
LAST EDIT:
I've finally managed to make it work. I am not sure if there was an implementation error or wrong P&Q matrices.