Difference between revisions of "NaviTrack Tutorial:Creating module:Adding module"

From NAMIC Wiki
Jump to: navigation, search
 
(15 intermediate revisions by one other user not shown)
Line 1: Line 1:
Here, we will add "MyTutorialModule" to your NaviTrack.
+
In this page, we will add "MyTutorialModule" to your NaviTrack.
 +
 
 +
=Step 0: Get the sample source codes=
 +
 
 +
You can download from [[Image:NTTutorial_May2007.zip]].
 +
 
 +
To extract files in UNIX,
 +
 
 +
% unzip NTTutorial_May2007.zip
  
 
=Step 1: Deploy your source codes=
 
=Step 1: Deploy your source codes=
Line 7: Line 15:
 
In UNIX:
 
In UNIX:
  
 +
% cd NTTutorial_May2007
 
  % cp *.cxx <your NaviTrack directory>/src/input/
 
  % cp *.cxx <your NaviTrack directory>/src/input/
 
  % cp *.h  <your NaviTrack directory>/include/OpenTracker/input/
 
  % cp *.h  <your NaviTrack directory>/include/OpenTracker/input/
 
  
 
=Step 2: Configure Cmake=
 
=Step 2: Configure Cmake=
Line 16: Line 24:
 
so that NaviTrack is compiled with your own module.
 
so that NaviTrack is compiled with your own module.
  
In SET(SOURCES ...) section in CMakeLists.txt (starts from L.126),
+
In SET(BASESRCS ...) section in CMakeLists.txt (starts from L.126),
 
add paths to your *.cxx files as:
 
add paths to your *.cxx files as:
  
  SET(SOURCES
+
  SET(BASESRCS
 
  src/core/Event.cxx
 
  src/core/Event.cxx
 
  src/core/EventAttributeBase.cxx
 
  src/core/EventAttributeBase.cxx
Line 27: Line 35:
 
   
 
   
 
  src/input/CustomTransformation.cxx
 
  src/input/CustomTransformation.cxx
  src/input/SpaceTravellerModule.cxx
+
  '''src/input/MyTutorialModule.cxx'''                      <----- Here !!!
  src/input/MyTutorialModule.cxx                       <----- Here !!!
+
  '''src/input/MyTutorialSink.cxx'''                        <----- Here !!!
 
  src/tool/OT_ACE_Log.cxx
 
  src/tool/OT_ACE_Log.cxx
 
  src/input/QuatToMatrix.cxx
 
  src/input/QuatToMatrix.cxx
Line 39: Line 47:
 
This registration enables the NaviTrack to recognize names of modules described in a XML configuration file.
 
This registration enables the NaviTrack to recognize names of modules described in a XML configuration file.
  
In addSPLModules() function in src/misc/SPLModules.cxx (starts from L.50):
+
To register your own module, you need to add just two lines into src/misc/SPLModules.cxx.
add your own module using OT_REGISTER_MODULE() macro as:
+
 
 +
===Include the header file===
 +
 
 +
At the including section in src/misc/SPLModules.cxx:
 +
 
 +
#include <OpenTracker/OpenTracker.h>
 +
#include <OpenTracker/misc/SPLCommonNodeFactory.h>
 +
#include <OpenTracker/core/Configurator.h>
 +
#include <OpenTracker/input/EndoScoutModule.h>
 +
 +
  ...
 +
 +
#include <OpenTracker/input/MyTutorialModule.h>              <--- Here !!!
 +
 
 +
===Call OT_REGISTER_MODULE() macro===
 +
Add your own module using OT_REGISTER_MODULE() macro in addSPLModules() function (L.50-):
  
 
   OPENTRACKER_API int addSPLModules()
 
   OPENTRACKER_API int addSPLModules()
Line 55: Line 78:
 
     ....
 
     ....
  
=Step 4: Configure and build it!=
+
=Step 4: Cmake and build it!=
 +
 
 +
Now you are ready to generate new Makefile and build your NaviTrack.
 +
 
 +
Run CMake to apply your change in CMakeLists.txt to Makefile and start building.
 +
 
 +
 
 +
=Step Extra: Add MyTutorialThread module=
 +
 
 +
You can add the thread module "MyTutorialThreadModule" to your
 +
NaviTrack in the same way as "MyTutorialModule".
 +
 
 +
 
 +
Go back to [[NaviTrack_Tutorial:Creating_module|Creating module]]

Latest revision as of 13:58, 18 May 2007

Home < NaviTrack Tutorial:Creating module:Adding module

In this page, we will add "MyTutorialModule" to your NaviTrack.

Step 0: Get the sample source codes

You can download from File:NTTutorial May2007.zip.

To extract files in UNIX,

% unzip NTTutorial_May2007.zip

Step 1: Deploy your source codes

Put your *.cxx files into "src/input/", and *.h into "include/OpenTracker/input".

In UNIX:

% cd NTTutorial_May2007
% cp *.cxx <your NaviTrack directory>/src/input/
% cp *.h   <your NaviTrack directory>/include/OpenTracker/input/

Step 2: Configure Cmake

Configure your "CMakeLists.txt" at the root of your NaviTrack source tree, so that NaviTrack is compiled with your own module.

In SET(BASESRCS ...) section in CMakeLists.txt (starts from L.126), add paths to your *.cxx files as:

SET(BASESRCS
src/core/Event.cxx
src/core/EventAttributeBase.cxx
src/core/Translator.cxx

...

src/input/CustomTransformation.cxx
src/input/MyTutorialModule.cxx                       <----- Here !!!
src/input/MyTutorialSink.cxx                         <----- Here !!!
src/tool/OT_ACE_Log.cxx
src/input/QuatToMatrix.cxx
src/types/Image.cxx
)

Step 3: Register your module in SPLModule

SPLModule is a special module to register all NaviTrack modules, whenever the NaviTracker is started. This registration enables the NaviTrack to recognize names of modules described in a XML configuration file.

To register your own module, you need to add just two lines into src/misc/SPLModules.cxx.

Include the header file

At the including section in src/misc/SPLModules.cxx:

#include <OpenTracker/OpenTracker.h>
#include <OpenTracker/misc/SPLCommonNodeFactory.h>
#include <OpenTracker/core/Configurator.h>
#include <OpenTracker/input/EndoScoutModule.h>

 ...

#include <OpenTracker/input/MyTutorialModule.h>              <--- Here !!!

Call OT_REGISTER_MODULE() macro

Add your own module using OT_REGISTER_MODULE() macro in addSPLModules() function (L.50-):

 OPENTRACKER_API int addSPLModules()
 {
 
   OT_REGISTER_MODULE(NaviTrack, NULL);
   
   OT_REGISTER_MODULE(SpaceTravellerModule, NULL);
   
   OT_REGISTER_MODULE(NDIModule, NULL);
   
   OT_REGISTER_MODULE(MyTutorialModule, NULL);                      <---   Here !!!
   
   ....

Step 4: Cmake and build it!

Now you are ready to generate new Makefile and build your NaviTrack.

Run CMake to apply your change in CMakeLists.txt to Makefile and start building.


Step Extra: Add MyTutorialThread module

You can add the thread module "MyTutorialThreadModule" to your NaviTrack in the same way as "MyTutorialModule".


Go back to Creating module