forums.naturalpoint.com

Discussion and Support for the OptiTrack, SmartNav and TrackIR brands by NaturalPoint

New streaming option: Motive Direct for Unity

NatNet, VRPN, TrackD, and Plugins

by XmanLCH » Wed Apr 06, 2016 6:00 am

Hi all,

I have been working on connecting Optitrack Motive to Unity for a while. I've tried the UnitySample in NatNet SDK but its XML format causes too much traffic in my wireless network and increases network latency. Since I am doing mobile VR, it's really crucial to have it connect wirelessly.

So instead of rewriting both UnitySample server and SlipStream/Body client and make my own protocol, I decided to just make a new client which receive tracking data directly from Motive without any intermediate server.

Here is the link to the project.
http://github.com/XmanLCH/MotiveDirect

Please feel free to clone and report issues.


Best,
Lung-Pan

======
Lung-Pan Cheng
PhD in HCI
Hasso Plattner Institute,
University of Potsdam
XmanLCH
 
Posts: 3
Joined: Wed Apr 06, 2016 5:16 am

by darkmax » Wed Apr 20, 2016 9:22 am

I'm using your code in my project, and it resolve my lag problem that I was having with the official method that recommends optitrack with generating xml in another app and the connect my unity app to this app.

Thanks.

PD. The only thing that I notice was that my computer in general was slow (not the tracking, the tracking was without lag) when I was coding in visual studio while running the app in unity using your code (like it consume to much resources), but maybe is just that my computer is not so powerful.
darkmax
 
Posts: 5
Joined: Tue Feb 09, 2016 4:33 pm

by Mallow » Mon Apr 25, 2016 12:44 am

Hi Lung-Pan, hi all,

Thanks for sharing MotiveDirect. I am thinking of using this option to stream my data from Motive to Unity (currently, on the same machine). Nevertheless, I am unable to run it under certain conditions.

  • Packets does not seem to be received when using 127.0.0.1 as a Host IP.
  • Same when using an IP address belonging to the same network as the cameras.

Would you know why ? On the other hand, when using a third network, MotiveDirect works, but the NET indicator in Motive stays yellow, which is weird since packets are received...

Thanks for your help.

Best,
Mallow.
Mallow
 
Posts: 3
Joined: Mon Apr 25, 2016 12:19 am

by uhlavalab » Mon May 02, 2016 1:00 pm

XmanLCH wrote:Hi all,

I have been working on connecting Optitrack Motive to Unity for a while. I've tried the UnitySample in NatNet SDK but its XML format causes too much traffic in my wireless network and increases network latency. Since I am doing mobile VR, it's really crucial to have it connect wirelessly.

So instead of rewriting both UnitySample server and SlipStream/Body client and make my own protocol, I decided to just make a new client which receive tracking data directly from Motive without any intermediate server.

Here is the link to the project.
http://github.com/XmanLCH/MotiveDirect

Please feel free to clone and report issues.


Best,
Lung-Pan

======
Lung-Pan Cheng
PhD in HCI
Hasso Plattner Institute,
University of Potsdam


Hi there,

I came across this post through a search and I have a question about this. I cloned the github repo and tried following your README, but it seems that using the Example.unity provided I can't get the gameobject to follow the tracking data.

I am running your repo and Motive off of the same computer, but I am having Motive's Local Interface set to a its public IP address rather than localhost or its internal IP. Aside from that everything else looks right.

If you could provide more information in your README, that might help find out what is going on. The project runs without errors or warnings.
uhlavalab
 
Posts: 2
Joined: Mon May 02, 2016 12:53 pm

by zachduer » Wed Jun 01, 2016 1:57 pm

Motive Direct works great. Thanks for making it - I was just about to dig down and make the same thing after getting frustrated with having a middleman in the NatNet SDK, so I'm very glad you already took the time to make this. I spent the afternoon getting very familiar with MotiveDirect because I had to make a wrapper for it, so I can say confidently that the code is well organized and easy to use. I only have three suggestions:
1) you might consider making a thread-safe variable that holds an instance of FrameOfData, for easy public access.
2) if you do 1), then include the FrameOfData structure and the substructures (RigidBody, Skeleton, LabeledMarker) in the ReadMe so that it's immediately clear from an outside perspective how to access the motion capture data without having to dig into the code.
3) correct for the below problem:

In response to uhlavalab and anyone else who may be having trouble, it's not immediately obvious without looking at the code, but if you start with a blank Unity project rather this the provided example project, you need to create new Tags called "tracked" and "untracked". It tries to tell Unity to use those tags (lines 564 and 606), but if they're not in the project, the rest of the script won't run.
zachduer
 
Posts: 1
Joined: Wed Jun 01, 2016 1:47 pm

by XmanLCH » Fri Jun 17, 2016 10:52 am

Hi all,

Thanks for all the feedback. It would be great if you can help me to create issues on my github
https://github.com/XmanLCH/MotiveDirect/issues

I did notice some problems mentioned above.

1.Eating too much CPU resource: it probably comes from that both the command and the data thread are running full-speed while loop with try-catch. I tried to use thead sleep in the loop then it worked fine. CPU usage went down quiet much. But not so sure it's the correct way so I haven't pushed to the new version yet.

2. Receiving no data if Motive's local interface set it to "loopback": it's a really weird problem because it does receive data if you set the local interface to any other IP address. I still have no clue about this. If you have any idea please let me know and maybe make a pull request.

Anyway, I believe OptiTrack is working on the exact same thing now but I hope this project could help you until they release their version.

Best,
Lung-Pan
XmanLCH
 
Posts: 3
Joined: Wed Apr 06, 2016 5:16 am

by Yoann » Mon Jul 11, 2016 8:10 am

Hello and thanks a lot for your solution XmanLCH. It's really helpful ! I'd like to know if you found the reason why it still can't connect in local loopback mode ?

Best regards,
Yoann
Yoann
 
Posts: 1
Joined: Mon Jul 11, 2016 8:04 am

by robotfunk » Mon Apr 30, 2018 7:41 am

Thanks so much for writing this, works nice and simple.

I'm trying to get my head around sending a NatNet command such as "StartRecording" but I'm getting 'unrecognized request' whatever I try. Could you be so kind as to give an example on how to do this?

best,

Jilt
robotfunk
 
Posts: 3
Joined: Sun Feb 23, 2014 12:47 pm

by steven.andrews » Mon Apr 30, 2018 10:39 am

Hi Jilt,

If you check out the WinFormsSample that is provided with our NatNet SDK, this demonstrates how to send all of the remote commands to Motive.

You can find some additional information on remote commands, with sample code, in our online documentation.

I hope this helps!
Steven
--
Steven Andrews
OptiTrack | Senior Customer Support Engineer
help.naturalpoint.com
support@optitrack.com
steven.andrews
NaturalPoint Employee
NaturalPoint Employee
 
Posts: 434
Joined: Mon Jan 19, 2015 11:52 am

by robotfunk » Tue May 01, 2018 4:25 am

Hi Steven,

this example does not use the DLL so creating messages is quite a bit different in this case.
robotfunk
 
Posts: 3
Joined: Sun Feb 23, 2014 12:47 pm


Return to OptiTrack Data Streaming