-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite climb bug when using EK3_OGN_HGT_MASK #26917
Conversation
04f24e7
to
c57c5c0
Compare
I guess this is a bug that can happen on a real vehicle as well? It's not just a SITL issue is it? |
I have no idea. I'm not even sure I'm replicating what @pavloblindnology is seeing. |
@peterbarker Sorry for late response. Yes, the fix is right.
@rmackay9 I tested this in SITL only, but I don't see any reason why it can't happen on a real vehicle. I don't remember all the details of my tests as it was quite a while ago. But the main idea is that with |
} else { | ||
gpsDataNew.hgt = 0.01 * (gpsloc.alt - EKF_origin.alt); | ||
} | ||
gpsDataNew.hgt = (ftype)((double)0.01 * (double)gpsloc.alt - ekfGpsRefHgt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this removes the (1<<2) bit check on the input side, do we need to change the two on the output side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the divergence, but leaves the feature broken. If a hot fix is required, remove the option to set bit 2. Looking at the code I think the underlying problem is that the offset beteween the origin height and ekfGpsRefHgt is is not being added tot he baro alt if bit 0 is set or to the range finder if bit 1 is set when in combination with bit 2. I will look at the code this week and try to come up with a longer term fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've forked this PR branch here https://github.com/priseborough/ardupilot/commits/PR26917/ and pushed an alternative set of patches for this issue that preserve the intent of the EK3_OGN_HGT_MASK bit 2 option.
priseborough@a38c01a
priseborough@f6a56d4
It passes the new autotests on my PC.
Note that my autotest only reproduces the issue - I didn't point any fail condition in for the specific bug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've forked this PR branch here https://github.com/priseborough/ardupilot/commits/PR26917/ and pushed an alternative set of patches for this issue that preserve the intent of the EK3_OGN_HGT_MASK bit 2 option.
priseborough/ardupilot@a38c01a
priseborough/ardupilot@f6a56d4
It passes the new autotests on my PC.
} else { | ||
gpsDataNew.hgt = 0.01 * (gpsloc.alt - EKF_origin.alt); | ||
} | ||
gpsDataNew.hgt = (ftype)((double)0.01 * (double)gpsloc.alt - ekfGpsRefHgt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the divergence, but leaves the feature broken. If a hot fix is required, remove the option to set bit 2. Looking at the code I think the underlying problem is that the offset beteween the origin height and ekfGpsRefHgt is is not being added tot he baro alt if bit 0 is set or to the range finder if bit 1 is set when in combination with bit 2. I will look at the code this week and try to come up with a longer term fix.
} else { | ||
gpsDataNew.hgt = 0.01 * (gpsloc.alt - EKF_origin.alt); | ||
} | ||
gpsDataNew.hgt = (ftype)((double)0.01 * (double)gpsloc.alt - ekfGpsRefHgt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've forked this PR branch here https://github.com/priseborough/ardupilot/commits/PR26917/ and pushed an alternative set of patches for this issue that preserve the intent of the EK3_OGN_HGT_MASK bit 2 option.
priseborough@a38c01a
priseborough@f6a56d4
It passes the new autotests on my PC.
I've reset this to Paul's branch and rebased this PR on master and removed the commit/revert pair. So some less-than-fortunate news. Somehow tridge's PR to use a better atmospheric model (#26915) also fixed the autotest. I bisected the code to work that out: IOW the autotest passes before the fixes in this branch are applied, which is Less Than Good. OTOH, since I've no idea how tridge's patch influences things, I'm quite happy to just carry on. @priseborough are you OK with merging this even 'though the problem doesn't reproduce on master post-tridge-patches? |
Will check log and get back to you |
The better atmospheric model changes how the offset between baro height and GPs height varies so it makes sense the autotest would be sensitive to this. I'm happy to merge on the basis the old model shows it failing before. It should be possible to make it fail on the new model by fudging the baro scale factor or similar. |
The offset generated by the EK3_OGN_HGT_MASK parameter bit 2 option is applied to the baro or range finder sensor so it does not have to be applied to the local position height.
Thanks Paul. Marking as MergeOnCIPass. |
Thanks @pavloblindnology - we've merged a fix for the bug you found. |
Any idea to which version of arducopter is going to include this? Does ":Apply corrections to local position" mean that it will update the home altitude accordingly? i have tried using it set to 1, but when it comes back to home its sometimes 10 meters off... Log: |
Hi @ddomit, This PR's fix will most likely be included in 4.5.5. We would normally have included it in the next release (4.5.4) but that's likely to include only a single small fix |
Thanks!! Do you think this fix and update will solve the issue im having? Will it update the home location with the altitude corrections it does? |
I think it's best to move this to the support forums. Support within a PR is difficult and the issue may very well be unrelated. Could you create a new topic in the support forum? |
Thanks @rmackay9 it is okay i'll wait for the release, i dont need to create an issue. I just have one doubt, i havent found anywhere, does "Apply corrections to local position" mean that it will update home altitude as well? |
Hi @ddomit, If bit2 ("Apply corrections to local position") is set then the vehicle's current altitude estimate is adjusted (instead of adjusting the EKF origin's altitude). The EKF doesn't have access to the AHRS home location (including its altitude) so it is not directly adjusting it. To put it another way, if bit2 is set and the EKF adjusts the vehicle's current altitude, before and after a flight, if you asked the AHRS what the home lat, lon and alt are it should show that they have not changed. |
Hi everyone. I made some SITL-tests from master, Plane-4.4, Plane-4.5. Almost sure this changes also fixes problem with baro drift: |
This bug-finding and fix are not mine. The autotest is mine, however :-)
@pavloblindnology reported them here: #24039
@pavloblindnology was this the fix you were recommending?
This PR is based on #26916 which adds some infrastructure changes to make autotesting with baro drift easier.