Servers by jDrones

Get NavEKF2 covariance elements, and/or re-run NavEKF2?

ardupilot
ekf
ekf2

(Hunt0r) #1

I would like uncertainty information for the wind estimate which is produced by the NavEKF2 filter and saved in the .bin log. Based on my understanding of EKFs, this is the time-history of the 2 diagonal elements of the EKF covariance matrix P corresponding to states VWN and VWE. (I think they would be the 23rd and 24th elements of P’s diagonal.)

I’m looking through the AP_NavEKF2 code, and I don’t see any methods which access this information. Do any exist?

If not, and my understanding is correct that the diagonal elements of P contain the wind-estimate variance, is there any way to “re-simulate” the EKF code by drawing information from a dataflash log? (I hope then, if I can re-run, I can obtain an exact copy of the info I’m seeking.)


(Amilcar Lucas) #2

ArduCopter code does not (yet) do wind estimation. those two elements are not used in the code at all.


(Hunt0r) #3

Ah, yes, I should have specified: I’m working with ArduPlane. (Specifically Plane 3.8 I think… I could look it up if it’s important.)

I think @priseborough might know the answer to this, who else does dev work on the NavEKF2? Please feel free to tag someone who might know, as I’m not sure who watches this forum!


(James Pattison) #4

No input re your specific question, but Replay might be useful for you.
http://ardupilot.org/dev/docs/testing-with-replay.html


(Hunt0r) #5

Thanks @james_pattison for the recommendation. I was able to run Replay on my log with no errors, but the output has NKF2.VWN set to all zeros. I don’t know why… but most importantly, I don’t know what the Replay tool actually does. (and doesn’t do)

Based on my present understanding, there is no record of the EKF’s internal covariance information during flight. To get it, I need to create a version of the ArduPlane firmware which logs the covariance information that I seek, and then “replay” my .bin logfile through that new firmware version in order to extract the covariance info. Can anyone comment on whether this is a “good” or “bad” thing to attempt?


(James Pattison) #6

Adding some debug code to log the innovations should be fine but to be frank this one is beyond me.


(tridge) #7

Hi @hunt0r,
You’ll need to add additional logging information to do this. There is a function getVariances() on NavEKF2 which provides some variances, but only for the velocity, position, magnetic field and airspeed. These are logged in the NKF4 packet.
You’ll need to extend getVariances() to allow access to the wind_vel variances, then add those to the logging.
Cheers, Tridge


(peterbarker) #8

Have you looked through the NKF* messages in the dataflash logs?


(Hunt0r) #9

@peterbarker Yes, I looked through all of them. Did I miss something?


(priseborough) #10

At the moment there is no way to access the covariance matrix elements corresponding to the wind states. An accessor function could be added to provide this. The variances currently provided by the getVariances() function are normalised innovation levels from the innovation consistency tests and not the covariance information the OP is looking for.


(Hunt0r) #11

Based on what I learned here, I’m going to investigate adding my desired covariance-logging and then using the Replay tool to extract the info I’m seeking. This seems to be a good solution, so I’ll mark this question as resolved.

As for learning the Replay tool, I am planning to just source-dive… which can be a time-consuming process. If anyone has documentation about Replay (or would be willing to answer a few quick questions) please contact me.

Thank you very much to all who responded!


(peterbarker) #12

No documentation, but feel free to drop questions in here.