Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

EKF: do not fuse multiple times the same height #767

Merged
merged 2 commits into from
Mar 4, 2020
Merged

Conversation

bresch
Copy link
Member

@bresch bresch commented Mar 4, 2020

The _fuse_height flag was never set to zero, hence the fusion was called at each iteration, even if no new data is available.
The effects were: high CPU usage and virtually less measurement noise due to multiple fusion of the same sample: see PX4/PX4-Autopilot#14204

Before this PR:

Feb 26, 2020
ekf2: update: 20247 events, 7280866us elapsed, 359.60us avg, min 12us max 979us 401.864us rms

With this PR:

ekf2: update: 4172 events, 777347us elapsed, 186.32us avg, min 11us max 855us 289.353us rms

Note that I had to increase the margins in the unit test because we're not fusing height at full speed anymore.

CPU load on a Pixhawk4 (FMUv5, F7), disarmed:
Before this PR:
DeepinScreenshot_select-area_20200304095534

With this PR:
DeepinScreenshot_select-area_20200304095755

The _fuse_height flag was never set to zero, hence the fusion was called
at each iteration, even if no new data is available.
The effects were: high CPU usage and virtually less measurement noise
due to multiple fusion of the same sample

Also remve unused variables
@bresch bresch self-assigned this Mar 4, 2020
@jkflying
Copy link
Contributor

jkflying commented Mar 4, 2020

Is there some way we can add tests to make sure this kind of thing can't happen in the future?
Eg. making sure the variances of all states increase if there are no new measurements

@bresch
Copy link
Member Author

bresch commented Mar 4, 2020

@jkflying Yes, I was thinking about that as well. I'll add that

@@ -1331,7 +1328,7 @@ void Ekf::controlFakePosFusion()
_using_synthetic_position = true;

// Fuse synthetic position observations every 200msec
if (isTimedOut(_time_last_fake_pos, (uint64_t)2e5) || _fuse_height) {
if (isTimedOut(_time_last_fake_pos, (uint64_t)2e5)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interpretation of the intent here was that we wanted to fuse the horizontal fake position the same amount as we fuse the baro data which we assume is available. Not sure if this is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I also thought, but then I think we have to do it differently because with that, we're fusing every 200ms + every baro update. We can discuss about that in the next call but for now, it seems fine not to do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the temptation to remove a global variable was too big....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I completely agree. If you feel comfortable to do so, please go ahead.

Copy link
Contributor

@kamilritz kamilritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch

@bresch bresch merged commit 230c865 into master Mar 4, 2020
@bresch bresch deleted the pr-fix-hgt-fusion branch March 4, 2020 09:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants