debug opt

This commit is contained in:
remilia 2025-05-16 14:50:33 +08:00
parent 3ec06830e7
commit 404ce769b6
4 changed files with 25 additions and 11 deletions

View File

@ -11,11 +11,19 @@
{ {
"metadata": {}, "metadata": {},
"cell_type": "code", "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", "id": "ac406034e9609c90",
"outputs": [], "outputs": [],
"execution_count": null "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": {}, "metadata": {},
"cell_type": "code", "cell_type": "code",

View File

@ -60,7 +60,7 @@ class SoftwareConfig:
video_height: int = 1080 video_height: int = 1080
video_width: int = 960 video_width: int = 960
live_ip: str = '11.6.1.71' live_ip: str = 'vmaosmax.as'
live_push_port: int = 5555 live_push_port: int = 5555
live_rep_port: int = 5556 live_rep_port: int = 5556
device_py_rep_port: int = 5558 device_py_rep_port: int = 5558

View File

@ -238,7 +238,6 @@ def device_upload(name, file: TextIOWrapper):
dd.set_name_and_file_only(name, file.read()) dd.set_name_and_file_only(name, file.read())
@device.command('recvm') @device.command('recvm')
def device_recvmonitor(): def device_recvmonitor():
ctx = zmq.Context() ctx = zmq.Context()
@ -247,7 +246,8 @@ def device_recvmonitor():
while True: while True:
b = pull.recv() b = pull.recv()
seq, encoder, host_ts, device_ts_low, device_ts_high, buffer = b2t(b) 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') @device.command('recvplot')
def device_recvplot(): def device_recvplot():
@ -271,6 +271,7 @@ def device_recvplot():
last_ts = ts last_ts = ts
host_host_ts_last = host_host_ts host_host_ts_last = host_host_ts
@device.command('recvplot2') @device.command('recvplot2')
def device_recvplot2(): def device_recvplot2():
ctx = zmq.Context() ctx = zmq.Context()
@ -284,11 +285,13 @@ def device_recvplot2():
print((host_host_ts - host_host_ts_last) / 10 ** 6, flush=True) print((host_host_ts - host_host_ts_last) / 10 ** 6, flush=True)
host_host_ts_last = host_host_ts host_host_ts_last = host_host_ts
@device.command('recvplot3') @device.command('recvplot3')
def device_recvplot3(): def device_recvplot3():
ctx = zmq.Context() ctx = zmq.Context()
pull = ctx.socket(zmq.PULL) pull = ctx.socket(zmq.PULL)
pull.connect(C.live_push_socket) pull.connect(C.live_push_socket)
print(C.live_push_socket)
last_ts = 0 last_ts = 0
first = True first = True
host_host_ts_last = time.time_ns() host_host_ts_last = time.time_ns()
@ -302,10 +305,11 @@ def device_recvplot3():
last_ts = ts last_ts = ts
first = False first = False
continue 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 last_ts = ts
host_host_ts_last = host_host_ts host_host_ts_last = host_host_ts
@device.command('recvplotdiff') @device.command('recvplotdiff')
def device_recvplotdiff(): def device_recvplotdiff():
ctx = zmq.Context() ctx = zmq.Context()
@ -382,7 +386,7 @@ def robot():
def robot_monitor(): def robot_monitor():
robot.setup() robot.setup()
output1 = robot.rt.output_subscribe( 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 开始 robot.rt.start() # rtsi 开始
while True: while True:
recv_out: DataObject = robot.rt.get_output_data() recv_out: DataObject = robot.rt.get_output_data()
@ -391,7 +395,7 @@ def robot_monitor():
if recv_out.recipe_id == output1.id: if recv_out.recipe_id == output1.id:
x, y, z, r, p, yy = recv_out.actual_TCP_pose x, y, z, r, p, yy = recv_out.actual_TCP_pose
fx, fy, fz, fr, fp, fyy = recv_out.actual_TCP_force fx, fy, fz, fr, fp, fyy = recv_out.actual_TCP_force
print('fx', fx) print('xts', x, recv_out.timestamp)
@robot.command('record') @robot.command('record')
@ -411,10 +415,11 @@ def robot_record(folder):
def rtsi_thread(): def rtsi_thread():
output1 = robot.rt.output_subscribe( 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 开始 robot.rt.start() # rtsi 开始
arr = [] arr = []
last_ns = time.time_ns() last_ns = time.time_ns()
last_device_ts = 0
while True: while True:
recv_out: DataObject = robot.rt.get_output_data() recv_out: DataObject = robot.rt.get_output_data()
if recv_out is None: if recv_out is None:
@ -423,8 +428,9 @@ def robot_record(folder):
x, y, z, rx, ry, rz = recv_out.actual_TCP_pose x, y, z, rx, ry, rz = recv_out.actual_TCP_pose
fx, fy, fz, frx, fry, frz = recv_out.actual_TCP_force fx, fy, fz, frx, fry, frz = recv_out.actual_TCP_force
ns = time.time_ns() ns = time.time_ns()
print(ns - last_ns,x) print(ns - last_ns, recv_out.timestamp - last_device_ts, x)
last_ns = ns last_ns = ns
last_device_ts = recv_out.timestamp
d = dict( d = dict(
# x=x, # x=x,

View File

@ -52,6 +52,6 @@ def b2t(b: bytes):
# device_ts_low = struct.unpack('<I', bb) # device_ts_low = struct.unpack('<I', bb)
# device_ts_low = b[4 + 8 + 4 + 8:4 + 8 + 4 + 8 + 4] # device_ts_low = b[4 + 8 + 4 + 8:4 + 8 + 4 + 8 + 4]
# print(bin(device_ts_low[0]),bin(device_ts_low[1]),bin(device_ts_low[2]),bin(device_ts_low[3])) # print(bin(device_ts_low[0]),bin(device_ts_low[1]),bin(device_ts_low[2]),bin(device_ts_low[3]))
buffer = b[4 + 8 + 8 + 8 + 4:] buffer = b[4 + 8 + 4 + 8 + 4 + 4:]
return seq, encoder, host_ts, device_ts_low, device_ts_high, buffer return seq, encoder, host_ts, device_ts_low, device_ts_high, buffer