Check if I has right: Is this the Extended Kalman Filter

I have learn the Kalman-Buncy filter for the LQG controllers. I know that this is a signal processing forum and not robotics not math forum. But Extended Kalman Filters are daily discussed here.

First of all! Let's say that I have model a nonlinear state space model: $$\dot{x} = f(x, u, t) + d(t)$$ $$y_m = g(x, u, t) + n(t)$$

Where:

• $\dot{x}$ is the derivative of the state vector of the system
• $x$ is the state vector of the system
• $u$ is the input signal vector
• $t$ is time
• $d(t)$ is the disturbance vector
• $f(x, t)$ is the standard form of nonlinear state space model
• $g(x, t)$ is the standard form of the output of a nonlinear state space model
• $n(t)$ is the noise vector
• $y_m$ is the measured output vector

My goal is to compute the Extended Kalman Filter gain $K$ fo the system so I can build my LQG controller.

Extended Kalman Filter uses jacobian linearizations to make the model $f(x, u, t)$ linear on equilibrium points.

So I build new linear state space matrix $A(t)$ and a output matrix $C(t)$ with respect to time. The linear state space model is:

$$\dot{x} = Ax + Bx$$ $$y = Cx + Du$$

But in this case I going to build: $$\delta \dot{x} = A(t) \delta x + B(t) \delta u$$ $$\delta y = C(t) \delta x + D(t) \delta u$$

Where:

• $\delta x = x - x_0$
• $\delta y = u - u_0$

The $x_0$ and $u_0$ is the equilibrium point and $u$ is the input vector.

I linearize $f(x, u, t)$ and $g(x, u, t)$ and get:

$$A(t) = \left [ \frac{\partial f({x}, u, t)}{\partial {x}} \right ]_{x = \hat{x}}$$ $$C(t) = \left [ \frac{\partial g({x}, u, t)}{\partial {x}} \right ]_{x = \hat{x}}$$

Where:

• $\hat{x}$ is the estimated state vector form the LQE-observer

And of course I get $B(t)$ matrix: $$B(t) = \left [ \frac{\partial f({x}, u, t)}{\partial {u}} \right ]_{x = u_0}$$

But to finding Extended Kalman Filter gain matrix $K$, matrix $B(t)$ is not important.

So now I have my LQE-observer: $$\dot{\hat{x}} = f(\hat{x} , t) + K[y_m - g(\hat{x}, u, t)]$$

And I find the Extended Kalman Filter gain $K$ from this Riccati equation:

$$\dot{P} = A(t)P + PA^T(t) - PC^T(t) R^{-1}C(t)P + Q$$

Where:

• $\dot{P}$ representing the state estimation error covariance matrix derivative
• $P$ is the state estimation error covariance matrix
• $Q$ and $R$ is the weighing matrices

Solve $P$ from the Riccati equation and put in in here:

$$K = PC^T(t)R^{-1}$$

Now we have our Extended Kalman Filter gain $K$.

Now I just plug $K$ into my LQG controller diagram: Questions:

1. So all I need to inclue more are linearizations with the jacobian matrix?
2. Have I done it right?
3. Which comes first, the linearizations or the estimations? I need the estimated vector $\hat{x}$ to get $K$ and I need $K$ to get $\hat{x}$.
4. Should $\dot{P} = 0$ when I solving the Riccati equation?
• Very good! but, the extended Kalman filter applies the linearizations, then proceeds by building the discrete Kalman filter parameters and updates those parameters inside the filter loop in terms of current states. You seem to use the continuous matrices and parameters for gain computations, that's possibly for Kalman-Bucy filter ? Do you want to use a contintous filter or a discrete filter? – Fat32 Jul 29 '17 at 21:50
• @Fat32 That means that I need to have a discrete nonlinear model? Building a discrete model from a linear model requires that I need to find the state transition matrix $\phi = e^{At}$ – Daniel Mårtensson Jul 29 '17 at 21:53
• @Fat32 I think that I want to use contintous filter, even that I going to implement my LQG into an Arduino or Raspberry Pi. Because I don't like the discrete version. Contintous kalman filter works well in a microcontroller. – Daniel Mårtensson Jul 29 '17 at 21:56
• Ok then. Lets see the possible answers. – Fat32 Jul 29 '17 at 21:57
• I don't even know why people want a discrete model? Is not contintous better when it comes to microcontrollers such as Arduino and Raspberry Pi? It's still possible to compute the next state $x$ by using this formula $x = x + \dot{x}*dt$ where $dt$ is the sampling time. – Daniel Mårtensson Jul 29 '17 at 22:02