Motive to Unity

NatNet, VRPN, TrackD, and Plugins
BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Motive to Unity

Post by BradleyNewman » Mon Nov 17, 2014 3:41 pm

I've extended some of the NatNet 2.7 SDK to enable streaming tracking data for multiple rigid bodies from Motive Body 1.7 Beta 2 into Unity. The NatNet 2.7 SDK includes a UnitySample application that by default only streams data for a single rigid body; this sample has been extended slightly to allow for streaming multiple rigid bodies. UnitySample.exe streams data from Motive to Unity over UDP as an XML stream. The UnitySample Unity project code has been extended substantially to streamline the process of streaming tracking data into Unity.

You can download "Motive To Unity" v1.0 from here: (with source code for UnitySample.exe and the Unity project and an included tutorial): https://drive.google.com/file/d/0B_5Y8u ... sp=sharing

Since our research lab is doing VR research we are particularly interested in the lowest latency possible, so if anyone has ideas for how to reduce latency over UDP I'd love to hear your ideas. In the future I'm planning to stream data via a native C++ DLL into Unity in the hope that latency is reduced further.

Best,
Bradley Newman
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

tsvilans
Posts: 3
Joined: Tue Nov 25, 2014 10:15 am
Location: London, UK
Contact:

Re: Motive to Unity

Post by tsvilans » Mon Dec 01, 2014 11:29 am

Hi,

I am also trying to get RigidBody + Marker motions into Unity, however I am directly unpacking the NatNet packet in Unity with C#. I've got it running, however I cannot get frame data from Motive correctly. When I send a model info request (message type 4), I am able to extract all the correct information. However, when I send a frame request (message type 6), Motive returns an 'unknown command' response (message type 100).

I've tried cycling through from 0 to 100 message types. The only ones that return anything are 0 (ping), 2 (generic request?) and 4 (model info request). Everything else returns 100.

I've taken a look at your code (which looks much more cleverly implemented than mine :) ), however your method is different and does not run into this problem. I'd like to avoid any 'middle-men', hence the unpacking directly in Unity, however I would love to get some advice / pointers about how to do this properly...
---
Tom Svilans
tomsvilans.com

NaturalPoint-Dustin
Posts: 612
Joined: Tue Mar 19, 2013 5:03 pm

Re: Motive to Unity

Post by NaturalPoint-Dustin » Mon Dec 01, 2014 4:41 pm

Hello,

I have a member of our dev team reviewing your question right now. We should have a response for you shortly.
Dustin
Technical Support Engineer
OptiTrack | TrackIR | SmartNav

tsvilans
Posts: 3
Joined: Tue Nov 25, 2014 10:15 am
Location: London, UK
Contact:

Re: Motive to Unity

Post by tsvilans » Tue Dec 02, 2014 2:35 am

Thanks, Dustin, really looking forward to it!
---
Tom Svilans
tomsvilans.com

NaturalPoint-Dustin
Posts: 612
Joined: Tue Mar 19, 2013 5:03 pm

Re: Motive to Unity

Post by NaturalPoint-Dustin » Tue Dec 02, 2014 2:55 pm

This is a slightly simplified approach but have you looked at the Unity sample within the NatNet samples directory? We recently added this sample. It gives you a very simple approach to communicate data into Unity in a simplified approach and does not require direct depacketization.

The primary up-side is that you can stream whatever information you want into Unity in whatever format you like...binary, XML, etc. and it's very simple. The primary down-side is that you'll have an EXE running in addition to Motive.

Please review this and let us know if it is a possible solution for you.

Best Regards,
Dustin
Technical Support Engineer
OptiTrack | TrackIR | SmartNav

niccoleo
Posts: 1
Joined: Mon Feb 09, 2015 9:36 am

Re: Motive to Unity

Post by niccoleo » Wed Feb 11, 2015 4:22 am

hi,
thanks for this project, very useful.
When I open the scene "sample" of the unity project on the same machine where there is Motive I can receive data, but when I try to stream to another machine I can't receive anything.
what is the order of the ip in UnitySample.exe?
In the tutorial I saw "UnitySample.exe 127.0.0.1 127.0.0.1".
which of the two is the server ip? the first? like this "UnitySample.exe SERVERIP CLIENTIP"?
thank you

NaturalPoint-Dustin
Posts: 612
Joined: Tue Mar 19, 2013 5:03 pm

Re: Motive to Unity

Post by NaturalPoint-Dustin » Thu Feb 12, 2015 4:45 pm

Hello,

I just opened the Unity Sample and confirmed that it is:

UnitySample [ServerIP] [LocalIP]

Best Regards,
Dustin
Technical Support Engineer
OptiTrack | TrackIR | SmartNav

BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Re: Motive to Unity

Post by BradleyNewman » Thu Mar 12, 2015 3:50 pm

Here's v2: https://drive.google.com/open?id=0B_5Y8 ... authuser=0
This is still streaming over UDP instead of a direct plugin.

Release Notes

Improvements:
Added ability to override a specific RB origin instead of using the origin assigned to OptitrackRigidBodyManager.

OptitrackRigidBody.cs
- Added ability to choose whether you want to use positional and/or rotational tracking.

Fixes:
- There was an issue where if you rotated the origin away from the World alignment it didn't correctly rotate all the rigid bodies. Now you can rotate the origin to some orientation other than the World and all RBs will get rotated correctly.
- SlipStream port was being used after running the app once. Fix kills the SlipStream when the application quits so the port is freed up again.
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

beckdo
NaturalPoint Employee
NaturalPoint Employee
Posts: 519
Joined: Tue Jan 02, 2007 2:02 pm

Re: Motive to Unity

Post by beckdo » Thu Mar 12, 2015 4:43 pm

That's great Bradly.

We've updated the UnitySample in NatNet so that it streams all rigid bodies and skeletons instead of only skeleton data. This will be a nice update for people wanting to stream rigid bodies to Unity because it won't require an work on their end to modify the UnitySample.

Thx,
Doug

BradleyNewman
Posts: 10
Joined: Mon Sep 01, 2014 2:35 pm
Location: Los Angeles, CA
Contact:

Re: Motive to Unity

Post by BradleyNewman » Thu Mar 12, 2015 5:59 pm

Awesome news! Thanks! Any plans for a DLL Unity plugin? Any amount of latency we can shave off for VR would be valuable.

Thanks,
Brad
Bradley Newman
Senior Research Associate
USC School of Cinematic Arts
Worldbuilding Media Lab (WbML) - worldbuilding.usc.edu

Post Reply