-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoord.py
75 lines (67 loc) · 2.75 KB
/
coord.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import time
import threading
import wx
#requires the following import to works sendmessage args
from wx.lib.pubsub import setuparg1
from wx.lib.pubsub import pub as Publisher
class nav(threading.Thread):
# Thread created to update the object coordinates
# Sleep function in run method is used for better real-time navigation
def __init__(self,nav, tracker_init, tck):
threading.Thread.__init__(self)
self.nav = nav
self.tck = tck
self.tracker_init = tracker_init
self._pause_ = False
self.start()
def stop(self):
self._pause_ = True
self.tracker_init.Close()
def run(self):
cm2mm = 10.0
x = 10.0
y = 10.0
z = -10.0
i=0
d=1
while self.nav:
if self.tck == "plh":
plh = self.tracker_init
plh.Run()
coord = (plh.PositionTooltipX1, plh.PositionTooltipY1, plh.PositionTooltipZ1,
plh.AngleX1, plh.AngleY1, plh.AngleZ1)
coord = (float(coord[0]) * cm2mm, float(coord[1]) * cm2mm,
float(coord[2]) * (-cm2mm), float(coord[3]),
float(coord[4]), float(coord[5]))
wx.CallAfter(Publisher.sendMessage, 'Update Orientation', coord)
elif self.tck == "mtc":
mtc = self.tracker_init
mtc.Run()
coord = (mtc.PositionTooltipX1, mtc.PositionTooltipY1, mtc.PositionTooltipZ1,
mtc.AngleX1, mtc.AngleY1, mtc.AngleZ1,
mtc.ProjectionCenterX / 10, mtc.ProjectionCenterY / 10, mtc.ProjectionCenterZ / 10,
mtc.ProjectionCableX / 10, mtc.ProjectionCableY / 10, mtc.ProjectionCableZ / 10)
print mtc.PositionTooltipX1
coord = (float(coord[0])*x, float(coord[1])*y,
float(coord[2])*z, float(coord[3]),
float(coord[4]), float(coord[5]),
float(coord[6])*x, float(coord[7])*y, float(coord[8])*z,
float(coord[9])*x, float(coord[10])*y, float(coord[11])*z)
print coord
wx.CallAfter(Publisher.sendMessage, 'Update Orientation', coord)
elif self.tck == "debug":
wx.CallAfter(Publisher.sendMessage, 'Update Orientation', i)
if i<=50 and d==1:
i+=1
d=1
elif i >= -50 and d == 0:
i -= 1
d = 0
elif i>50:
d=0
else:
d=1
print d, i
time.sleep(0.175)
if self._pause_:
return