forked from Archive/PX4-Autopilot
Lov voltage warning should work again
This commit is contained in:
parent
56575eb068
commit
f51320d1af
|
@ -550,6 +550,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||||
|
|
||||||
/* set battery warning flag */
|
/* set battery warning flag */
|
||||||
status.battery_warning = VEHICLE_BATTERY_WARNING_NONE;
|
status.battery_warning = VEHICLE_BATTERY_WARNING_NONE;
|
||||||
|
status.condition_battery_voltage_valid = false;
|
||||||
|
|
||||||
// XXX for now just set sensors as initialized
|
// XXX for now just set sensors as initialized
|
||||||
status.condition_system_sensors_initialized = true;
|
status.condition_system_sensors_initialized = true;
|
||||||
|
@ -606,8 +607,8 @@ int commander_thread_main(int argc, char *argv[])
|
||||||
enum VEHICLE_BATTERY_WARNING battery_warning_previous = VEHICLE_BATTERY_WARNING_NONE;
|
enum VEHICLE_BATTERY_WARNING battery_warning_previous = VEHICLE_BATTERY_WARNING_NONE;
|
||||||
bool armed_previous = false;
|
bool armed_previous = false;
|
||||||
|
|
||||||
bool low_battery_voltage_actions_done;
|
bool low_battery_voltage_actions_done = false;
|
||||||
bool critical_battery_voltage_actions_done;
|
bool critical_battery_voltage_actions_done = false;
|
||||||
|
|
||||||
uint64_t last_idle_time = 0;
|
uint64_t last_idle_time = 0;
|
||||||
|
|
||||||
|
@ -810,19 +811,15 @@ int commander_thread_main(int argc, char *argv[])
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
orb_copy(ORB_ID(battery_status), battery_sub, &battery);
|
orb_copy(ORB_ID(battery_status), battery_sub, &battery);
|
||||||
status.battery_voltage = battery.voltage_v;
|
|
||||||
status.condition_battery_voltage_valid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
warnx("bat v: %2.2f", battery.voltage_v);
|
||||||
* Only update battery voltage estimate if system has
|
|
||||||
* been running for two and a half seconds.
|
|
||||||
*/
|
|
||||||
if (t - start_time > 2500000 && status.condition_battery_voltage_valid) {
|
|
||||||
status.battery_remaining = battery_remaining_estimate_voltage(status.battery_voltage);
|
|
||||||
|
|
||||||
} else {
|
/* only consider battery voltage if system has been running 2s and battery voltage is not 0 */
|
||||||
status.battery_voltage = 0.0f;
|
if ((t - start_time) > 2000000 && battery.voltage_v > 0.001f) {
|
||||||
|
status.battery_voltage = battery.voltage_v;
|
||||||
|
status.condition_battery_voltage_valid = true;
|
||||||
|
status.battery_remaining = battery_remaining_estimate_voltage(status.battery_voltage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update subsystem */
|
/* update subsystem */
|
||||||
|
|
Loading…
Reference in New Issue