mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-05 03:11:36 +08:00
MAVLink: Fix current reporting
This commit is contained in:
@@ -608,10 +608,14 @@ protected:
|
|||||||
_mavlink->send_message(MAVLINK_MSG_ID_SYS_STATUS, &msg);
|
_mavlink->send_message(MAVLINK_MSG_ID_SYS_STATUS, &msg);
|
||||||
|
|
||||||
/* battery status message with higher resolution */
|
/* battery status message with higher resolution */
|
||||||
mavlink_battery_status_t bat_msg;
|
mavlink_battery_status_t bat_msg = {};
|
||||||
bat_msg.id = 0;
|
bat_msg.id = 0;
|
||||||
bat_msg.battery_function = MAV_BATTERY_FUNCTION_ALL;
|
bat_msg.battery_function = MAV_BATTERY_FUNCTION_ALL;
|
||||||
bat_msg.type = MAV_BATTERY_TYPE_LIPO;
|
bat_msg.type = MAV_BATTERY_TYPE_LIPO;
|
||||||
|
bat_msg.current_consumed = battery_status.discharged_mah;
|
||||||
|
bat_msg.energy_consumed = -1;
|
||||||
|
bat_msg.current_battery = battery_status.current_a * 100;
|
||||||
|
bat_msg.battery_remaining = battery_status.remaining >= 0 ? battery_status.remaining * 100.0f : -1;
|
||||||
bat_msg.temperature = INT16_MAX;
|
bat_msg.temperature = INT16_MAX;
|
||||||
for (unsigned int i = 0; i < (sizeof(bat_msg.voltages) / sizeof(bat_msg.voltages[0])); i++) {
|
for (unsigned int i = 0; i < (sizeof(bat_msg.voltages) / sizeof(bat_msg.voltages[0])); i++) {
|
||||||
if ((int)i < battery_status.cell_count) {
|
if ((int)i < battery_status.cell_count) {
|
||||||
@@ -621,9 +625,6 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: calculate this
|
|
||||||
bat_msg.energy_consumed = -1.0f;
|
|
||||||
|
|
||||||
_mavlink->send_message(MAVLINK_MSG_ID_BATTERY_STATUS, &bat_msg);
|
_mavlink->send_message(MAVLINK_MSG_ID_BATTERY_STATUS, &bat_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user