How to determine if SteamVR_TrackedObject is a Vive or Vive Tracker controller

What is the best way to determine if SteamVR_TrackedObject Vive Controller and Vive Tracker are?


When 0 controllers and 1 tacker are paired:

The tracker is taken as Controller (right) CameraRig .

When 1 controller and 1 tacker are paired:

The tracker is installed on device 2.

When two controllers and 1 tacker are paired:

Create a third SteamVR_TrackedObject and place it in the CameraRig objects array. Also, when the controller loses tracking, so does the tracker.


In each scenario, Tracker becomes a different SteamVR_TrackedObject.index . What is the best way to check if SteamVR_TrackedObject Tracker is, or find an index Tracker?

+6
source share
2 answers

The only SteamVR_TrackedObject validation method I found is to validate ETrackedDevicePoperty.Prop_RenderModelName_String :

 uint index = 0; var error = ETrackedPropertyError.TrackedProp_Success; for (uint i = 0; i < 16; i++) { var result = new System.Text.StringBuilder((int)64); OpenVR.System.GetStringTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_RenderModelName_String, result, 64, ref error); if (result.ToString().Contains("tracker")) { index = i; break; } } 

Then you can set SteamVR_TrackedObject.index for indexing:

 GetComponent<SteamVR_TrackedObject>().index = (SteamVR_TrackedObject.EIndex)index; 

It was rather difficult to find any documentation on this issue, but here are some sources:

+9
source

Just stumbled upon this old question, and I think the accepted answer was strictly correct when asked - although there is a direct way to do it now: you can use GetTrackedDeviceClass .

It will return the value of the ETrackedDeviceClass enumeration. Possible values:

  • Invalid - if there is no monitored device at this index,
  • HMD - if the device is a headset,
  • Controller - if the device, well, in general, the controller is one of your cases,
  • GenericTracker is another of your cases
  • TrackingReference - for base stations supporting cameras, etc.,
  • DisplayRedirect - documentation - "Accessories that are not necessarily tracked by themselves, but can redirect video output from other monitored devices"
  • Max is undocumented and I haven't stumbled upon it yet
+1
source

Source: https://habr.com/ru/post/1266261/


All Articles