Page 1 of 1

Update queued measurements in kalman filter

Posted: Thu Dec 24, 2020 3:31 pm
by marc345
Hi everbody

I recently work on a university project involving the extended Kalman filter algorithm of the CF. I noticed something earlier, in the task that implements the eKf in the estimator_kalman.c source file in the modules folder of the firmware.

We have a variable doneUpdate which is initialized to false at the beginning of each task round and set to true if we predicted the state forward or updated the state with some sensor measurement, because we finally have to finalize the state according the the algorithm.

However on the following line the doneUpdate variable is logically ORed (||) with the function call to updateQueuedMeasurments() which returns true if any connected sensor had measurement data ready and an update was done.

I experimented a bit and found out that in the case when doneUpdate is already true, due to a prediction in the same eKf round, updateQueuedMeasurments() won't get called because the overall expression evaluates to true nevertheless what the function returns. This would mean we never do an measurement update in the same round as a prediction, and only look at the measurement queues if no prediction took place in a round before. Is this the intended behavior?

All the best and Merry Christmas to everybody,

Re: Update queued measurements in kalman filter

Posted: Mon Dec 28, 2020 10:44 am
by kimberly

Yes this is interesting indeed! I will try to look into it this week if I have time or else next week! It is the holidays so it is a bit empty here now at the office :)

Re: Update queued measurements in kalman filter

Posted: Fri Jan 08, 2021 10:35 am
by kristoffer
Hi Marc!

That is not the intention, good catch!
It looks like it was me messing up when refactoring.

Fixed in ... issues/669


Re: Update queued measurements in kalman filter

Posted: Sun Jan 10, 2021 12:12 pm
by marc345
Cool, thanks for letting me know.

All the best