From a8617cf6817e063b56ceaad360186c41033aa785 Mon Sep 17 00:00:00 2001 From: Matteo Del Seppia <71389092+matteodelseppia@users.noreply.github.com> Date: Tue, 4 Jun 2024 03:48:38 +0200 Subject: [PATCH] Fix float and uint64_t comparison (#23199) fix: ControlAllocator float and int comparison bug There was an incorrect comparison between a float variable `dt` and a `uint64_t` value representing 5 milliseconds (`5_ms`). As a result, `do_update` could never become true even if the last torque setpoint was received more than 5 milliseconds before. To solve this, the `5_ms` value has been converted to seconds (0.005f) for the comparison with `dt`. --- src/modules/control_allocator/ControlAllocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/control_allocator/ControlAllocator.cpp b/src/modules/control_allocator/ControlAllocator.cpp index 2ead22c570..3399bd6190 100644 --- a/src/modules/control_allocator/ControlAllocator.cpp +++ b/src/modules/control_allocator/ControlAllocator.cpp @@ -393,7 +393,7 @@ ControlAllocator::Run() if (_vehicle_thrust_setpoint_sub.update(&vehicle_thrust_setpoint)) { _thrust_sp = matrix::Vector3f(vehicle_thrust_setpoint.xyz); - if (dt > 5_ms) { + if (dt > 0.005f) { do_update = true; _timestamp_sample = vehicle_thrust_setpoint.timestamp_sample; }