From 1ecfaff6ea34d218b5d3c6bfb5d88c22e2370570 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sat, 23 Apr 2016 17:51:24 +0200 Subject: [PATCH] Fix up power consumption estimation --- src/modules/systemlib/battery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/systemlib/battery.cpp b/src/modules/systemlib/battery.cpp index 646ad0b470..6adea6cbfb 100644 --- a/src/modules/systemlib/battery.cpp +++ b/src/modules/systemlib/battery.cpp @@ -120,7 +120,7 @@ Battery::sumDischarged(hrt_abstime timestamp, float current_a) // Ignore first update because we don't know dT. if (_last_timestamp != 0) { - _discharged_mah = current_a * (timestamp - _last_timestamp) * 1.0e-3f / 3600.0f; + _discharged_mah += current_a * ((float)(timestamp - _last_timestamp)) / 1e3f / 3600.0f; } _last_timestamp = timestamp;