我有一个 6 自由度机械臂模型:
我想计算正向运动学,所以我使用 DH 矩阵。DH参数为:
static const std::vector<float> theta = {
0,0,90.0f,0,-90.0f,0};
// d
static const std::vector<float> d = {
380.948f,0,0,-560.18f,0,0};
// a
static const std::vector<float> a = {
-220.0f,522.331f,80.0f,0,0,94.77f};
// alpha
static const std::vector<float> alpha = {
90.0f,0,90.0f,-90.0f,-90.0f,0};
和计算:
glm::mat4 Robothand::armForKinematics() noexcept
{
glm::mat4 pose(1.0f);
float cos_theta, sin_theta, cos_alpha, sin_alpha;
for (auto i = 0; i < 6;i++)
{
cos_theta = cosf(glm::radians(theta[i]));
sin_theta = sinf(glm::radians(theta[i]));
cos_alpha = cosf(glm::radians(alpha[i]));
sin_alpha = sinf(glm::radians(alpha[i]));
glm::mat4 Ai = {
cos_theta, -sin_theta * cos_alpha,sin_theta * sin_alpha, a[i] * cos_theta,
sin_theta, cos_theta * cos_alpha, -cos_theta * sin_alpha,a[i] * sin_theta,
0, sin_alpha, cos_alpha, d[i],
0, 0, 0, 1 };
pose = pose * Ai;
}
return pose;
}
我遇到的问题是,我无法得到正确的结果,例如,我想计算从第一个关节到第四个关节的变换矩阵,我将 for 循环更改 i < 3,然后我可以得到姿势矩阵,我可以通过姿势*(0,0,0,1)在第四坐标系中的原点坐标。但是结果(380.948,382.331,0)似乎不正确,因为它应该沿着x轴而不是y-移动轴。我已经阅读了很多关于 DH 矩阵的书籍和资料,但我无法弄清楚它有什么问题。