From 8685f0e794a031c4c643d232cb3546f37c39858b Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Tue, 15 Sep 2026 08:10:31 +0200 Subject: [PATCH] =?UTF-8?q?fix(SNNBot):=20skip=20learning=20when=20aim=20e?= =?UTF-8?q?rror=20<=201.5=C2=B0=20(dead=20zone)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- SNNBot_garage/src/SNNBot.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SNNBot_garage/src/SNNBot.nim b/SNNBot_garage/src/SNNBot.nim index 1d6e151..a1b8864 100644 --- a/SNNBot_garage/src/SNNBot.nim +++ b/SNNBot_garage/src/SNNBot.nim @@ -399,7 +399,14 @@ method run*(bot: SNNBot) = # correctAngle must be [0,360): targetRel is -180..180, shift it var correctAngle = targetRel + 180.0 let aimRaw = bot.res.forward(bot.lastBinInput) - bot.res.learn(bot.lastBinInput, correctAngle) + # Dead zone: only learn if aim error > 1.5° (prevents ring buffer churn) + if aimRaw >= 0.0: + let aimErr = abs(normalizeRelativeAngle(aimRaw - correctAngle)) + if aimErr > 1.5: + bot.res.learn(bot.lastBinInput, correctAngle) + else: + # Cold start: always learn + bot.res.learn(bot.lastBinInput, correctAngle) let aimErr = if aimRaw >= 0.0: abs(normalizeRelativeAngle(aimRaw - correctAngle)) else: -1.0 echo "RES tick=" & $bot.tick & " aim=" & (if aimRaw >= 0.0: formatFloat(aimRaw, ffDecimal, 1) else: "cold") &