添加调试信息

This commit is contained in:
zzh
2025-06-04 12:17:16 +08:00
parent 268d0d6993
commit 1e6f8c7442
3 changed files with 9 additions and 7 deletions

View File

@@ -27,7 +27,7 @@ HOST = "0.0.0.0"
PORT = 65444 PORT = 65444
# TODO: 帧率控制配置 # TODO: 帧率控制配置
PERIOD = 0.1 PERIOD = 1
class VisionMode(enum.Enum): class VisionMode(enum.Enum):

View File

@@ -10,7 +10,7 @@ from multiprocessing import Manager, set_start_method
import json import json
from lib.io.process3d import Process3D from lib.io.process3d import Process3D
from lib.io.process2d import Process2D from lib.io.process2d import Process2D
from collections import deque, OrderedDict from collections import deque, OrderedDict
import numpy as np import numpy as np
import socket import socket
from lib.camera.ArenaCamera import ArenaCamera from lib.camera.ArenaCamera import ArenaCamera
@@ -203,6 +203,7 @@ class Presenter:
try: try:
server.accept_client() server.accept_client()
while True: while True:
start = time.time()
# TODO: next_time 记录时钟控制帧率 # TODO: next_time 记录时钟控制帧率
next_time = time.perf_counter() + PERIOD next_time = time.perf_counter() + PERIOD
try: try:
@@ -210,9 +211,6 @@ class Presenter:
tcp_rec_buf = server.recv_data() tcp_rec_buf = server.recv_data()
if tcp_rec_buf: if tcp_rec_buf:
self.rec_tcp_data_handle(tcp_rec_buf) self.rec_tcp_data_handle(tcp_rec_buf)
elif not tcp_rec_buf:
print("Client disconnected gracefully")
continue
except ConnectionResetError: except ConnectionResetError:
print("Warring: clietn force disconnect!!! ") print("Warring: clietn force disconnect!!! ")
break break
@@ -241,7 +239,13 @@ class Presenter:
except TypeError as e: except TypeError as e:
print(f"JSON encode failed: {e}") print(f"JSON encode failed: {e}")
tcp_send_buf = b"{}" tcp_send_buf = b"{}"
print(f"DEBUG:{self.pkt}")
server.send_data(tcp_send_buf) server.send_data(tcp_send_buf)
end = time.time()
duration_ms = (end - start) * 1000
print(f"[INFO] 每帧耗时: {duration_ms:.2f} ms")
# TODO: 控制帧率 # TODO: 控制帧率
now = time.perf_counter() now = time.perf_counter()

View File

@@ -1,7 +1,5 @@
import socket import socket
from open3d import re
class TcpServer: class TcpServer:
def __init__(self, host="0.0.0.0", port=65444) -> None: def __init__(self, host="0.0.0.0", port=65444) -> None: