LightHouse-UESTC/Code/triad_openvr/README.md

52 lines
1.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Triad OpenVR Python封装库
这是一个增强的OpenVR的封装库对比现有的一些较为完善的库如 [cmbruns](https://github.com/cmbruns)开发的 [pyopenvr library](https://github.com/cmbruns/pyopenvr)。Triad OpenVR Python 封装库是为了更加简便的方式去使用python处理SteamVR跟踪系统的数据。
## 一、使用样例
通过python获取SteamVR的手柄的位置并绘制在Figure上示例代码如下
```python
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](images/simple_xcoord_plot.png "Example Plot")
## 二、配置文件
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"
}
]
}
```