Skip to content

Commit

Permalink
Improvements Microntracker support (invesalius#154)
Browse files Browse the repository at this point in the history
* Improvements Microntracker support

-Removed unused markers files

* Minor bug fix: disconnect tracker
  • Loading branch information
rmatsuda authored and tfmoraes committed Nov 27, 2018
1 parent 0ea23c2 commit feaf214
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 559 deletions.
3 changes: 3 additions & 0 deletions invesalius/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@

CAL_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'CalibrationFiles'))
MAR_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'Markers'))
PROBE_NAME = "1Probe"
REF_NAME = "2Ref"
OBJ_NAME = "3Coil"

#OBJECT TRACKING
OBJ_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'objects'))
Expand Down
45 changes: 15 additions & 30 deletions invesalius/data/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,22 @@ def GetCoordinates(trck_init, trck_id, ref_mode):

def ClaronCoord(trck_init, trck_id, ref_mode):
trck = trck_init[0]
scale = np.array([1.0, 1.0, -1.0])
coord = None
k = 0
# TODO: try to replace 'while' and use some Claron internal computation
trck.Run()
scale = np.array([1.0, 1.0, 1.0])

if ref_mode:
while k < 20:
try:
trck.Run()
probe = np.array([trck.PositionTooltipX1, trck.PositionTooltipY1,
trck.PositionTooltipZ1, trck.AngleX1, trck.AngleY1, trck.AngleZ1])
reference = np.array([trck.PositionTooltipX2, trck.PositionTooltipY2,
trck.PositionTooltipZ2, trck.AngleZ2, trck.AngleY2, trck.AngleX2])
k = 30
except AttributeError:
k += 1
print("wait, collecting coordinates ...")
if k == 30:
coord = dynamic_reference(probe, reference)
coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5])
else:
while k < 20:
try:
trck.Run()
coord = np.array([trck.PositionTooltipX1 * scale[0], trck.PositionTooltipY1 * scale[1],
trck.PositionTooltipZ1 * scale[2], trck.AngleX1, trck.AngleY1, trck.AngleZ1])

k = 30
except AttributeError:
k += 1
print("wait, collecting coordinates ...")
coord1 = np.array([float(trck.PositionTooltipX1)*scale[0], float(trck.PositionTooltipY1)*scale[1],
float(trck.PositionTooltipZ1)*scale[2],
float(trck.AngleZ1), float(trck.AngleY1), float(trck.AngleX1)])

coord2 = np.array([float(trck.PositionTooltipX2)*scale[0], float(trck.PositionTooltipY2)*scale[1],
float(trck.PositionTooltipZ2)*scale[2],
float(trck.AngleZ2), float(trck.AngleY2), float(trck.AngleX2)])

coord3 = np.array([float(trck.PositionTooltipX3) * scale[0], float(trck.PositionTooltipY3) * scale[1],
float(trck.PositionTooltipZ3) * scale[2],
float(trck.AngleZ3), float(trck.AngleY3), float(trck.AngleX3)])

coord = np.vstack([coord1, coord2, coord3])

Publisher.sendMessage('Sensors ID', probe_id=trck.probeID, ref_id=trck.refID)

Expand Down
21 changes: 14 additions & 7 deletions invesalius/data/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def ClaronTracker(tracker_id):
trck_init = pyclaron.pyclaron()
trck_init.CalibrationDir = const.CAL_DIR.encode(const.FS_ENCODE)
trck_init.MarkerDir = const.MAR_DIR.encode(const.FS_ENCODE)
trck_init.NumberFramesProcessed = 10
trck_init.NumberFramesProcessed = 1
trck_init.FramesExtrapolated = 0
trck_init.PROBE_NAME = "1Probe"
trck_init.REF_NAME = "5Ref"
trck_init.PROBE_NAME = const.PROBE_NAME.encode(const.FS_ENCODE)
trck_init.REF_NAME = const.REF_NAME.encode(const.FS_ENCODE)
trck_init.OBJ_NAME = const.OBJ_NAME.encode(const.FS_ENCODE)
trck_init.Initialize()

if trck_init.GetIdentifyingCamera():
Expand Down Expand Up @@ -215,10 +216,16 @@ def DisconnectTracker(tracker_id, trck_init):
print('Debug tracker disconnected.')
else:
try:
trck_init.Close()
trck_init = False
lib_mode = 'wrapper'
print('Tracker disconnected.')
if tracker_id == 3:
trck_init.close()
trck_init = False
lib_mode = 'serial'
print('Tracker disconnected.')
else:
trck_init.Close()
trck_init = False
lib_mode = 'wrapper'
print('Tracker disconnected.')
except:
trck_init = True
lib_mode = 'error'
Expand Down
3 changes: 2 additions & 1 deletion invesalius/gui/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,8 @@ def _init_gui(self):
choice_ref.SetSelection(self.obj_ref_id)
choice_ref.SetToolTip(tooltip)
choice_ref.Bind(wx.EVT_COMBOBOX, self.OnChoiceRefMode)
choice_ref.Enable(0)
if self.tracker_id != const.MTC:
choice_ref.Enable(0)

# Buttons to finish or cancel object registration
tooltip = wx.ToolTip(_(u"Registration done"))
Expand Down
1 change: 1 addition & 0 deletions invesalius/gui/task_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ def OnChoiceTracker(self, evt, ctrl):
print("Tracker connected!")
elif choice == 6:
if trck:
self.ResetTrackerFiducials()
Publisher.sendMessage('Update status text in GUI',
label=_("Disconnecting tracker ..."))
Publisher.sendMessage('Remove sensors ID')
Expand Down
38 changes: 0 additions & 38 deletions navigation/mtc_files/Markers/1b

This file was deleted.

39 changes: 0 additions & 39 deletions navigation/mtc_files/Markers/2Coil

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Marker]
FacetsCount=1
SliderControlledXpointsCount=0
Name=5Ref
Name=2Ref

[Facet1]
VectorsCount=2
Expand Down
38 changes: 0 additions & 38 deletions navigation/mtc_files/Markers/2b

This file was deleted.

48 changes: 24 additions & 24 deletions navigation/mtc_files/Markers/3Coil
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ Name=3Coil
VectorsCount=2

[Facet1V1]
EndPos(0,0)=-8.9434442564413246
EndPos(0,1)=-6.1153268241647966e-016
EndPos(0,2)=3.4944724709513123e-016
EndPos(1,0)=8.9434442564413299
EndPos(1,1)=-8.8089826871897666e-016
EndPos(1,2)=-4.6592966279350834e-016
EndPos(0,0)=-8.9198865356554879
EndPos(0,1)=-3.2134269776695802e-005
EndPos(0,2)=2.5837917664003644e-015
EndPos(1,0)=8.9199450751944145
EndPos(1,1)=-3.9241103842582014e-005
EndPos(1,2)=2.4152836077220795e-015

[Facet1V2]
EndPos(0,0)=-8.9439343674574907
EndPos(0,1)=11.937904678416533
EndPos(0,2)=-5.2417087064269685e-016
EndPos(1,0)=-8.9434442564413246
EndPos(1,1)=-6.1153268241647966e-016
EndPos(1,2)=3.4944724709513123e-016
EndPos(0,0)=-8.9091438029221042
EndPos(0,1)=11.945533367263891
EndPos(0,2)=1.2918958832001822e-015
EndPos(1,0)=-8.9198865356554879
EndPos(1,1)=-3.2134269776695802e-005
EndPos(1,2)=2.5837917664003644e-015

[Tooltip2MarkerXf]
Scale=1.
S0=0.80000000000000182
R0,0=0.9563047559630351
R1,0=1.8041124150158794e-016
R2,0=-0.29237170472273794
S1=47.299999999999962
R0,1=9.0347825433700193e-002
R1,1=0.95105651629515331
R2,1=0.29551442139416562
S2=42.399999999999991
R0,2=0.27806201495688238
R1,2=-0.30901699437494834
R2,2=0.90949986972269081
S0=0.
R0,0=1.
R1,0=0.
R2,0=0.
S1=0.
R0,1=0.
R1,1=1.
R2,1=0.
S2=0.
R0,2=0.
R1,2=0.
R2,2=1.
39 changes: 0 additions & 39 deletions navigation/mtc_files/Markers/4Coil

This file was deleted.

37 changes: 0 additions & 37 deletions navigation/mtc_files/Markers/COOLCARD

This file was deleted.

Loading

0 comments on commit feaf214

Please sign in to comment.