From 471810c595c5dfbb308880c391cf262e26f47bd3 Mon Sep 17 00:00:00 2001 From: OK2CM Date: Sat, 23 May 2026 12:49:06 +0200 Subject: [PATCH] fix: Fixed invalid integration of negative target_delta. (cherry picked from commit 6b4164c3409ca414f6e2ae6987d7c1836bbb750a) --- source/Core/Threads/PIDThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp index e7183248ac..b8e0530ac7 100644 --- a/source/Core/Threads/PIDThread.cpp +++ b/source/Core/Threads/PIDThread.cpp @@ -130,7 +130,7 @@ template struct PID { // Thus we multiply this out by the interval time to ~= dv/dt // Then the shift by 1000 is ms -> Seconds - integration_running_sum += (target_delta * interval_ms * Ki) / 1000; + integration_running_sum += (target_delta * (T)interval_ms * Ki) / 1000; // We constrain integration_running_sum to limit windup // This is not overly required for most use cases but can prevent large overshoot in constrained implementations