Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Publishing VR input to ROS

Discussion in 'Robotics' started by GerenMeric, Jul 20, 2023.

  1. GerenMeric

    GerenMeric

    Joined:
    May 15, 2023
    Posts:
    47
    Hello there,

    I am pretty new to ROS and Unity. I have managed to connect an Oculus Quest 2 to unity and i can display a live video stream in the VR headset. Now, i want to get rotation of my headset and if a button pressed on left or right controllers. I currently OpenXR installed and set up in Unity by following these two tutorials/ courses:

    https://learn.unity.com/tutorial/0-...?uv=2020.3&courseId=60183276edbc2a2e6c4c7dae#

    https://learn.unity.com/tutorial/create-a-vr-starter-project-from-scratch#62a2a478edbc2a0eaaf89a50

    Do i need to install Oculus XR or OVR? Or can i do it with OpenXR? If so how can i do that?

    Thanks for any advice, any help in advance.
     
    Last edited: Jul 20, 2023
  2. Envilon

    Envilon

    Joined:
    Aug 8, 2020
    Posts:
    55
    Hi, I'm not sure if I understand this post correctly because in the title, you are asking about publishing inputs to ROS, and in the text, you are talking about registering the inputs from your VR device. In that case, it is not a ROS-related question, and I think someone would have helped you quicker if you were to ask in the VR forum.

    In your case (as far as I know from your other posts in this forum), you need OpenXR Plugin, XR Interaction Toolkit, and you are hopefully using the "new" Input System. And if you have the locomotion and controls set up correctly, you should be able to use the input system to register these positions and triggers in your code.

    For the ROS part, you'll probably publish some message about the controller inputs when you register a button press. But you probably don't want to stream the position and rotation data into ROS continuously, so you'll probably run some fixed publisher timer when you actually publish these data into ROS.
     
    GerenMeric likes this.
  3. GerenMeric

    GerenMeric

    Joined:
    May 15, 2023
    Posts:
    47
    Hi @Envilon, thank you so much for your suggestions. Open XR and XR Interaction toolkit worked for me. Now, i can publish messages on use of controls.