Streaming Question

NatNet, VRPN, TrackD, and Plugins
bmoyerbmoyer
Posts: 9
Joined: Wed Jan 30, 2008 4:09 pm
Location: Pennsylvania

Streaming Question

Post by bmoyerbmoyer »

I would like to use LabVIEW to retreive the stream coming from the Rigid Body Toolkit. According your documentation, I should configure a UDP multicast client using port 1510 and group 1001. The LabVIEW function for such a client asks for the network address, which I assume can be 127.0.0.1. It also askes for the port for the UDP socket which I assume is the same as 1510. Finally, it asks for a multicast address (the IP address of the multicast group) - which must be in the range of 224.0.0.0 to 239.255.255.255. It seems as if your group 1001 and that IP address must be linked but I do not know how. Any suggestions?
Brian
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Streaming Question

Post by beckdo »

Hey Brian,

I don't believe LabView would understand what to do with the data if it was able to connect directly to the Rigid Body Tool. I haven't personally used LabView but I have a feeling there will need to either be an intermediary between the two or additional code to parse the data somehow in LabView.
bmoyerbmoyer
Posts: 9
Joined: Wed Jan 30, 2008 4:09 pm
Location: Pennsylvania

Re: Streaming Question

Post by bmoyerbmoyer »

Thanks Doug,
I expected to have to parse the data in LabVIEW so that isn't a big surprise - the hardest part for me is getting it there. Any advice?
Brian
bmoyerbmoyer
Posts: 9
Joined: Wed Jan 30, 2008 4:09 pm
Location: Pennsylvania

Re: Streaming Question

Post by bmoyerbmoyer »

Hey Doug,
Any other advice on this topic - how do I set the multicast address given the group number of 1001?
Brian
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Streaming Question

Post by beckdo »

Hey Brian,

I apologize for the slow response. Several from our team were down at SIGGRAPH last week, including myself. I will follow-up on this for you.

D
krisny
Posts: 2
Joined: Fri Nov 07, 2008 8:14 am

Re: Streaming Question

Post by krisny »

Hi.

Any response to this yet?
I am aslo trying to use natnet for streaming, but I can not figure out how to set the multicast address to group 1001.

Kristian
bgamp
Posts: 4
Joined: Sat Nov 08, 2008 6:43 pm

Re: Streaming Question

Post by bgamp »

Me three. I need to get the rigid body information into matlab, but the udp interface command does not support multicast.... Reading through all the documentation, it seems strange there is no way to output through normal udp.

I have looked into other methods, like writing a java program to act as an interface - but I would prefer it if I could run more "cleanly" by using the inherent udp command in matlab.

Help?

B
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Streaming Question

Post by beckdo »

Morgan should be chiming in shortly. He's our NatNet expert and should be able to provide you with some info.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Streaming Question

Post by morgan »

Hi folks,

I think the question is how do i connect to a NatNet stream directly, without using the NatNet SDK, so I'll try to answer that.

NatNet data is delivered in UDP packets using IP Multicast. The multicast address (or group) is 244.0.0.1.

To connect to the NatNet server app (e.g. TrackingTools), you'll need to specify:
- the server's address
- the client's address
- the multicast address ("group")

Below is a simple example of client connection to a NatNet stream natively. This code is a WinSock implementation in C, but should be easily portable to other environs (such as LabView or MatLab):

Code: Select all


    in_addr MyAddress, ServerAddress, MultiCastAddress;
    MultiCastAddress.S_un.S_addr = inet_addr("224.0.0.1");
   
    // create socket
    SOCKET MySocket = socket(AF_INET, SOCK_DGRAM, 0);
    struct sockaddr_in MySocketAddr;
    memset(&MySocketAddr, 0, sizeof(MySocketAddr));
    MySocketAddr.sin_family = AF_INET;
    MySocketAddr.sin_port = htons(1001);
    MySocketAddr.sin_addr = MyAddress; 
    if (bind(MySocket, (struct sockaddr *)&MySocketAddr, sizeof(struct sockaddr)) == SOCKET_ERROR)
    {
	printf("[PacketClient] WSAStartup failed (error: %d)\n", WSAGetLastError());
        WSACleanup();
        return 0;
    }

    // join multicast group
    struct ip_mreq Mreq;
    Mreq.imr_multiaddr = MultiCastAddress;
    Mreq.imr_interface = MyAddress;
    retval = setsockopt(MySocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&Mreq, sizeof(Mreq));
    if (retval == SOCKET_ERROR)
    {
        printf("[PacketClient] WSAStartup failed (error: %d)\n", WSAGetLastError());
        WSACleanup();
        return -1;
    }

   // listen for data
    char  szData[20000];
    int addr_len = sizeof(struct sockaddr);
    sockaddr_in TheirAddress;
    while (1)
    {
        int nDataBytesReceived = recvfrom(
            MySocket,
            szData,
            sizeof(szData),
            0,
            (sockaddr *)&TheirAddress,
            &addr_len);

        Unpack(szData);
    }



Note that using the NatNet SDK is the recommended mechanism, as it insulates your client app from changes in the bistream syntax.

If you would like a complete example in C, please email support and we can get one out to you.

Alternatively, if anyone is interested in writing a .NET or ActiveX control wrapper for the NatNet SDK for use in component aware clients, let us know.

Hope this helps,

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

Re: Streaming Question

Post by morgan »

This is trickier.

The Tracking tools can stream using VRPN or NatNet. VRPN uses TCP/IP for connection, and UDP packets for data transfer. This would be easier to connect to directly from MatLab, but decoding VRPN packets is very complicated.

The ideal solution would be either a .Net Assembly or an ActiveX control wrapper that both LabView and MatLab clients (as well as any compnent aware client) could use.

If this approach would work for you let us know and we can try to bump the priority.

Morgan
Post Reply