vive-tracker-apiserver


Namevive-tracker-apiserver JSON
Version 0.0.7 PyPI version JSON
download
home_pageNone
SummaryVive Tracker APIServer
upload_time2024-04-15 12:46:52
maintainerNone
docs_urlNone
authordavidliyutong
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Vive Tracker APIServer

## Get Started

```shell
pip install vive-tracker-apiserver
```

From source:

```shell
git clone https://github.com/mvig-robotflow/vive-tracker-apiserver
cd vive-tracker-apiserver
python setup.py install
```

## Usage

### Set up the SteamVR

First, install [SteamVR](https://www.steamvr.com/zh-cn/). Configure and pair the trackers with HMD or receiver.

Then run the configuration command:

```shell
python -m vive_tracker_apiserver configure
```

This will automatically detect all trackable devices and generate a `config.yaml` file under `$pwd`. It looks like [this](manifests/config.yaml)

```yaml
vive_tracker_apiserver:
  api:
    interface: 0.0.0.0
    port: 8080
  data_path: ./tracker_data
  debug: false
  trackers:
  - name: tracker_1
    uid: LHR-656F5409
  - name: tracker_2
    uid: LHR-6A736404
```

> The screen might blink during this configuration

After the configuration. Run the apiserver with configuration

```shell
python -m vive_tracker_apiserver serve --config=config.yaml
```

```text
...
INFO:apiserver.app:loading openvr components
...
INFO:apiserver.app:server is tarted!
INFO:apiserver.app:vive tracker service listen at 8080
INFO:apiserver.app:vive tracker config Config(path='./config.yaml', trackers=[TrackerConfig(uid='LHR-656F5409', name='tracker_1'), TrackerConfig(uid='LHR-6A736404', name='tracker_2')], api_port=8080, api_interface='0.0.0.0', debug=False, data_path='./tracker_data', valid=True)
```

Here is a minimal working example:

```python
import time
from vive_tracker_apiserver.client import Client

def get_description(data):
    return str([f'id:{item.meta.uid} x: {item.pos_x:.2f} y: {item.pos_y:.2f} z: {item.pos_z:.2f}' for item in data.payload])

def test_server():
    endpoint = "localhost:8080"

    c = Client(endpoint)
    response = c.get_group()
    print("GetTrackerGroup client received: " + str(response))

    stream = c.open_group_stream()
    print("GetTrackerGroupStream client received: " + str(response))

    try:
        while True:
            data = stream.read()
            if data.meta.valid == False:
                time.sleep(0.05)
                continue
            print('\r'+get_description(data), end="")
    except KeyboardInterrupt as e:
        stream.close()

if __name__ == '__main__':
    test_server()
```

## gRPC Server

Run this command

```shell
python -m vive_tracker_apiserver serve
```

### Testing with cli tools

```shell
python -m vive_tracker_apiserver test.server
```

You will be asked to input API endpoint.

### Testing with Open3D visualization

```shell
python -m vive_tracker_apiserver test.visualize
```

You will be asked to input API endpoint.

### Generate Client

First run `cd vive_tracker_apiserver/grpc`, then run:

```shell
# cd vive_tracker_apiserver/grpc
python -m grpc_tools.protoc -I../../manifests/protos --python_out=. --pyi_out=. --grpc_python_out=. ../../manifests/protos/tracker_packet.proto
```

You might need to replace line 5 of `vive_tracker_apiserver/grpc/tracker_packet_pb2_grpc.py` with `import vive_tracker_apiserver.grpc.tracker_packet_pb2 as tracker__packet__pb2`



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "vive-tracker-apiserver",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "davidliyutong",
    "author_email": "davidliyutong@sjtu.edu.cn",
    "download_url": "https://files.pythonhosted.org/packages/d9/bd/429d0bd13f222cde80c7dde82d2c8549cffdc676f981d01ddc4c70f8f02e/vive-tracker-apiserver-0.0.7.tar.gz",
    "platform": null,
    "description": "# Vive Tracker APIServer\n\n## Get Started\n\n```shell\npip install vive-tracker-apiserver\n```\n\nFrom source:\n\n```shell\ngit clone https://github.com/mvig-robotflow/vive-tracker-apiserver\ncd vive-tracker-apiserver\npython setup.py install\n```\n\n## Usage\n\n### Set up the SteamVR\n\nFirst, install [SteamVR](https://www.steamvr.com/zh-cn/). Configure and pair the trackers with HMD or receiver.\n\nThen run the configuration command:\n\n```shell\npython -m vive_tracker_apiserver configure\n```\n\nThis will automatically detect all trackable devices and generate a `config.yaml` file under `$pwd`. It looks like [this](manifests/config.yaml)\n\n```yaml\nvive_tracker_apiserver:\n  api:\n    interface: 0.0.0.0\n    port: 8080\n  data_path: ./tracker_data\n  debug: false\n  trackers:\n  - name: tracker_1\n    uid: LHR-656F5409\n  - name: tracker_2\n    uid: LHR-6A736404\n```\n\n> The screen might blink during this configuration\n\nAfter the configuration. Run the apiserver with configuration\n\n```shell\npython -m vive_tracker_apiserver serve --config=config.yaml\n```\n\n```text\n...\nINFO:apiserver.app:loading openvr components\n...\nINFO:apiserver.app:server is tarted!\nINFO:apiserver.app:vive tracker service listen at 8080\nINFO:apiserver.app:vive tracker config Config(path='./config.yaml', trackers=[TrackerConfig(uid='LHR-656F5409', name='tracker_1'), TrackerConfig(uid='LHR-6A736404', name='tracker_2')], api_port=8080, api_interface='0.0.0.0', debug=False, data_path='./tracker_data', valid=True)\n```\n\nHere is a minimal working example:\n\n```python\nimport time\nfrom vive_tracker_apiserver.client import Client\n\ndef get_description(data):\n    return str([f'id:{item.meta.uid} x: {item.pos_x:.2f} y: {item.pos_y:.2f} z: {item.pos_z:.2f}' for item in data.payload])\n\ndef test_server():\n    endpoint = \"localhost:8080\"\n\n    c = Client(endpoint)\n    response = c.get_group()\n    print(\"GetTrackerGroup client received: \" + str(response))\n\n    stream = c.open_group_stream()\n    print(\"GetTrackerGroupStream client received: \" + str(response))\n\n    try:\n        while True:\n            data = stream.read()\n            if data.meta.valid == False:\n                time.sleep(0.05)\n                continue\n            print('\\r'+get_description(data), end=\"\")\n    except KeyboardInterrupt as e:\n        stream.close()\n\nif __name__ == '__main__':\n    test_server()\n```\n\n## gRPC Server\n\nRun this command\n\n```shell\npython -m vive_tracker_apiserver serve\n```\n\n### Testing with cli tools\n\n```shell\npython -m vive_tracker_apiserver test.server\n```\n\nYou will be asked to input API endpoint.\n\n### Testing with Open3D visualization\n\n```shell\npython -m vive_tracker_apiserver test.visualize\n```\n\nYou will be asked to input API endpoint.\n\n### Generate Client\n\nFirst run `cd vive_tracker_apiserver/grpc`, then run:\n\n```shell\n# cd vive_tracker_apiserver/grpc\npython -m grpc_tools.protoc -I../../manifests/protos --python_out=. --pyi_out=. --grpc_python_out=. ../../manifests/protos/tracker_packet.proto\n```\n\nYou might need to replace line 5 of `vive_tracker_apiserver/grpc/tracker_packet_pb2_grpc.py` with `import vive_tracker_apiserver.grpc.tracker_packet_pb2 as tracker__packet__pb2`\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Vive Tracker APIServer",
    "version": "0.0.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "915f339366d9a20c3d9563c9670cd93baab837e710f5c4edda1938efe07cf046",
                "md5": "b3797d3ea96dbbcdd0e56a7702390800",
                "sha256": "15ecc2c2b5ad67313881f42bdfb3df55693dfc9f60fd4fa2498e7b2076f884a4"
            },
            "downloads": -1,
            "filename": "vive_tracker_apiserver-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b3797d3ea96dbbcdd0e56a7702390800",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 22451,
            "upload_time": "2024-04-15T12:46:51",
            "upload_time_iso_8601": "2024-04-15T12:46:51.752047Z",
            "url": "https://files.pythonhosted.org/packages/91/5f/339366d9a20c3d9563c9670cd93baab837e710f5c4edda1938efe07cf046/vive_tracker_apiserver-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9bd429d0bd13f222cde80c7dde82d2c8549cffdc676f981d01ddc4c70f8f02e",
                "md5": "e849084ba69fa6c99391b6bd29247e08",
                "sha256": "75621a6c3f2bf7176d977ebe209f80d7bb4bbe6c85bcfb38056615eacf3d9ccb"
            },
            "downloads": -1,
            "filename": "vive-tracker-apiserver-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "e849084ba69fa6c99391b6bd29247e08",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 16099,
            "upload_time": "2024-04-15T12:46:52",
            "upload_time_iso_8601": "2024-04-15T12:46:52.726760Z",
            "url": "https://files.pythonhosted.org/packages/d9/bd/429d0bd13f222cde80c7dde82d2c8549cffdc676f981d01ddc4c70f8f02e/vive-tracker-apiserver-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 12:46:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "vive-tracker-apiserver"
}
        
Elapsed time: 0.22275s