OSVR-Unity icon indicating copy to clipboard operation
OSVR-Unity copied to clipboard

Tracking with dtrack/vrpn in Unity

Open HendrikLober opened this issue 8 years ago • 11 comments

Hey there folks! I want to read data from an infrared tracker in Unity. For this I have the option to use the dtrack- and the vrpn protokol.

The vrpn.net project does not work, because the dll is build for .NET 4.0, whereas Unity requires 3.5. Building the c++ vrpn project as dll yields a library, which I can't even open in the dependency walker.

So my question is: Can I connect to Hardware via the dtrack or vrpn protocol by using OSVR in Unity? Does it have a native implementation for this?

Thank you for your time.

HendrikLober avatar Apr 06 '16 12:04 HendrikLober

OSVR uses VRPN natively. It also has the ability to use external VRPN servers as data sources. See https://osvr.github.io/whitepapers/vrpn_in_osvr/ for more info on using an external device and https://www.youtube.com/watch?v=TtLn6XpEisw for using OSVR with Unity.

russell-taylor avatar Apr 06 '16 13:04 russell-taylor

I'm guessing by the fact that you opened an issue on VRPN that this didn't solve your problem.

There is a small example of a sample config file using ART DTrack, via a separately-running VRPN server , located here: https://github.com/OSVR/OSVR-Core/blob/master/apps/external-devices/osvr_server_config.externalvrpn.ART_DTrack_Flystick.json Don't be put off by the mention of the flystick - you can access just the tracker if desired, the goal of that config was to show how you'd set up the flystick if you happened to have one of them too. The /me/head section shows how you'd be able to apply a transform in the config if required (if the coordinate system for the head tracker didn't match that required for OSVR's display system), but it could be simplified to:

"/me/head": "/DTrackDevice/tracker/0",

and so on, so you can give names like this to the various tracked objects from DTrack and access them through OSVR pose interfaces in Unity. You then just run a VRPN server in the background, on port 3884, with the vrpn.cfg file edited to uncomment the DTrack driver, as well as running the OSVR server.

Does that help?

rpavlik avatar Apr 07 '16 22:04 rpavlik

Thank you both for your quick reply! I opened the Tickets here and on the VRPN-Project simultaneously. I have no experience of how fast one would receive an Answer on these Tickets. And I'm still flabbergasted!

I will try out OSVR in the following three days and see if it works in my situation. I also found a VRPNNet.dll for .NET 3.5, which should be accepted by Unity. Both Visual Studio and Mono Develop build the project fine, but the Unity compiler has a final say and claims to not know the file/namespace, as well as removing it from the references in the IDEs. Shuffling the File position and settings around, using it as plugin etc. did not resolve it.

Unity seems to have some Beef with DLLs, I will see if OSVR can settle this dispute. Thanks again for your quick help!

HendrikLober avatar Apr 08 '16 10:04 HendrikLober

No problem. Sensics maintains both OSVR and VRPN, so in practice I'd probably respond to the ticket in either place :-P I'd think you should be able to downgrade the VRPNNet project to .NET 3.5, but the OSVR plugin for Unity is a lot more featureful and well integrated (the equivalent to VRPN.Net is Managed-OSVR - the Unity plugin is a layer of integration on top of that dealing with the joys of left-handed coordinate systems, different units, etc. as well as game object integration) and probably the easier route.

rpavlik avatar Apr 08 '16 14:04 rpavlik

So I've tried the following things with OSVR now without any positive results:

  • I downloaded the OSVR-Unity-master and opened the project folder in Unity5.3 and Unity4.6
  • Both versions say "namespace ClientKit is not existing. Are you missing an assembly reference?"
  • There is a ClientKit.cs script however it's namespace hierarchy is OSVR->Unity->class ClientKit, but it is always referenced as OSVR.ClientKit
  • When correcting this it is still missing a OSVR.[Unity.]ClientKit.ClientContext
  • The OSVR-Unity-master I downloaded, by just clicking the "Download .ZIP" button on the OSVR-Unity github page does not contain any *.unitypackage, like the documentation states and no .DLLs. Using the .CMD scripts in the folder has also not added any files.
  • Since I've not installed OSVR yet, I downloaded the OSVR-Core-master and tried building it with CMake3.2.3 yielding the error: " Could not find a package configuration file provided by "libfunctionality" with any of the following names: libfunctionalityConfig.cmake, libfunctionality-config.cmake"
  • I have not tried using the OSVR-winInstaller yet, that will be the next step.

Also the Documentation states, that I need to be running an OSVR-Server if I expect any functionality. Now, the Infrared trackers I want to use are configured with a program called "Personal Space Tracker (PST)", which already acts as a VRPN-Server sending data like [devicename]@localhost. Does the OSVR-Server have a different functionality? Do two VRPN-Servers conflict with each other? I would be willing to sacrifice the PST object configuration data just to get things working.

HendrikLober avatar Apr 11 '16 09:04 HendrikLober

So the OSVR Unity requires a compiled version of OSVR-Core and Managed-OSVR. the recommended way of using it is just by getting a prebuilt .unitypackage - see this page: http://osvr.github.io/build-with/#building-an-app-with-unity

The PST server will conflict with the OSVR server, which right now uses the VRPN port - if you can configure the PST server to run on a non-default port, then you point OSVR at the PST server.

rpavlik avatar Apr 11 '16 14:04 rpavlik

Hey there!

I have the Problem that I send the data from DTrack over the VRPN Server to the OSVR Server but there is nothing to see in the Tracking Viewer.

The Servers are set up correctly. I'm using the Flystick sample-data from DTrack as the Output.

In the end I want to import it into Unreal Engine 4.13 which should not be hard to do because of the plugin.

Why does my OSVR does not get the data from the VRPN Server? Does it interpret the data the wrong way?

Thanks for your help!

scYllA913 avatar Oct 11 '16 12:10 scYllA913

@scYllA913 I think you need to specify which paths you are looking for via command line args when launching TrackerViewer. By default, TrackerViewer looks for /me/head, /me/hands/left, and /me/hands/left. If you have data coming in on other paths, you won't see it in TrackerViewer by default. See: https://github.com/OSVR/OSVR-Tracker-Viewer

DuFF14 avatar Oct 11 '16 15:10 DuFF14

Since I'm currently working on something like the same thing. Did you bring it to work @HendrikLober ? I'm currently searching for a way to replace the tracking data of the HDK with the DTrack data.

sroettgermann avatar Apr 21 '17 13:04 sroettgermann

No, I gave it up after several weeks of trying. I would've needed it for my bachelors degree back then, but I chose a different topic. Also I can't recall the things I tried, so I wont be able to help you much. But best of luck!

HendrikLober avatar Apr 21 '17 19:04 HendrikLober

Hm... okay @HendrikLober, thanks anyway. Maybe someone else can help me with this.

sroettgermann avatar Apr 24 '17 07:04 sroettgermann