简体   繁体   English

使用 3d 变换矩阵

[英]Using 3d transformation matrices

In an AI class we have a robot that has an arm with 7 joints.在 AI class 中,我们有一个具有 7 个关节的 arm 的机器人。 Each joint can rotate a different direction.每个关节可以旋转不同的方向。 I need to know where the very end is going to be.我需要知道最后会在哪里。 I've been trying to do 3d matrix multiplication and it works for one joint but once I add in another it doesn't line up with a model I made using the Java3D api.我一直在尝试做 3d 矩阵乘法,它适用于一个关节,但是一旦我添加另一个关节,它就不会与我使用 Java3D Z8A5DA52ED126447D359E70C05721A 制作的 model 对齐。 This is how I'm trying to calculate the position of the second joint.这就是我试图计算第二个关节的 position 的方式。

double[][] b = {{0, 0, 0, 1}};

// Joint 1
b = HercMatrix.MatMul(b, HercMatrix.getTranslation(0, 0, -110));
b = HercMatrix.MatMul(b, HercMatrix.getRotation(0, arm.getJointAngle(0), 0));

// Joint 2
b = HercMatrix.MatMul(b, HercMatrix.getTranslation(0, 0, -250));
b = HercMatrix.MatMul(b, HercMatrix.getRotation(arm.getJointAngle(1), 0, 0));

System.out.println("Matrix: " + b[0][0] + ", " + b[0][1] + ", " + b[0][2]);

I imagine it's they way I go about applying the multiplications.我想这是我 go 关于应用乘法的方式。 I know for a fact it's not my matmul or matrice generation code, I've tested all that individually.我知道事实上这不是我的 matmul 或矩阵生成代码,我已经单独测试了所有这些。

the second translation I have needs to be on the relative x-axis of the first joint's angle.我的第二个平移需要在第一个关节角度的相对 x 轴上。 But I have no idea if this is how I do it...但我不知道这是否是我的做法......

Any help or ideas is greatly appreciated.非常感谢任何帮助或想法。

It's difficult to answer exactly without seeing the structure of your affine transformation matrices, and the definitions of the angle variables.如果没有看到仿射变换矩阵的结构和角度变量的定义,很难准确回答。 The normal definition of the translation matrix assumes the position vector is multiplied from the left, for example, which seems to be opposite to your use. 平移矩阵的正常定义假设 position 向量从左边相乘,例如,这似乎与您的使用相反。 Check also that b[0][3]==1 at the end.最后还要检查 b[0][3]==1 。

You code seems to be equivalent to the following pseudocode:您的代码似乎等同于以下伪代码:

b = origin.translate(Joint1).rotate(Joint1).translate(Joint2).rotate(Joint2);

This is not equivalent to这不等于

b = origin.translate(Joint2).rotate(Joint2).translate(Joint1).rotate(Joint1);

so check which order of transformations you require.所以检查你需要的转换顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM