Difference between revisions of "Tracker Daemon"

From NAMIC Wiki
Jump to: navigation, search
m (Text replacement - "http://www.slicer.org/slicerWiki/index.php/" to "https://www.slicer.org/wiki/")
 
(23 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
Tracker Daemon is created for the communication between Slicer 3 and IGSTK through socket connection. For now, a program built on top of IGSTK can send tracking data to Slicer 3, which then updates the locator and related images accordingly. In the future, Tracker Daemon will be used to receive realtime images.
 
Tracker Daemon is created for the communication between Slicer 3 and IGSTK through socket connection. For now, a program built on top of IGSTK can send tracking data to Slicer 3, which then updates the locator and related images accordingly. In the future, Tracker Daemon will be used to receive realtime images.
 +
 +
'''See [[OpenIGTLink]] for the new version of this Daemon.'''
  
 
= Recipe for using Tracker Daemon=
 
= Recipe for using Tracker Daemon=
# Rerun CMake in the VTK that you used for building IGSTK and turn "VTK_USE_PARALLEL" ON. Then compile VTK (no need to make a clean build, it will just build the vtkParallel library).
+
== Prepare VTK & IGSTK ==
# Put the igstkTracker.cxx file from the NAMIC sandbox directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets/IGSTKAdaptor into the IGSTK/Source directory. (replacing the existing one). Rerun CMake on IGSTK, then build IGSTK.
+
* Rerun CMake in the VTK that you used for building IGSTK and turn "VTK_USE_PARALLEL" ON. Then compile VTK (no need to make a clean build, it will just build the vtkParallel library).
# Configure the directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets with CMake, provide in IGSTK_DIR the directory where you build IGSTK, and provide ITK_DIR and VTK_DIR as the directories that you used for building IGSTK. They don't have to be the same that you used for building Slicer.
+
* Put the igstkTracker.cxx file from the NAMIC sandbox directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets/IGSTKAdaptor into the IGSTK/Source directory. (replacing the existing one). Rerun CMake on IGSTK, then build IGSTK.
# Once you build from step (3) above, you will get three executables.
+
== Prepare NAMICSandbox Integration Code ==
* igstkTrackerToolSocketRelayTest1.exe
+
* Configure the directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets with CMake, provide in IGSTK_DIR the directory where you build IGSTK, and provide ITK_DIR and VTK_DIR as the directories that you used for building IGSTK. They don't have to be the same that you used for building Slicer.
* igstkTrackerToolSocketRelayTest2.exe
+
 
* igstkTransformSocketListener.exe
+
== Prepare Slicer IGT ==
 +
 
 +
=== Download Slicer IGT ===
 +
 
 +
Download Slicer IGT by using the following command
 +
 
 +
    svn co http://www.na-mic.org/svn/Slicer3/branches/IGT Slicer3
 +
 
 +
=== Build Slicer IGT ===
 +
 
 +
Simply run the script
 +
 
 +
 
 +
  ./Slicer3/Scripts/getbuildtest.tcl
 +
 
 +
 
 +
This Tcl script will download all necessary libraries, will configure them and will initiate the build of Slicer.
  
  
 +
For more details on how to build it, please see the full page
  
    First, test your system by running the following
+
* [https://www.slicer.org/wiki/Slicer3:Build_Instructions Slicer3 Build Instructions].
    commands:
 
  
    a) igstkTransformSocketListener.exe 16666  &
+
== Testing ==
    b) igstkTrackerToolSocketRelayTest2.exe  localhost 16666 &
 
  
    preferably, run each command on a different console.
+
=== First Test ===
  
 +
Once you build from step above, you will get three executables:
  
    That should print out the following output on the console (a):
+
* igstkTrackerToolSocketRelayTest1.exe,
 +
* igstkTrackerToolSocketRelayTest2.exe
 +
* igstkTransformSocketListener.exe
  
$  Port = 16666
+
First, test your system by running the following commands:  
0 : 1  0  0  0  1  0  0  0  1  0  100  0
 
1 : 1  0  0  0  1  0  0  0  1  0.999983  99.995  0
 
2 : 1  0  0  0  1  0  0  0  1  1.99987  99.98  0
 
3 : 1  0  0  0  1  0  0  0  1  2.99955  99.955  0
 
4 : 1  0  0  0  1  0  0  0  1  3.99893  99.92  0
 
5 : 1  0  0  0  1  0  0  0  1  4.99792  99.875  0
 
6 : 1  0  0  0  1  0  0  0  1  5.9964  99.8201  0
 
7 : 1  0  0  0  1  0  0  0  1  6.99428  99.7551  0
 
  
 +
# igstkTransformSocketListener.exe 16666
 +
# igstkTrackerToolSocketRelayTest2.exe  localhost 16666
  
    This is a made-up tracker that provides position in
+
Preferably, run each command on a different console.  
    a circle.
 
  
 +
That should print out the following output on the console of command (1):
  
    If this works fine, then move to the following test:
+
<br>
 +
$  Port = 16666 <br>
 +
0 : 1  0  0  0  1  0  0  0  1  0  100  0 <br>
 +
1 : 1  0  0  0  1  0  0  0  1  0.999983  99.995  0 <br>
 +
2 : 1  0  0  0  1  0  0  0  1  1.99987  99.98  0 <br>
 +
3 : 1  0  0  0  1  0  0  0  1  2.99955  99.955  0 <br>
 +
4 : 1  0  0  0  1  0  0  0  1  3.99893  99.92  0 <br>
 +
5 : 1  0  0  0  1  0  0  0  1  4.99792  99.875  0 <br>
 +
6 : 1  0  0  0  1  0  0  0  1  5.9964  99.8201  0 <br>
 +
7 : 1  0  0  0  1  0  0  0  1  6.99428  99.7551  0 <br>
  
 +
This is a made-up tracker that provides position in a circle. If this works fine, then move to the following test:
  
 +
=== Second Test ===
  
5) Kill the two commands above.
+
* Kill the two commands above.
  
6) Run, in separate consoles the following commands:
+
* Run, in separate consoles the following commands:  
  
    a) igstkTransformSocketListener.exe 16666 &
+
# igstkTransformSocketListener.exe 16666
    b) igstkTrackerToolSocketRelayTest1.exe  localhost 16666 &
+
# igstkTrackerToolSocketRelayTest1.exe  localhost 16666
  
  
    Note that now in (b) you use the executable with "1".
+
Note that now in (2) you use the executable with "1". This execuatble will initialize the Aurora Tracker in serial port 0, and start grabbing transforms and sending them through the socket. In console (a), you should see transform values comming in, but this time, the values will match the movements of the Aurora Tracker Tool.
  
    This execuatble will initialize the Aurora Tracker in
+
* If this works fine, then move to the real final test;
    serial port 0, and start grabbing transforms and sending
+
*  Kill the two commands above
    them through the socket.
 
  
    In console (a), you should see transform values comming in,
+
=== Third Test ===
    but this time, the values will match the movements of the
 
    Aurora Tracker Tool.
 
  
 +
Start Slicer IGT, and follows Steve recipe: <br>
  
7) If this works fine, then move to the real final test;
+
# create a transform called "tracker" <br>
 +
# load a dataset or a moder and make it a child of the "tracker" transform that you just created <br>
 +
# Open the Interactor window and from there start the tracker daemon by using the following commands:
 +
## source $::SLICER_BUILD/../Slicer3/Modules/TrackerDaemon/Tcl/trackerd.tcl
 +
## trackerd_start
  
  
8) Kill the two commands above
+
Once Slicer is ready waiting for transforms, then do in a console the following command: <br>
  
9) Start Slicer IGT, and follows Steve recipe:
 
  
    a) create a transform called "tracker"
+
  igstkTrackerToolSocketRelayTest1.exe  localhost 8529
    b) load a dataset or a moder and make it a child
 
      of the "tracker" transform that you just created
 
    c) Open the Interactor window and from there start
 
      the tracker daemon (I'll need help from Steve
 
      here, to remember the exact command).
 
  
  
10) Once Slicer is ready waiting for transforms,
+
Note that this time we use a different port number. At that point, the Aurora tracker should be initialized (beeping), and Slicer should popup a message asking for authorization to let somebody connect in "127.0.0.1". If you click on "OK" in that message, then Slicer should start receiving the transforms from the socket, and you should see the volume moving as you move the Tracket tool.
    then do in a console the following command:
 
  
    igstkTrackerToolSocketRelayTest1.exe  localhost 8529 &
+
= Discussion =
 +
'''Luis:'''
 +
We were discussing yesterday the socket API with Andinet and Matt,
 +
and they pointed out that we should include the TimeStamp in the
 +
stream that is sent through the socket.
  
 +
Slicer can decide later how to use this TimeStamp values.
  
    Note that this time we use a different port number.
+
Currently, this Time Stamp comes down to two doubles that mark the
 +
beginning and the end of the time window in which the Transform is
 +
known to be valid.
  
 +
The values are in milliseconds, and are provided by the
 +
itk::RealTimeClock, which can actually be mapped back to a
 +
{hour, day, month, year} set of values if necessary.
  
    At that point, the Aurora tracker should be initialized
+
That will make possible to synchronize with video inputs and
    (beeping), and Slicer should popup a message asking for
+
with Transforms sent from other trackers. All of this under the
    authorization to let somebody connect in "127.0.0.1".
+
assumption that if the Tracker is running in a different computer,
 +
then the two computers have been time-synchronized.
  
    If you click on "OK" in that message, then Slicer should
+
= Screenshots =
    start receiving the transforms from the socket, and you
 
    should see the volume moving as you move the Tracket tool.
 

Latest revision as of 18:07, 10 July 2017

Home < Tracker Daemon

Purpose

Tracker Daemon is created for the communication between Slicer 3 and IGSTK through socket connection. For now, a program built on top of IGSTK can send tracking data to Slicer 3, which then updates the locator and related images accordingly. In the future, Tracker Daemon will be used to receive realtime images.

See OpenIGTLink for the new version of this Daemon.

Recipe for using Tracker Daemon

Prepare VTK & IGSTK

  • Rerun CMake in the VTK that you used for building IGSTK and turn "VTK_USE_PARALLEL" ON. Then compile VTK (no need to make a clean build, it will just build the vtkParallel library).
  • Put the igstkTracker.cxx file from the NAMIC sandbox directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets/IGSTKAdaptor into the IGSTK/Source directory. (replacing the existing one). Rerun CMake on IGSTK, then build IGSTK.

Prepare NAMICSandbox Integration Code

  • Configure the directory NAMICSandBox/trunk/IGSTK-Slicer-IntegrationViaSockets with CMake, provide in IGSTK_DIR the directory where you build IGSTK, and provide ITK_DIR and VTK_DIR as the directories that you used for building IGSTK. They don't have to be the same that you used for building Slicer.

Prepare Slicer IGT

Download Slicer IGT

Download Slicer IGT by using the following command

   svn co http://www.na-mic.org/svn/Slicer3/branches/IGT Slicer3

Build Slicer IGT

Simply run the script


 ./Slicer3/Scripts/getbuildtest.tcl


This Tcl script will download all necessary libraries, will configure them and will initiate the build of Slicer.


For more details on how to build it, please see the full page

Testing

First Test

Once you build from step above, you will get three executables:

  • igstkTrackerToolSocketRelayTest1.exe,
  • igstkTrackerToolSocketRelayTest2.exe
  • igstkTransformSocketListener.exe

First, test your system by running the following commands:

  1. igstkTransformSocketListener.exe 16666
  2. igstkTrackerToolSocketRelayTest2.exe localhost 16666

Preferably, run each command on a different console.

That should print out the following output on the console of command (1):


$ Port = 16666
0 : 1 0 0 0 1 0 0 0 1 0 100 0
1 : 1 0 0 0 1 0 0 0 1 0.999983 99.995 0
2 : 1 0 0 0 1 0 0 0 1 1.99987 99.98 0
3 : 1 0 0 0 1 0 0 0 1 2.99955 99.955 0
4 : 1 0 0 0 1 0 0 0 1 3.99893 99.92 0
5 : 1 0 0 0 1 0 0 0 1 4.99792 99.875 0
6 : 1 0 0 0 1 0 0 0 1 5.9964 99.8201 0
7 : 1 0 0 0 1 0 0 0 1 6.99428 99.7551 0

This is a made-up tracker that provides position in a circle. If this works fine, then move to the following test:

Second Test

  • Kill the two commands above.
  • Run, in separate consoles the following commands:
  1. igstkTransformSocketListener.exe 16666
  2. igstkTrackerToolSocketRelayTest1.exe localhost 16666


Note that now in (2) you use the executable with "1". This execuatble will initialize the Aurora Tracker in serial port 0, and start grabbing transforms and sending them through the socket. In console (a), you should see transform values comming in, but this time, the values will match the movements of the Aurora Tracker Tool.

  • If this works fine, then move to the real final test;
  • Kill the two commands above

Third Test

Start Slicer IGT, and follows Steve recipe:

  1. create a transform called "tracker"
  2. load a dataset or a moder and make it a child of the "tracker" transform that you just created
  3. Open the Interactor window and from there start the tracker daemon by using the following commands:
    1. source $::SLICER_BUILD/../Slicer3/Modules/TrackerDaemon/Tcl/trackerd.tcl
    2. trackerd_start


Once Slicer is ready waiting for transforms, then do in a console the following command:


  igstkTrackerToolSocketRelayTest1.exe  localhost 8529


Note that this time we use a different port number. At that point, the Aurora tracker should be initialized (beeping), and Slicer should popup a message asking for authorization to let somebody connect in "127.0.0.1". If you click on "OK" in that message, then Slicer should start receiving the transforms from the socket, and you should see the volume moving as you move the Tracket tool.

Discussion

Luis: We were discussing yesterday the socket API with Andinet and Matt, and they pointed out that we should include the TimeStamp in the stream that is sent through the socket.

Slicer can decide later how to use this TimeStamp values.

Currently, this Time Stamp comes down to two doubles that mark the beginning and the end of the time window in which the Transform is known to be valid.

The values are in milliseconds, and are provided by the itk::RealTimeClock, which can actually be mapped back to a {hour, day, month, year} set of values if necessary.

That will make possible to synchronize with video inputs and with Transforms sent from other trackers. All of this under the assumption that if the Tracker is running in a different computer, then the two computers have been time-synchronized.

Screenshots