NaviTrack Tutorial:Integrating:How to use sample codes

From NAMIC Wiki
Jump to: navigation, search
Home < NaviTrack Tutorial:Integrating:How to use sample codes

Installing sample codes

The sample codes provided here are based on the codes used in the last tutorial. If you have not added MyTutorialModule into your NaviTrack, please follow the instructions described in the last tutorial's page.

Getting archive

Get zip archive File:NTTutorial May2007 3.zip.

Deploy the files

Extract files from the archive. In UNIX:

$ unzip NTTutorial_May2007_2.zip
Archive:  ./NTTutorial_May2007_2.zip

Archive: ../NTTutorial_May2007_2.zip

  creating: NTTutorial_May2007_2/
 inflating: NTTutorial_May2007_2/MyTutorialModule.cxx
 inflating: NTTutorial_May2007_2/MyTutorialSink.cxx
 
 ...
 
 inflating: NTTutorial_May2007_2/tutorial_source.xml
 inflating: NTTutorial_May2007_2/pullimage.cxx

Copy files to following directories

File name Description Copy to
MyTutorial*.cxx NaviTrack Module NaviTrack/src/input
MyTutorial*.h NaviTrack Module headers NaviTrack/include/OpenTracker/input
Makefile Makefile for sample application Working directory
Makefile.nosc.in Makefile parameters (for systems w/o GTK+) Working directory
Makefile.sc.in Makefile parameters (for systems w/ GTK+ Working directory
pushpos.cxx Sample application to send coordinate data Working directory
pullpos.cxx Sample application to receive coordinate data Working directory
pushimage.cxx Sample application to send image data Working directory
pullimage.cxx Sample application to receive image data Working directory
pgmimage.* Library to read/write PGM image format Working directory
simplecanvas.* Library to display image (requires GTK+) Working directory
tutorial_source.xml NaviTrack configuration for pushpos and pushimage Working directory
tutorial_sink.xml NaviTrack configuration for pullpos and pullimage Working directory
human-0?.pgm Images for demo Working directory

Rebuild NaviTrack

Go to NaviTrack directory and just run make.

$ cd NaviTrack
$ make

Build applications

Build with GTK+ (enabling image display function)

Edit Makefile line 1 and 2 as follows:

#include ./Makefile.nosc.in     # no viewer
include ./Makefile.sc.in       # use simple image viewer (requires GTK+)

Edit Makefile.sc.in for your environment:

NTDIR   = /projects/igtdev/tokuda/NaviTrack/branches/nt-brp
CXX     = g++
LIBS    = -lNaviTrack
INCDIR  = -I${NTDIR}/include
LIBDIR  = -L. -L${NTDIR}

Run make:

$ make clean
$ make

Build without GTK+ (disabling image display function)

Edit Makefile line 1 and 2 as follows:

include ./Makefile.nosc.in     # no viewer
#include ./Makefile.sc.in       # use simple image viewer (requires GTK+)

Edit Makefile.nosc.in for your environment:

NTDIR   = /projects/igtdev/tokuda/NaviTrack/branches/nt-brp
CXX     = g++
LIBS    = -lNaviTrack
INCDIR  = -I${NTDIR}/include
LIBDIR  = -L. -L${NTDIR}

Run make:

$ make clean
$ make

Running the applications

Passing coordinate data

Open two terminals and go to the directory where the programs exists.

Terminal 1 (pushpos: sending side)

$ ./pushpos tutorial_source.xml

Terminal 2 (pullpos: receiving side)

$ ./pullpos tutorial_sink.xml

Passing image data

In terminal 1 (sending side: pushimage)

$ ./pushimage tutorial_source.xml

In terminal 2 (receiving side: pullimage)

$ ./pullimage tutorial_source.xml


!!NOTE!! You may encounter application errors, while passing image data through a network using NaviTrack NetworkModule. This is because NaviTrack NetworkModule uses UDP for a communication between Sink and Source. Each data has header information in this communication including entire size of the data, and packet loss causes inconsistency between data size information in header and actual data size. NaviTrack has no capability to recover this kind of error in the current version.


Back to Integrating into your application.