OSVR / OSVR-Unity

Package for authoring OSVR experiences with Unity.
Apache License 2.0
98 stars 38 forks source link

Tracking with dtrack/vrpn in Unity #152

Open HendrikLober opened 8 years ago

HendrikLober commented 8 years ago

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.

russell-taylor commented 8 years ago

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.

rpavlik commented 8 years ago

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?

HendrikLober commented 8 years ago

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!

rpavlik commented 8 years ago

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.

HendrikLober commented 8 years ago

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

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.

rpavlik commented 8 years ago

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.

scYllA913 commented 7 years ago

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!

DuFF14 commented 7 years ago

@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

sroettgermann commented 7 years ago

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.

HendrikLober commented 7 years ago

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!

sroettgermann commented 7 years ago

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