# Convert OpenVR pose 4x3 matrix to ROS style (z up) matrix

What is the procedural logic to perform Y-up to Z-up axis conversion on a right-handed 4x3 matrix? Ideally, i would like to achieve this with either vanilla python or with tf.transformations.

I am struggling to convert from OpenGL style 4x3 matrix (X to the right, Y up, and Z aft) to ROS (X forward, Y left, and Z up).

I'm able to extract the postion vector from the matrix and apply use .dot() to alter the translation to work as expected, however however I've not been successful with the rotational axes.

code looks like this:

    position_mat = numpy.array([
openvr_tracking_matrix[0][3], openvr_tracking_matrix[1][3], openvr_tracking_matrix[2][3]
])

# Row Major
[openvr_tracking_matrix[0][0], openvr_tracking_matrix[0][1], openvr_tracking_matrix[0][2], 0],
[openvr_tracking_matrix[1][0], openvr_tracking_matrix[1][1], openvr_tracking_matrix[1][2], 0],
[openvr_tracking_matrix[2][0], openvr_tracking_matrix[2][1], openvr_tracking_matrix[2][2], 0],
[0, 0, 0, 1]
])

formatted_position = numpy.asarray(position_mat.dot(np.runtimeSettings['configuration_matrix'].value[:3, :3])).reshape(-1)

return formatted_position, rot_matrix.dot(np.runtimeSettings['configuration_matrix'].value)


so Im returning a list (vector3) and the dot() of the rotation_matrix input

The matrix I'm using to convert with is:

[ 1 0 0 0 ]

[ 0 0 -1 0 ]

[ 0 1 0 0 ]

[ 0 0 0 1 ]

Is this conceptually actually achieved with a scale or reflection operation?

I've seen a few stabs as doing this (including a reference a built-in blender module/script that appears to do exactly what I need deep inside blender; but i can't find the code for it.

help appreciated understand what I'm missing and getting to a documented way to do this deliberately.

edit retag close merge delete