The math formula in Github is not supported well, you had better clone this repository.
This is a repository for Extended Kalman Filter
. If you want to know more about Extended Kalman Filte
, you can read a book named Probabilistic Robotics
. Thanks to this course which provides a framework.
This course provides the information of sensors and landmarks. In sensor_data.txt
, the data is like:
ODOMETRY 0.100692392654 0.100072845247 0.000171392857486
SENSOR1 1.89645381418 0.374031885671
SENSOR2 3.85367751107 1.51951017943
ODOMETRY 0.0993660353102 0.0999680211112 -0.000241341506349
SENSOR1 1.8392269046 0.248025655056
SENSOR2 3.91387355108 1.39726707495
...
For the line with ODOMETRY
, it consists of the
The followings are landmarks observed by the robot. For example, in SENSOR1 1.89645381418 0.374031885671, SENSOR1
is the id of observed landmark, 1.89645381418, 0.374031885671 are the range
and bearing
, respectively.
Note that the data is formatted as (ODOMETRY, SENSOR, SENSOR, ODOMETRY, SENSOR, ODOMETRY, SENSOR...). Several SENSORs
are following one ODOMETRY
, and they are at the same timestamp.
The odometry motion model is as follows
Note that in this repository,
We need speicify the
We combine them together
$$ \Sigma_0 = \left(\begin{array}{cc} \mathbf{0}{3\times 3} & \mathbf{0}{3\times 2n} \ \mathbf{0}{2n \times 3} & \mathbf{I}{2n \times 2n} \times inf \ \end{array}\right) $$
We firstly ignore range and bearing, which is
We can further expand this equation
It means that
$$
\begin{aligned}
g(u_t, o_{t-1}) & = g(\delta_{rot1}, \delta_{trans}, \delta_{rot2},x_{t-1}, y_{t-1}, \theta_{t-1}) \
& =
\left(\begin{array}{c}
x_{t-1}+ \delta_{trans}cos(\theta + \delta_{rot1}) \
y_{t-1} + \delta_{trans}sin(\theta + \delta_{rot1}) \
\theta_{t-1} + \delta_{rot1} + \delta_{rot2}
\end{array}\right)
\end{aligned}\
$$
If we let
$$
\left(\begin{array}{c}
g_x({x_{t-1}, y_{t-1}, \theta_{t-1}}) \
g_y({x_{t-1}, y_{t-1}, \theta_{t-1}}) \
g_{theta}({x_{t-1}, y_{t-1}, \theta_{t-1}})
\end{array}\right)
=\left(\begin{array}{c}
x_{t-1}+ \delta_{trans}cos(\theta + \delta_{rot1}) \
y_{t-1} + \delta_{trans}sin(\theta + \delta_{rot1}) \
\theta_{t-1} + \delta_{rot1} + \delta_{rot2}
\end{array}\right)
$$
We can easily calculate the patial derivative of the
We further simplify this equation
Next, we need to consider the range and bearing. However, we can easily find that motion model has no influence on the measurement, so $\frac{\partial{g(u_t, o_{t-1})}}{\partial{m_{t-1}}} = \mathbf{0}{3\times 2n}$. The same for $\frac{\partial{g(u_t, m{t-1})}}{\partial{o_{t-1}}} = \mathbf{0}{2n \times 3}$. And $g(u_t, m{t-1}) = m_{t-1}$, so
Finally, we get the partial derivative of
$$ G_t = \frac{\partial{g(u_t, o_{t-1}) }}{\partial{o_{t-1}}} = \left(\begin{array}{cc} \frac{\partial{g(u_t, o_{t-1}) }}{\partial{o_{t-1}}} & \mathbf{0}{3\times 2n}\ \mathbf{0}{2n \times 3} & \mathbf{I}_{2n \times 2n} & \ \end{array}\right) $$
For the motion noise, we simply specify it as $$ R_t = \left(\begin{array}{cc} \left(\begin{array}{ccc} 0.1 & 0 & 0\ 0 & 0.1 & 0\ 0 & 0 & 0.01\ \end{array}\right) & \mathbf{0}{3 \times 2n} \ \mathbf{0}{2n \times 3} & \mathbf{0}_{2n \times 2n} \ \end{array}\right) $$
For now, we know
So far, we get the expression of
We can easily calculate the partial derivatives of
Note that in this equation, some
We further simplify this equation.
By the way, you may need this equation: $$ \frac{\partial{arctan2(y, x)}}{\partial{x}}= \frac{-y}{x^2+y^2} $$
Now, back to the first issue, not all the landmarks can be observed at one timestamp. Therefore, if the robot find a landmark which has not been seen before, we use the measurement to set up the coordinate of the landmark. Then, we need to map
And the final
For tbe sensor noise, we just assume that
python main.py
The result is as follows