-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
base: master
Are you sure you want to change the base?
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. Not sure if this conflicts with any other assumptions in the codebase? |
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: