Skip to content

Commit

Permalink
AP_Baro: Check if origin alt is zero before using it as field elevation
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabsingh3003 committed Sep 27, 2023
1 parent babdb36 commit 5586af9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libraries/AP_Baro/AP_Baro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,9 @@ 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) {
_field_elevation_active = origin.alt * 0.01;
new_field_elev = true;
}
Expand Down

0 comments on commit 5586af9

Please sign in to comment.