I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation.

2025/04/1316:44:39 news 1626

has read many blogs and papers related to Kalman filter on the Internet. They either only talk about theory, lack of sentiment, or have perceptual knowledge, and lack of theoretical derivation. There are very few people who can take care of both of them until I saw a foreign blog post, which really amazed me. I have to admire the author's meticulous spirit. I will translate it and share it with you.

I have to talk about Kalman filtering because what it can do is simply amazing! It is surprising that few software engineers and scientists know something about it, which frustrates me because Kalman filtering is such a powerful tool to blend information in uncertainty, while at the same time, its ability to extract precise information looks incredible.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews. What is Kalman filtering?

You can use Kalman filtering in any dynamic system with uncertain information to make informed predictions about the next direction of the system. Even with various interferences, Kalman filtering can always point out what is happening.

is ideal for using Kalman filtering in continuously changing systems. It has the advantage of small memory occupancy (no need to retain other historical data except for the previous amount of state), and is very fast, which is very suitable for real-time problems and embedded system .

Most of the mathematical formulas found on Google about implementing Kalman filtering look a bit obscure, and this situation is a bit bad. In fact, if you look at it in the right way, Kalman filtering is very simple and easy to understand. Below I will explain it clearly with beautiful pictures and colors. You only need to understand some basic probability and knowledge of matrix .

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews. What can we do with Kalman filtering?

Example with toys: You have developed a small robot that can run around in the woods. This robot needs to know the exact location it is in order to navigate.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We can say that the robot has a state

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

, indicating the position and speed:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Note that this state is just a bunch of numbers about the basic properties of this system, it can be anything else. In this example is position and speed, it can also be the total amount of liquid in a container, the temperature of the car engine, the position coordinates of the user's finger on the touchpad, or any signal you need to track.

This robot has GPS and the accuracy is about 10 meters, which is pretty good, but it needs to accurately position within 10 meters. There are many gullies and cliffs in the woods. If the robot takes a wrong step, it is possible to fall off the cliff, so GPS alone is not enough.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Perhaps we know some information about how a robot moves: for example, the robot knows the instructions sent to the motor, knows whether it is moving in one direction and no one intervenes, and in the next state, the robot is likely to move in the same direction. Of course, the robot knows nothing about its own movement: it may be affected by wind, its wheels are a little tilted, or it may be overturned when encountering uneven ground. Therefore, the length of the wheels turning cannot accurately represent the distance the robot actually walks, and the prediction is not perfect.

GPS sensor tells us some status information, and our predictions tell us how the robot will move, but they are all indirect and accompanied by some uncertainty and inaccuracy. But if all the information available to us is used, can we get a better result than any estimate based on our own? The answer is YES of course, which is what Kalman filtering is used for.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews, how Kalman filtering sees your problem

Next we continue to explain with simple examples of only position and speed.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We do not know the actual position and speed. There are many possible correct combinations between them, but some of them are more likely than others:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Kalman filtering assumes that both variables (position and speed, in this example) are random and obey Gaussian distribution . Each variable has a mean μ, indicating the center of the random distribution (the most likely state), and variance

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

, indicating uncertainty.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

There are really a lot of things to learn for embedded Internet of Things. Don’t learn the wrong route and content, which will lead to the salary being unavailable!

free sharing of everyone a data package, almost 150G. The learning content, articles and projects are relatively new and comprehensive! It is estimated that it will cost at least dozens of fish to buy.

Click here to find the assistant to get 0 yuan: I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

In the figure above, the position and speed are not related, which means that the possible values ​​of the other variable cannot be inferred from the state of one of the variables. The following example is more interesting: position and velocity are related, and the possibility of observing a specific position depends on the current velocity:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

This situation is possible, for example, we estimate the new position based on the old position. If the speed is too high, we may have moved far. If you move slowly, the distance will not be very far. Tracking this relationship is very important because it brings us more information: one of the measurements tells us possible values ​​of other variables, which is the purpose of Kalman filtering, extracting more information as much as possible from measurement data containing uncertainty!

This correlation is represented by the covariance moment

matrix. In short, each element in the matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

represents the correlation between the i-th and j-th state variables. (You may have guessed that the covariance matrix is ​​an symmetric matrix , which means that i and j can be exchanged arbitrarily). The covariance matrix is ​​usually represented by "

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

", and the elements in it are represented by "

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

".

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews. Use matrix to describe the problem

We build state variables based on Gaussian distribution, so at the moment k, two information is needed: the best estimation

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

(i.e. the mean, commonly represented by μ elsewhere), and the covariance matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

(1)

(of course, here we only use position and speed. In fact, this state can contain multiple variables, representing any information you want to represent). Next, we need to predict the next state (k-1 moment) based on the current state of (k-1 moment). Remember, we don't know which of all predictions for the next state is "real", but our prediction function doesn't care. It predicts all possibilities and gives a new Gaussian distribution.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We can use the matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

to represent this prediction process:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

It moves each point in our original estimate to a new prediction position. If the original estimate is correct, this new prediction position is the position that the system will move to next. So how do we use a matrix to predict the position and speed of the next moment? The following is a basic kinematics formula:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Now, we have a prediction matrix to represent the state of the next moment, but we still don’t know how to update the covariance matrix.At this time, we need to introduce another formula. If we multiply each point in the distribution by matrix A, then how will its covariance matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

change? It is very simple. The formula is given below:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

combined with equations (4) and (3) to obtain:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNewsI have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews, external control amount

We have not captured all information. There may be external factors that will control the system, bringing some changes that have no correlation with the system's own state.

Taking the train's motion state model as an example, the train driver may manipulate the accelerator to speed up the train. Similarly, in our robot example, the navigation software may issue a command to turn the wheel or stop it. If we know this extra information, we can represent it with a vector

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

and add it to our prediction equation for correction.

Assuming that due to the setting or control command of the throttle, we know the expected acceleration

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

. According to the basic kinematic equation, we can get:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

is represented in the form of a matrix, which is:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

is called the control matrix, and

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

is called the control vector (for simple systems without external control, this part can be ignored). Let's think about it again. What should we do if our prediction is not 100% accurate?

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews, external interference

If these state quantities change based on the system's own attributes or known external control effects, no problems will occur.

But what if there is unknown interference? For example, suppose we track a quadrotor, which may be disturbed by wind, if we track a wheeled robot, the wheels may slip, or a small slope on the road will slow it down. In this way, we cannot continue to track these states, and if these external interferences are not taken into account, our predictions will be biased.

After each prediction, we can add some new uncertainty to build this uncertainty model between the "outside world" (i.e., interference we have not tracked):

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

After each state variable in the original estimate is updated to a new state, it still obeys the Gaussian distribution. We can say that each state variable of

moves to a new area that obeys the Gaussian distribution, with the covariance being

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

. In other words, we treat these untracked interferences as noise with covariance

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

This produces a new Gaussian distribution with different covariances (but with the same mean).

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We obtain the extended covariance by simply adding

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

. The complete expression of the prediction step is given below:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

From the above formula, we can see that The new optimal estimate is predicted based on the optimal estimate on the previous , and the correction of is added to the known external control amount .

and new uncertainty is predicted by the uncertainty on , and the interference from the external environment of is added.

OK. We have a vague estimate of the possible trends of the system, and use

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

and

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

to represent it. What happens if the sensor data is combined?

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews. Use measurement values ​​to correct the estimated value

We may have multiple sensors to measure the current state of the system. It doesn't matter which sensor specifically measures which state variable. Maybe one is the measurement position and the other is the measurement speed. Each sensor indirectly tells us some state information.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Note that the units and scales of the data read by the sensor may be different from the units and scales of the state we want to track. We use the matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

to represent the data of the sensor.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We can calculate the distribution of sensor readings, which is shown in the following formula in the previous expression:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

One of the major advantages of Kalman filtering is that it can handle sensor noise. In other words, our sensors are more or less unreliable, and each state in the original estimate can correspond to sensor readings within a certain range.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

From the measured sensor data, we can roughly guess what state the system is currently in. But due to uncertainty, some states may be closer to the real state than the readings we get.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We represent this uncertainty (for example: sensor noise) with covariance

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

. The mean value of this distribution is the sensor data we read, called

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

.

Now we have two Gaussian distributions, one near the predicted value and the other near the sensor reading.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

We must find the optimal solution between predicted value (pink) and sensor measurement value (green) .

So, what is our most likely state? For any possible reading

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

, there are two situations: (1) the measured value of the sensor; (2) the predicted value obtained from the previous state. If we want to know the probability that both cases may occur, just multiply these two Gaussian distributions.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

The rest is the overlapping part. The mean of this overlapping part is the two most likely values, that is, the optimal estimate of all the given information.

voila! This overlapping region looks like another Gaussian distribution.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

As you can see, multiply two Gaussian distributions with different means and variance, and you will get a new Gaussian distribution with independent means and variance! The following is explained with a formula.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews, Fusion Gaussian distribution

First analyze the simplest points with one-dimensional Gaussian distribution, with variance

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

and μ The Gaussian curve can be represented by the following formula:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

What will be obtained if two functions that obey the Gaussian distribution are multiplied?

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Substitute formula (9) into formula (10) (note re-normalization so that the total probability is 1) can be obtained:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

The same part of the two equations in formula (11) is represented by k:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

The following further write equations (12) and (13) into matrix form, if Σ It represents the covariance of the Gaussian distribution,

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

represents the mean of each dimension, then:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

is called the Kalman gain, which will be used below. Relax! We are almost done!

Integrate all formulas

We have two Gaussian distributions, predict part

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

, and measure part

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

, put them in formula (15) to calculate the overlap between them:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

From formula (14), you can get Kalman gain as:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

Multiply the inverse of the matrix left at the same time (note that

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

contains

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

) and then offset the equation, and then the inverse of the second equation of the matrix

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

at the same time obtain the following equation:

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

above gives the complete update step equation.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

is the new optimal estimate. We can put it and

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

in the next prediction and update equation and iterate continuously.

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews

I have read a lot of blogs and papers related to Kalman filtering online, either only talking about theory, lack of sentiment, or having perceptual knowledge, lack of theoretical derivation. - DayDayNews. Summary of all the above formulas, you only need to use formulas (7), (18), and (19). (If you forget, you can re-derive it according to equations (4) and (15))

We can use these formulas to build an accurate model for any linear system . For nonlinear systems, we use extended Kalman filtering. The difference is that EKF has an additional process of linearizing the prediction and measurement parts.

Original text reprinted in:

http://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/

 Copyright belongs to the original Owned by the author or platform, for learning reference and academic research only. If there is any infringement, please contact us to delete it~ Thank you 

for the last

. I'll share so much with you today. The key to technology is to accumulate and discover . If you feel you have gained something, like, share, and collect .

Original link: https://mp.weixin.qq.com/s/v6YpLHYvVFrbASJwbnqRZA

Reprinted from: The last bug

Original link: Explain the principle of Kalman filtering ~

This article comes from the Internet and conveys knowledge for free. The copyright belongs to the original author. If there is any copyright issue in the work, please contact me to delete it.

news Category Latest News