Commit d2b69c976a0b9d0eb55549420cc670c9d14366c5
Committed by
Thiago Franco de Moraes
1 parent
5ad7deb8
Exists in
master
Support fastrak (#104)
* Supported polhemus fastrak * Fixed scale for fastrak
Showing
2 changed files
with
31 additions
and
5 deletions
Show diff stats
invesalius/data/coordinates.py
@@ -102,10 +102,8 @@ def PolhemusCoord(trck, trck_id, ref_mode): | @@ -102,10 +102,8 @@ def PolhemusCoord(trck, trck_id, ref_mode): | ||
102 | 102 | ||
103 | 103 | ||
104 | def PolhemusWrapperCoord(trck, trck_id, ref_mode): | 104 | def PolhemusWrapperCoord(trck, trck_id, ref_mode): |
105 | - if trck_id == 2: | ||
106 | - scale = 10. * np.array([1., 1.0, -1.0]) | ||
107 | - else: | ||
108 | - scale = 25.4 * np.array([1., 1.0, -1.0]) | 105 | + |
106 | + scale = 25.4 * np.array([1., 1.0, -1.0]) | ||
109 | coord = None | 107 | coord = None |
110 | 108 | ||
111 | if ref_mode: | 109 | if ref_mode: |
invesalius/data/trackers.py
@@ -32,7 +32,7 @@ def TrackerConnection(tracker_id, action): | @@ -32,7 +32,7 @@ def TrackerConnection(tracker_id, action): | ||
32 | 32 | ||
33 | if action == 'connect': | 33 | if action == 'connect': |
34 | trck_fcn = {1: ClaronTracker, | 34 | trck_fcn = {1: ClaronTracker, |
35 | - 2: PolhemusTracker, # FASTRAK | 35 | + 2: PolhemusTrackerFT, # FASTRAK |
36 | 3: PolhemusTracker, # ISOTRAK | 36 | 3: PolhemusTracker, # ISOTRAK |
37 | 4: PolhemusTracker, # PATRIOT | 37 | 4: PolhemusTracker, # PATRIOT |
38 | 5: DebugTracker} | 38 | 5: DebugTracker} |
@@ -87,6 +87,24 @@ def ClaronTracker(tracker_id): | @@ -87,6 +87,24 @@ def ClaronTracker(tracker_id): | ||
87 | 87 | ||
88 | return trck_init, lib_mode | 88 | return trck_init, lib_mode |
89 | 89 | ||
90 | +def PolhemusTrackerFT(tracker_id): | ||
91 | + trck_init = None | ||
92 | + lib_mode = 'wrapper' | ||
93 | + try: | ||
94 | + import polhemusFT | ||
95 | + | ||
96 | + trck_init = polhemusFT.polhemusFT() | ||
97 | + trck_check = trck_init.Initialize() | ||
98 | + | ||
99 | + if trck_check: | ||
100 | + # First run is necessary to discard the first coord collection | ||
101 | + trck_init.Run() | ||
102 | + else: | ||
103 | + trck_init = trck_check | ||
104 | + except: | ||
105 | + print 'Could not connect to Polhemus via wrapper.' | ||
106 | + | ||
107 | + return trck_init, lib_mode | ||
90 | 108 | ||
91 | def PolhemusTracker(tracker_id): | 109 | def PolhemusTracker(tracker_id): |
92 | trck_init = None | 110 | trck_init = None |
@@ -213,6 +231,16 @@ def DisconnectTracker(tracker_id): | @@ -213,6 +231,16 @@ def DisconnectTracker(tracker_id): | ||
213 | lib_mode = 'error' | 231 | lib_mode = 'error' |
214 | print 'The ClaronTracker library is not installed.' | 232 | print 'The ClaronTracker library is not installed.' |
215 | 233 | ||
234 | + elif tracker_id == 2: | ||
235 | + try: | ||
236 | + import polhemusFT | ||
237 | + polhemusFT.polhemusFT().Close() | ||
238 | + lib_mode = 'wrapper' | ||
239 | + print 'Polhemus tracker disconnected.' | ||
240 | + except ImportError: | ||
241 | + lib_mode = 'error' | ||
242 | + print 'The polhemus library is not installed.' | ||
243 | + | ||
216 | elif tracker_id == 4: | 244 | elif tracker_id == 4: |
217 | try: | 245 | try: |
218 | import polhemus | 246 | import polhemus |