[英]Is the rotation matrix in Pybullet converting world coordinates into camera or camera to world?
I am working on a project, where I need to replace the renderings by pybullet with renders generated with pytorch3d.我正在做一个项目,我需要将 pybullet 的渲染替换为 pytorch3d 生成的渲染。
I figured out that pybullet and pytorch3d have different definitions for the coordinate systems (see these links: pybullet , pytorch3d ; x and z axes are flipped), and I accounted for that in my code.我发现 pybullet 和 pytorch3d 对坐标系有不同的定义(请参阅这些链接: pybullet , pytorch3d ;x 和 z 轴被翻转),我在我的代码中解释了这一点。 But I still have inconsistency in the rendered objects.
但是我在渲染的对象中仍然存在不一致。 I thought the problem could be that while pytorch3d expects a c2w rotation matrix (ie camera to world), pybullet could probably expect a w2c rotation matrix.
我认为问题可能在于,虽然 pytorch3d 需要一个 c2w 旋转矩阵(即相机到世界),但 pybullet 可能需要一个 w2c 旋转矩阵。 However, I cannot find any documentation related to this.
但是,我找不到与此相关的任何文档。 Has anyone ever encountered this problem, or maybe can give some useful hint on how to find out what exactly pybullet expects its rotation matrix to be?
有没有人遇到过这个问题,或者可以就如何找出 pybullet 期望它的旋转矩阵到底是什么提供一些有用的提示?
Thanks!谢谢!
I assume you are talking about the viewMatrix
expected by pybullet.getCameraImage()
.我假设您正在谈论
viewMatrix
pybullet.getCameraImage()
预期的 viewMatrix 。 This should indeed be a world-to-camera rotation matrix.这确实应该是一个世界到相机的旋转矩阵。
However, in pyBullet the camera is looking in negative z-direction while I usually expect it to be in positive one.然而,在 pyBullet 中,相机是在负 z 方向看,而我通常认为它是正方向。 I am compensating for this by adding a 180°-rotation around the x-axis:
我通过围绕 x 轴添加 180° 旋转来对此进行补偿:
rot_x_180 = np.array(
[
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1],
]
)
tf_mat = rot_x_180 @ tf_world_to_camera
view_matrix = tf_mat.flatten(order="F")
where tf_world_to_camera
is a homogeneous rotation matrix.其中
tf_world_to_camera
是齐次旋转矩阵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.