Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMART_BATTERY_* messages: Added #1072

Merged
merged 6 commits into from Feb 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 51 additions & 1 deletion message_definitions/v1.0/common.xml
Expand Up @@ -2629,6 +2629,27 @@
<description>Battery is charging.</description>
</entry>
</enum>
<enum name="MAV_SMART_BATTERY_FAULT">
<description>Smart battery supply status/fault flags (bitmask) for health indication.</description>
<entry value="1" name="MAV_SMART_BATTERY_FAULT_DEEP_DISCHARGE">
<description>Battery has deep discharged.</description>
</entry>
<entry value="2" name="MAV_SMART_BATTERY_FAULT_SPIKES">
<description>Voltage spikes.</description>
</entry>
<entry value="4" name="MAV_SMART_BATTERY_FAULT_SINGLE_CELL_FAIL">
<description>Single cell has failed.</description>
</entry>
<entry value="8" name="MAV_SMART_BATTERY_FAULT_OVER_CURRENT">
<description>Over-current fault.</description>
</entry>
<entry value="16" name="MAV_SMART_BATTERY_FAULT_OVER_TEMPERATURE">
<description>Over-temperature fault.</description>
</entry>
<entry value="32" name="MAV_SMART_BATTERY_FAULT_UNDER_TEMPERATURE">
<description>Under-temperature fault.</description>
</entry>
</enum>
<enum name="MAV_VTOL_STATE">
<description>Enumeration of VTOL states</description>
<entry value="0" name="MAV_VTOL_STATE_UNDEFINED">
Expand Down Expand Up @@ -4434,7 +4455,7 @@
<field type="float" name="yaw_rate" units="rad/s">Angular rate in yaw axis</field>
</message>
<message id="147" name="BATTERY_STATUS">
<description>Battery information</description>
<description>Battery information. Updates GCS with flight controller battery status. Use SMART_BATTERY_* messages instead for smart batteries.</description>
<field type="uint8_t" name="id">Battery ID</field>
<field type="uint8_t" name="battery_function" enum="MAV_BATTERY_FUNCTION">Function of the battery</field>
<field type="uint8_t" name="type" enum="MAV_BATTERY_TYPE">Type (chemistry) of the battery</field>
Expand Down Expand Up @@ -5057,6 +5078,35 @@
<field type="uint8_t" name="severity" enum="MAV_SEVERITY">Severity of status. Relies on the definitions within RFC-5424.</field>
<field type="char[254]" name="text">Status text message, without null termination character.</field>
</message>
<!-- Smart battery messages -->
<message id="370" name="SMART_BATTERY_INFO">
<wip/>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<!-- This message is work-in-progress and it can therefore change. It should NOT be used in stable production environments. -->
<description>Smart Battery information (static/infrequent update). Use for updates from: smart battery to flight stack, flight stack to GCS. Use instead of BATTERY_STATUS for smart batteries.</description>
<field type="uint8_t" name="id">Battery ID</field>
<field type="int32_t" name="capacity_full_specification" units="mAh">Capacity when full according to manufacturer, -1: field not provided.</field>
<field type="int32_t" name="capacity_full" units="mAh">Capacity when full (accounting for battery degradation), -1: field not provided.</field>
<field type="uint16_t" name="cycle_count">Charge/discharge cycle count. -1: field not provided.</field>
<field type="int32_t" name="serial_number">Serial number. -1: field not provided.</field>
<field type="char[50]" name="device_name">Static device name. Encode as manufacturer and product names separated using an underscore.</field>
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
<field type="uint16_t" name="weight" units="g">Battery weight. 0: field not provided.</field>
<field type="uint16_t" name="discharge_minimum_voltage" units="mV">Minimum per-cell voltage when discharging. If not supplied set to UINT16_MAX value.</field>
<field type="uint16_t" name="charging_minimum_voltage" units="mV">Minimum per-cell voltage when charging. If not supplied set to UINT16_MAX value.</field>
<field type="uint16_t" name="resting_minimum_voltage" units="mV">Minimum per-cell voltage when resting. If not supplied set to UINT16_MAX value.</field>
</message>
<message id="371" name="SMART_BATTERY_STATUS">
<wip/>
<!-- This message is work-in-progress and it can therefore change. It should NOT be used in stable production environments. -->
<description>Smart Battery information (dynamic). Use for updates from: smart battery to flight stack, flight stack to GCS. Use instead of BATTERY_STATUS for smart batteries.</description>
<field type="uint16_t" name="id">Battery ID</field>
<field type="int16_t" name="capacity_remaining" units="%">Remaining battery energy. Values: [0-100], -1: field not provided.</field>
<field type="int16_t" name="current" units="cA">Battery current (through all cells/loads). Positive if discharging, negative if charging. UINT16_MAX: field not provided.</field>
<field type="int16_t" name="temperature" units="cdegC">Battery temperature. -1: field not provided.</field>
<field type="int32_t" name="fault_bitmask" display="bitmask" enum="MAV_SMART_BATTERY_FAULT">Fault/health indications.</field>
<field type="int32_t" name="time_remaining" units="s">Estimated remaining battery time. -1: field not provided.</field>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not make more sense to move the voltages array to the last field in order to let mavlink2 automatically truncate the array ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amilcarlucas This one is more complicated. The ordering is by size first, and only based on declaration order within the common sizes.

So to move the voltages to the end I would need to change id and cell_offset from uint8_t to uint16_t. So basically 2 bytes extra for every message. That said, I think it is worth it, because we know that as long as we have less than 14 cells we're saving space.

Seems a reasonable tradeoff (until someone decides to create and extension message that breaks this. I'll change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<field type="uint16_t" default="0" name="cell_offset">The cell number of the first index in the 'voltages' array field. Using this field allows you to specify cell voltages for batteries with more than 16 cells.</field>
<field type="uint16_t[16]" name="voltages" units="mV">Individual cell voltages. Batteries with more 16 cells can use the cell_offset field to specify the cell offset for the array specified in the current message . Index values above the valid cell count for this battery should have the UINT16_MAX value.</field>
</message>
<!-- Rover specific messages -->
<message id="9000" name="WHEEL_DISTANCE">
<description>Cumulative distance traveled for each reported wheel.</description>
Expand Down