This commit is contained in:
vmaosmini 2025-05-14 13:50:09 +08:00
parent 9e25a12683
commit de83fafc0d

View File

@ -352,6 +352,12 @@ def robot_record(folder):
p.mkdir(parents=True, exist_ok=True)
robot.setup()
# last_ns = time.perf_counter_ns()
# while True:
# ns = time.perf_counter_ns()
# print(ns - last_ns)
# last_ns = ns
q = queue.Queue()
def rtsi_thread():
@ -359,31 +365,35 @@ def robot_record(folder):
'actual_TCP_pose,actual_TCP_force', 250) # 输出订阅,配方1
robot.rt.start() # rtsi 开始
arr = []
last_ns = time.time_ns()
while True:
recv_out: DataObject = robot.rt.get_output_data()
if recv_out is None:
continue
if recv_out.recipe_id == output1.id:
ns = time.time_ns()
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)
last_ns = ns
d = dict(
x=x,
y=y,
z=z,
fx=fx,
fy=fy,
fz=fz,
rx=rx,
ry=ry,
rz=rz,
frx=frx,
fry=fry,
frz=frz,
ns=ns
# x=x,
# y=y,
# z=z,
# fx=fx,
# fy=fy,
# fz=fz,
# rx=rx,
# ry=ry,
# rz=rz,
# frx=frx,
# fry=fry,
# frz=frz,
# ns=ns
)
arr.append(d)
print(arr.__len__())
# arr.append(d)
# print(arr.__len__())
# if arr.__len__() == 100:
# q.put(arr)
# arr = []
@ -393,11 +403,11 @@ def robot_record(folder):
print(q.get()[0]['ns'])
tr = threading.Thread(target=rtsi_thread)
tw = threading.Thread(target=write_thread)
# tw = threading.Thread(target=write_thread)
tr.start()
tw.start()
# tw.start()
tr.join()
tw.join()
# tw.join()
if __name__ == '__main__':