VRPN streaming multiple trackables

NatNet, VRPN, TrackD, and Plugins
Post Reply
Posts: 1
Joined: Fri Aug 19, 2011 9:15 am

VRPN streaming multiple trackables

Post by lrozo » Fri Aug 19, 2011 9:57 am

Hi everyone,

I'm using the VRPN to read data from a Optitrack system, of course, using the tracking tools application. I can read data from one trackable, as shown in the example provided by NatNet (http://www.naturalpoint.com/optitrack/d ... tools.html).
My question is related to that I need to read data from more than one trackable (two, three, or more rigid bodies defined in the Tracking Tools). So, of course, the simplest way to achieve this is hardcode the same pieces of code (a callback function mainly). But this is not portable and "shareable"...I have this problem, because I want to use a class containing all the VRPN stuff, so the user only would need to define the number of trackables, and the class should do all the stuff...but the problem here is that I can not do this because I have to hardcode the callback function. My idea would be to have an array of instance of the mentioned class, but the other issue here is that the callback is a global function, so it is the same function for all the instances of the class.

Any ideas ?? Do you know if it is solved by anyone else ?



NaturalPoint Employee
NaturalPoint Employee
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: VRPN streaming multiple trackables

Post by beckdo » Tue Aug 23, 2011 11:35 am

VRPN has a really nice setup for the callbacks and multiple tracked objects.

When you register the callback via register_change_handler, you have a couple options. 1. You can register a different callback for each tracked object. 2. The first parameter in the register_change_handler function is called 'user data', and you can put anything you want in there and it will be passed to the callback function. You could simply put an integer in there, perhaps the index of what tracked object? If you wanted to store a bunch of information you could pass the pointer of an info structure with all kinds of info in it. It's up to you.

Post Reply