Skip to content

Unity prefabs for UDP communication between HoloLens and arbitrary machines

License

Notifications You must be signed in to change notification settings

mbaytas/HoloLensUDP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HoloLensUDP

unstable

Unity prefabs and scripts for UDP communication between Microsoft HoloLens and arbitrary machines.

  • Prefabs
    • UDPCommunication: Foundation prefab that does most of the work. You must have this in the scene and set it up correctly. For most purposes you can get away without modifying this at all.
    • UDPResponder: Prefab with UDPResponse script, for responding to incoming messages.
    • UDPGenerator: Prefab with UDPGeneration script, for sending messages.
  • Scripts
    • UDPCommunication: Implements UDP communication functionality. For most purposes you shouldn't have to modify this.
    • UDPResponse: Implements example behavior for sending UDP messages on each Update. You can modify this, but you can also set its the DataString property externally.
    • UDPGeneration: Implements example behavior for responding to incoming UDP messages. You will probably have to modify this.
  • Scenes
    • Test: Test/demo scene that shows how it all comes together.

Derived from this post by DrNeurosurg on the Windows Mixed Reality Developer Forum.

This is only Unity assets for one HoloLens. You're going to need to have someone else to talk to. Check out QualisysUDP for talking to a motion capture system, and MyoUDP for talking to Myo armbands.

These assets do not work inside the Unity editor / HoloLens emulator. They must be deployed on HoloLens device to function. This is because the HoloLens uses the asynchronous programming features in UWP, which Unity currently does not support, so a lot of functionality comes inside '#if !UNITY_EDITOR' blocks.

Dependencies

Requires HoloToolkit-Unity (v1.5.7), because I can't live without its Build Window.

Instructions

...for People Who Know What They Are Doing

  1. Drop in the UDPCommunication prefab. This can be configured as a sender, listener, or both. (I found it preferable to have different instances and set different port numbers for sending and listening.) Listeners and senders will both need an Internal Port number, an External IP, and an External Port, as well as the Send Ping property set to true. Only the listener requires a UDP Event.

  2. Drop in a UDPResponder or UDPGenerator prefab. The UDPResponder needs to be hooked up using the UDPEvent property on the UDPCommunication prefab; then you can modify the UDPResponse script to change behavior. The UDPGenerator has a UDPCommGameObject property to hook it up, and a string property you can set; or you could modify its code.

...for N00bs

  1. Clone/download and copy into own project.

  2. Import HoloToolkit-Unity. If this is the first time you have done this, feel enlightened.

  3. Open up the scene called Test..

  4. Observe that there are four important game objects in the scene: UDPCommunication_Listener, UDPResponder, UDPCommunication_Sender, and UDPGenerator.

  5. Observe that UDPCommunication_Listener and UDPCommunication_Sender are instances of the same UDPCommunication prefab.

  6. Read and try to make sense of the previous section. If you fail, Google the following: Unity tutorials, UDP communication.

  7. Deploy on device. It will not work inside the Unity editor / HoloLens emulator.

Notes

  • I found it preferable to set up different listeners and senders for different concerns/streams, rather than having only one of each to handle everything.

  • You might get non-specific errors when building for the device. These sometimes happen randomly. Just try again.


This is derived from my work with Qualisys AB, the HAPPERN research group at Koç University, and the t2i Interaction Laboratory at Chalmers University of Technology.

About

Unity prefabs for UDP communication between HoloLens and arbitrary machines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages