I am trying to become familiar with state estimation, specifically with the use of an accelerometer.
I am simulating the following experiment: a 1D spring-mass system (mass $m = 1$, spring constant $k = 1$) with an accelerometer attached, measuring horizontal acceleration. I am just trying to get the prediction step working, so I am assuming a perfect accelerometer.
I have the following state-space equation:
$$\begin{bmatrix} x_k \\ v_k \end{bmatrix} = \begin{bmatrix} 1 & \Delta t \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x_{k-1} \\ v_{k-1} \end{bmatrix} + \begin{bmatrix} \Delta t^2/2 \\ \Delta t\end{bmatrix} a_{k}$$
where $\Delta t = 0.01, \begin{bmatrix} x_1 \\ v_1\end{bmatrix} = \begin{bmatrix} 1 \\ 0\end{bmatrix}$. The accelerations $a_k$ are the true accelerations for such a system, given by $a(t) = \ddot{x} = -x(t) = -cos(t)$
However, when propagating this forward in a for-loop, and comparing to the truth, I get the following plot:
Why is there a linear trend in the predicted position of the mass? Is it integration error of some kind, or am I doing something wrong during the prediction step?