Commit 5c432f0f6ecb84b8abad82cf8a6b0f856368261e

Authored by Renan
Committed by Thiago Franco de Moraes
1 parent 05b7be51

Fix trackers connection (#76)

* Fix polhemus tracker connection
-adjust trigger baudrate

* Fix ISOTRAK connection

* Fix FASTRAK

* remove unnecessary print
invesalius/data/coordinates.py
@@ -192,12 +192,8 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode): @@ -192,12 +192,8 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode):
192 try: 192 try:
193 plh1 = [float(s) for s in data[1:len(data)]] 193 plh1 = [float(s) for s in data[1:len(data)]]
194 j = 1 194 j = 1
195 - except ValueError:  
196 - trck_init.write("P")  
197 - data = trck_init.readline()  
198 - data = data.replace('-', ' -')  
199 - data = [s for s in data.split()]  
200 - print "Trying to fix the error!!" 195 + except:
  196 + print "error!!"
201 197
202 coord = data[0:6] 198 coord = data[0:6]
203 return coord 199 return coord
invesalius/data/trackers.py
@@ -132,11 +132,10 @@ def PlhWrapperConnection(): @@ -132,11 +132,10 @@ def PlhWrapperConnection():
132 132
133 133
134 def PlhSerialConnection(tracker_id): 134 def PlhSerialConnection(tracker_id):
135 - trck_init = None  
136 try: 135 try:
137 import serial 136 import serial
138 137
139 - trck_init = serial.Serial(0, baudrate=115200, timeout=0.2) 138 + trck_init = serial.Serial('COM1', baudrate=115200, timeout=0.2)
140 139
141 if tracker_id == 2: 140 if tracker_id == 2:
142 # Polhemus FASTRAK needs configurations first 141 # Polhemus FASTRAK needs configurations first
@@ -145,6 +144,7 @@ def PlhSerialConnection(tracker_id): @@ -145,6 +144,7 @@ def PlhSerialConnection(tracker_id):
145 elif tracker_id == 3: 144 elif tracker_id == 3:
146 # Polhemus ISOTRAK needs to set tracking point from 145 # Polhemus ISOTRAK needs to set tracking point from
147 # center to tip. 146 # center to tip.
  147 + trck_init.write("F")
148 trck_init.write("Y") 148 trck_init.write("Y")
149 149
150 trck_init.write('P') 150 trck_init.write('P')
@@ -154,6 +154,7 @@ def PlhSerialConnection(tracker_id): @@ -154,6 +154,7 @@ def PlhSerialConnection(tracker_id):
154 trck_init = None 154 trck_init = None
155 155
156 except: 156 except:
  157 + trck_init = None
157 print 'Could not connect to Polhemus serial.' 158 print 'Could not connect to Polhemus serial.'
158 159
159 return trck_init 160 return trck_init
@@ -183,9 +184,7 @@ def PlhUSBConnection(tracker_id): @@ -183,9 +184,7 @@ def PlhUSBConnection(tracker_id):
183 if not data: 184 if not data:
184 trck_init = None 185 trck_init = None
185 186
186 - except uc.USBError as err:  
187 - print 'Could not set configuration %s' % err  
188 - else: 187 + except:
189 print 'Could not connect to Polhemus USB.' 188 print 'Could not connect to Polhemus USB.'
190 189
191 return trck_init 190 return trck_init
invesalius/data/trigger.py
@@ -35,7 +35,7 @@ class Trigger(threading.Thread): @@ -35,7 +35,7 @@ class Trigger(threading.Thread):
35 try: 35 try:
36 import serial 36 import serial
37 37
38 - self.trigger_init = serial.Serial('COM1', baudrate=115200, timeout=0) 38 + self.trigger_init = serial.Serial('COM1', baudrate=9600, timeout=0)
39 self.nav_id = nav_id 39 self.nav_id = nav_id
40 self._pause_ = False 40 self._pause_ = False
41 self.start() 41 self.start()