Page 1 of 2
Streaming Question
Posted: Fri Aug 08, 2008 3:46 pm
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
Re: Streaming Question
Posted: Fri Aug 08, 2008 4:23 pm
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.
Re: Streaming Question
Posted: Fri Aug 08, 2008 7:53 pm
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
Re: Streaming Question
Posted: Fri Aug 15, 2008 11:09 am
by bmoyerbmoyer
Hey Doug,
Any other advice on this topic - how do I set the multicast address given the group number of 1001?
Brian
Re: Streaming Question
Posted: Mon Aug 18, 2008 9:09 am
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
Re: Streaming Question
Posted: Fri Nov 07, 2008 9:09 am
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
Re: Streaming Question
Posted: Sat Nov 08, 2008 6:49 pm
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
Re: Streaming Question
Posted: Mon Nov 10, 2008 12:42 pm
by beckdo
Morgan should be chiming in shortly. He's our NatNet expert and should be able to provide you with some info.
Re: Streaming Question
Posted: Mon Nov 10, 2008 1:25 pm
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
Re: Streaming Question
Posted: Mon Nov 10, 2008 2:14 pm
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