mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 04:43: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:
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2019-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -88,10 +88,9 @@ INA226::INA226(I2CSPIBusOption bus_option, const int bus, int bus_frequency, int
|
||||
0.0,
|
||||
0.0,
|
||||
false,
|
||||
false, // TODO: selected source?
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE,
|
||||
0,
|
||||
0.0,
|
||||
true
|
||||
0.0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -262,10 +261,9 @@ INA226::collect()
|
||||
(float) _bus_voltage * INA226_VSCALE,
|
||||
(float) _current * _current_lsb,
|
||||
true,
|
||||
true, // TODO: Determine if this is the selected source
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE,
|
||||
0,
|
||||
_actuator_controls.control[actuator_controls_s::INDEX_THROTTLE],
|
||||
true
|
||||
_actuator_controls.control[actuator_controls_s::INDEX_THROTTLE]
|
||||
);
|
||||
|
||||
ret = OK;
|
||||
@@ -276,10 +274,9 @@ INA226::collect()
|
||||
0.0,
|
||||
0.0,
|
||||
false,
|
||||
false, // TODO: selected source?
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE,
|
||||
0,
|
||||
0.0,
|
||||
true
|
||||
0.0
|
||||
);
|
||||
ret = -1;
|
||||
perf_count(_comms_errors);
|
||||
@@ -352,10 +349,9 @@ INA226::RunImpl()
|
||||
0.0f,
|
||||
0.0f,
|
||||
false,
|
||||
false,
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE,
|
||||
0,
|
||||
0.0f,
|
||||
true
|
||||
0.0f
|
||||
);
|
||||
|
||||
if (init() != OK) {
|
||||
|
||||
@@ -149,7 +149,8 @@ VOXLPM::measure()
|
||||
|
||||
switch (_ch_type) {
|
||||
case VOXLPM_CH_TYPE_VBATT: {
|
||||
_battery.updateBatteryStatus(tnow, _voltage, _amperage, true, true, 0, 0, true);
|
||||
_battery.updateBatteryStatus(tnow, _voltage, _amperage, true,
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE, 0, 0);
|
||||
}
|
||||
|
||||
// fallthrough
|
||||
@@ -170,7 +171,8 @@ VOXLPM::measure()
|
||||
} else {
|
||||
switch (_ch_type) {
|
||||
case VOXLPM_CH_TYPE_VBATT: {
|
||||
_battery.updateBatteryStatus(tnow, 0.0, 0.0, true, true, 0, 0, true);
|
||||
_battery.updateBatteryStatus(tnow, 0.0, 0.0, true,
|
||||
battery_status_s::BATTERY_SOURCE_POWER_MODULE, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2019-2020 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -95,7 +95,7 @@ UavcanBatteryBridge::battery_sub_cb(const uavcan::ReceivedDataStructure<uavcan::
|
||||
// battery.average_time_to_empty = msg.;
|
||||
battery.serial_number = msg.model_instance_id;
|
||||
battery.connected = true;
|
||||
battery.system_source = msg.status_flags & uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE;
|
||||
battery.source = battery_status_s::BATTERY_SOURCE_POWER_MODULE;
|
||||
// battery.priority = msg.;
|
||||
// battery.is_powering_off = msg.;
|
||||
// battery.warning = msg.;
|
||||
|
||||
Reference in New Issue
Block a user