add debug mode

This commit is contained in:
Ilya Uraev 2025-05-21 19:52:20 +03:00
parent c317b727cf
commit 506e32b74f

View file

@ -3,6 +3,9 @@
import socket
import json
DEBUG: bool = True
class RobotClient:
def __init__(self, host, port):
self.host = host
@ -11,9 +14,14 @@ class RobotClient:
self.sock.connect((self.host, self.port))
def _send(self, cmd) -> dict:
if (DEBUG):
print(f"DEBUG: sended: {cmd}")
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
data = self.sock.recv(1024).decode("utf-8")
return json.loads(data)
ret = json.loads(data)
if (DEBUG):
print(f"DEBUG: received: {ret}")
return ret
def rpy_to_quat(self, arr):
cmd = {"command": "rpy_to_quaternion", "rpy": arr}