File Exchange

image thumbnail

NatNet (Motive/Arena) simple sample for location data by Or Hirshfeld

version (21.7 KB) by Or Hirshfeld
a Simple Sample to transfer Mocap data from Motive/Arena to Matlab using NatNet stream


Updated 27 Oct 2014

View License

It took me time to understand the sample including in NateNet SDK and the only thing i required from it is to get current data. so after many hours of trails and errors I wish to help fellow programmer that would need to handle this task.
please acknowledge me if you use this code

Cite As

Or Hirshfeld (2020). NatNet (Motive/Arena) simple sample for location data by Or Hirshfeld (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

When I try to obtain data from the OptiTrack system to MATLAB I end up with empty data packs, although when I use different samples I am able to receive data.
Using this, I am getting the error of Struct contents reference from a non-struct array object, when using the quaternion, how to solve this issue?

KIDUS guys

Hey, I am very new to Motive, Natnet. Is there anyone that can explain to me about Natnet and how to use it may be show me the step to follow.

Bao Kang Hee

Same as you, I would require current data from motive. However, I need the location of a rigid body (x,y and z) and I have modified the code but it seem to be wrong somewhere.

rigidBodyData = frameOfData.RigidBodies(1);
xVals = rigidBodyData.x;

The above line returns me an error "Struct contents reference from a non-struct array object."

Anybody can help me on this?

Or Hirshfeld

Hi Tony
I'm glad to hear you are trying my work
try to check how the streaming is set in Motive/Arena on the server computer
first check that it active.
it's also should indicate which ip it use for broadcast.
maybe you have few net adapters, try to find the right ip that you use for connecting.

also try to test run it on the same computer while the streaming

Tony Pham

Hi Or Hirshfeld! I try to run your Matlab code on a client computer to connect to a server on which the Optitrack is running. I change the HostIP to the server's IP, but the return value of the function theClient.Initialize(HostIP, HostIP) is 3 which is not successful. So what is the possible reason? I used to use Visual C++, and it worked well. The matlab version I am using is R2013b. Thank you


updating toolbox

Added html of the code

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux