Created new AnalogBattery class

This commit is contained in:
Timothy Scott
2019-07-25 16:46:32 +02:00
committed by Julian Oes
parent bff1df7080
commit d7bb5d46bb
20 changed files with 687 additions and 253 deletions

View File

@@ -346,7 +346,7 @@ void Simulator::handle_message_hil_sensor(const mavlink_message_t *msg)
static uint64_t last_integration_us = 0;
// battery simulation (limit update to 100Hz)
if (hrt_elapsed_time(&_battery_status.timestamp) >= 10_ms) {
if (hrt_elapsed_time(&_last_battery_timestamp) >= 10_ms) {
const float discharge_interval_us = _param_sim_bat_drain.get() * 1000 * 1000;
@@ -370,7 +370,9 @@ void Simulator::handle_message_hil_sensor(const mavlink_message_t *msg)
vbatt *= _battery.cell_count();
const float throttle = 0.0f; // simulate no throttle compensation to make the estimate predictable
_battery.updateBatteryStatus(vbatt, ibatt, now_us, true, 0, throttle, armed);
_battery.updateBatteryStatus(now_us, vbatt, ibatt, true, true, 0, throttle, armed, true);
_last_battery_timestamp = now_us;
}
}