telemetry: add energy_consumed_wh to Battery#2882
Open
bansiesta wants to merge 1 commit into
Open
Conversation
053e5b9 to
9b143bb
Compare
bansiesta
added a commit
to bansiesta/MAVSDK-Proto
that referenced
this pull request
May 20, 2026
Exposes the energy_consumed field from BATTERY_STATUS MAVLink message as a new float field in Watt-hours. Sentinel value -1 maps to NaN. Companion PR: mavlink/MAVSDK#2882
Exposes the energy_consumed field from BATTERY_STATUS MAVLink message. Converts from hectojoules (hJ) to Watt-hours (Wh) by dividing by 36 (1 hJ = 100 J, 1 Wh = 3600 J). Reports NaN when autopilot signals the field is unavailable (sentinel value -1). Fixes mavlink#1748
9b143bb to
89a59b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1748 — exposes the
energy_consumedfield from the MAVLinkBATTERY_STATUSmessage which was previously ignored.Changes
telemetry.hpp): Addedenergy_consumed_whfield toBatterystructtelemetry.cpp): Updatedoperator==andoperator<<forBatterytelemetry_impl.cpp): Populatedenergy_consumed_whinprocess_battery_status()— converts from hectojoules (hJ, the MAVLink unit) to Watt-hours:energy_consumed / 36.0f(1 hJ = 100 J, 1 Wh = 3600 J). Sentinel value −1 (not available) maps toNaN.telemetry.h,telemetry.cpp): Added field tomavsdk_telemetry_battery_tand translation functionstelemetry.py): Added field toBatteryCStruct,Battery.__init__,Battery.from_c_struct,Battery.to_c_struct, andBattery.__str__Notes
The proto definition (
telemetry.proto) has a companion PR in MAVSDK-Proto addingfloat energy_consumed_wh = 9to theBatterymessage. The.pb.h/.pb.ccgenerated files need to be regenerated once that proto PR merges (requires protoc 29.1).