Page 1 of 1

How to use EKF to estimate position

Posted: Sun Feb 03, 2019 3:53 pm
by Duncan
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

Re: How to use EKF to estimate position

Posted: Mon Feb 04, 2019 8:34 am
by arnaud
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.

Re: How to use EKF to estimate position

Posted: Fri Feb 08, 2019 8:51 pm
by Duncan
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

Re: How to use EKF to estimate position

Posted: Mon Mar 04, 2019 2:30 pm
by arnaud
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.