mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 17:40:34 +08:00
battery: check source param inside battery lib
This moves the handling of the BAT%d_SOURCE param inside of the battery library. Users of the library now pass the source instead of the flag whether to publish. The battery library then checks if the source is selected using the param and publishes accordingly. Since we removed the strange system_source flag, we now need to look at all batteries in commander. For current estimation - I think - it makes sense to sum them up.
This commit is contained in:
@@ -3821,6 +3821,8 @@ void Commander::battery_status_check()
|
||||
// oldest timestamp.
|
||||
hrt_abstime oldest_update = hrt_absolute_time();
|
||||
|
||||
_battery_current = 0.0f;
|
||||
|
||||
// Only iterate over connected batteries. We don't care if a disconnected battery is not regularly publishing.
|
||||
for (size_t i = 0; i < num_connected_batteries; i++) {
|
||||
if (batteries[i].warning > worst_warning) {
|
||||
@@ -3831,9 +3833,8 @@ void Commander::battery_status_check()
|
||||
oldest_update = batteries[i].timestamp;
|
||||
}
|
||||
|
||||
if (batteries[i].system_source) {
|
||||
_battery_current = batteries[i].current_filtered_a;
|
||||
}
|
||||
// Sum up current from all batteries.
|
||||
_battery_current += batteries[i].current_filtered_a;
|
||||
}
|
||||
|
||||
bool battery_warning_level_increased_while_armed = false;
|
||||
|
||||
Reference in New Issue
Block a user