Skip to content

Commit

Permalink
AP_GPS: Ignore Z-axis difference while dual GPS difference check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykhailo Tomashivskyi authored and tomashmyh committed Sep 28, 2024
1 parent 8895723 commit 1f2fc72
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,12 @@ bool AP_GPS::all_consistent(float &distance) const
}

// calculate distance
distance = state[0].location.get_distance_NED(state[1].location).length();
if (state[0].have_altitude && state[1].have_altitude) {
distance = state[0].location.get_distance_NED(state[1].location).length();
} else {
distance = state[0].location.get_distance_NE(state[1].location).length();
}

// success if distance is within 50m
return (distance < 50);
}
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class AP_GPS
bool have_vertical_accuracy; ///< does GPS give vertical position accuracy? Set to true only once available.
bool have_gps_yaw; ///< does GPS give yaw? Set to true only once available.
bool have_gps_yaw_accuracy; ///< does the GPS give a heading accuracy estimate? Set to true only once available
bool have_altitude; ///< does GPS give altitude? Set to false only if GPS instance does not provide altitude.
float undulation; //<height that WGS84 is above AMSL at the current location
bool have_undulation; ///<do we have a value for the undulation
uint32_t last_gps_time_ms; ///< the system time we got the last GPS timestamp, milliseconds
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_GPS/AP_GPS_MAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void AP_GPS_MAV::handle_msg(const mavlink_message_t &msg)
if (have_alt) {
loc.alt = packet.alt * 100; // convert to centimeters
}
state.have_altitude = have_alt;
state.location = loc;

if (have_hdop) {
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_GPS/GPS_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ AP_GPS_Backend::AP_GPS_Backend(AP_GPS &_gps, AP_GPS::Params &_params, AP_GPS::GP
state.have_speed_accuracy = false;
state.have_horizontal_accuracy = false;
state.have_vertical_accuracy = false;
state.have_altitude = true;
}

/**
Expand Down

0 comments on commit 1f2fc72

Please sign in to comment.