# VIVE tracker integration

> 1. [Introduction](#pdf-page-to9aw0m0lozdfyoc0g3c-introduction)
> 2. [Use cases](#pdf-page-to9aw0m0lozdfyoc0g3c-use-cases)
> 3. [Connect the VIVE Tracker to a PC](#pdf-page-to9aw0m0lozdfyoc0g3c-using-pc)
> 4. [Using in ROS2 with the libsurvive library](#pdf-page-to9aw0m0lozdfyoc0g3c-using-ros2)
> 5. [Annex: connect the VIVE tracker to a PC ](#pdf-page-to9aw0m0lozdfyoc0g3c-using-pc-1)
> 6. [References](#pdf-page-to9aw0m0lozdfyoc0g3c-references)

## Introduction <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-introduction" id="pdf-page-to9aw0m0lozdfyoc0g3c-introduction"></a>

The Vive tracker can be used to provide a reasonably accurate ground truth reference for robotics. By enabling it using the libsurvive library, position and pose information can be viewed and stored in ROSBAGS for further analysis.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FE3PVr3Sh9YJCkEVAXpJ7%2Fintroducing-tracker-992.webp?alt=media&#x26;token=ba322b8a-1f23-432b-ac9c-2dc0513ca16d" alt="" width="352"><figcaption></figcaption></figure>

VIVE Tracker (3.0) can pair with HTC’s wireless dongle or use its USB interface to transfer tracking data to a PC. An accessory attached to VIVE Tracker (3.0) can:

* Simulate buttons of the VIVE Controller through the underlying Pogo pin port.
* Send specific data to a PC through the USB interface of VIVE Tracker (3.0).

|                      | Tracker (3.0)                                      |
| -------------------- | -------------------------------------------------- |
| **Tracking**         | Support for SteamVR BS1.0 and BS2.0                |
| **Status indicator** | LED                                                |
| **Input**            | Power button, Pogo pin, USB-C                      |
| **Charging**         | USB-C                                              |
| **Attachment**       | 1/4-inch UNC Threaded mount (standard tripod mount |

## How it works <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-use-cases" id="pdf-page-to9aw0m0lozdfyoc0g3c-use-cases"></a>

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FLoEE5fZ8xPRkyKbvWIHd%2FPicture104.png?alt=media&#x26;token=8f1fdbdd-bd46-433c-9fa6-7224b3686451" alt=""><figcaption><p>Side view of HTC Vive working principle with α being the angle between a sweeping plane and the normal vector to the lighthouse.[3]</p></figcaption></figure>

## Status lights <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-use-cases" id="pdf-page-to9aw0m0lozdfyoc0g3c-use-cases"></a>

The status light shows:

* Green when the controller is in normal mode
* Blinking red when battery is low
* Blinking blue when the controller is pairing with the headset
* Blue when the controller is connecting with the headset
* Orange when charging

## Use cases <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-use-cases" id="pdf-page-to9aw0m0lozdfyoc0g3c-use-cases"></a>

As mentioned in the Developer guide \[2], the VIVE Tracker provides five use cases:

* Use case 1: Track passive objects through USB interface in VR. In this case, the dongle is not used. VIVE Tracker (3.0) is connected to the PC through USB to directly transfer tracking data.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FeXgFF53pSGLt9JQOjIPL%2Fimage.png?alt=media&#x26;token=28ad7846-354d-438b-befa-0efb71acb361" alt="" width="354"><figcaption></figcaption></figure>

* Use case 2: Track passive objects through USB interface in VR, with the accessory passing data to a PC through USB, BT/Wi-Fi or propriety RF. This is similar to Use Case 1 but the accessory directly transfers the tracking data to a PC for a specific purpose based on its design.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FHQuicAdAESiyizgkOzmP%2Fimage.png?alt=media&#x26;token=ddeb0cd8-eec9-4531-8a03-9971dd1029e2" alt="" width="375"><figcaption></figcaption></figure>

* Use case 3: Track moving objects by wireless interface in VR. In this case, the dongle is used to transfer tracking data from the VIVE Tracker (3.0) to a PC.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FHaN9aXcp958h2yZxw9fX%2Fimage.png?alt=media&#x26;token=7b0f4634-cf97-44c7-b6b6-46631b9ffffb" alt="" width="375"><figcaption></figcaption></figure>

* Use case 4: Track moving objects using a wireless interface in VR, with the accessory passing data to a PC through USB, BT/Wi-Fi or propriety RF. This is similar to Use Case 3 but the accessory directly transfer the tracking data to/from a PC for a specific purpose based on its design.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2F1fwUmZMdVgsK5vlw6SwP%2Fimage.png?alt=media&#x26;token=8396a848-53b9-4183-81c1-521eab29265e" alt="" width="375"><figcaption></figcaption></figure>

* Use case 5: Track moving objects using a wireless interface in VR, with the accessory simulating buttons of the VIVE Controller or passing data to a PC through the VIVE Tracker (3.0). This is similar to Use Case 3 but the accessory connects with the VIVE Tracker (3.0) to transfer a button event to a PC through the Pogo pins or USB interface.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FNB510peTe26tqhv3FMXi%2Fimage.png?alt=media&#x26;token=0c459723-875c-4793-a435-257b3a09ea84" alt="" width="375"><figcaption></figcaption></figure>

## Using with ROS2 and libsurvive library <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-using-ros2" id="pdf-page-to9aw0m0lozdfyoc0g3c-using-ros2"></a>

To VIVE tracker in NavQPlus using ROS2, you need to follow the instructions in the following github repository: <https://github.com/asymingt/libsurvive_ros2>

libsurvive\_ros2 provides a lightweight ROS2 wrapper around the libsurvive project, an open source set of tools and libraries that enable 6 dof tracking on lighthouse and vive based systems.

First of all set the udev rules:

```
sudo curl -fsSL https://raw.githubusercontent.com/cntools/libsurvive/master/useful_files/81-vive.rules \
    -o /etc/udev/rules.d/81-vive.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
```

And install the required packages:

```
sudo apt-get install build-essential \
    cmake \
    freeglut3-dev \
    libatlas-base-dev \
    liblapacke-dev \
    libopenblas-dev \
    libpcap-dev \
    libusb-1.0-0-dev \
    libx11-dev \
    zlib1g-dev
```

Then create a workspace and install the ROS2 wrapper:

```
mkdir -p ~/ros2_ws/src
cd  ~/ros2_ws/src
git clone https://github.com/asymingt/libsurvive_ros2.git
cd ..
colcon build
source install/setup.bash
```

Connect the VIVE Tracker to the NavQPlus using an USB-C to USB-C cable.

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FebWtnQ1gEDpqtL4c4YGj%2F20240419_094506.jpg?alt=media&#x26;token=ccf79d8b-5268-4f25-ba90-bc7fad965696" alt="" width="375"><figcaption></figcaption></figure>

Launch the ROS2 node:

```
ros2 launch libsurvive_ros2 libsurvive_ros2.launch.py rosbridge:=true
```

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FatYwiYsClSZcklEwz2oK%2FMicrosoftTeams-image%20(55).png?alt=media&#x26;token=852e719a-e2c6-40d9-9931-07bdbca490f2" alt=""><figcaption></figcaption></figure>

Three topics are published:

* /libsurvive/cfg: listens for device configuration
* /libsurvive/imu: listens for devie inertial measurements
* /libsurvive/joy: listens to the button

We need to look at the topic */libsurvive/imu* of type *sensor\_msgs/msg/Imu.*

To display topic data in foxglove, we need first to add the topics */libsurvive/imu* and */tf\_static* to the whitelist.&#x20;

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2F4vlnhXhU7hR9QZDozuVo%2FMicrosoftTeams-image%20(61).png?alt=media&#x26;token=70c2e7af-3296-4677-9873-ee9f110f44e4" alt=""><figcaption></figcaption></figure>

{% file src="<https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2F4g7ILayVSEBGTkn0Atx2%2Fvive-tracker-foxglove.webm?alt=media&token=24c2d064-6a0d-4c40-873b-a7a4e49172ec>" %}

## Annex: Connect the VIVE Tracker to a PC  <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-using-pc" id="pdf-page-to9aw0m0lozdfyoc0g3c-using-pc"></a>

This is simply the default method for connecting the unit. It can be used to ensure the device is working correctly. However for collecting data in ROS2, you will want to use the libsurvive library.

1- Download steam : <https://store.steampowered.com/about/>

2- Download steamVR <https://store.steampowered.com/app/250820/SteamVR/>

Connect the tracker to the PC via the USB-C cable then open Steam app. Got to "*Library"* then launch SteamVR app (click on the green button)

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2Fs0V5yDxkidqet0Sdplui%2Fimage.avif?alt=media&#x26;token=859c9b03-0bc8-46d0-808b-8aa5c60c74aa" alt="" width="292"><figcaption></figcaption></figure>

When launched, a small window will appear:

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FYXh8ImbdwFgF1LWoe3r0%2Fimage.png?alt=media&#x26;token=42158577-cb53-4040-8d7d-ee6a25d9ac05" alt=""><figcaption></figcaption></figure>

<figure><img src="https://396338415-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU93yDWZcgjXGgsC1Duqv%2Fuploads%2FIBoG9pwUIS1awTwx14v9%2Fimage-1.png?alt=media&#x26;token=6d6e553d-4ec1-42ad-a42a-6d471cd146da" alt=""><figcaption></figcaption></figure>

## References: <a href="#pdf-page-to9aw0m0lozdfyoc0g3c-references" id="pdf-page-to9aw0m0lozdfyoc0g3c-references"></a>

\[1] [Official website](https://developer.vive.com/eu/hardware/tracker3/?_gl=1*4k7c8u*_ga*MjEwMzkxMTM1LjE3MTAzMjQ4Njg.*_ga_68NRVQF2CG*MTcxMjU2ODk4NS40LjEuMTcxMjU2OTE1NC4wLjAuMTU1MTM0MjYzNQ..*_fplc*Q1hoRm13ZlJoQlFlS1NRZFB4YWlGOEdRUG5yeEhtYTllYVZOcktyNmhUUzZaTmZobE04aXNUUEFTNWRucWVreERIb2VvV3g3V0Z1cDF3NVlwb0lmU2QlMkI2TTdCc3VBU3Z4QklKakpMOXRlVE9VY1lpbVhBakd3VWdhc25pSHclM0QlM0Q.*_ga_JK4N8EYCGF*MTcxMjU2ODk4NS40LjEuMTcxMjU2OTE1NC4wLjAuMA..)

\[2] [Developer guide](https://dl.vive.com/Tracker/Guideline/HTC%20Vive%20Tracker%20\(3.0\)%20Developer%20Guidelines_v1.0_01182021.pdf?_gl=1*at9evb*_ga*MjEwMzkxMTM1LjE3MTAzMjQ4Njg.*_ga_68NRVQF2CG*MTcxMjU2ODk4NS40LjEuMTcxMjU2OTUxMC4wLjAuMTU1MTM0MjYzNQ..*_fplc*QXZLbGtZYmNkMFViRjZKdVc5ayUyRlkzRU5oZTFvJTJCekV1NUpINEZqVmh6ZiUyQnpLZDlubm5aSlR1ak1KS2hTMTJVREFKcyUyQlVMR28zWlRRMnRqQXlzcGlsS1lWU0RXYnA3TTJ5VmZJdDJiJTJCUExieUVkdmNISWpJSzB0Sk0lMkZpJTJGRHclM0QlM0Q.*_ga_JK4N8EYCGF*MTcxMjU2ODk4NS40LjEuMTcxMjU2OTUxMC4wLjAuMA..)

\[3] Borges, Miguel, Andrew Symington, Brian Coltin, Trey Smith, and Rodrigo Ventura. “HTC Vive: Analysis and Accuracy Improvement.” In *2018 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)*, 2610–15. Madrid: IEEE, 2018. <https://doi.org/10.1109/IROS.2018.8593707>.
