Extended Kalman Filter Explained with Python Code

In the following code, I have implemented an Extended Kalman Filter for modeling the movement of a car with constant turn rate and velocity. The code is mainly based on this work (I did some bug fixing and some adaptation such that the code runs similar to the Kalman filter that I have earlier implemented).

Extended Kalman filter
Trajectory of the car, click on the image for large scale

References: [1] [2] [3] [4] [5]

4.3 4 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

12 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
deb0ch
5 years ago

Hi, first of all thank you for you amazing video series that is helping me so much understanding the Kalman filter !

In this video, what is the C function and Ck matrix at the end, in the Update State equations ?

Jonathon Walker
4 years ago

Any way to get the /home/behnam/Kalman/2014-03-26-000-Data.csv file?

syamsibnu
syamsibnu
4 years ago

Hi, I like your explanation, in the video.
Actually I try to practice EKF by simulating a simple pendulum and using python code.
however I got a problem, How can I have further discussion about it. ?
If you don’t mind, would you send me your email, so I can share my short python code about my problem.
Thanks

Vijay
Vijay
4 years ago

Hello!
Amazing work.
I just have one doubt, in the given dataset, latitude and logitude values are in range of 111 and 13 respectively. Then how come output is in range from 0-100? Please explain this? I just need co-ordinates of ekf plot in terms of lat and long,so i can see how much difference when compared to gps values. If you know piece of code to get these co-ordinates, please share.
Thankyou
 

Last edited 4 years ago by Vijay
Stephen Nguyen
Stephen Nguyen
3 years ago

Hi. Firstly, thank you for your video and source code in python. It’s very useful for me. However, could you plz explain the motion equation when the car does not drive straight and especially the Jacobian matrix?

Stephen Nguyen
Stephen Nguyen
3 years ago

In addition, in your source code, Does JA*P_t_1*JA.T + Q_t means np.dot or just np.mul?

Alexandr
Alexandr
3 years ago

Traceback (most recent call last):
  File “e:\Python_Test\test4efk.py”, line 157, in <module>
    converters={1:bytespdate2num(‘%H%M%S%f’),
  File “e:\Python_Test\test4efk.py”, line 149, in bytespdate2num
    strconverter = mdates.strpdate2num(fmt)
AttributeError: module ‘matplotlib.dates’ has no attribute ‘strpdate2num’
how fix it?

Last edited 3 years ago by Alexandr
shasha
shasha
1 year ago
Reply to  Alexandr

replace with this

def bytespdate2num(fmt, encoding=‘utf-8’):
strconverter = lambda x: datetime.datetime.strptime(x.decode(encoding), fmt)

def bytesconverter(b):
dt = strconverter(b)
return mdates.date2num(dt)

return bytesconverter

12
0
Would love your thoughts, please comment.x
()
x