cmbruns / pyopenvr

Unofficial python bindings for Valve's OpenVR virtual reality SDK
BSD 3-Clause "New" or "Revised" License
254 stars 41 forks source link

getControllerStateWithPose() returns all zeros #86

Open mungewell opened 3 years ago

mungewell commented 3 years ago

More hacking around and discovered another problem. I do NOT have real hardware, so the possibility exists that it is bug else where... but 'fake' trackers are shown in Virtual World.

Discovered that waitGetPoses() only works when you are operating as VRApplication_Scene, meaning that script terminates (or is terminated) other VR application - runs in construct though...

So I have shifted to getControllerStateWithPose().

            if options.kinect:
                '''
                poses, game_poses = openvr.VRCompositor().waitGetPoses(poses, None)
                kinect = poses[1]
                '''
                res, state, kinect = openvr.VRSystem().getControllerStateWithPose(0,2)

                mat = kinect.mDeviceToAbsoluteTracking
                A = np.matrix(
                    ((mat.m[0][0], mat.m[0][1], mat.m[0][2], mat.m[0][3]),
                    (mat.m[1][0], mat.m[1][1], mat.m[1][2], mat.m[1][3]),
                    (mat.m[2][0], mat.m[2][1], mat.m[2][2], mat.m[2][3]),)
                    , np.float32)

                P = A.dot(np.matrix('0; 0; 0; 1')) + np.array( \
                    [[options.Y], [options.X], [options.Z]])

                position = (P[2][0], P[0][0], P[1][0])

Any suggestions as to why? Do the 'controllers' have to have a button press before this function returns data?

https://github.com/mungewell/pyPSVR/blob/master/example5_threaded/threaded_psvr.py#L347 https://github.com/SDraw/driver_kinectV1