-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwil_talker_console.py
59 lines (41 loc) · 1.51 KB
/
wil_talker_console.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# WYSIWYG Indoor Localization
# Sample code:
# Gather and adjust pose information - then just print it on the console
#
# Author: David Vincze
#
# https://github.com/szaguldo-kamaz/
#
import time, sys
from WIL import WIL
## configuration ##
calibdata_filename = 'wil_calibparams.txt'
### start ###
if len(sys.argv) > 1:
wilobj = WIL(sys.argv[1])
else:
wilobj = WIL()
# try to read previous calibration config data (set verbose so calibrate_from_file() will print actual values)
wilobj.set_verbose(True)
if wilobj.calibrate_from_file(calibdata_filename):
print(f"Calibration data loaded from: {calibdata_filename}")
else:
print(f"Cannot load calibration data from: {calibdata_filename}, using default values (no calibration).")
wilobj.set_verbose(False)
print("Waiting for all the tracked devices to be actually tracked...")
while not wilobj.all_poses_valid():
if wilobj.update() != 0:
print("WIL update error!")
break
print("I see all the tracked devices.")
while True:
if wilobj.update() != 0:
print("WIL update error!")
break
for trackername in wilobj.get_tracker_names():
trackerpos = wilobj.trackers[trackername].get_raw_position()
trackeroriq = wilobj.trackers[trackername].get_raw_orientation_quat()
trackerorie = wilobj.trackers[trackername].get_raw_orientation_euler_degrees()
print(f"{trackername}({wilobj.trackers[trackername].serial}) {trackerpos} {trackeroriq} {trackerorie}")
time.sleep(0.01)
sock_trackerinfo.close()