Wiki

Clone wiki

UDP_Module / Home

Augmented Human Assistance Logo

Welcome to UDP_Module wiki

This project was created with the intention to facilitate the UDP integration in games made with Unity 3D that are part of the AHA project. This UDP module follows the UDP protocol of the RehabNet-CP.

UDP_Module quick guide

1 - Start by downloading the UDP_Module Unity package.

2 - Import the package into your project

3 - Open the UDP scene

4 - Check the Device prefab that is inside the Resources Folder. This object must have a Tag which is "Device", if it's not set please define it and save.

5 - Press Play (make sure you already have the RehabNet-CP connected and streaming data)

6 - Press The Connect Button (if you're streaming data through a different port just edit it in the Port inputfield before pressing Connect)

UDP UI screenshot1

7 - Press Filtering and choose which axis your player will use

UDP UI screenshot1

8 - Finnally go to Devices and choose the device and joint that you want to be tracked

UDP UI screenshot1

9 - Move in the direction of the represented arrows

UDP UI screenshot1

10 - In the end a message will be printed in the console: "Calibration finished". At this point the calibration is done and saved locally and next time you press Play it will not ask you to calibrate again.

And that's it! Happy tracking!

Integrating the UDP_module into your scene

You may want to integrate this UDP_module directly into your scene and not using the UDP scene. You can do that easily by using the provided prefabs.

Here some steps to help you along the way:

1 - Open your scene and make sure there is a Canvas in it.

2 - Drag the CalibrationUI prefab into your Canvas

3 - Drag the UDP prefab into the hierarchy without being parented to any other object (set it to the zero position or at the center of your visible world in the game vew)

4 - Click on this UDP object and select the CalibrationProcess script in the inspector

5 - Open this CalibrationProcess script and set the _rangeMin and _rangeMax vector values

6 - Follow the instructions mentioned on the quick guide starting in the step 4.

All should be working. If not, just submit an issue describing the difficulties you are encountering. Thank you!

UDP_Module scripts

CalibrationUiNavigation

This script is attached to the CalibrationUI prefab and is responsible for all the UI navigation. You can turn the visibility on/off by pressing the "U" key.

UdpReceiver

Establishes the UDP connection and checks if there is an existing calibration

UdpData

Responsible to parse the incoming data from the selected device

CalibrationProcess

This script handles with everything related with the calibration process and scaling of the real world coordinates to virtual world coordinates. There are some values you need to change when you are integrating into your game.

1 - The virtual world minimum and maximum range. These two vectors represent the minimum and maximum positions that your player can reach. Usually it is represented by the screen visibility. The following example is the one used in the UDP scene:

private Vector3 _rangeMax = new Vector3(10, 5.5f, 1);
private Vector3 _rangeMin = new Vector3(-10, -5.5f, -1);

2 - The real world tracked minimum and maximum positions (edit these only if you are not going to execute the calibration):

public static Vector3 Max = new Vector3(10, 5.5f, 1);
public static Vector3 Min = new Vector3(-10, -5.5f, -1);

If you have a direct mapping of 1:1 real and virtual world coordinates all you need to do is setting the same values in both _rangeMin and Min vectors, and the same for the _rangeMax and Max and disable the Calibrate option in the UI, so it doesn't make any type of calibration.

Filtering

Responsible for applying a LowPass filtering according to the values that user can input by the interface (In Filtering). Remember you can turn the UI visibility on by pressing The "U" key.

CalibrationData

This script contains the two methods of Saving and Loading calibration from the local XML file.

Updated