AP_Camera: stop adjusting logged altitudes manually, use location methods

This commit is contained in:
Peter Barker 2024-04-11 15:33:28 +10:00 committed by Peter Barker
parent 0f913b5bdf
commit 43995763db
1 changed files with 16 additions and 13 deletions

View File

@ -28,19 +28,22 @@ void AP_Camera_Backend::Write_CameraInfo(enum LogMessages msg, uint64_t timestam
// completely ignore this failure! AHRS will provide its best guess. // completely ignore this failure! AHRS will provide its best guess.
} }
int32_t altitude, altitude_rel, altitude_gps; int32_t altitude_cm = 0;
if (current_loc.relative_alt) { if (!current_loc.get_alt_cm(Location::AltFrame::ABSOLUTE, altitude_cm)) {
altitude = current_loc.alt+ahrs.get_home().alt; // ignore this problem...
altitude_rel = current_loc.alt;
} else {
altitude = current_loc.alt;
altitude_rel = current_loc.alt - ahrs.get_home().alt;
} }
int32_t altitude_rel_cm = 0;
if (!current_loc.get_alt_cm(Location::AltFrame::ABOVE_HOME, altitude_rel_cm)) {
// ignore this problem...
}
int32_t altitude_gps_cm = 0;
const AP_GPS &gps = AP::gps(); const AP_GPS &gps = AP::gps();
if (gps.status() >= AP_GPS::GPS_OK_FIX_3D) { if (gps.status() >= AP_GPS::GPS_OK_FIX_3D) {
altitude_gps = gps.location().alt; if (!gps.location().get_alt_cm(Location::AltFrame::ABSOLUTE, altitude_gps_cm)) {
} else { // ignore this problem...
altitude_gps = 0; }
} }
// if timestamp is zero set to current system time // if timestamp is zero set to current system time
@ -57,9 +60,9 @@ void AP_Camera_Backend::Write_CameraInfo(enum LogMessages msg, uint64_t timestam
gps_week : gps.time_week(), gps_week : gps.time_week(),
latitude : current_loc.lat, latitude : current_loc.lat,
longitude : current_loc.lng, longitude : current_loc.lng,
altitude : altitude, altitude : altitude_cm,
altitude_rel: altitude_rel, altitude_rel: altitude_rel_cm,
altitude_gps: altitude_gps, altitude_gps: altitude_gps_cm,
roll : (int16_t)ahrs.roll_sensor, roll : (int16_t)ahrs.roll_sensor,
pitch : (int16_t)ahrs.pitch_sensor, pitch : (int16_t)ahrs.pitch_sensor,
yaw : (uint16_t)ahrs.yaw_sensor yaw : (uint16_t)ahrs.yaw_sensor