【问题标题】:Vive Tracker without HMD Axis seem inverted没有 HMD Axis 的 Vive Tracker 似乎倒置了
【发布时间】:2018-10-10 10:51:46
【问题描述】:

我想提取有关我的 Vive Tracker 传感器姿势的信息。

我发现this tutorial 非常准确并且有效,但是...

例如,当我将 vive 追踪器放在桌子上并用手旋转它时,它不会改变 YAW,而是改变追踪器的 PITCH。

我应该如何读取姿势矩阵以获得正确的轴?

【问题讨论】:

    标签: python rotation tracker htc-vive


    【解决方案1】:

    我遇到了同样的问题,因为旋转矩阵是用头显和控制器的相同功能读取的。

    如果是 Vive Tracker,您应该使用 OpenVR 的其他功能,以便正确读取姿势。

    这样做:

    #get the pose with orientation in radians
        def get_pose_radians(self):
            pose = self.vr.getControllerStateWithPose(openvr.TrackingUniverseStanding, self.index,openvr.k_unMaxTrackedDeviceCount)
            return convert_to_radians(pose[2].mDeviceToAbsoluteTracking)
    

    以弧度表示姿势的函数可能是:

    #Convert the 3x4 position/rotation matrix to a x,y,z location and the appropriate Euler angles (in radians)
    def convert_to_radians(pose_mat):
    
    roundfact = 16
    
    x = pose_mat[0][3]
    y = pose_mat[1][3]
    z = pose_mat[2][3]
    
    # Algorhitm 1
    
    #read here: https://steamcommunity.com/app/358720/discussions/0/343787920117426152/
    pitch = math.atan2(pose_mat[2][1], pose_mat[2][2])
    yaw = math.asin(pose_mat[2][0])
    roll = math.atan2(-pose_mat[1][0], pose_mat[0][0])
    return [x,y,z,yaw, pitch, roll]
    

    为了避免云台锁等,我建议你使用四元数,有这个功能:

    def convert_to_quaternion(pose_mat):
        r_w = math.sqrt( max( 0, 1 + pose_mat[0][0] + pose_mat[1][1]+ pose_mat[2][2] ) ) / 2
        r_x = math.sqrt( max( 0, 1 + pose_mat[0][0] - pose_mat[1][1] - pose_mat[2][2] ) ) / 2
        r_y = math.sqrt( max( 0, 1 - pose_mat[0][0] + pose_mat[1][1] - pose_mat[2][2] ) ) / 2
        r_z = math.sqrt( max( 0, 1 - pose_mat[0][0] - pose_mat[1][1] + pose_mat[2][2] ) ) / 2
        r_x *= math.copysign(1, r_x * ( -pose_mat[2][1] + pose_mat[1][2] ) )
        r_y *= math.copysign(1,r_y * ( -pose_mat[0][2] + pose_mat[2][0] ) )
        r_z *= math.copysign(1,r_z * ( pose_mat[1][0] - pose_mat[0][1] ) )
    
        x = pose_mat[0][3]
        y = pose_mat[1][3]
        z = pose_mat[2][3]
        return [x,y,z,r_w,r_x,r_y,r_z]
    

    【讨论】:

      猜你喜欢
      • 2019-03-15
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多