Streaming from TrackingTools to c++ program (Linux)

NatNet, VRPN, TrackD, and Plugins
Post Reply
Kenneth
Posts: 1
Joined: Fri Jan 24, 2014 6:15 am

Streaming from TrackingTools to c++ program (Linux)

Post by Kenneth »

Hi.

I´m sorry if this question is answered in another post, but I would appreciate some input or help to get started with my application.

Short version:
How can I stream positions (x,y,z) and orientation (roll, pitch, yaw) from a Windows computer running TrackingTools, possibly with NatNet running in Visual Studio, to my c++ program running on a Linux (Ubuntu 12.04 64bit) computer? The c++ program is used to autonomously control a quadcopter (AR. Drone), and I want to use (at least) the position measurements from the camera setup as inputs to my position and velocity controller in a lab.

Details:
I have an application for the quadcopter AR. Drone that uses onboard sensors to compute the position of the drone (dead reckoning). This works ok for short term operations, but I want to create an integrated navigation system that updates the position estimates with measurements from OptiTrack (TrackingTools). This software can be run from a remote Windows computer, and will as far as I can tell be the server for the streaming protocol. From [1] it seems NatNet is the best option, as VRPN cannot stream markers(?).

From the NatNet documentation[2], I read that a “direct depacketization client” is the best fit for Unix/Linux clients that cannot run the NatNet API. I am not familiar with direct depacketization, but I guess it is something like c++ code written to receive a data stream from a given port with UDP/TCP.

So, I kind of have several questions. Most important is if what I suggested will work or not, and if anyone has some code example for the Linux client (and possibly the NatNet Windows server). I read that one can adapt the PacketClient.cpp file to my application. Does this mean I can/should write the client code (PacketClient.cpp) within my existing .cpp program, or as a separate program run in a second terminal when the quadcopter is in the air? Can I compile PacketClient.cpp using c++ from my Linux terminal? Ultimately, I want to access positions (x,y,z) from the cameras as variables within my .cpp application in real time.

Thanks a lot for any replies.

[1] http://wiki.optitrack.com/index.php?tit ... _Streaming
[2] http://www.naturalpoint.com/optitrack/s ... 0Guide.pdf
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Streaming from TrackingTools to c++ program (Linux)

Post by morgan »

Yes - if you need marker data you can integrate the PacketClient.cpp code directly into your Linux CPP code.

The PacketClient.cpp sample uses winsock so you'll want to replace with unix sockets:

replace

#include <winsock2.h>
#include <ws2tcpip.h>

with:

#include <sys/socket.h>

Our use of winsock is limited to the BSD compatible routines, so you should be fine.

You can remove the WASStartup/WSACleanup as this is not required on unix.

hope this helps,

Morgan
Post Reply