LightHouse-UESTC/Code/triad_openvr/README.md

1.5 KiB
Raw Blame History

Triad OpenVR Python封装库

这是一个增强的OpenVR的封装库对比现有的一些较为完善的库如 cmbruns开发的 pyopenvr library。Triad OpenVR Python 封装库是为了更加简便的方式去使用python处理SteamVR跟踪系统的数据。

一、使用样例

通过python获取SteamVR的手柄的位置并绘制在Figure上示例代码如下

import triad_openvr as vr
import pylab as plt
v = vr.triad_openvr()
data = v.devices["controller_1"].sample(1000,250)
plt.plot(data.time,data.x)
plt.title('Controller X Coordinate')
plt.xlabel('Time (seconds)')
plt.ylabel('X Coordinate (meters)')

Example plot of captured data

二、配置文件

config.json的作用是通过序列号识别设备以便为同一物理设备保持相同的名称。为了使其正常工作只需在'config.json'文件中更改序列号和名称。以下是一个配置文件的示例:

{
    "devices":[
        {
          "name": "hmd",
          "type": "HMD",
          "serial":"XXX-XXXXXXXX"
        },
        {
          "name": "tracking_reference_1",
          "type": "Tracking Reference",
          "serial":"LHB-XXXXXXXX"
        },
        {
          "name": "controller_1",
          "type": "Controller",
          "serial":"XXX-XXXXXXXX"
        },
        {
          "name": "tracker_1",
          "type": "Tracker",
          "serial":"LHR-XXXXXXXX"
        }
    ]
}