colorized debug
This commit is contained in:
parent
752dd0afca
commit
74da19ed55
1 changed files with 7 additions and 4 deletions
11
utils.py
11
utils.py
|
@ -4,6 +4,9 @@ import socket
|
||||||
import json
|
import json
|
||||||
|
|
||||||
DEBUG: bool = True
|
DEBUG: bool = True
|
||||||
|
RESET = "\033[0m"
|
||||||
|
CYAN = "\033[36m"
|
||||||
|
YELLOW = "\033[33m"
|
||||||
|
|
||||||
|
|
||||||
class RobotClient:
|
class RobotClient:
|
||||||
|
@ -14,13 +17,13 @@ class RobotClient:
|
||||||
self.sock.connect((self.host, self.port))
|
self.sock.connect((self.host, self.port))
|
||||||
|
|
||||||
def _send(self, cmd) -> dict:
|
def _send(self, cmd) -> dict:
|
||||||
if (DEBUG):
|
if DEBUG:
|
||||||
print(f"DEBUG: sended: {cmd}")
|
print(f"{CYAN}DEBUG: sended:{RESET} {cmd}")
|
||||||
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
|
self.sock.sendall(json.dumps(cmd).encode("utf-8"))
|
||||||
data = self.sock.recv(1024).decode("utf-8")
|
data = self.sock.recv(1024).decode("utf-8")
|
||||||
ret = json.loads(data)
|
ret = json.loads(data)
|
||||||
if (DEBUG):
|
if DEBUG:
|
||||||
print(f"DEBUG: received: {ret}")
|
print(f"{YELLOW}DEBUG: received:{RESET} {ret}")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def rpy_to_quat(self, arr):
|
def rpy_to_quat(self, arr):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue