diff --git a/libraries/AP_Baro/AP_Baro.h b/libraries/AP_Baro/AP_Baro.h index 5996c673a6..cfe20eed01 100644 --- a/libraries/AP_Baro/AP_Baro.h +++ b/libraries/AP_Baro/AP_Baro.h @@ -102,7 +102,8 @@ public: float get_altitude(uint8_t instance) const { return sensors[instance].altitude; } // get altitude above mean sea level - float get_altitude_AMSL(void) const { return get_altitude() + _field_elevation_active; } + float get_altitude_AMSL(uint8_t instance) const { return get_altitude(instance) + _field_elevation_active; } + float get_altitude_AMSL(void) const { return get_altitude_AMSL(_primary); } // returns which i2c bus is considered "the" external bus uint8_t external_bus() const { return _ext_bus; } diff --git a/libraries/AP_Baro/AP_Baro_Logging.cpp b/libraries/AP_Baro/AP_Baro_Logging.cpp index 91c622aaa0..e0e38f9bec 100644 --- a/libraries/AP_Baro/AP_Baro_Logging.cpp +++ b/libraries/AP_Baro/AP_Baro_Logging.cpp @@ -13,6 +13,7 @@ void AP_Baro::Write_Baro_instance(uint64_t time_us, uint8_t baro_instance) time_us : time_us, instance : baro_instance, altitude : get_altitude(baro_instance), + altitude_AMSL : get_altitude_AMSL(baro_instance), pressure : get_pressure(baro_instance), temperature : (int16_t)(get_temperature(baro_instance) * 100 + 0.5f), climbrate : get_climb_rate(), diff --git a/libraries/AP_Baro/LogStructure.h b/libraries/AP_Baro/LogStructure.h index 791cf33a55..d67b6be3c4 100644 --- a/libraries/AP_Baro/LogStructure.h +++ b/libraries/AP_Baro/LogStructure.h @@ -11,6 +11,7 @@ // @Field: TimeUS: Time since system startup // @Field: I: barometer sensor instance number // @Field: Alt: calculated altitude +// @Field: AltAMSL: altitude AMSL // @Field: Press: measured atmospheric pressure // @Field: Temp: measured atmospheric temperature // @Field: CRt: derived climb rate from primary barometer @@ -23,6 +24,7 @@ struct PACKED log_BARO { uint64_t time_us; uint8_t instance; float altitude; + float altitude_AMSL; float pressure; int16_t temperature; float climbrate; @@ -51,10 +53,10 @@ struct PACKED log_BARD { #define LOG_STRUCTURE_FROM_BARO \ { LOG_BARO_MSG, sizeof(log_BARO), \ "BARO", \ - "Q" "B" "f" "f" "c" "f" "I" "f" "f" "B", \ - "TimeUS," "I," "Alt," "Press," "Temp," "CRt," "SMS," "Offset," "GndTemp," "Health", \ - "s" "#" "m" "P" "O" "n" "s" "m" "O" "-", \ - "F" "-" "0" "0" "B" "0" "C" "?" "0" "-", \ + "Q" "B" "f" "f" "f" "c" "f" "I" "f" "f" "B", \ + "TimeUS," "I," "Alt," "AltAMSL," "Press," "Temp," "CRt," "SMS," "Offset," "GndTemp," "Health", \ + "s" "#" "m" "m" "P" "O" "n" "s" "m" "O" "-", \ + "F" "-" "0" "0" "0" "B" "0" "C" "?" "0" "-", \ true \ }, \ { LOG_BARD_MSG, sizeof(log_BARD), \