使用 3d 变换矩阵
在人工智能课程中,我们有一个机器人,它的手臂有 7 个关节。 每个关节可以向不同的方向旋转。 我需要知道最后的结局在哪里。 我一直在尝试进行 3d 矩阵乘法,它适用于一个关节,但一旦我添加另一个关节,它就与我使用 Java3D api 制作的模型不相符。 这就是我试图计算第二个关节位置的方法。
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]);
我想这就是我应用乘法的方式。 我知道事实上这不是我的 matmul 或矩阵生成代码,我已经单独测试了所有这些代码。
我的第二个平移需要位于第一个关节角度的相对 x 轴上。 但我不知道这是否是我的做法......
非常感谢任何帮助或想法。
In an AI class we have a robot that has an arm with 7 joints. 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. This is how I'm trying to calculate the position of the second joint.
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. I know for a fact it's not my matmul or matrice generation code, I've tested all that individually.
the second translation I have needs to be on the relative x-axis of the first joint's angle. But I have no idea if this is how I do it...
Any help or ideas is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不了解仿射变换矩阵的结构以及角度变量的定义,很难准确回答。 平移矩阵的正常定义假设位置向量乘以例如,向左,这似乎与您的使用相反。 还要检查最后的 b[0][3]==1 。
您的代码似乎等同于以下伪代码:
这不等同于
因此请检查您需要的转换顺序。
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. Check also that b[0][3]==1 at the end.
You code seems to be equivalent to the following pseudocode:
This is not equivalent to
so check which order of transformations you require.