mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-14 19:53:34 +08:00
simulator_mavlink: take care of battery percentage rounding errors
In 5bb9babc20 I made MAVLink send a
rounded up integer instead of rounded down. This makes sense in practice
because the low battery reactions happen exactly when the reported number
switches in the UI. But here we want to provoke an exact 50% in the UI so
we stop counting at 49.9%, it get's rounded up and we see the expected
result.
This commit is contained in:
@@ -327,7 +327,7 @@ void Simulator::handle_message(mavlink_message_t *msg, bool publish)
|
||||
}
|
||||
|
||||
float ibatt = -1.0f; // no current sensor in simulation
|
||||
const float minimum_percentage = 0.5f; // change this value if you want to simulate low battery reaction
|
||||
const float minimum_percentage = 0.499f; // change this value if you want to simulate low battery reaction
|
||||
|
||||
/* Simulate the voltage of a linearly draining battery but stop at the minimum percentage */
|
||||
float battery_percentage = 1.0f - (now_us - batt_sim_start) / discharge_interval_us;
|
||||
|
||||
Reference in New Issue
Block a user