Discussion and Support for the OptiTrack, SmartNav and TrackIR brands by NaturalPoint

Tracking tools - Matlab and Labview

by litch09 » Sun Jan 24, 2010 3:58 pm

I have also posted the Matlab demo on Mathworks file exchange - ... ange/26449?
Posts: 32
Joined: Tue Mar 10, 2009 6:28 pm

by smith32 » Mon Mar 29, 2010 2:30 pm

Hi guys,

I'm also trying to use the TrackingTools through MATLAB, except in my case I'm trying to implement it in a Simlink C coded MEX function.

I was able to run the code posted by litch09 (thanks a lot) without any issue. However, when I compile my S-Function code (that works without any TrackingTools calls) I get a LNK2019: unresolved external sympbol error pointing to any TT_ function I tried to call. When I call the compiler (mex mySFunction.c NPTrackingTools.lib) I include the NPTrackingTools.lib file but I still get the errors. Right now I've got all the files located in the same directory, but I tried referencing them their initial location and I get the same result. I've also tried compiling using the Real-Time Workshop but I get the same linking error.

I'd appreciate any insight or suggestions anyone can provide, thanks a lot.
Posts: 11
Joined: Wed Mar 24, 2010 2:13 pm

by smith32 » Mon Mar 29, 2010 3:43 pm

Quick update, I searched around and realized that I could just rename and compile my C coded S-Function as C++. As soon as I did this, all the errors went away. Hopefully this will help out others if they're looking to do something similar.

I plan on developing a TrackingTools Simulink block and some NatNet streaming blocks, when it's finished I'll post a link to the files for others to use.

Posts: 11
Joined: Wed Mar 24, 2010 2:13 pm

by Drorm » Thu Jun 24, 2010 1:10 am


I'm trying to use the VI program ( for capturing data about the rigid body but it said that �No cameras have been found to be connected� although I see the rigid body in the tracking tools program.

Posts: 1
Joined: Thu Jun 24, 2010 12:58 am

by chrisjordan22 » Thu Jun 24, 2010 8:52 am


I'm looking to create a Simulink S-Function TrackingTools block and was wondering if you made any progress.


Posts: 1
Joined: Tue Jun 22, 2010 1:36 pm

by litch09 » Wed Jun 30, 2010 7:54 pm

Hi Drorm,

I'd need to know what you've done in more detail. It is necessary to have setup your project in Tracking Tools first (with hardware key). Then close down the Tracking Tools program and open the Labview VI ( When you run the VI, it should work automatically, if it worked in Tracking Tools and the position and orientation data should display in 'real-time'.

Posts: 32
Joined: Tue Mar 10, 2009 6:28 pm

by litch09 » Wed Jun 30, 2010 7:58 pm

I should also note, that it is probably best to rebuild the NPTrackingTools VI library from the DLL (see comments on how to import shared library in previous posts) for each new version of the Tracking Tools software that is released.
Posts: 32
Joined: Tue Mar 10, 2009 6:28 pm

by c.s.chapman » Fri May 27, 2011 5:26 pm


Has anyone tried the Tracking Tools API to Matlab interface with a newer version of Matlab and Tracking tools? I am running Matlab 7.10.0 (R2010a) and Tracking Tools 2.3.2. The load library seems to function OK (typical warnings and functions not found), but I seem get no respone from my Optitrak system. That is, when I run:

>> calllib('NPTrackingTools', 'TT_Initialize');

Nothing happens and a 0 is returned. I'm assuming this is not what is supposed to happen.

When I run:

>> calllib('NPTrackingTools', 'TT_LoadProject', project_file);

It returns a value of 3. What do these return values mean, and where can we learn more about them?

In any case, all of my functions don't do much of anything. However, it does seem to be able to count the cameras. That is, running:

>> calllib('NPTrackingTools', 'TT_CameraCount')

Correctly identifies the number of cameras that are currently attached. Similarly, if I unplug a camera, run "update" and then count the cameras again, it correctly identifies that I have one less.

In any case, I am looking for any way to get the Optitrak data into Matlab in realtime. Any suggestions?

Posts: 4
Joined: Wed May 25, 2011 3:10 pm

by heath789 » Wed Aug 10, 2011 7:45 am

I am also attempting to use the demo code posted by litch09 (Thanks!) but can't get things to work entirely.

The library seems to load okay, and the TT program stops accepting commands directly, but the calllib functions do not seem to work.

Am I supposed to have TT running when I run the demo code?


Posts: 41
Joined: Wed Aug 10, 2011 7:42 am

by NaturalPoint - Mike » Thu Aug 11, 2011 10:54 am

If you're using the Tracking Tools API, Tracking Tools should not be running at the time. What version of Tracking Tools are you using? Are you compiling against the header files and binaries included with that version? What IDE are you using?
NaturalPoint - Mike
Posts: 1896
Joined: Tue Feb 01, 2011 8:41 am
Location: Corvallis, OR


Return to Tracking Tools