-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
AP_Baro: Allow setting field elevation to 0 #28605
Conversation
Some slightly ignorant questions: Would it be a better experience to just convert it to 0.01? Could drifting back down to 0 cause the Baro reset to happen again? |
That would work too. My only concern would be it's different to what the user specified, which may lead to confusion in later data analysis if they don't know about the 0 -> 0.01 change. |
libraries/AP_Baro/AP_Baro.cpp
Outdated
_field_elevation_active = origin.alt * 0.01; | ||
new_field_elev = true; | ||
} else if (!armed && AP::ahrs().get_origin(origin) && origin.alt == 0) { | ||
GCS_SEND_TEXT(MAV_SEVERITY_ALERT, "Origin altitude cannot be 0"); |
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.
Wouldn't it make sense to name the parameter here?
libraries/AP_Baro/AP_Baro.cpp
Outdated
@@ -961,9 +961,11 @@ void AP_Baro::update_field_elevation(void) | |||
is_zero(_field_elevation)) { | |||
// auto-set based on origin | |||
Location origin; | |||
if (!armed && AP::ahrs().get_origin(origin)) { | |||
if (!armed && AP::ahrs().get_origin(origin) && origin.alt != 0) { | |||
_field_elevation_active = origin.alt * 0.01; | |||
new_field_elev = true; |
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.
The issue is that new_field_elev
can be set true
even is the value hasn't changed. Probably should be something like:
Location origin;
if (!armed && AP::ahrs().get_origin(origin)) {
new_field_elev = !is_equal(_field_elevation_active, origin.alt * 0.01f);
_field_elevation_active = origin.alt * 0.01;
}
29518b2
to
e2ca841
Compare
I've changed this to @nexton-winjeel's suggestion - we can now set the field elevation to 0. However the field elevation can now only be set once per boot. Not sure if this conflicts with any other assumptions in the codebase? |
How does this handle moving the home location from a GCS? |
Just tested this with copter SITL. No issues with: a) taking off, b) setting home to a different location (and altitude), c) setting RTL. Copter landed fine in the new home location. |
e2ca841
to
b289292
Compare
b289292
to
95313ab
Compare
I think this will solve the "now" problem, but might create "future" problems. Could there be a situation where you'd want to update the pressure datum more than once? Maybe an auto take off to auto land an hr away and then disarm... relaunch back home without rebooting? I feel like there should be a method for pushing EKF origin without having it impact auto datum and/or the ability to trigger an auto Baro datum on secondary arming at some later time in the flight. As stated, I think this "could" be fine as is. I just think it's elucidating a broader problem that maybe should be looked at. |
Closing this one, as it appears there's a requirement to update the baro in-flight. Will ponder a different solution... |
This came up when using a vision-based vehicle (no GPS).
When using
set_gps_global_origin_send
to set the GPS origin of a vehicle, if the set altitude is exactly 0 thenAP_Baro
will continually keep resetting the field elevation.This patch will warn the user if they try to do this.This patch will allow setting the altitude to 0, but only once per boot.
Example pymavlink code to demonstrate issue: