Skip to content
Snippets Groups Projects
Commit 1e14b10d authored by Matthias Grob's avatar Matthias Grob
Browse files

simulator_mavlink: take care of battery percentage rounding errors

In 5bb9babc 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.
parent a89e550f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment