Code covered by the BSD License  

Highlights from
Tracking Tools (Optitrack)

4.66667

4.7 | 3 ratings Rate this file 25 Downloads (last 30 days) File Size: 2.43 KB File ID: #26449

Tracking Tools (Optitrack)

by

 

Demo on how to use the Tracking Tools API from Matlab to interface with Optitrack cameras.

| Watch this File

File Information
Description

% TT_Tools_demo(project_file)
%
% This function demonstrates basic functionality of the Tracking Tools API
% from Natural Point (to be used with Optitrack). Before use it is
% essential to have calibrated cameras and created the desirable
% trackable/s and save these in a project file. The project file is then
% passed to the function and the library loaded if need be before
% attempting to plot any data
%
% Input - project_file - a string containing path and filename for the
% project file that is to be used (default value assigned if
% not assigned)
%
% Written by Glen Lichtwark, University of Queensland, Australia
% Last updated: 22nd Jan 2010
% Please acknowledge in any academic papers which may utilise this code

Acknowledgements

This file inspired Nat Net (Motive/Arena) Simple Sample For Location Data By Or Hirshfeld and Trackable Location (Mocap) From Optitrack Tracking Tools To Simulink By Or Hirshfeld In Technion.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
22 Oct 2014 Akhil Jain

Hi Glen. I was trying to use your code with MATLAB 7.11.1 and TT 2.5.3 32 bit. Whenever I run this code on MATLAB my cameras get automatically switched off and get an output of ans = 0. Can you please help me out with this ? Thank you.

06 Oct 2014 Or Hirshfeld

Great code
It's Helped me a lot

Now I want to move to newer versions
so I wish to create interface between Simulink to Motive I already succeed to interface between Matlab and Motive through NatNet, I reviewed the sample available with NatNet SDK to do so but I'm having trouble to migrate it to Simulink, I tried using Matlab function block unsuccessfully, it's have problem to use the dll command.

the error i got from Simulink is : Undefined function or variable 'NatNetML.NatNetClientML'.

I want to thanks Glen Lichtwark sample that helped me writing interface to matlab http://www.mathworks.com/matlabcentral/fileexchange/26449-tracking-tools--optitrack-

the code i tried is the follwing:

function [x,y,z,yaw,pitch,roll] = Location_Orinteation_Motive_64bit(RigidBody_ID) %#codegen
coder.extrinsic('–sync:on','quaternion','fullfile','NET.addAssembly','addpath')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
addpath('E:\Motive')
dllPath = fullfile('c:','NatNetSDK2.5','lib','x64','NatNetML.dll');
assemblyInfo = NET.addAssembly(dllPath);
theClient = NatNetML.NatNetClientML(0); % Input = iConnectionType: 0 = Multicast, 1 = Unicast
% Connect to an OptiTrack server (e.g. Motive)
HostIP = char('127.0.0.1');
theClient.Initialize(HostIP, HostIP); % Flg = returnCode: 0 = Success
% data
frameOfData = theClient.GetLastFrameOfData()
rigidBodyData = frameOfData.RigidBodies(RigidBody_ID)
x=rigidBodyData.x
y=rigidBodyData.y
z=rigidBodyData.y
% angle
q = quaternion( rigidBodyData.qx, rigidBodyData.qy, rigidBodyData.qz, rigidBodyData.qw ); % extrnal file quaternion.m
qRot = quaternion( 0, 0, 0, 1); % rotate pitch 180 to avoid 180/-180 flip for nicer graphing
q = mtimes(q, qRot);
angles = EulerAngles(q,'zyx');
yaw = angles(2) * 180.0 / pi;
pitch = -angles(1) * 180.0 / pi; % must invert due to 180 flip above
roll = -angles(3) * 180.0 / pi; % must invert due to 180 flip above

thanks
Or Hirshfeld

http://il.linkedin.com/pub/or-hirshfeld/4b/79/577/

14 Jul 2014 avi

I'm getting:
Caught unexpected "char*" Exception message is:
Index out of range

what should i do about it? i tried every thing

11 Apr 2013 Glen Lichtwark

Jose9, are you using a 32-bit or 64-bit version of Matlab? The 64-bit version will not work, however perhaps if you install the new version of Motive with your Tracking Tools license, then this may work. I will test this in the coming months.

23 Nov 2012 jose9

Hi Glen, I'm interested in your work, i have just purchased TT 2.5.0, and i used your matlab code with any succeed, and do you have any idea about the solution of this.

Thank very much

26 Oct 2012 Glen Lichtwark

For anyone who is interested, I have recently tried running previously posted Matlab code on the latest 64-bit version of TT (2.5.0) with a 64-bit version of Matlab and haven't succeeded. It seems that 'loadlibrary' throws an error that I can't pinpoint the source of. I will look into this further for a solution....

16 Nov 2010 Etienne

Easy to use, clear and work fine, many thanks Glen!

Contact us