Using HTC Vive Comos with OpenXR

Hi !
I followed the documentation but I don’t succeed to bind my HTC Vive Cosmos Controller with my application. The compilation return an error with the code below :

CHECK_XRCMD(xrSuggestInteractionProfileBindings(m_instance, &suggestedBindings));

Can u help me, please ?

Thanks for answers !

Please share the compiler error, more of the surrounding code, and definition of CHECK_XRCMD. Are you modifying hello_xr or starting from scratch? Here’s the “simple controller” code from hello xr: OpenXR-SDK-Source/openxr_program.cpp at master · KhronosGroup/OpenXR-SDK-Source · GitHub

You can see that you need to call xrStringToPath for the interaction profile path itself, populate an array of suggested bindings, then fill in your XrInteractionProfileSuggestedBinding structure. This part of the API is not very type-safe so I’m surprised you hit a compiler error - it would be more likely to e.g. forget to initialize the type field of the structure causing a runtime/validation error.

In fact, it’s not a compiler error but an error window which is displaying.
image

I’m using the SDK sources from github and more precisely, the hello_xr sample.
With breakpoints, I can see with CHECK_XRCMD a XR_ERROR_PATH_UNSUPPORTED.
However, I wrote the same path that it is written in the doc :
/interaction_profiles/htc/vive_cosmos_controller

That’s why I don’t understand…

Have you enabled the XR_HTC_vive_cosmos_controller_interaction extension? It is required when using the Cosmos interaction profile.

yep, like all things mentioned in extensions, you have to enable the extension before you’re allowed to use them.

I don’t know to enable an extension. I don’t see how to proceed in the documentation.
Can u help me please ?

Extensions are enabled by adding them as C strings to the array of extension names provided to xrCreateInstance().
https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#instance-initialization

For the hello_xr example, you would have to append the extension to the extensions vector in the CreateInstanceInternal() function:
https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/tests/hello_xr/openxr_program.cpp#L213

1 Like

I see.
Thanks.
I used xrEnumerateInstanceExtensionProperties to get the extensions that I can use and my headset doesn’t appear in the list.

However, the HP MR Controller appears. I enabled its extension and it works. I have no more Debug Error or Exceptions.
But the binding failed :

Wed Mar 02 2022 09:28:27.565 - Failed to load binding file. We'll wait and try again when CRC or load count changes( computed CRC=0, old CRC=0, shared CRC=0, load count=0, shared load count=2

Can you tell me what is wrong ?
Thanks a lot !

That log message does not seem relevant to this. Neither OpenXR or the hello_xr template use binding files, and googling that exact message brings up SteamVR logs. If you are using the SteamVR runtime, it may be checking if it has user modified bindings for your application.

Are the binding working otherwise when the headset is worn?

I checked. The binding is not modified in SteamVR.
When the headset is used, it’s just not working in the hello_xr sample.

Have you tested with both the SteamVR and Vive OpenXR runtimes?

Is the application transitioning into XR_SESSION_STATE_FOCUSED when the headset is worn?

Does input work in OpenXR applications, like the unmodified hello_xr sample?

I only use the SteamVR runtime.
Yes, the application is transitionning into XR_SESSION_STATE_FOCUSED.
I only test the hello_xr sample and input doesn’t work in it.

Sounds like it could possibly be an issue with your setup. It might be a good idea to verify whether the input works correctly in SteamVR as well as other OpenXR applications.

From what I understand, if an OpenXR application doesn’t use the Cosmos controller extension, the runtime should fall back to the closest matching interaction profile in the core spec and still allow input.

The input works correctly in SteamVR.
What are other OPenXR applications ?
I just know the sample available in the SDK : hello_xr.

Blender 3.0 has OpenXR support. It even has a toggle for the Cosmos controller extension.
https://docs.blender.org/manual/en/latest/addons/3d_view/vr_scene_inspection.html

Good new : Input works in Blender.

Good, sounds that your setup works correctly then, and it’s an issue with the application.

The hello_xr template should print out the bindings for each action once the session comes into focus and the runtime attaches the action sets. Does it print out anything?

I have these following logs :

[12:07:01.484][Info   ] XrEventDataSessionStateChanged: state XR_SESSION_STATE_VISIBLE->XR_SESSION_STATE_FOCUSED session=2365491969200 time=3984926473600
Thu Mar 03 2022 12:07:01.484 - Failed to load binding file. We'll wait and try again when CRC or load count changes( computed CRC=0, old CRC=0, shared CRC=0, load count=0, shared load count=2
[12:07:01.494][Info   ] Grab action is bound to nothing
[12:07:01.495][Info   ] Quit action is bound to nothing
[12:07:01.495][Info   ] Pose action is bound to nothing
[12:07:01.495][Info   ] Vibrate action is bound to nothing

Maybe I was wrong about that error message being irrelevant. Looking at it, SteamVR generates binding files even for OpenXR applications under \Steam\config\openxr\ with names like system.generated.hello_xr.exe_vive_controller_0_binding.json. Maybe it’s failing to write the file. Looking at the SteamVR logs might also help. They’re available from the the menu in the SteamVR window under Developer → Web Console.

Another thing to check is whether the runtime has managed to attach an interaction profile to the controllers, using
xrGetCurrentInteractionProfile().

Okay, I take notes of that.
After your advice, I uninstall and reinstall Vive apps, Steam and SteamVR and it works well :
The sample associates my controller to the cosmos controller and to the hp mr controller.
I bound a button to the quit action and it works.

1 Like