This ROS2 Node publishes pose data from HTC Vive Tracker on Ubuntu 22.04.
Note: This software depends on SteamVR on Ubuntu. Be advised that SteamVR is not fully supported on Ubuntu and may not install properly with your version of Ubuntu/graphics drivers/hardware. It is recommended to try to get SteamVR installed on your computer before considering using this library.
Up-to-date graphics drivers
SteamVR requires >4GB disk space
Have git, python3 and ros2 installed on your system
-
Install Steam from http://store.steampowered.com/ or via apt:
sudo apt install steam
- Open steam with
steam
command, or through the Ubuntu menu. Make a Steam account & Log in. - Enable the Steam beta through the Steam Menu -> Settings -> Account -> Beta Participation. See the video here to see how to enable the beta.
- (Recommended) Save your credentials while logging in, and once you do log in open the
Steam
Menu item in the top left corner and selectGo Offline
. This prevents Steam from updating every time you use the Vive Tracker.
-
Install SteamVR.
- Click Library -> VR
- On the left you should now see SteamVR. Add to library.
- Before installing, left click on SteamVR and click on
Properties
- In Tab
Betas
underBeta Participation
selectlinux_v1.14
-
Install udev rules to be able to use USB dongles
- Download and follow instructions at https://gitlab.com/fabiscafe/game-devices-udev
- Download https://github.com/ValveSoftware/steam-devices and do the same with these files
-
Make a Symbolic Link from libudev.so.0 to libudev.so.1 for SteamVR to use.
sudo ln -s /lib/x86_64-linux-gnu/libudev.so.1 /lib/x86_64-linux-gnu/libudev.so.0
-
Disable the headset requirement and enable a null (simulated) headset:
-
open general settings file in text editor:
gedit ~/.steam/steam/steamapps/common/SteamVR/resources/settings/default.vrsettings
-
Change the following properties (add if they do not exist) to the following values:
"requireHmd" : false,
"activateMultipleDrivers" : true
"forcedDriver": "null"
-
Open driver settings file
gedit ~/.steam/steam/steamapps/common/SteamVR/drivers/null/resources/settings/default.vrsettings
-
Set
enable
(line 3) totrue
in null driver to enable it.
-
-
Download this project to your computer in a directory of your choice (in the following
~/ros2_steamvr
is used).cd ~/ros2_steamvr git clone https://github.com/moon-wreckers/vive_tracker.git
-
Create python venv and install dependencies
- install environment manager poetry with pipx (if pipx does not work you can also use pip, but installing a python package with normal pip and without a virtual environment will change your system python which can be dangerous)
sudo apt install pipx pipx install poetry
- create the poetry environment with all necessary packages
cd ~/ros2_steamvr/vive_tracker_ros2 poetry install
- install environment manager poetry with pipx (if pipx does not work you can also use pip, but installing a python package with normal pip and without a virtual environment will change your system python which can be dangerous)
-
Set configuration of vive_tracker_ros2 Python Node
- open
~/ros2_steamvr/vive_tracker_ros2/vive_config.yaml
- set property
ros2_packages_path
to the python package location of your ROS2 installation - (Optionally) define node refresh rate and set alias for your trackers
- open
-
(Optional) set bash alias
- open ~/.bashrc
- add the following line and save:
alias run_vive_tracker_ros2="cd ~/ros2_steamvr/vive_tracker_ros2 && poetry run python run.py"
-
Start SteamVR from the Steam Library.
-
Turn on the tracker with its button, and make sure that its wireless USB dongle is plugged in to your computer. If the tracker shows up in the SteamVR overlay skip to step 4.
-
Sync the tracker. Hold the button on the tracker until the light blinks. On the SteamVR overlay click the "SteamVR" dropdown menu. Click Devices->Pair Controller. The Tracker should then pair with the computer, and a green outline of the tracker should appear on the SteamVR overlay. If this doesn't work try unplugging the wireless USB dongle, plugging it back in, and restarting SteamVR. Restarting your computer wouldn't hurt either.
-
Ensure the Lighthouse base stations are turned on, facing each other, have green lights showing on them. Place the tracker in view of the Base Stations. The SteamVR overlay should now show at least two green square Base Stations and a solid green Tracker hexagon. The tracker is now working.
-
If you're only using 1 Base Station, make sure it's set to mode A.
-
If you're using 2 Base Stations without a sync cable, ensure they're set to modes B and C.
-
If you're using 2 Base Stations with a sync cable, ensure they're set to modes A and B.
-
-
(Optional) Set world origin
You can set the world origin by placing a tracker to the desired position:
- Open the script
set_world_origin.py
and change the variabletracker_name
to the tracker whose current pose should define your world frame. - Run
set_world_origin.py
by calling:cd ~/ros2_steamvr/vive_tracker_ros2 poetry run python set_world_origin.py
- Open the script
-
Run tracking ROS2 node.
With bash alias:
run_vive_tracker_ros2
or directly:
cd ~/ros2_steamvr/vive_tracker_ros2 poetry run python run.py
-
(Optional) Start RViz in another terminal with
rviz2
-
(Optional) In the lower left corner of RViz click on
Add
, and scroll down the Add menu to add aTF
. If all went well you should now be able to see the tracker moving in RViz. -
If for some reason it isn't working, check to ensure that the Tracker is turned on, SteamVR is still running, the tracker icon is green, and the vive_tracker ros2 node is still running.
Here's a handy command, run this in the command line to start SteamVR with the command steamvr
alias steamvr='LD_LIBRARY_PATH=~/.steam/bin32/ ~/.steam/bin32/steam-runtime/run.sh ~/.steam/steam/steamapps/common/SteamVR/bin/vrstartup.sh' >> ~/.bashrc && source ~/.bashrc
This will start the server in another process, so you're free to keyboard interrupt (Ctrl+C) the terminal once the server starts.
To kill the SteamVR process:
sudo pkill -9 vr*
This project is based on https://github.com/moon-wreckers/vive_tracker.git, which uses ROS1. Many thanks to Daniel Arnett et.al.!