LightHouse-UESTC/Code/triad_openvr/tracker_test.py

30 lines
796 B
Python
Raw Normal View History

2023-11-29 13:21:56 +08:00
import triad_openvr
import time
import sys
v = triad_openvr.triad_openvr()
2023-11-29 22:56:01 +08:00
# v.print_discovered_objects()
2023-11-29 13:21:56 +08:00
if len(sys.argv) == 1:
interval = 1/250
elif len(sys.argv) == 2:
interval = 1/float(sys.argv[1])
else:
print("Invalid number of arguments")
interval = False
if interval:
while(True):
start = time.time()
txt = ""
pose_euler = v.devices["hmd_1"].get_pose_euler()
if pose_euler is not None:
for each in pose_euler:
txt += "%.4f" % each
txt += " "
print("\r" + txt, end="")
sleep_time = interval - (time.time() - start)
if sleep_time > 0:
time.sleep(sleep_time)
else:
print("定位器超出基站扫描视野范围!")