From 404ce769b68268635ab2c9b3451257b0787ae8bb Mon Sep 17 00:00:00 2001 From: remilia Date: Fri, 16 May 2025 14:50:33 +0800 Subject: [PATCH] debug opt --- cmd_example.ipynb | 10 +++++++++- flandre/__init__.py | 2 +- flandre/launcher.py | 22 ++++++++++++++-------- flandre/utils/RfFrame.py | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/cmd_example.ipynb b/cmd_example.ipynb index fa72452..4e02204 100644 --- a/cmd_example.ipynb +++ b/cmd_example.ipynb @@ -11,11 +11,19 @@ { "metadata": {}, "cell_type": "code", - "source": "!flandre device upload fakename config/device/max-256-120,U=120,M=PWI,S=\\(256\\ 6002\\).txt", + "source": "!flandre device upload fakename \"config/device/mini-64-30,U=30,M=PWI,S=(64 1501).txt\"", "id": "ac406034e9609c90", "outputs": [], "execution_count": null }, + { + "metadata": {}, + "cell_type": "code", + "source": "!flandre device upload fakename \"config/device/max-256-120,U=120,M=PWI,S=(256 6002).txt\"", + "id": "71eae473ab305743", + "outputs": [], + "execution_count": null + }, { "metadata": {}, "cell_type": "code", diff --git a/flandre/__init__.py b/flandre/__init__.py index b1aff29..6d79c1a 100644 --- a/flandre/__init__.py +++ b/flandre/__init__.py @@ -60,7 +60,7 @@ class SoftwareConfig: video_height: int = 1080 video_width: int = 960 - live_ip: str = '11.6.1.71' + live_ip: str = 'vmaosmax.as' live_push_port: int = 5555 live_rep_port: int = 5556 device_py_rep_port: int = 5558 diff --git a/flandre/launcher.py b/flandre/launcher.py index fb172a5..bb6f99c 100644 --- a/flandre/launcher.py +++ b/flandre/launcher.py @@ -238,7 +238,6 @@ def device_upload(name, file: TextIOWrapper): dd.set_name_and_file_only(name, file.read()) - @device.command('recvm') def device_recvmonitor(): ctx = zmq.Context() @@ -247,7 +246,8 @@ def device_recvmonitor(): while True: b = pull.recv() seq, encoder, host_ts, device_ts_low, device_ts_high, buffer = b2t(b) - print(seq, encoder, host_ts, device_ts_low, device_ts_high) + print(f'S={seq} E={encoder} HT={host_ts} DTL={device_ts_low} BS={buffer.__len__()}') + @device.command('recvplot') def device_recvplot(): @@ -271,6 +271,7 @@ def device_recvplot(): last_ts = ts host_host_ts_last = host_host_ts + @device.command('recvplot2') def device_recvplot2(): ctx = zmq.Context() @@ -284,11 +285,13 @@ def device_recvplot2(): print((host_host_ts - host_host_ts_last) / 10 ** 6, flush=True) host_host_ts_last = host_host_ts + @device.command('recvplot3') def device_recvplot3(): ctx = zmq.Context() pull = ctx.socket(zmq.PULL) pull.connect(C.live_push_socket) + print(C.live_push_socket) last_ts = 0 first = True host_host_ts_last = time.time_ns() @@ -302,10 +305,11 @@ def device_recvplot3(): last_ts = ts first = False continue - print((ts - last_ts) / 10 ** 6,(host_host_ts - host_host_ts_last) / 10 ** 6, flush=True) + print((ts - last_ts) / 10 ** 6, (host_host_ts - host_host_ts_last) / 10 ** 6, flush=True) last_ts = ts host_host_ts_last = host_host_ts + @device.command('recvplotdiff') def device_recvplotdiff(): ctx = zmq.Context() @@ -382,7 +386,7 @@ def robot(): def robot_monitor(): robot.setup() output1 = robot.rt.output_subscribe( - 'actual_TCP_pose,actual_TCP_force', 250) # 输出订阅,配方1 + 'actual_TCP_pose,actual_TCP_force,timestamp', 250) # 输出订阅,配方1 robot.rt.start() # rtsi 开始 while True: recv_out: DataObject = robot.rt.get_output_data() @@ -391,7 +395,7 @@ def robot_monitor(): if recv_out.recipe_id == output1.id: x, y, z, r, p, yy = recv_out.actual_TCP_pose fx, fy, fz, fr, fp, fyy = recv_out.actual_TCP_force - print('fx', fx) + print('xts', x, recv_out.timestamp) @robot.command('record') @@ -411,10 +415,11 @@ def robot_record(folder): def rtsi_thread(): output1 = robot.rt.output_subscribe( - 'actual_TCP_pose,actual_TCP_force', 250) # 输出订阅,配方1 + 'actual_TCP_pose,actual_TCP_force,timestamp', 250) # 输出订阅,配方1 robot.rt.start() # rtsi 开始 arr = [] last_ns = time.time_ns() + last_device_ts = 0 while True: recv_out: DataObject = robot.rt.get_output_data() if recv_out is None: @@ -423,9 +428,10 @@ def robot_record(folder): x, y, z, rx, ry, rz = recv_out.actual_TCP_pose fx, fy, fz, frx, fry, frz = recv_out.actual_TCP_force ns = time.time_ns() - print(ns - last_ns,x) + print(ns - last_ns, recv_out.timestamp - last_device_ts, x) last_ns = ns - + last_device_ts = recv_out.timestamp + d = dict( # x=x, # y=y, diff --git a/flandre/utils/RfFrame.py b/flandre/utils/RfFrame.py index ab7045d..e861335 100644 --- a/flandre/utils/RfFrame.py +++ b/flandre/utils/RfFrame.py @@ -52,6 +52,6 @@ def b2t(b: bytes): # device_ts_low = struct.unpack('