Motive to Matlab streaming

NatNet, VRPN, TrackD, and Plugins
Post Reply
MSierra
Posts: 3
Joined: Sun Oct 30, 2016 12:03 am

Motive to Matlab streaming

Post by MSierra »

Hi,

I'm working on a project and I intend to make use of Optitrack and stream the data to Matlab in order to generate some plots for analysis. I found on the Optitrack website about NatNet SDK and proceeded to download and test it out.

I followed the general streaming instructions and chose 'Loopback' since I intend to stream from Motive to Matlab on the same computer. I then checked the 'Broadcast Fame Data' option and ran the sample client provided in Natnet.

1. An error in Matlab states that the variable 'theClient' is undefined. Should I rename it to something else?

2. After that happened I checked Motive and found that the 'NET' button on the bottom right is yellow which means no client is detected.

I then concluded that these 2 software are not connected yet, thus the errors.

How do I correct this?
Are there extra steps that I needed to take to connect them?

I will say here that coding is not my forte so any help or extra info is greatly appreciated.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Motive to Matlab streaming

Post by morgan »

Thanks for your post. Regarding the client issue:

1. An error in Matlab states that the variable 'theClient' is undefined. Should I rename it to something else?

This likely indicates the Matlab script did not load the NatNet DLL successfully. You will want to edit your NatNetMatLabSample.m file as shown below to make sure it points to the location of the NatNetML.dll / NatNet.dll (usually <NatNet insall folder>\lib\x64 :

Code: Select all

        % Add NatNet .NET assembly so that Matlab can access its methods, delegates, etc.
        % Note : The NatNetML.DLL assembly depends on NatNet.dll, so make sure they
        % are both in the same folder and/or path if you move them.
        display('[NatNet] Creating Client.')
		curDir = pwd;
		mainDir = fileparts(fileparts(curDir));
		dllPath = fullfile(mainDir,'lib','x64','NatNetML.dll');
        assemblyInfo = NET.addAssembly(dllPath);
Hope this helps,

Morgan
MSierra
Posts: 3
Joined: Sun Oct 30, 2016 12:03 am

Re: Motive to Matlab streaming

Post by MSierra »

Hi Morgan,

Thanks for your reply.

I've went to check out the codes for the NatNet sample again to see if the changes you recommended were needed. It turns out that no changes were needed to the codes.

I then repeated the steps with the settings shown here and the error below came up.

Settings (in Optitrack data streaming pane):
Broadcast Frame Data: Checked
Local Interface: Local Loopback
Stream Markers: True
Stream Rigid Bodies: True
Remote Trigger: False
Type: Unicast (I've changed the code in Matlab accordingly to reflect Unicast usage)
Command Port:1510
Data Port: 1511
Multicast Interface: 239.255.42.99
VPRN and Trackd Streaming engine boxes left unchecked.

Error in MatLab:

Code: Select all

NatNetMatlabSample
NatNet Sample Begin
[NatNet] Creating Client
err = 

NetException with properties:
 
ExceptionObject: [1x1 System.IOFileNotFoundException]
identifier: 'MATLAB:NET:CLRException:AddAssembly'
message: 'Message: Could not load file or assembly 'file:///C:\User...'
cause: {}
stack: [1x1 struct]

Undefined funciton or variable 'theClient'.
Error in NatNetMatlabSample (line 118)
theClient.Uninitialize();
So overall this was what I intended to portray in my first post. I haven't been able to figure out how to correct this. I hope you can help. Thank you.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Motive to Matlab streaming

Post by morgan »

This error:

identifier: 'MATLAB:NET:CLRException:AddAssembly'
message: 'Message: Could not load file or assembly 'file:///C:\User...'

Indicates MATLAB was unable to load the NatNet assembly (NatNetML.dll). The error message does not show the full path. Can you confirm the path to the NatNet assembly is correct? Also - sometimes paths can get too long for MATLAB, in which case try moving the NatNet location to a shorter path, and updating the Matlab dll Path to point to it?

Morgan
MSierra
Posts: 3
Joined: Sun Oct 30, 2016 12:03 am

Re: Motive to Matlab streaming

Post by MSierra »

Hi Morgan,

Is what you said akin to putting Natnet folder in Matlab folder? If it is, I've already done that but I encountered a similar error.

If it's not, I hope you can maybe show me how to move or update the paths as you've described.

Thank you.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Motive to Matlab streaming

Post by morgan »

It is not necessary to put the NatNet folder into the Matlab folder.

Just make sure the path to your NatNet folder matches the MatLab example code.

It would be helpful to see the complete path in this error message you reported:

message: 'Message: Could not load file or assembly 'file:///C:\User...'
Post Reply