Difference between revisions of "Using the Vive Trackers in Unity"

From Interaction Station Wiki
Jump to navigation Jump to search
(21 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
== Before getting started: ==
 
== Before getting started: ==
 
   
 
   
Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset.  
+
Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset.<br/>
 +
[[File:vive_trackers_01_dongle.png]]
  
 
The trackers have a standard 1/4” camera thread on the underside and can be attached to tripods. In the interaction station we also have a few different straps that allow the trackers to be worn on the body, for example on your waist, on your feet or on your hands.   
 
The trackers have a standard 1/4” camera thread on the underside and can be attached to tripods. In the interaction station we also have a few different straps that allow the trackers to be worn on the body, for example on your waist, on your feet or on your hands.   
  
'''PLEASE NOTE''' this guide was written for SteamVR 1.10.28, Unity 2019.2 and SteamVR Unity Plugin v2.5.0. Things change rapidly in the VR world so you may have to seek out a more up-to-date guide.  
+
'''PLEASE NOTE''' this guide was written for SteamVR 1.10.28, Unity 2019.2 and SteamVR Unity Plugin v2.5.0. Things change rapidly in the VR world so you may have to seek out a more up-to-date guide.
 
 
  
 
== In the Steam VR app: ==
 
== In the Steam VR app: ==
 
   
 
   
1.)Pair trackers in SteamVR
+
1.) Pair trackers in SteamVR
 
  https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html
 
  https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html
*
 
2.)Once the tracker is paired, right click the  tracker and select manage trackers
 
 
3.)In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those)
 
  
 +
2.) Once the tracker is paired, right click the  tracker and select manage trackers<br/>
 +
<br/>
 +
[[File:vive_trackers_02_manage.png | 500px]]<br/>
 +
<br/>
 +
3.) In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those)<br/>
 +
<br/>
 +
[[File:vive_trackers_03_assign.png | 500px]]
  
 
== In Unity: ==
 
== In Unity: ==
Line 26: Line 29:
 
https://github.com/ValveSoftware/steamvr_unity_plugin
 
https://github.com/ValveSoftware/steamvr_unity_plugin
  
'''2.)Generate Controller Bindings:'''  
+
'''2.)Generate Controller Bindings:''' <br/>
-select window/steamvr input  
+
-select window/steamvr input<br/>
-click save and generate binding  
+
 
-click open binding ui (you may have to select the binding for your specific unity project)
+
[[File:steamvr_input.png]]
 +
 
 +
-click save and generate binding<br/>
  
-in binding ui click on current controller to tracker assigned to body part
+
[[File:Vive_trackers_saveandgenerate.png | 500px]]
    -It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.
 
    -repeat for each additional body part
 
  
 +
-click open binding ui (you may have to select the binding for your specific unity project)<br/>
 +
<br/>
 +
[[File:Vive_trackers_openbinding.png | 500px]]
 +
 +
<br/>
 +
'''3.) Manage Bindings'''<br/>
 +
-in binding ui click on current controller to tracker assigned to body part<br/>
 +
-It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.<br/>
 +
-repeat for each additional body part<br/>
 +
<br/>
 
-now you will have bindings for each tracker.
 
-now you will have bindings for each tracker.
  
Line 40: Line 53:
 
   
 
   
  
-To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig.Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig])
+
-To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig. Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig]). If you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source. The controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.<br/>
-if you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source.  
+
[[File:steamvr_controller_left.png|500px]] [[File:steamvr_controller_left_model.png|500px]]
-the controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.
+
<br/><br/><br/>
 +
-to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot <br/><br/>
 +
-add a steamvr_behavior_pose component to the game object and change the input source to left foot<br/><br/>
 +
 
 +
[[File:steamvr_left_foot.png | 500px ]]
  
-to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot
+
[[File:steamvr_left_foot_source.png | 500px]]
-add a steamvr_behavior_pose component to the game object and change the input source to left foot
 
-add a child game object to your left foot, and rename to model
 
-add a steamvr_render_model component to the model game object. You can leave all the settings as default.
 
  
-and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers.
+
-add a child game object to your left foot, and rename to model <br/><br/>
  
 +
-add a steamvr_render_model component to the model game object. You can leave all the settings as default. <br/>
  
   
+
[[File:steamvr_left_food_model.png | 500px]]
  
 +
<br/>
 +
<br/>
 +
-and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers.
  
 
== More info: ==
 
== More info: ==

Revision as of 12:23, 18 March 2020

Before getting started:

Each vive tracker requires its own USB dongle. The number of USB dongles that you can use at one time is limited by the USB bandwidth on the motherboard of the computer. In the HTC.VIVE space in the Interaction Station there is an extra USB PCI card installed that should allow you to connect all the of the dongles at the same time. The trackers seem to work best with the dongles in line of sight from the tracker, so it’s recommended to use the USB extensions that come with the dongles. In most cases the trackers will not work if the headset isn’t connected, there are hacks to get around this but the easiest setup is to connect the headset.
Vive trackers 01 dongle.png

The trackers have a standard 1/4” camera thread on the underside and can be attached to tripods. In the interaction station we also have a few different straps that allow the trackers to be worn on the body, for example on your waist, on your feet or on your hands.

PLEASE NOTE this guide was written for SteamVR 1.10.28, Unity 2019.2 and SteamVR Unity Plugin v2.5.0. Things change rapidly in the VR world so you may have to seek out a more up-to-date guide.

In the Steam VR app:

1.) Pair trackers in SteamVR

https://www.vive.com/us/support/wireless-tracker/category_howto/pairing-vive-tracker.html

2.) Once the tracker is paired, right click the tracker and select manage trackers

Vive trackers 02 manage.png

3.) In the manage tackers section assign tracker to a body part (knees and elbows don’t work yet, so don’t use those)

Vive trackers 03 assign.png

In Unity:

1.)Import Steam VR Unity package (from GitHub or Asset Store)
https://assetstore.unity.com/packages/tools/integration/steamvr-plugin-32647
https://github.com/ValveSoftware/steamvr_unity_plugin

2.)Generate Controller Bindings:
-select window/steamvr input

Steamvr input.png

-click save and generate binding

Vive trackers saveandgenerate.png

-click open binding ui (you may have to select the binding for your specific unity project)

Vive trackers openbinding.png


3.) Manage Bindings
-in binding ui click on current controller to tracker assigned to body part
-It will probably show nothing under Current Binding, so you need to "Create New Binding". In there, you either have to Add Action Pose or Edit Action Poses. There, assign Pose to user/foot/left/pose/raw. Make sure to save your binding.
-repeat for each additional body part

-now you will have bindings for each tracker.

Using the trackers inside of Unity:

-To get an idea of how we might use the trackers in Unity, we can take a look at the SteamVR camera rig. Remove the main camera from your scene and add the camera rig to your scene (Assets/steamVR/Prefabs/[Camera Rig]). If you take a look at controller left game object, it is just a empty game object with a steamvr_behaviour_pose script attached to it. If you take a look at the input source it is currently assigned to the left hand, but you can select a number of other body parts as the input source. The controller left gameObject has a child object with a steamvr_render_model script attached to it. This will handle rendering the model of the controller.
Steamvr controller left.png Steamvr controller left model.png


-to add our own trackers into the scene add an empty game object as a child of the [camera rig], rename it to your body part that you are tracking ie. left foot

-add a steamvr_behavior_pose component to the game object and change the input source to left foot

Steamvr left foot.png

Steamvr left foot source.png

-add a child game object to your left foot, and rename to model

-add a steamvr_render_model component to the model game object. You can leave all the settings as default.

Steamvr left food model.png



-and voila that should be enough to have a tracker in your scene complete with a render model for the tracker. You can repeat these steps to add additional trackers.

More info:

https://github.com/ViveSoftware/ViveInputUtility-Unity/wiki/SteamVR-Input-System-Compatibility
https://medium.com/@sarthakghosh/a-complete-guide-to-the-steamvr-2-0-input-system-in-unity-380e3b1b3311