From 97426742f704c3e856a25742c498e2a43ff9bcf8 Mon Sep 17 00:00:00 2001 From: tymek Date: Fri, 1 Aug 2025 17:59:19 +0200 Subject: [PATCH] pid steering --- steer-pid.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/steer-pid.py b/steer-pid.py index f35baf4..1c56568 100644 --- a/steer-pid.py +++ b/steer-pid.py @@ -77,7 +77,6 @@ for chunk in stream.iter_content(chunk_size=1024): cv2.circle(frame, center, radius, (255, 0, 0), 2) cv2.circle(frame, center, 5, (0, 0, 255), -1) - if int(radius) >= 100: motorL.stop() motorR.stop() @@ -106,8 +105,8 @@ for chunk in stream.iter_content(chunk_size=1024): k = wp * p + wi * i + wd * d - motorL.start(-v * min(100 + k, 100)) - motorR.start(v * min(100 - k, 100)) + motorL.start(max(0, -v * min(100 + k, 100))) + motorR.start(max(0, v * min(100 - k, 100))) xp = x ip = i @@ -116,7 +115,7 @@ for chunk in stream.iter_content(chunk_size=1024): cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2) print("PDI: ", p, d, dtms, i) else: - ip=0 + ip = 0 # ============================ # 👆 KONIEC DETEKCJI PIŁKI 👆 # ============================