cmbruns / pyopenvr

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

OpenVR has an error in obtaining data for VR headsets and controllers #94

Open Recialhot opened 8 months ago

Recialhot commented 8 months ago

when i run this,the z-coordinate of the positioning data is in the second position, and there is clearly an issue. Why is this?

code:

def convert_to_numpy(matrix): return np.array([[matrix.m[0][0], matrix.m[0][1], matrix.m[0][2], matrix.m[0][3]], [matrix.m[1][0], matrix.m[1][1], matrix.m[1][2], matrix.m[1][3]], [matrix.m[2][0], matrix.m[2][1], matrix.m[2][2], matrix.m[2][3]], [0.0, 0.0, 0.0, 1.0]])

hmd_pose = get_device_pose(poses, openvr.k_unTrackedDeviceIndex_Hmd) if hmd_pose:

    hmd_matrix_np = convert_to_numpy(hmd_pose)

    position = hmd_matrix_np[:3, 3]
    rotation = hmd_matrix_np[:3, :3]
    print("Headset Pose:")
    print("Position: ", position)
    print("Rotation: ", rotation)

result: Position: [-0.1273, 1.5742, 0.4805]

risa2000 commented 8 months ago

@Recialhot OpenVR (SteamVR) uses OpenGL coordinates, i.e. right-handed system with X pointing to right and Y pointing up. Is it what confuses you?

Recialhot commented 8 months ago

@Recialhot OpenVR (SteamVR) uses OpenGL coordinates, i.e. right-handed system with X pointing to right and Y pointing up. Is it what confuses you?

Thanks. I want to know what specific position is relative to the controller when I obtain the data of the controller through similar code? Is it similar to a human palm or wrist? I am using Pico。

left_controller_pose = get_device_pose(poses, openvr.TrackedControllerRole_LeftHand)

def get_device_pose(poses, device_index): pose = poses[device_index] return pose.mDeviceToAbsoluteTracking

risa2000 commented 8 months ago

Thanks. I want to know what specific position is relative to the controller when I obtain the data of the controller through similar code? Is it similar to a human palm or wrist? I am using Pico。

@Recialhot I have no idea. If you are interested in knowing how the physical features of the controller (its local coordinates) map into the tracking space, I believe it depends on the controller/driver implementation and the role. The easiest would be to figure it out on the controller directly.