Skip to content

ROS2 package for publishing HTC VIVE VR controller pose and button status on Linux.

License

Notifications You must be signed in to change notification settings

iltlo/vive_ros2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vive_ros2

Overview

This vive_ros2 package provides a ROS2 interface to the HTC VIVE controllers. Due to compatibility issues between the OpenVR library and ROS2, this package utilizes socket programming to enable data transfer between two standalone programs running under ROS2 on Ubuntu.

vive-robot-arm-control.mp4

Installation Instructions

1. Install Steam and SteamVR

  1. Install the latest version of Steam from Steam Store.
  2. Install SteamVR in the Steam application.

2. Download and Build OpenVR SDK

cd ~
mkdir libraries && cd libraries
git clone https://github.com/ValveSoftware/openvr.git -b v2.5.1
cd openvr
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ../
make

3. VR Setup

  1. Follow the official VIVE Pro Setup Guide to setup the lighthouse, headset, controller, etc.
  2. Plug in the VIVE and set the permission as below:
    sudo chmod +rw /dev/hidraw*
  3. You are ready to use the VIVE.
(OPTIONAL) Build the sample code to test the VIVE setup.
cd ~/libraries/openvr/samples
mkdir build && cd build
cmake .. -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/opt/Qt/5.6/gcc_64/lib/cmake -DCMAKE_BUILD_TYPE=Release

Run the demo code as follows:

# copy the texture files to the bin folder
cd ~
cp libraries/openvr/samples/bin/cube_texture.png libraries/openvr/samples/bin/hellovr_* build
# Run demo code
~/.steam/steam/ubuntu12_32/steam-runtime/run.sh ~/vive_ws/libraries/openvr/samples/bin/linux64/hellovr_opengl

Usage

  1. Clone the repository.
    # here I use ~/vive_ws as the ROS2 workspace, you can change it to your own workspace
    mkdir -p ~/vive_ws/src && cd ~/vive_ws/src
    git clone https://github.com/iltlo/vive_ros2.git
  2. Build the package.
    cd ~/vive_ws
    colcon build --packages-select vive_ros2
    source install/setup.bash
  3. Set the environment variables.
    # for bash shell
    echo "source ~/vive_ws/src/vive_ros2/scripts/set_vr_env.sh" >> ~/.bashrc
    source ~/.bashrc
    # for zsh shell
    echo "source ~/vive_ws/src/vive_ros2/scripts/set_vr_env.sh" >> ~/.zshrc
    source ~/.zshrc
  4. Start SteamVR.
    $STEAMVR/bin/linux64/vrserver --keepalive
  5. Run the package.
    # Terminal 1:
    ros2 run vive_ros2 vive_input
    # Terminal 2:
    ros2 run vive_ros2 vive_node

Demo

Using VIVE Pro controller to control a WidowX-250-S robot arm in ROS2 (using absolute pose). VIVE Pro Demo

Visualizing the absolute and relative poses of the controller on RViz. VIVE Pro Demo

Development Status

  • Obtain absolute pose data of controller
  • Implement the server client model
  • Haptic feedback to enhance user experience
  • Solve relative transformations
  • Add bounding conditions
  • Refactor code to improve readability
  • Optimize performance
  • Server-client 2-way communication

Development Environment

  • Ubuntu 22.04
  • ROS2 Humble
  • OpenVR SDK v2.5.1
  • HTC VIVE Pro

Languages