NatNetML.dll - setting a callback in Matlab

NatNet, VRPN, TrackD, and Plugins
Post Reply
kundziad
Posts: 3
Joined: Sat Jan 26, 2013 2:47 pm

NatNetML.dll - setting a callback in Matlab

Post by kundziad »

Hello,

I am using NatNetML.dll to connect to Tracking Tools using MATLAB. The essential functions work, i.e. I can use m_NatNet.GetLastFrameOfData() to get the positions of markers and rigid bodies.

Unfortunately there is no way for me to learn when exactly a new frame is available. I tried to set up a callback in the following way:

Code: Select all

lh = addlistener(m_NatNet,'OnFrameReady',@frame_ready_callback)
when my callback function is the following:

Code: Select all

function [ ] = frame_ready_callback( src, evnt )
    disp('New frame ready.')
end
Unfortunately it doesn't work and the function is never called. Does anyone have any ideas what I might have done wrong?

Do I maybe need to specify my own event? I wouldn't think so, especially that I am not sure how this should be done. I was under the impression that adding a listener should be enough, but it doesn't do the trick.
kundziad
Posts: 3
Joined: Sat Jan 26, 2013 2:47 pm

Re: NatNetML.dll - setting a callback in Matlab

Post by kundziad »

Here is a relevant part of MATLAB documentation: Working with .NET Events in MATLAB.

Can someone from Natural Point confirm that the OnFrameReady event has the standard signature mentioned in the help page?
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: NatNetML.dll - setting a callback in Matlab

Post by morgan »

The NatNet Managed Library (NatNetML.dll) uses the following .NET compatible event signature, which has been tested correct in C#/VB.Net and other managed clients:

Code: Select all

 public delegate void FrameReadyEventHandler(FrameOfMocapData^ data, NatNetClientML^ client);
MatLab appears to require a specific event handler signature in order to consume .NET events, which we currently do not support.

We definitely would like to support MatLab however. I've gone ahead and added this event signature as a feature request - we'll try to get this into the next NatNet SDK release.

Morgan
Post Reply