How to use EKF to estimate position

Firmware/software/electronics
Post Reply
Duncan
Beginner
Posts: 11
Joined: Mon Aug 27, 2018 1:13 am

How to use EKF to estimate position

Post by Duncan » Sun Feb 03, 2019 3:53 pm

Hi,

I am trying to estimate the position of the CF and some Bluetooth devices based on the Bluetooth RSSI value. I want to use the built-in EKF inside the CF firmware to realize it. Is it possible?
And if it is, are there any materials(codes, similar projects, examples of using EKF, etc) I could refer?

Thanks in advance.
Duncan

arnaud
Bitcraze
Posts: 1974
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to use EKF to estimate position

Post by arnaud » Mon Feb 04, 2019 8:34 am

Hi,

Since the RSSI value is usually not very linear, it would be pretty hard to achieve positioning with it. My understanding is that BLE is good for near/far indication but not so much for actual positioning.

Though, I can try to explain a bit the process of adding a sensor to the EKF, I am not an expert by far (I have yet to do it myself), but I have seen the process for a couple of sensors.

First you need a measurement and its standard deviation. For BLE RSSI I guess you will have a distance measurement to a transmitter antenna, you will have to do some test to see how precise your measurements are and set the standard deviation accordingly (this is a bit of a guessing game at the end since the STDdev is used as a gain parameter against the other sensors, to choose if your measurement can be trusted a lot of not, but a good initial guess never hurts).

Once you have the measurement, you need to add an update function in the EKF, this is the part where my knowledge fall short, but you can look at the research papers linked in the EKF source code, EKF resources online and at the existing update function implementation. For example if you manage to get a distance measurement to transmitters with known location you can use the existing updateWithDistance function used by the LPS TWR mode: https://github.com/bitcraze/crazyflie-f ... #L255-L261.

Once you are pushing your measurements in the EKF, it should do its magic as long as the standard deviation you provide with the measurement are not too far from the truth.

Duncan
Beginner
Posts: 11
Joined: Mon Aug 27, 2018 1:13 am

Re: How to use EKF to estimate position

Post by Duncan » Fri Feb 08, 2019 8:51 pm

Thank you, Arnaud.

Yes, using RSSI to do the position localization is not accurate enough but I am trying to improve it with all kinds of math models. EKF is a part of them.
I watched the source code "estimator_kalman" in the firmware and the resources you recommended. As you said, with those "measurement update function" I think I can easily feed new RSSI measurement to the EKF. But is that built-in EKF only specialized to localize the position of the Crazyflie? Since I also want to estimate something other than the position of the Crazyflie, I might need a more general EKF. Can I realize it by editing the built-in EKF?

Duncan

arnaud
Bitcraze
Posts: 1974
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to use EKF to estimate position

Post by arnaud » Mon Mar 04, 2019 2:30 pm

When Crazyflie is not flying, the EKF is quite generic and is going to use the full accelerometer reading to estimate the position. When flying, only acceleration linear with Z are used which makes the EKF quadrotor-specific. So if you keep the variable that detect flying to 'false' and you feed 3 axis accelerometer and gyro data, the ekf should be quite generic.

Post Reply