forked from RothkopfLab/catchingballs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppt.py
40 lines (33 loc) · 1.2 KB
/
ppt.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
import viz
# import add-on
vrpn = viz.add('vrpn7.dle')
def add_tracker(marker=0):
"""
Add a tracker to the vrpn object
:param marker: marker number
:return: the new tracker
"""
tracker = vrpn.addTracker('PPT0@WV', marker)
return tracker
def link(tracker, target, ori=None, offset=[0, 0, 0], pre_trans=[0, 0, 0]):
"""
Link the tracker to a target (with an optional rotation sensor ori)
:param tracker: tracker to be linked
:param target: target to link to
:param ori: orientation tracker
:param offset: offset from tracker to target
:param pre_trans: pre multiplied with input matrix
:return: link object
"""
if ori:
# merge orientation and position trackers
merged_trackers = viz.mergeLinkable(pos=tracker, ori=ori)
else:
merged_trackers = tracker
# link to target (usually viz.MainView or an object like a glove)
complete_link = viz.link(merged_trackers, target)
complete_link.setOffset(offset)
# distance between tracker and actual position of target
complete_link.preTrans(pre_trans)
# TODO: maybe different solution (offsets and stuff)
return complete_link