手术机器人手臂OpenGL的运动 [英] Movement of a surgical robot's arm OpenGL

查看:147
本文介绍了手术机器人手臂OpenGL的运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于OpenGL中外科手术机器人手臂运动的问题.

I have a question concerning surgical robot arm's movements in OpenGL.

我们的手臂由7个部件组成,这些部件应该是手臂的关节,它们负责弯曲和扭曲手臂.我们以这种方式绘制手臂:首先,创建负责像上下"那样移动肩膀的元素,然后使用Translatef移动"到绘制下一个负责扭转肩膀的元素的位置(我们使用Rotatef来控制运动,以此类推,然后使用下一个关节(肘部,腕部).

Our arm consists of 7 pieces that suppose to be the arm's joints and they are responsible for bending and twisting the arm. We draw the arm this way: first we create the element which is responsible for moving the shoulder like "up and down" and then we "move" using Translatef to the point in which we draw the next element, responsible for twisting the shoulder (we control the movement using Rotatef) and so on with the next joints (elbow, wrist).

关键是要制造出可以像人一样运动的手臂.我们的机制起作用了,但是现在我们的导师希望我们在手臂的末端画一条线.我们将负责绘制和移动手臂的代码放在push和pop矩阵之间,因此它的工作原理与实际类似,我的意思是,当我们移动除魂器时,arm中的任何其他元素也会移动.

The point is to create an arm that can make human-like movements. Our mechanism works, but now our tutor wants us to draw a line strip with the end of the arm. We put the code responsible for drawing and moving an arm between push and pop matrix, so it works like in real, I mean when we move the soulder, any other elements in arm also moves.

有许多元素在移动,旋转,我们有几个旋转矩阵附加到我们可以控制的不同元素上,现在我们不知道如何精确地找到手臂末端的新位置.可以向线带添加新点的空间.有人可以帮忙吗?

There is a lot of elements moving, rotating, we have a couple of rotate matrices that are attached to different elements which we can control and now we have no idea how to precisely find a new location of the end of an arm in space to be able to add a new point to a line strip. Anyone can help?

    glGetFloatv(GL_MODELVIEW_MATRIX,mvm2);

     x=mvm2[12];
     y=mvm2[13];
     z=mvm2[14];

     glPointSize(5.0f);
     glColor3f(1.0f, 0.0f, 0.0f);

     glBegin(GL_POINTS);
     glVertex3f(x,y,z);
     glEnd();

当我使用手表检查x,y,z值是什么时,我得到了(0,-1.16-12e,17.222222),这是不对的,因为我的手臂的长度约为9.0(在z轴上) ).我认为只有modelview矩阵的最后一列很重要,并且我不必通过顶点的局部坐标来对其进行修改,因为自从我在这里完成绘制以来,它们就是(0,0,0).

When I checked using watch what are the x,y,z values, I got (0,-1.16-12e,17.222222), what can't be true, as my arm has length about 9.0 (on z-axis). I think only the last column of modelview matrix is important and I don't have to muliply it by local coordinates of the vertex, as the they are (0,0,0) since I finish my drawning here.

推荐答案

如果应该使用glGetFloatv,则表示使用GL_MODELVIEW_MATRIX参数调用它,并返回当前模型视图矩阵.然后,您可以使用此矩阵将点从手的坐标系转换为世界空间CS.

If you're supposed to use glGetFloatv, then this refers to calling it with the GL_MODELVIEW_MATRIX argument, which returns the current model view matrix. You can then use this matrix to transform a point from the coordinate system of the hand to the world space CS.

但是,调用glGetFloatv是不好的做法,因为这可能会导致渲染性能下降.我认为您应该与您的导师谈谈教学过时甚至不推荐使用的功能,也许他可以请教授来更新材料.

However, calling glGetFloatv is bad practice, as it will probably result in reduced rendering performance. I think you should talk to your tutor about teaching outdated and even deprecated functionality, maybe he can get the prof to update the materials.

您获取翻译的代码正确.但是,您不能在应用相同的模型视图矩阵的情况下绘制点.绘制之前,必须使用glLoadIdentity或通过弹出来重置模型视图矩阵.

Your code for retrieving the translation is correct. However, you can't draw the point with the same model view matrix applied. Before drawing it, you have to reset the model view matrix with glLoadIdentity or by popping .

这篇关于手术机器人手臂OpenGL的运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆