Support MAVLink BATTERY_STATUS_V2#7
Conversation
0a6d621 to
d40823a
Compare
c48d113 to
fbe129c
Compare
- ignore trailing whitespace - have LSP automatically find compile_commands.json
d40823a to
da448a3
Compare
| #if AP_BATTERY_ENABLED | ||
| void send_battery_status(const uint8_t instance) const; | ||
| bool send_battery_status(); | ||
| #if AP_MAVLINK_BATTERY_STATUS_V2_ENABLED | ||
| void send_battery_status_v2(const uint8_t instance) const; | ||
| bool send_battery_status_v2(); | ||
| #endif // AP_MAVLINK_BATTERY_STATUS_V2_ENABLED | ||
| #endif // AP_BATTERY_ENABLED |
There was a problem hiding this comment.
Look into making these private.
There was a problem hiding this comment.
Maybe even via a separate tiny PR.
| #if AP_BATTERY_ENABLED | ||
| int8_t battery_remaining_pct(const uint8_t instance) const; | ||
| #endif |
There was a problem hiding this comment.
Instead move this up to the others, or down to the privates.
| #if HAL_WITH_MCU_MONITORING | ||
| void send_mcu_status(void); | ||
| #endif | ||
| #if AP_BATTERY_ENABLED |
There was a problem hiding this comment.
| #if AP_BATTERY_ENABLED | |
| #if AP_MAVLINK_BATTERY_STATUS_ENABLED |
| break; | ||
| #endif | ||
|
|
||
| #if AP_BATTERY_ENABLED |
There was a problem hiding this comment.
| #if AP_MAVLINK_BATTERY_STATUS_ENABLED |
| } | ||
| } | ||
|
|
||
| // return true if reported consumed and remaining capacities are relative to a full battery |
There was a problem hiding this comment.
Expand to say what the alternative is - what might you be otherwise relative to?
| return status_flags; | ||
| } | ||
|
|
||
| status_flags |= MAV_BATTERY_STATUS_FLAGS_NOT_READY_TO_USE | |
There was a problem hiding this comment.
struct {
uint32_t oldval;
uint32_t newval;
} conversions[] {
{ MAV_BATTERY_FAULT_DEEP_DISCHARGE, MAV_BATTERY_STATUS_FLAGS_FAULT_UNDER_VOLT |MAV_BATTERY_STATUS_FLAGS_BAD_BATTERY },
.
.
};
(and iterate that to convert from one to the other
| self.get_sim_time(drain_mav=True) # required for timeout in run_cmd_get_ack to work | ||
| self.send_poll_message("BATTERY_STATUS_V2") | ||
| self.run_cmd_get_ack( | ||
| mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, | ||
| mavutil.mavlink.MAV_RESULT_ACCEPTED, | ||
| timeout=timeout_sec, | ||
| ) | ||
| status_v2 = self.assert_receive_message("BATTERY_STATUS_V2", | ||
| timeout=timeout_sec) |
There was a problem hiding this comment.
| self.get_sim_time(drain_mav=True) # required for timeout in run_cmd_get_ack to work | |
| self.send_poll_message("BATTERY_STATUS_V2") | |
| self.run_cmd_get_ack( | |
| mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, | |
| mavutil.mavlink.MAV_RESULT_ACCEPTED, | |
| timeout=timeout_sec, | |
| ) | |
| status_v2 = self.assert_receive_message("BATTERY_STATUS_V2", | |
| timeout=timeout_sec) | |
| status_v2 = self.poll_message("BATTERY_STATUS_V2") |
| status_v2 = self.assert_receive_message("BATTERY_STATUS_V2", | ||
| timeout=timeout_sec) | ||
| status_v1 = self.assert_receive_message("BATTERY_STATUS", | ||
| timeout=timeout_sec, |
There was a problem hiding this comment.
| timeout=timeout_sec, |
| condition=f"BATTERY_STATUS.id=={status_v2.id}", | ||
| ) | ||
|
|
||
| status_v1_voltage = status_v1.voltages[0] * 0.001 |
There was a problem hiding this comment.
assert_received_message_values (with poll True)
| raise NotAchievedException("Power-monitor BATTERY_STATUS_V2 should not report capacity relative to full") | ||
|
|
||
| self.start_subtest("Set BATTERY_STATUS_V2 stream rate") | ||
| self.set_message_rate_hz("BATTERY_STATUS_V2", 2) |
There was a problem hiding this comment.
self.context_set_message_rate_hz("BATTERY_STATUS_V2", 2)
da448a3 to
c01c4a1
Compare
af38ddf to
b8103d1
Compare
| @@ -75,6 +75,10 @@ | |||
| #define AP_MAVLINK_MSG_WIND_ENABLED AP_AHRS_ENABLED | |||
| #endif | |||
|
|
|||
| #ifndef AP_MAVLINK_BATTERY_STATUS_V2_ENABLED | |||
There was a problem hiding this comment.
| #ifndef AP_MAVLINK_BATTERY_STATUS_V2_ENABLED | |
| #ifndef AP_MAVLINK_MSG_BATTERY_STATUS_V2_ENABLED |
cc0226a to
bec1699
Compare
22ae1f5 to
fa0ec26
Compare
This is a draft useful for anchoring discussion on ArduPilot#33196