mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-12-01 13:26:36 +08:00
feat(battery_simulator): single 0V sample failure injection
Use `failure battery intermittent` to trigger.
This commit is contained in:
@@ -109,6 +109,12 @@ void BatterySimulator::Run()
|
||||
vbatt = _battery.empty_cell_voltage();
|
||||
}
|
||||
|
||||
if (_zero_volt_spike) {
|
||||
// Zero volt but only one sample. Replicates some I2C comm failures
|
||||
vbatt = 0.0f;
|
||||
_zero_volt_spike = false;
|
||||
}
|
||||
|
||||
vbatt *= _battery.cell_count();
|
||||
|
||||
_battery.setConnected(true);
|
||||
@@ -157,6 +163,17 @@ void BatterySimulator::updateCommands()
|
||||
supported = true;
|
||||
_force_empty_battery = true;
|
||||
}
|
||||
|
||||
} else if (failure_type == vehicle_command_s::FAILURE_TYPE_INTERMITTENT) {
|
||||
handled = true;
|
||||
PX4_WARN("CMD_INJECT_FAILURE, battery intermittent (single 0V sample)");
|
||||
supported = true;
|
||||
|
||||
if (instance == 0) {
|
||||
supported = true;
|
||||
_zero_volt_spike = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ private:
|
||||
bool _armed{false};
|
||||
|
||||
bool _force_empty_battery{false};
|
||||
bool _zero_volt_spike{false};
|
||||
|
||||
perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user