pid steering

This commit is contained in:
tymek 2025-08-01 18:11:47 +02:00
parent 97426742f7
commit a56abda2cd

View file

@ -105,15 +105,18 @@ for chunk in stream.iter_content(chunk_size=1024):
k = wp * p + wi * i + wd * d k = wp * p + wi * i + wd * d
motorL.start(max(0, -v * min(100 + k, 100))) speedL = max(0, -v * min(100 + k, 100))
motorR.start(max(0, v * min(100 - k, 100))) speedR = max(0, v * min(100 - k, 100))
motorL.start(speedL)
motorR.start(speedR)
xp = x xp = x
ip = i ip = i
# (Opcjonalnie) Wypisz pozycję # (Opcjonalnie) Wypisz pozycję
cv2.putText(frame, f"P:{int(p)} D:{int(d)} I:{int(i)}", (10, 30), cv2.putText(frame, f"P:{int(p)} D:{int(d)} I:{int(i)}", (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2) cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)
print("PDI: ", p, d, dtms, i) #print("PDI: ", p, d, dtms, i)
print(p, d, speedL, speedR)
else: else:
ip = 0 ip = 0
# ============================ # ============================