how do you use mDeviceToAbsoluteTracking to find the tracking data for a controller
See original GitHub issueheres my code
import sys
import time
import openvr
import math
def from_matrix_to_pose_dict(matrix):
pose = {}
# From http://steamcommunity.com/app/358720/discussions/0/358417008714224220/#c359543542244499836
position = {}
position['x'] = matrix[0][3]
position['y'] = matrix[1][3]
position['z'] = matrix[2][3]
q = {}
q['w'] = math.sqrt(max(0, 1 + matrix[0][0] + matrix[1][1] + matrix[2][2])) / 2.0
q['x'] = math.sqrt(max(0, 1 + matrix[0][0] - matrix[1][1] - matrix[2][2])) / 2.0
q['y'] = math.sqrt(max(0, 1 - matrix[0][0] + matrix[1][1] - matrix[2][2])) / 2.0
q['z'] = math.sqrt(max(0, 1 - matrix[0][0] - matrix[1][1] + matrix[2][2])) / 2.0
q['x'] = math.copysign(q['x'], matrix[2][1] - matrix[1][2])
q['y'] = math.copysign(q['y'], matrix[0][2] - matrix[2][0])
q['z'] = math.copysign(q['z'], matrix[1][0] - matrix[0][1])
pose['position'] = position
pose['orientation'] = q
return pose
openvr.init(openvr.VRApplication_Scene)
poses = [] # will be populated with proper type after first call
for i in range(100):
poses, _ = openvr.VRCompositor().waitGetPoses(poses, None)
hmd_pose = poses[openvr.k_unTrackedDeviceIndex_Hmd]
matrix = (hmd_pose.mDeviceToAbsoluteTracking)
d = from_matrix_to_pose_dict(matrix)
print(d)
sys.stdout.flush()
time.sleep(0.2)
openvr.shutdown()
its doing what i want it to except that its getting data from the head mount display and i want it to get data from a controller instead how would i do so?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How to Get Raw (Positional) Data from HTC Vive? - CodeProject
2) Open samples/samples_vs2010.sln solution file by visual studio. Then, run it to make sure everyting works. You should see a window like the ......
Read more >Week Three: Tracking - David Weis
Simple code for getting tracking data from OpenVR using the C# bindings: ... mDeviceToAbsoluteTracking; Position pos = new ...
Read more >Using HTC Vive to Control Dynamixel Servo
Get into your tracking area with the Vive controller and click any button on them and move around the left controller. You should...
Read more >What is OpenVR and how to get started with its APIs
So let's start coding our Hello World application using OpenVR, while we describe which are the most relevant operations needed to obtain data...
Read more >Solved: Is there a way to know if the controllers are bein...
Is there a way to know if the controllers are being tracked using the ... using Unity's Legacy XR Input this should provide...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fixed it sorry not very familiar with this website
You will get the pose exactly the same way as you did for the HMD:
and then do whatever you want with it.
There is not much documentation for the Python code, as it basically mimics the native API. So for example, for how to use
WaitGetPoses
you might want to read the official doc (https://github.com/ValveSoftware/openvr/wiki/IVRCompositor::WaitGetPoses), or even read the source code (https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h).