本工程借助于clion配置的qt环境,同时依赖eigen tinyxml2等开源库,也借鉴了博客上一些文章,具体哪些忘记了,十分抱歉。本工程仅供参考。机械臂模型为史陶比尔官网的TX2-60L-HB。可以去那下载对应的stp文件。
最终图:
通过鼠标中键控制旋转 缩放,配合ctrl进行平移。加载模型文件路径是xml文件:书写类似于这种
<?xml version="1.0" encoding="UTF-8"?>
<root><Joint>../Mo/1.STL</Joint><Joint>../Mo/2.STL</Joint><Joint>../Mo/3.STL</Joint><Joint>../Mo/4.STL</Joint><Joint>../Mo/5.STL</Joint><Joint>../Mo/6.STL</Joint><Joint>../Mo/7.STL</Joint><Joint>../Mo/1.STL</Joint>
</root>
单独于机械臂模型之外的为环境模型(示意一下)设置目标关节值控制机器人当前关节。到机器人坐标系转换矩阵为环境模型到机械臂基坐标的转换矩阵。
代码十分粗糙。
robot_body_load.h
#ifndef NEWTRAVEL_ROBOT_BODY_LOAD_H
#define NEWTRAVEL_ROBOT_BODY_LOAD_H//#include "glew.h"
#include <QMatrix3x3>
#include <QMatrix4x4>
#include <QOpenGLBuffer>
#include <QOpenGLExtraFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget>
#include <QQuaternion>
#include <QStringList>
#include <QTime>
#include <QTimer>
#include <QVector2D>
#include <QVector>
#include "robot_camera.h"#include "Log/log.h"struct JointParameters
{QVector<float> vecJoint; // joint positionQOpenGLVertexArrayObject vaoJoint; //声明VAO顶点数组对象QOpenGLBuffer vboJoint; //声明VBO数组缓冲对象GLsizei iNumberOfTriangle;
};class RobotBody : public QOpenGLWidget, public QOpenGLExtraFunctions
{Q_OBJECTpublic:RobotBody(QWidget *parent = nullptr);~RobotBody();protected:void initializeGL() override;void paintGL() override;void resizeGL(int w, int h) override;public:void loadAscllStl(const QString& filename, int ratio, JointParameters &oJointPara); //文件名和放大系数void SetDrawParameters(JointParameters &oJointPara);void mousePressEvent(QMouseEvent *event) override;void mouseMoveEvent(QMouseEvent *event) override;void wheelEvent(QWheelEvent *event) override;void InitialTranslate();void SetRobotRotation(int iJointIndex);private:bool ReadXml(std::vector<std::string> &vecNodePath);void SetJointValue();public Q_SLOTS:void SetRotationAngleOfJoint_0(double value);void SetRotationAngleOfJoint_1(double value);void SetRotationAngleOfJoint_2(double value);void SetRotationAngleOfJoint_3(double value);void SetRotationAngleOfJoint_4(double value);void SetRotationAngleOfJoint_5(double value);
public Q_SLOTS:void SetFilePath(const QString &sFilePath);void setTargetJoints(const QString &sTrans);void SetTargetJointDegreeFlag(bool bDegreeFlag);void SetOtherModelTransform(QMatrix4x4 mat4Transform);void SetUnitOfLength(bool bIsMillimeter);
signals :void SetRotationOfJoint_0(double dValue);void SetRotationOfJoint_1(double dValue);void SetRotationOfJoint_2(double dValue);void SetRotationOfJoint_3(double dValue);void SetRotationOfJoint_4(double dValue);void SetRotationOfJoint_5(double dValue);
private:JointParameters m_aJointModel[9];QVector<float> Position;QVector<float> Normal; //读文件时的俩个临时变量顶点位置,法向量QOpenGLShaderProgram shaderprogram;QMatrix4x4 view;QMatrix4x4 projection;QVector2D mousePos;QVector2D mousePosForTranslationView;QQuaternion rotation;QMatrix4x4 Rot;QMatrix4x4 m_matJointTrans[9];QMatrix4x4 m_matJointRot[7];QVector<float> m_vecRotDegree;std::map<int, QVector3D> m_mapRotVector;QVector3D m_v3dCamera;qreal alpha;qreal theta;double m_dEyeToModelDistance;QVector2D m_v2cMove;RobotCamera m_oRobotCamera;bool m_bIsFile;QString m_sXmlFile;bool m_bTargetJointRadianFlag;bool m_bMillimeterFlag;};
#endif // NEWTRAVEL_ROBOT_BODY_LOAD_H
robot_body_load.cpp
#include "robot_body_load.h"
#include "Configure/configure_base.h"
#include <QFile>
#include <QMouseEvent>
#include <QOpenGLShaderProgram>
#include <QStringList>RobotBody::RobotBody(QWidget *parent): QOpenGLWidget(parent), alpha(0.0), theta(0.0), m_dEyeToModelDistance(0.00), m_v2cMove(0.0, 0.0)
{QSurfaceFormat format;format.setAlphaBufferSize(24); //设置alpha缓冲大小format.setVersion(3, 3); //设置版本号format.setSamples(10); //设置重采样次数,用于反走样m_bIsFile = false;m_bTargetJointRadianFlag = false;m_bMillimeterFlag = true;this->setFormat(format);// Set Joint rotationQVector3D qRotVector(0, -1, 0);m_mapRotVector[0] = qRotVector;qRotVector = {0, 0, 1};m_mapRotVector[1] = qRotVector;qRotVector = {0, 0, 1};m_mapRotVector[2] = qRotVector;qRotVector = {0, 0, 1};m_mapRotVector[3] = qRotVector;qRotVector = {0, 0, 1};m_mapRotVector[4] = qRotVector;qRotVector = {0, 0, 1};m_mapRotVector[5] = qRotVector;m_vecRotDegree.resize(6);for (float &ii : m_vecRotDegree){ii = 0.0;}Rot.setToIdentity();m_v3dCamera = QVector3D(2, 0, 0.5);mousePosForTranslationView = QVector2D(0.0, 0.0);// External import fixed modelm_matJointTrans[7].setToIdentity();m_matJointTrans[7].translate(0, -1, 0);m_matJointTrans[8].setToIdentity();
}RobotBody::~RobotBody()
{makeCurrent();
}void RobotBody::loadAscllStl(const QString &filename, int ratio, JointParameters &oJointPara)
{ZLOG << "load text file " << filename.toStdString();QFile file(filename);if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ZLOG << "Open stl_file failed.";return;}while (!file.atEnd()){QString line = file.readLine().trimmed(); // trimmed去除了开头和结尾的空白字符串QStringList words = line.split(' ', QString::SkipEmptyParts);if (words[0] == "facet"){Normal = {ratio * words[2].toFloat(), ratio * words[3].toFloat(), ratio * words[4].toFloat()};}else if (words[0] == "vertex"){Position = {ratio * words[1].toFloat(), ratio * words[2].toFloat(), ratio * words[3].toFloat()};oJointPara.vecJoint.append(Position);oJointPara.vecJoint.append(Normal);}else{continue;}}ZLOG << "write vertice_temp success!";file.close();oJointPara.iNumberOfTriangle = oJointPara.vecJoint.size()/6;
}void RobotBody::SetDrawParameters(JointParameters &oJointPara)
{oJointPara.vaoJoint.create(); // 创建一个VAO对象,OpenGL会给它(顶点数组缓存对象)分配一个idoJointPara.vaoJoint.bind(); //将RC中的当前顶点数组缓存对象Id设置为VAO的idoJointPara.vboJoint.create();oJointPara.vboJoint.bind();oJointPara.vboJoint.allocate(oJointPara.vecJoint.data(),sizeof(float) *oJointPara.vecJoint.size()); //将顶点数据分配到VBO中,第一个参数为数据指针,第二个参数为数据的字节长度shaderprogram.setAttributeBuffer("aPos", GL_FLOAT, 0, 3, sizeof(GLfloat) * 6);shaderprogram.enableAttributeArray("aPos");shaderprogram.setAttributeBuffer("aNormal", GL_FLOAT, sizeof(GLfloat) * 3, 3, sizeof(GLfloat) * 6);shaderprogram.enableAttributeArray("aNormal");this->glEnable(GL_DEPTH_TEST);oJointPara.vaoJoint.release(); //释放oJointPara.vboJoint.release();
}void RobotBody::initializeGL()
{this->initializeOpenGLFunctions(); //初始化opengl函数shaderprogram.create(); //生成着色器程序const char *vertexShaderSource ="#version 330 core \n""layout (location = 0) in vec3 aPos; \n""layout (location = 1) in vec3 aNormal; \n""uniform mat4 view;\n""uniform mat4 projection;\n""uniform vec2 v2dMove;\n""uniform mat4 baseTrans;\n""uniform mat4 Rot;\n""out vec3 FragPos;\n""out vec3 Normal;\n""void main()\n""{\n""gl_Position = Rot * projection * view * baseTrans * vec4(aPos[0] ,aPos[1] , aPos[2],1.0);\n""Normal = vec3(baseTrans * vec4(aNormal,1.0));\n""FragPos = vec3(vec4(aPos, 1.0));\n""}\0";// 片段着色器const char *fragmentShaderSource = "#version 330 core\n""out vec4 FragColor;\n""uniform vec3 objectColor;\n""uniform vec3 lightColor;\n""in vec3 FragPos;\n""in vec3 Normal;\n""uniform vec3 lightPos;\n""void main()\n""{\n""float ambientStrength = 0.05;\n""vec3 ambient = ambientStrength * lightColor;\n""vec3 norm = normalize(Normal);\n""vec3 lightDir = normalize(lightPos - FragPos);\n""float diff = max(dot(norm, lightDir), 0.0);\n""vec3 diffuse = diff * lightColor;\n""vec3 result = (ambient + diffuse) * objectColor;\n""FragColor = vec4(result, 1.0);\n""}\n\0";shaderprogram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);shaderprogram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);//将添加到此程序的着色器与addshader链接在一起if (!shaderprogram.link()){ZLOG << "ERROR: link error"; //如果链接出错,打印报错信息}
}void RobotBody::resizeGL(int w, int h)
{this->glViewport(0, 0, w, h);projection.setToIdentity();projection.perspective(60.0f, (GLfloat)w / (GLfloat)h, 0.001f, 500.0f);
}void RobotBody::paintGL()
{this->glClearColor(0.9f, 0.94f, 1.0f, 1.0f); //设置清屏颜色this->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清空颜色缓冲区if (m_bIsFile){std::vector<std::string> sPath;if (ReadXml(sPath)){for (size_t ii = 0; ii < sPath.size(); ++ii){loadAscllStl(sPath[ii].c_str(), 1, m_aJointModel[ii]);ZLOG << sPath[ii];}for (auto &ii : m_aJointModel){SetDrawParameters(ii);}m_bIsFile = false;}}shaderprogram.bind();//将此着色器程序绑定到活动的qopenglcontext,并使其成为当前着色器程序。任何先前绑定的着色器程序都将被释放//成功绑定返回ture,反之,返回false.{QVector3D lightColor(1.0f, 1.0f, 1.0f);QVector3D objectColor(1.0f, 0.5f, 0.31f);QVector3D lightPos(m_oRobotCamera.NewEye->x(), m_oRobotCamera.NewEye->y(), m_oRobotCamera.NewEye->z());GLfloat mat_ambient[] = {0.0f, 0.0f, 0.2f, 1.0f};glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);view.setToIdentity();view.lookAt(QVector3D(m_oRobotCamera.NewEye->x(), m_oRobotCamera.NewEye->y(), m_oRobotCamera.NewEye->z()),QVector3D(m_oRobotCamera.NewView->x(), m_oRobotCamera.NewView->y(), m_oRobotCamera.NewView->z()),QVector3D(m_oRobotCamera.NewUp->x(), m_oRobotCamera.NewUp->y(), m_oRobotCamera.NewUp->z()));shaderprogram.setUniformValue("objectColor", objectColor);shaderprogram.setUniformValue("lightColor", lightColor);shaderprogram.setUniformValue("lightPos", lightPos);Rot.translate(m_v2cMove.x(), -m_v2cMove.y(), 0);m_v2cMove = QVector2D(0, 0);shaderprogram.setUniformValue("Rot", Rot);shaderprogram.setUniformValue("view", view);projection.translate(0.0, 0.0, m_dEyeToModelDistance);m_dEyeToModelDistance = 0.0;shaderprogram.setUniformValue("projection", projection);InitialTranslate();for (int ii = 0; ii < 6; ii++){SetRobotRotation(ii);shaderprogram.setUniformValue("baseTrans", m_matJointTrans[ii]);m_aJointModel[ii].vaoJoint.bind();this->glDrawArrays(GL_TRIANGLES, 0, m_aJointModel[ii].iNumberOfTriangle);}shaderprogram.setUniformValue("baseTrans", m_matJointTrans[6]);m_aJointModel[6].vaoJoint.bind();this->glDrawArrays(GL_TRIANGLES, 0, m_aJointModel[6].iNumberOfTriangle);shaderprogram.setUniformValue("baseTrans", m_matJointTrans[7]);m_aJointModel[7].vaoJoint.bind();this->glDrawArrays(GL_TRIANGLES, 0, m_aJointModel[7].iNumberOfTriangle);shaderprogram.setUniformValue("baseTrans", m_matJointTrans[8]);m_aJointModel[8].vaoJoint.bind();this->glDrawArrays(GL_LINES, 0, m_aJointModel[8].iNumberOfTriangle);}
}void RobotBody::InitialTranslate()
{m_matJointTrans[0].setToIdentity();m_matJointTrans[1].setToIdentity();m_matJointTrans[1].translate(0, 0, 0.375);m_matJointTrans[1].rotate(-90, 1, 0, 0);m_matJointTrans[2].setToIdentity();m_matJointTrans[3].setToIdentity();m_matJointTrans[3].translate(0, -0.4, 0.02);m_matJointTrans[4].setToIdentity();m_matJointTrans[4].rotate(90, 1, 0, 0);m_matJointTrans[5].setToIdentity();m_matJointTrans[5].translate(0, 0, 0.45);m_matJointTrans[5].rotate(-90, 1, 0, 0);m_matJointTrans[6].setToIdentity();m_matJointTrans[6].translate(0, -0.07, 0.0);m_matJointTrans[6].rotate(90, 1, 0, 0);}void RobotBody::SetRobotRotation(int iJointIndex)
{m_matJointRot[iJointIndex].setToIdentity();m_matJointRot[iJointIndex].rotate(m_vecRotDegree[iJointIndex], m_mapRotVector[iJointIndex]);m_matJointTrans[iJointIndex + 1] =m_matJointTrans[iJointIndex] * m_matJointTrans[iJointIndex + 1] * m_matJointRot[iJointIndex];
}void RobotBody::mousePressEvent(QMouseEvent *event)
{mousePos = QVector2D(event->pos());m_oRobotCamera.getInitPos(event->x(), event->y());
}void RobotBody::mouseMoveEvent(QMouseEvent *event)
{if (event->buttons() & Qt::MiddleButton){if (event->modifiers() == Qt::CTRL){QVector2D newPos = (QVector2D)event->pos();m_v2cMove = (newPos - mousePos) / 500;mousePos = newPos;}else{m_oRobotCamera.executeRotateOperation(event->x(), event->y());}}this->update();
}void RobotBody::wheelEvent(QWheelEvent *event)
{if (event->delta() >= 0){m_dEyeToModelDistance = 0.1f;}else{m_dEyeToModelDistance = -0.1f;}this->update();
}void RobotBody::SetRotationAngleOfJoint_0(double value)
{InitialTranslate();m_vecRotDegree[0] = (float)value;SetRobotRotation(0);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetRotationAngleOfJoint_1(double value)
{InitialTranslate();m_vecRotDegree[1] = (float)value;SetRobotRotation(1);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetRotationAngleOfJoint_2(double value)
{InitialTranslate();m_vecRotDegree[2] = (float)value;SetRobotRotation(2);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetRotationAngleOfJoint_3(double value)
{InitialTranslate();m_vecRotDegree[3] = (float)value;SetRobotRotation(3);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetRotationAngleOfJoint_4(double value)
{InitialTranslate();m_vecRotDegree[4] = (float)value;SetRobotRotation(4);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetRotationAngleOfJoint_5(double value)
{InitialTranslate();m_vecRotDegree[5] = (float)value;SetRobotRotation(5);m_v2cMove = QVector2D(0, 0);m_dEyeToModelDistance = 0.0;update();
}void RobotBody::SetFilePath(const QString &sFilePath)
{m_sXmlFile = sFilePath;ZLOG << "The path is: " << sFilePath.toStdString();m_bIsFile = true;update();
}bool RobotBody::ReadXml(std::vector<std::string> &vecNodePath)
{LoadConfigre oConfig;oConfig.ReadXML(m_sXmlFile.toStdString());std::string sNodePath = "/Joint";int iCount = oConfig.GetCountBrotherElement(sNodePath);std::string sResult;for (int ii = 0; ii < iCount; ++ii){ZLOG << "sNodePath: " << sNodePath + "[" + std::to_string(ii) + "]";if (!oConfig.GetElementValue(sNodePath + "[" + std::to_string(ii) + "]", sResult)){ZLOG << "Failed to load xml " << sNodePath;return false;}vecNodePath.push_back(sResult);}return true;
}void RobotBody::setTargetJoints(const QString &sTrans)
{std::string sTargetJoint = sTrans.toStdString();ZLOG << "The path is: " << sTargetJoint;int iIndex = sTargetJoint.find(',');int iCount = 0;while (std::string::npos != iIndex){std::string sJointValue = sTargetJoint.substr(0, sTargetJoint.find(','));m_vecRotDegree[iCount] = strtod(sJointValue.c_str(), nullptr);iCount++;sTargetJoint = sTargetJoint.substr(sTargetJoint.find(',') + 1, std::string::npos);iIndex = sTargetJoint.find(',');}m_vecRotDegree[5] = strtod(sTargetJoint.c_str(), nullptr);if (m_bTargetJointRadianFlag){for (int ii = 0; ii < m_vecRotDegree.size(); ++ii){double dDegree = m_vecRotDegree[ii] * 180 / 3.1415926;m_vecRotDegree[ii] = dDegree;}}SetJointValue();
}void RobotBody::SetJointValue()
{emit SetRotationOfJoint_0(m_vecRotDegree[0]);emit SetRotationOfJoint_1(m_vecRotDegree[1]);emit SetRotationOfJoint_2(m_vecRotDegree[2]);emit SetRotationOfJoint_3(m_vecRotDegree[3]);emit SetRotationOfJoint_4(m_vecRotDegree[4]);emit SetRotationOfJoint_5(m_vecRotDegree[5]);
}
void RobotBody::SetTargetJointDegreeFlag(bool bDegreeFlag)
{m_bTargetJointRadianFlag = bDegreeFlag;ZLOG << " Degree flag is " << m_bTargetJointRadianFlag;
}void RobotBody::SetOtherModelTransform(QMatrix4x4 mat4Tansform)
{if (mat4Tansform(3,0) != 1){QVector4D vecPos;if (m_bMillimeterFlag){vecPos[0] = mat4Tansform(0, 3)/1000;vecPos[1] = mat4Tansform(1, 3)/1000;vecPos[2] = mat4Tansform(2, 3)/1000;vecPos[3] = 1;mat4Tansform.setColumn(3,vecPos);}m_matJointTrans[7] = mat4Tansform;ZLOG << "TransForm is: " << mat4Tansform(0, 0) << ", " << mat4Tansform(1, 1) << ", " << mat4Tansform(1, 2) << ", "<< mat4Tansform(0, 3);ZLOG << "TransForm is: " << mat4Tansform(1, 0) << ", " << mat4Tansform(2, 1) << ", " << mat4Tansform(2, 2) << ", "<< mat4Tansform(1, 3);ZLOG << "TransForm is: " << mat4Tansform(2, 0) << ", " << mat4Tansform(2, 1) << ", " << mat4Tansform(2, 2) << ", "<< mat4Tansform(2, 3);update();}
}
void RobotBody::SetUnitOfLength(bool bIsMillimeter)
{m_bMillimeterFlag = bIsMillimeter;
}
robot_camera.h
#ifndef NEWTRAVEL_ROBOT_CAMERA_H
#define NEWTRAVEL_ROBOT_CAMERA_H#include "Eigen/Eigen"
#include <iostream>class RobotCamera
{public:RobotCamera(){OldMouse = new Eigen::Vector2d(0,0);Mouse = new Eigen::Vector2d(0,0);NewEye = new Eigen::Vector3d(2, 0, 0.5);NewUp = new Eigen::Vector3d(0, 0, 1);NewView = new Eigen::Vector3d(0, 0, 0.5);AuxY = new Eigen::Vector3d(0, 1, 0);AuxZ = new Eigen::Vector3d();*AuxZ = *NewEye - *NewView;AuxX = new Eigen::Vector3d();*AuxX = (*AuxY).cross(*AuxZ);AuxX->normalize();}Eigen::Matrix<double, 3, 3> getRotateMatrix(float angle, const Eigen::Vector3d &vector){angle = angle / 2 * M_PI / 180;Eigen::Vector3d vec = vector.normalized();float cosa = cos(angle);float sina = sin(angle);double a = vec.x() * sina;double b = vec.y() * sina;double c = vec.z() * sina;Eigen::Matrix<double, 3, 3> matrix;matrix(0, 0) = 1.0 - 2.0 * (b * b + c * c);matrix(1, 1) = 1.0 - 2.0 * (c * c + a * a);matrix(2, 2) = 1.0 - 2.0 * (a * a + b * b);matrix(0, 1) = 2.0 * (a * b - c * cosa);matrix(0, 2) = 2.0 * (a * c + b * cosa);matrix(1, 0) = 2.0 * (a * b + c * cosa);matrix(1, 2) = 2.0 * (b * c - a * cosa);matrix(2, 0) = 2.0 * (a * c - b * cosa);matrix(2, 1) = 2.0 * (b * c + a * cosa);return matrix;}void getInitPos(int x, int y){Mouse->x() = x;Mouse->y() = y;*OldMouse = *Mouse;}void executeRotateOperation(int x, int y){Mouse->x() = x;Mouse->y() = y;Eigen::Vector3d MouseTrace = *AuxY * (OldMouse->y() - Mouse->y()) + *AuxX * (Mouse->x() - OldMouse->x());Eigen::Vector3d RotateAsix = MouseTrace.cross(*AuxZ);RotateAsix.normalize();float angle = MouseTrace.norm();Eigen::Matrix<double, 3, 3> rotatMatrix = getRotateMatrix(angle, RotateAsix);*NewEye = rotatMatrix * (*NewEye);*NewUp = rotatMatrix * (*NewUp);NewUp->normalized();*AuxY = *NewUp;*AuxZ = *NewEye - *NewView;*AuxX = (*AuxY).cross(*AuxZ);AuxX->normalize();*OldMouse = *Mouse;}//旋转后观察点方向与视线向上方向Eigen::Vector3d *NewEye;Eigen::Vector3d *NewUp;Eigen::Vector3d *NewView;private://辅助坐标系三根轴Eigen::Vector3d *AuxX;Eigen::Vector3d *AuxY;Eigen::Vector3d *AuxZ;Eigen::Vector2d *OldMouse;Eigen::Vector2d *Mouse;
};#endif // NEWTRAVEL_ROBOT_CAMERA_H
robot_joint_degree_control_slider.cpp
#include "robot_joint_degree_control_slider.h"RobotJointDegreeControlSlider::RobotJointDegreeControlSlider(QWidget *parent) : QSlider(parent), m_Multiplier(10000.0)
{connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));setSingleStep(1);setOrientation(Qt::Horizontal);setFocusPolicy(Qt::NoFocus);
}RobotJointDegreeControlSlider::~RobotJointDegreeControlSlider() noexcept {}void RobotJointDegreeControlSlider::Initial(int iIndex)
{setMaximum(180);setMinimum(-180);setOrientation(Qt::Horizontal);resize(260, 30);move(920, iIndex * 40 + 10);setSingleStep(5);show();
}int RobotJointDegreeControlSlider::GetCurrent()
{int iValue = value();std::cout << iValue << std::endl;return iValue;
}void RobotJointDegreeControlSlider::setValue(int Value)
{emit valueChanged((double)Value / m_Multiplier);
}void RobotJointDegreeControlSlider::setValue(double Value, bool BlockSignals)
{QSlider::blockSignals(BlockSignals);QSlider::setValue(Value * m_Multiplier);if (!BlockSignals)emit valueChanged(Value);QSlider::blockSignals(false);
}void RobotJointDegreeControlSlider::setRange(double Min, double Max)
{QSlider::setRange(Min * m_Multiplier, Max * m_Multiplier);emit rangeChanged(Min, Max);
}void RobotJointDegreeControlSlider::setMinimum(double Min)
{QSlider::setMinimum(Min * m_Multiplier);emit rangeChanged(minimum(), maximum());
}double RobotJointDegreeControlSlider::minimum() const
{return QSlider::minimum() / m_Multiplier;
}void RobotJointDegreeControlSlider::setMaximum(double Max)
{QSlider::setMaximum(Max * m_Multiplier);emit rangeChanged(minimum(), maximum());
}double RobotJointDegreeControlSlider::maximum() const
{return QSlider::maximum() / m_Multiplier;
}double RobotJointDegreeControlSlider::value() const
{int Value = QSlider::value();return (double)Value / m_Multiplier;
}
robot_joint_degree_control_slider.h
#ifndef NEWTRAVEL_ROBOT_JOINT_DEGREE_CONTROL_SLIDER_H
#define NEWTRAVEL_ROBOT_JOINT_DEGREE_CONTROL_SLIDER_H#include <QSlider>
#include <iostream>
#include <QtGui/QtGui>class RobotJointDegreeControlSlider : public QSlider
{
Q_OBJECT
public:RobotJointDegreeControlSlider(QWidget *parent = nullptr);~RobotJointDegreeControlSlider();void setRange(double Min, double Max);void setMinimum(double Min);double minimum() const;void setMaximum(double Max);double maximum() const;double value() const;public slots:void setValue(int value);void setValue(double Value, bool BlockSignals = false);private slots:signals :void valueChanged(double Value);void rangeChanged(double Min, double Max);private:double m_Multiplier;
public:void Initial(int iIndex);int GetCurrent();};#endif // NEWTRAVEL_ROBOT_JOINT_DEGREE_CONTROL_SLIDER_H
robot_joint_degree_spinbox.cpp
#include "robot_joint_degree_spinbox.h"RobotJointSpinBox::RobotJointSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
{
}RobotJointSpinBox::~RobotJointSpinBox() noexcept {}void RobotJointSpinBox::Initial(int iIndex)
{resize(50, 30);move(860, iIndex * 40 + 10);setMinimum(-180);setMaximum(180);setSingleStep(1);show();
}void RobotJointSpinBox::SetLimitValue(double iMaxValue,double iMinValue,double iStep)
{setMaximum(iMaxValue);setMinimum(iMinValue);setSingleStep(iStep);setValue(0);
}
robot_joint_degree_spinbox.h
#ifndef NEWTRAVEL_ROBOT_JOINT_DEGREE_SPINBOX_H
#define NEWTRAVEL_ROBOT_JOINT_DEGREE_SPINBOX_H#include <QSpinBox>
#include <QTextEdit>class RobotJointSpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:RobotJointSpinBox(QWidget *parent = nullptr);~RobotJointSpinBox();public:void Initial(int iIndex);void SetLimitValue(double iMaxValue,double iMinValue,double iStep);
};#endif // NEWTRAVEL_ROBOT_JOINT_DEGREE_SPINBOX_H
robot_joint_label.cpp
#include "robot_joint_label.h"RobotJointLabel::RobotJointLabel(QWidget *parent) : QLabel(parent) {}RobotJointLabel::~RobotJointLabel() noexcept = default;void RobotJointLabel::Initial(int iIndex)
{
// move(800, iIndex * 40 + 10);
// resize(50, 30);setText(QString::fromStdString("Joint_" + std::to_string(iIndex)));
// show();
}
robot_joint_label.h
#ifndef NEWTRAVEL_ROBOT_JOINT_LABEL_H
#define NEWTRAVEL_ROBOT_JOINT_LABEL_H#include <QLabel>
#include <iostream>class RobotJointLabel : public QLabel
{
Q_OBJECT
public:RobotJointLabel(QWidget *parent = nullptr);~RobotJointLabel();public:void Initial(int iIndex);};#endif // NEWTRAVEL_ROBOT_JOINT_LABEL_H
robot_main.cpp
#include "ui_robot_simulation_platform.h"
#include "simulation.h"int main(int argc, char *argv[])
{QApplication a(argc, argv);Ui::RobotSimulation w;w.show();return a.exec();
}
robot_other_model_transform.cpp
#include "robot_other_model_transform.h"
#include "Log/log.h"
OtherModelTrans::OtherModelTrans(QWidget *parent) : QTextEdit(parent) {}void OtherModelTrans::SetValue()
{emitValue();
}void OtherModelTrans::emitValue()
{QString sValue = toPlainText();ZLOG << sValue.toStdString();std::string sTransValue = sValue.toStdString();QMatrix4x4 mat4Trans;mat4Trans.setToIdentity();QVector<std::string> vecRPY;std::string sRPY = sTransValue.substr(sTransValue.find('{'),std::string::npos);int iRPYIndex = sRPY.find('{');while (std::string::npos != iRPYIndex){std::string sRPYValue = sRPY.substr(iRPYIndex + 1,sRPY.find_first_of('}') - iRPYIndex - 1);vecRPY.push_back(sRPYValue);sRPY = sRPY.substr(sRPY.find_first_of('}') + 1 ,std::string::npos);iRPYIndex = sRPY.find('{');}QVector4D vecRot;for (int i = 0; i < vecRPY.size(); ++i){size_t iRPYIndex = vecRPY[i].find(',');int iIndex = 0;while (std::string::npos != iRPYIndex){std::string sPPYValue = vecRPY[i].substr(0,iRPYIndex);vecRot[iIndex] = (strtod(sPPYValue.c_str(), nullptr));vecRPY[i] = vecRPY[i].substr(iRPYIndex + 1,std::string::npos);iRPYIndex = vecRPY[i].find(',');iIndex ++ ;}vecRot[iIndex] = (strtod(vecRPY[i].c_str(), nullptr));mat4Trans.setColumn(i,vecRot);}QVector4D vecPose;if(std::string::npos != sTransValue.find("Vector3D(")){int iInd = 0;int iIndex = sTransValue.find("Vector3D(") + 9;std::string sPos = sTransValue.substr(iIndex,sTransValue.find_first_of(')') - iIndex);size_t iCount = sPos.find(',');while (std::string::npos != iCount){std::string sPoseValue = sPos.substr(0,iCount);vecPose[iInd] = (strtod(sPoseValue.c_str(), nullptr));sPos = sPos.substr(iCount + 1,std::string::npos);iCount = sPos.find(',');iInd++;}vecPose[iInd] = (strtod(sPos.c_str(), nullptr));vecPose[3] = 1;}mat4Trans.setColumn(3,vecPose);emit SetValue(mat4Trans);
}OtherModelTrans::~OtherModelTrans() {}
robot_other_model_transform.h
#ifndef NEWTRAVEL_ROBOT_OTHER_MODEL_TRANSFORM_H
#define NEWTRAVEL_ROBOT_OTHER_MODEL_TRANSFORM_H#include <QtWidgets/QTextEdit>
#include <QMatrix4x4>class OtherModelTrans : public QTextEdit
{
Q_OBJECT
public:OtherModelTrans(QWidget *parent = nullptr);~OtherModelTrans() override;signals :void SetValue(QMatrix4x4 oFilePath);
public Q_SLOTS:void SetValue();
public:void emitValue();
};#endif // NEWTRAVEL_ROBOT_OTHER_MODEL_TRANSFORM_H
robot_pushbutton_openfile.cpp
#include "robot_pushbutton_openfile.h"OpenFile::OpenFile(FileDialog *pFileDialog,QWidget *parent) : QPushButton(parent)
{m_pQFileDialog = pFileDialog;
}OpenFile::~OpenFile() {}
robot_pushbutton_openfile.h
#ifndef NEWTRAVEL_ROBOT_PUSHBUTTON_OPENFILE_H
#define NEWTRAVEL_ROBOT_PUSHBUTTON_OPENFILE_H#include <QtWidgets/QPushButton>
#include "robot_qfile_dialog.h"
#include <iostream>
class OpenFile : public QPushButton
{
Q_OBJECT
public:OpenFile(FileDialog *pFileDialog,QWidget *parent = nullptr);~OpenFile();void mousePressEvent(QMouseEvent *event) override{openfile();}void openfile(){QString strFileName = FileDialog::getOpenFileName(this, "Open File", "",tr("XML(*.xml)"), nullptr, QFileDialog::DontResolveSymlinks);strFileName = QDir::toNativeSeparators(strFileName);if (!strFileName.isEmpty()){m_pQFileDialog->SetPath(strFileName);std::cout << "strFileName : " << strFileName.toStdString() <<std::endl;}}private:FileDialog *m_pQFileDialog;
};#endif // NEWTRAVEL_ROBOT_PUSHBUTTON_OPENFILE_H
robot_pushbutton_send_message.cpp
#include "robot_pushbutton_send_message.h"SendButton::SendButton(QWidget*parent):QPushButton(parent){}SendButton::~SendButton() {}void SendButton::mousePressEvent(QMouseEvent *event)
{emit SendMessage();
}
robot_pushbutton_send_message.h
#ifndef NEWTRAVEL_ROBOT_PUSHBUTTON_SEND_MESSAGE_H
#define NEWTRAVEL_ROBOT_PUSHBUTTON_SEND_MESSAGE_H#include "robot_target_joint.h"
#include <QtWidgets/QPushButton>class SendButton : public QPushButton
{Q_OBJECT
public:SendButton(QWidget *parent = nullptr);~SendButton();void mousePressEvent(QMouseEvent *event) override;
signals :void SendMessage();
};
#endif // NEWTRAVEL_ROBOT_PUSHBUTTON_SEND_MESSAGE_H
robot_qfile_dialog.cpp
#include "robot_qfile_dialog.h"FileDialog::FileDialog(QWidget *parent):QFileDialog(parent)
{
// connect(this, SIGNAL(fileSelected(QString)), this, SLOT(SetPath(QString)));
}FileDialog::~FileDialog()
{
}
void FileDialog::emitSelectFile(QString oFilePath)
{{}
}
void FileDialog::SetPath(QString sPath)
{emit fileSelected(sPath);
}
robot_qfile_dialog.h
#ifndef NEWTRAVEL_ROBOT_QFILE_DIALOG_H
#define NEWTRAVEL_ROBOT_QFILE_DIALOG_H#include <QtWidgets/QFileDialog>class FileDialog : public QFileDialog
{Q_OBJECT
public:explicit FileDialog(QWidget *parent = nullptr);~FileDialog() override;
public Q_SLOTS:void SetPath(QString sPath);
signals :void fileSelected(QString oFilePath);public:void emitSelectFile(QString oFilePath);};#endif // NEWTRAVEL_ROBOT_QFILE_DIALOG_H
robot_simulation.cpp
#include "robot_simulation.h"
#include "robot_simulation_main_platform.h"RobotSimulationPlatform::RobotSimulationPlatform(QWidget *parent) : QWidget(parent), ui(new Ui::RobotSimulation)
{ui->setupUi(this);m_pWidget = new RobotBody(this);m_pWidget->resize(800,600);m_pWidget->show();for (int ii = 0; ii < 6; ++ii){m_pRobotJointLabel[ii] = new RobotJointLabel(this);m_pRobotJointLabel[ii]->Initial(ii);m_pSpinBox[ii] = new RobotJointSpinBox(this);m_pSpinBox[ii]->Initial(ii);m_pMySlider[ii] = new RobotJointDegreeControlSlider(this);m_pMySlider[ii]->Initial(ii);connect(m_pMySlider[ii], SIGNAL(valueChanged(int)),m_pSpinBox[ii], SLOT(setValue(int)));}connect(m_pMySlider[0], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_0(int)));connect(m_pMySlider[1], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_1(int)));connect(m_pMySlider[2], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_2(int)));connect(m_pMySlider[3], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_3(int)));connect(m_pMySlider[4], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_4(int)));connect(m_pMySlider[5], SIGNAL(valueChanged(int)),m_pWidget, SLOT(SetRotationAngleOfJoint_5(int)));}RobotSimulationPlatform::~RobotSimulationPlatform()
{delete ui;
}
robot_simulation.h
#ifndef NEWTRAVEL_ROBOT_SIMULATION_H
#define NEWTRAVEL_ROBOT_SIMULATION_H#include "robot_body_load.h"
#include "robot_joint_degree_control_slider.h"
#include "robot_joint_degree_spinbox.h"
#include "robot_joint_label.h"
#include <QWidget>QT_BEGIN_NAMESPACE
namespace Ui
{
class RobotSimulation;
}
QT_END_NAMESPACEclass RobotSimulationPlatform : public QWidget
{Q_OBJECTpublic:explicit RobotSimulationPlatform(QWidget *parent = nullptr);~RobotSimulationPlatform() override;private:Ui::RobotSimulation *ui;RobotBody *m_pWidget;RobotJointDegreeControlSlider *m_pMySlider[6];RobotJointSpinBox *m_pSpinBox[6];RobotJointLabel *m_pRobotJointLabel[6];
};#endif // NEWTRAVEL_ROBOT_SIMULATION_H
robot_simulation_main_platform.h
#ifndef UI_MY_ROBOT_H
#define UI_MY_ROBOT_H#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>QT_BEGIN_NAMESPACEclass UiWindowOfRobot
{
public:void setupUi(QWidget *my_robot){if (my_robot->objectName().isEmpty())my_robot->setObjectName(QString::fromUtf8("my_robot"));my_robot->resize(1200, 600);retranslateUi(my_robot);QMetaObject::connectSlotsByName(my_robot);} // setupUivoid retranslateUi(QWidget *my_robot){my_robot->setWindowTitle(QApplication::translate("my_robot", "my_robot", nullptr));} // retranslateUi};namespace Ui {class RobotSimulation : public UiWindowOfRobot
{};
} // namespace UiQT_END_NAMESPACE#endif // UI_MY_ROBOT_H
robot_simulation_platform.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>RobotSimulationPlatform</class><widget class="QWidget" name="RobotSimulationPlatform"><property name="geometry"><rect><x>0</x><y>0</y><width>1210</width><height>916</height></rect></property><property name="windowTitle"><string>RobotSimulationPlatform</string></property><widget class="QWidget" name="m_pMainWidget"><property name="geometry"><rect><x>10</x><y>10</y><width>1151</width><height>791</height></rect></property><layout class="QGridLayout" name="m_pMainGridLayout" columnstretch="2,1"><item row="0" column="0"><layout class="QVBoxLayout" name="m_pRobotShowAndButtonVerticalLayout" stretch="6,1"><property name="spacing"><number>6</number></property><item><widget class="QGroupBox" name="m_pRobotGroup"><property name="title"><string/></property><widget class="QOpenGLWidget" name="openGLWidget"><property name="enabled"><bool>true</bool></property><property name="geometry"><rect><x>20</x><y>40</y><width>721</width><height>611</height></rect></property><property name="minimumSize"><size><width>650</width><height>600</height></size></property></widget></widget></item><item><widget class="QGroupBox" name="m_pPushButtonGroup"><property name="title"><string>GroupBox</string></property><widget class="QSplitter" name="m_pSplitterPushButton"><property name="geometry"><rect><x>0</x><y>20</y><width>311</width><height>41</height></rect></property><property name="orientation"><enum>Qt::Horizontal</enum></property><widget class="QPushButton" name="pushButton"><property name="text"><string>PushButton</string></property></widget><widget class="QPushButton" name="pushButton_2"><property name="text"><string>PushButton</string></property></widget></widget></widget></item></layout></item><item row="0" column="1"><layout class="QVBoxLayout" name="m_pVerticalLayoutRobotController" stretch="2,1,1"><item><widget class="QGroupBox" name="m_pGroupBoxRobotJoints"><property name="minimumSize"><size><width>2</width><height>12</height></size></property><property name="tabletTracking"><bool>false</bool></property><property name="title"><string/></property><widget class="QWidget" name="m_pMainWidget"><property name="geometry"><rect><x>10</x><y>30</y><width>361</width><height>250</height></rect></property><layout class="QVBoxLayout" name="m_pVerticalLayoutRobotJoints"><property name="spacing"><number>16</number></property><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_1"><item><widget class="QLabel" name="m_pLabelRobotJoint_1"><property name="text"><string>Joint_1</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_1"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_1"><property name="minimum"><number>-180</number></property><property name="maximum"><number>180</number></property><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_2"><item><widget class="QLabel" name="m_pLabelRobotJoint_2"><property name="text"><string>Joint_2</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_2"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_2"><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_3"><item><widget class="QLabel" name="m_pLabelRobotJoint_3"><property name="text"><string>Joint_3</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_3"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_3"><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_4"><item><widget class="QLabel" name="m_pLabelRobotJoint_4"><property name="text"><string>Joint_4</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_4"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_4"><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_5"><item><widget class="QLabel" name="m_pLabelRobotJoint_5"><property name="text"><string>Joint_5</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_5"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_5"><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutJoint_6"><item><widget class="QLabel" name="m_pLabelRobotJoint_6"><property name="text"><string>Joint_6</string></property></widget></item><item><widget class="QDoubleSpinBox" name="m_pDoubleSpinBoxJoint_6"/></item><item><widget class="QSlider" name="m_pHorizontalSliderJoint_6"><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item></layout></widget></widget></item><item><widget class="QGroupBox" name="m_pGroupBoxTargetJointsSettingCenter"><property name="title"><string/></property><widget class="QWidget" name="m_pMainWidget"><property name="geometry"><rect><x>10</x><y>30</y><width>361</width><height>141</height></rect></property><layout class="QVBoxLayout" name="m_pVerticalLayoutTargetJointsSettingCenter"><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutTargetJointsLabel"><item><widget class="QLabel" name="m_pLabelSettingJoints"><property name="text"><string>末端关节值</string></property></widget></item><item><widget class="QCheckBox" name="m_pCheckBoxDegree"><property name="text"><string>弧度</string></property></widget></item></layout></item><item><widget class="QTextEdit" name="m_pTextEditTargetJoints"/></item></layout></widget></widget></item><item><widget class="QGroupBox" name="m_pGroupBoxOtherModelSetting"><property name="title"><string/></property><widget class="QWidget" name="m_pMainWidget"><property name="geometry"><rect><x>10</x><y>30</y><width>361</width><height>151</height></rect></property><layout class="QVBoxLayout" name="m_pVerticalLayoutOtherModel"><item><layout class="QHBoxLayout" name="m_pHorizontalLayoutOtherModel"><item><widget class="QLabel" name="m_pLabelOtherModelTransformName"><property name="text"><string>头部到机器人坐标转换矩阵:</string></property></widget></item><item><widget class="QCheckBox" name="m_pCheckBoxTransformUnitOfLength"><property name="text"><string>米</string></property></widget></item><item><widget class="QCheckBox" name="m_pCheckBoxOtherModelDegree"><property name="text"><string>弧度</string></property></widget></item></layout></item><item><widget class="QTextEdit" name="m_pTextEditOtherModelTransform"/></item></layout></widget></widget></item></layout></item></layout></widget></widget><resources/><connections/>
</ui>
robot_target_joint.cpp
#include "robot_target_joint.h"
InputText::InputText(QWidget *parent) : QTextEdit(parent) {}InputText::~InputText() = default;void InputText::emitValue()
{QString sValue = toPlainText();emit SetValue(sValue);
}void InputText::SetValue()
{emitValue();
}
robot_target_joint.h
#ifndef NEWTRAVEL_ROBOT_TARGET_JOINT_H
#define NEWTRAVEL_ROBOT_TARGET_JOINT_H
#include <QtWidgets/QTextEdit>class InputText : public QTextEdit
{
Q_OBJECT
public:InputText(QWidget *parent = nullptr);~InputText() override;signals :void SetValue(const QString &oFilePath);
public Q_SLOTS:void SetValue();
public:void emitValue();
};#endif // NEWTRAVEL_ROBOT_TARGET_JOINT_H
simulation.h
#ifndef NEWTRAVEL_SIMULATION_H
#define NEWTRAVEL_SIMULATION_H
#include <QFileDialog>#include "robot_body_load.h"
#include "robot_joint_degree_control_slider.h"
#include "robot_joint_degree_spinbox.h"
#include "robot_joint_label.h"
#include "robot_other_model_transform.h"
#include "robot_pushbutton_openfile.h"
#include "robot_pushbutton_send_message.h"
#include "robot_target_joint.h"
#include "ui_robot_simulation_platform.h"
#include <QGroupBox>
#include <QKeyEvent>
#include <QWidget>QT_BEGIN_NAMESPACE
namespace Ui
{
class RobotSimulationPlatform;
}namespace Ui
{class RobotSimulation : public RobotSimulationPlatform, public QWidget
{
public:RobotSimulation(QWidget *parent = nullptr);void Init();void InitIconInitialPosition();void InitSignalConnection();void SetUpUI(QWidget *RobotSimulationPlatform);void RetranslateUi(QWidget *RobotSimulationPlatform);public:void InitMainWindow(QWidget *RobotSimulationPlatform);void InitRobotShowGroupt(QWidget *pQWidget);void InitRobotShowAndButtonVerticalLayout();void InitMainGridLayout(QWidget *pQWidget);void InitPushButtonGroup();void InitRobotControllerVerticalLayout();void InitRobtJointsGroup();void InitRobtJointsWidget();void InitRobotJointsVerticalLayout();void InitRobtJoint_1HorizontalLayout();void InitRobotJointsController();void InitRobotTargetJointSettingFormat();void InitRobotTargetJointSettingComponent();void InitLoadOtherModelComponent();void InitLoadOtherModelFormat();void SetMainGridLayout();void SetRobotShowAndButtonVerticalLayout();void SetRobotControllerVerticalLayout();void SetRobotJointsController();void SetRobotJointsVerticalLayout();void SetRobotTargetJointsFormat();void SetLoadOtherModelFormat();void keyPressEvent(QKeyEvent *ev) override;private:RobotJointSpinBox *m_pMySpinBox[6]{};RobotJointDegreeControlSlider *m_pMySlider[6]{};RobotJointLabel *m_pMyJointLabel[6]{};QHBoxLayout *m_pRobotJointsHorizontalLayout[6]{};OpenFile *pOpenFile{};FileDialog *m_pFileDialog{};InputText *m_pTargetJoints;SendButton *m_pSendButton;OtherModelTrans *m_pOtherModelTrans;
};RobotSimulation::RobotSimulation(QWidget *parent) : QWidget(parent)
{Init();SetUpUI(this);InitIconInitialPosition();InitSignalConnection();
}void RobotSimulation::SetUpUI(QWidget *RobotSimulationPlatform)
{if (RobotSimulationPlatform->objectName().isEmpty())RobotSimulationPlatform->setObjectName(QString::fromUtf8("RobotSimulationPlatform"));InitMainWindow(RobotSimulationPlatform);InitMainGridLayout(m_pMainWidget);InitRobotShowGroupt(m_pMainWidget);InitPushButtonGroup();InitRobotShowAndButtonVerticalLayout();SetRobotShowAndButtonVerticalLayout();InitRobtJointsGroup();InitRobtJointsWidget();InitRobtJoint_1HorizontalLayout();InitRobotJointsController();SetRobotJointsController();InitRobotJointsVerticalLayout();SetRobotJointsVerticalLayout();InitRobotTargetJointSettingFormat();InitRobotTargetJointSettingComponent();SetRobotTargetJointsFormat();InitLoadOtherModelFormat();InitLoadOtherModelComponent();//SetLoadOtherModelFormat();InitRobotControllerVerticalLayout();SetRobotControllerVerticalLayout();SetMainGridLayout();QMetaObject::connectSlotsByName(RobotSimulationPlatform);RetranslateUi(RobotSimulationPlatform);
}void RobotSimulation::RetranslateUi(QWidget *RobotSimulationPlatform)
{RobotSimulationPlatform->setWindowTitle(QApplication::translate("RobotSimulationPlatform", "RobotSimulationPlatform", nullptr));} // retranslateUivoid RobotSimulation::InitIconInitialPosition()
{for (int ii = 0; ii < 6; ++ii){m_pMySpinBox[ii]->SetLimitValue(180, -180, 1);m_pMySlider[ii]->setMaximum(180);m_pMySlider[ii]->setMinimum(-180);m_pMySlider[ii]->setValue(0);}
}void RobotSimulation::InitSignalConnection()
{for (int ii = 0; ii < 6; ++ii){QObject::connect(m_pMySlider[ii], SIGNAL(valueChanged(double)), m_pMySpinBox[ii], SLOT(setValue(double)));QObject::connect(m_pMySpinBox[ii], SIGNAL(valueChanged(double)), m_pMySlider[ii], SLOT(setValue(double)));}QObject::connect(m_pMySlider[0], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_0(double)));QObject::connect(m_pMySlider[1], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_1(double)));QObject::connect(m_pMySlider[2], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_2(double)));QObject::connect(m_pMySlider[3], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_3(double)));QObject::connect(m_pMySlider[4], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_4(double)));QObject::connect(m_pMySlider[5], SIGNAL(valueChanged(double)), openGLWidget, SLOT(SetRotationAngleOfJoint_5(double)));QObject::connect(m_pFileDialog, SIGNAL(fileSelected(const QString &)), openGLWidget, SLOT(SetFilePath(const QString &)));QObject::connect(m_pSendButton, SIGNAL(SendMessage()), m_pTargetJoints, SLOT(SetValue()));QObject::connect(m_pTargetJoints, SIGNAL(SetValue(const QString &)), openGLWidget, SLOT(setTargetJoints(const QString &)));QObject::connect(m_pSendButton, SIGNAL(SendMessage()), m_pOtherModelTrans, SLOT(SetValue()));QObject::connect(m_pOtherModelTrans, SIGNAL(SetValue(QMatrix4x4)), openGLWidget, SLOT(SetOtherModelTransform(QMatrix4x4)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_0(double)), m_pMySlider[0], SLOT(setValue(double)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_1(double)), m_pMySlider[1], SLOT(setValue(double)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_2(double)), m_pMySlider[2], SLOT(setValue(double)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_3(double)), m_pMySlider[3], SLOT(setValue(double)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_4(double)), m_pMySlider[4], SLOT(setValue(double)));QObject::connect(openGLWidget, SIGNAL(SetRotationOfJoint_5(double)), m_pMySlider[5], SLOT(setValue(double)));QObject::connect(m_pCheckBoxDegree, SIGNAL(clicked(bool)), openGLWidget, SLOT(SetTargetJointDegreeFlag(bool)));QObject::connect(m_pCheckBoxTransformUnitOfLength, SIGNAL(clicked(bool)), openGLWidget, SLOT(SetUnitOfLength(bool)));
}void RobotSimulation::InitRobotShowGroupt(QWidget *pQWidget)
{m_pRobotGroup = new QGroupBox(pQWidget);m_pRobotGroup->setObjectName(QString::fromUtf8("groupBox_4"));openGLWidget = new RobotBody(m_pRobotGroup);openGLWidget->setObjectName(QString::fromUtf8("openGLWidget"));openGLWidget->setEnabled(true);openGLWidget->setGeometry(QRect(20, 40, 721, 611));openGLWidget->setMinimumSize(QSize(650, 600));
}void RobotSimulation::InitMainGridLayout(QWidget *pQWidget)
{m_pMainGridLayout = new QGridLayout(pQWidget);m_pMainGridLayout->setObjectName(QString::fromUtf8("gridLayout"));
}void RobotSimulation::InitRobotShowAndButtonVerticalLayout()
{m_pRobotShowAndButtonVerticalLayout = new QVBoxLayout();m_pRobotShowAndButtonVerticalLayout->setSpacing(6);m_pRobotShowAndButtonVerticalLayout->setObjectName(QString::fromUtf8("verticalLayout_4"));
}void RobotSimulation::InitMainWindow(QWidget *RobotSimulationPlatform)
{RobotSimulationPlatform->resize(1200, 850);RobotSimulationPlatform->setWindowTitle("史陶比尔机器人三维仿真软件");m_pMainWidget = new QWidget(RobotSimulationPlatform);m_pMainWidget->setObjectName(QString::fromUtf8("layoutWidget"));m_pMainWidget->setGeometry(QRect(10, 10, 1151, 791));
}void RobotSimulation::InitPushButtonGroup()
{m_pPushButtonGroup = new QGroupBox(m_pMainWidget);m_pPushButtonGroup->setObjectName(QString::fromUtf8("groupBox_5"));m_pSplitterPushButton = new QSplitter(m_pPushButtonGroup);m_pSplitterPushButton->setObjectName(QString::fromUtf8("splitter_3"));m_pSplitterPushButton->setGeometry(QRect(0, 20, 311, 41));m_pSplitterPushButton->setOrientation(Qt::Horizontal);m_pFileDialog = new FileDialog(m_pSplitterPushButton);pOpenFile = new OpenFile(m_pFileDialog, m_pSplitterPushButton);pOpenFile->setObjectName(QString::fromUtf8("pushButton"));pOpenFile->setText("加载存储模型路径文件");m_pSplitterPushButton->addWidget(pOpenFile);m_pSendButton = new SendButton(m_pSplitterPushButton);m_pSendButton->setObjectName(QString::fromUtf8("pushButton"));m_pSendButton->setText("确认");m_pSplitterPushButton->addWidget(m_pSendButton);
}void RobotSimulation::SetRobotShowAndButtonVerticalLayout()
{m_pRobotShowAndButtonVerticalLayout->addWidget(m_pRobotGroup);m_pRobotShowAndButtonVerticalLayout->addWidget(m_pPushButtonGroup);m_pRobotShowAndButtonVerticalLayout->setStretch(0, 6);m_pRobotShowAndButtonVerticalLayout->setStretch(1, 1);
}void RobotSimulation::SetMainGridLayout()
{m_pMainGridLayout->setContentsMargins(0, 0, 0, 0);m_pMainGridLayout->addLayout(m_pRobotShowAndButtonVerticalLayout, 0, 0, 1, 1);m_pMainGridLayout->addLayout(m_pVerticalLayoutRobotController, 0, 1, 1, 1);m_pMainGridLayout->setColumnStretch(0, 2);m_pMainGridLayout->setColumnStretch(1, 1);
}void RobotSimulation::InitRobotControllerVerticalLayout()
{m_pVerticalLayoutRobotController = new QVBoxLayout();m_pVerticalLayoutRobotController->setObjectName(QString::fromUtf8("verticalLayout_5"));
}
void RobotSimulation::SetRobotControllerVerticalLayout()
{m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxRobotJoints);m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxTargetJointsSettingCenter);m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxOtherModelSetting);m_pVerticalLayoutRobotController->setStretch(0, 2);m_pVerticalLayoutRobotController->setStretch(1, 1);m_pVerticalLayoutRobotController->setStretch(2, 1);
}
void RobotSimulation::InitRobtJointsGroup()
{m_pGroupBoxRobotJoints = new QGroupBox(m_pMainWidget);m_pGroupBoxRobotJoints->setObjectName(QString::fromUtf8("groupBox"));m_pGroupBoxRobotJoints->setMinimumSize(QSize(2, 12));m_pGroupBoxRobotJoints->setTabletTracking(false);
}
void RobotSimulation::InitRobtJointsWidget()
{m_pQWidgetRobotJoint = new QWidget(m_pGroupBoxRobotJoints);m_pQWidgetRobotJoint->setObjectName(QString::fromUtf8("layoutWidget1"));m_pQWidgetRobotJoint->setGeometry(QRect(10, 30, 361, 250));
}void RobotSimulation::InitRobotJointsVerticalLayout()
{m_pVerticalLayoutRobotJoints = new QVBoxLayout(m_pQWidgetRobotJoint);m_pVerticalLayoutRobotJoints->setSpacing(16);m_pVerticalLayoutRobotJoints->setObjectName(QString::fromUtf8("verticalLayout"));m_pVerticalLayoutRobotJoints->setContentsMargins(0, 0, 0, 0);
}void RobotSimulation::InitRobtJoint_1HorizontalLayout()
{for (auto &ii : m_pRobotJointsHorizontalLayout){ii = new QHBoxLayout();ii->setObjectName(QString::fromUtf8("horizontalLayout"));}
}void RobotSimulation::Init()
{m_pRobotJointsHorizontalLayout[0] = m_pHorizontalLayoutJoint_1;m_pRobotJointsHorizontalLayout[1] = m_pHorizontalLayoutJoint_2;m_pRobotJointsHorizontalLayout[2] = m_pHorizontalLayoutJoint_3;m_pRobotJointsHorizontalLayout[3] = m_pHorizontalLayoutJoint_4;m_pRobotJointsHorizontalLayout[4] = m_pHorizontalLayoutJoint_5;m_pRobotJointsHorizontalLayout[5] = m_pHorizontalLayoutJoint_6;
}void RobotSimulation::InitRobotJointsController()
{for (int ii = 0; ii < 6; ++ii){m_pMyJointLabel[ii] = new RobotJointLabel();m_pMyJointLabel[ii]->Initial(ii);m_pMySpinBox[ii] = new RobotJointSpinBox(m_pQWidgetRobotJoint);m_pMySpinBox[ii]->setObjectName(QString::fromUtf8("doubleSpinBox"));m_pMySlider[ii] = new RobotJointDegreeControlSlider(m_pQWidgetRobotJoint);m_pMySlider[ii]->setObjectName(QString::fromUtf8("horizontalSlider"));m_pMySlider[ii]->setOrientation(Qt::Horizontal);}
}
void RobotSimulation::SetRobotJointsController()
{for (int ii = 0; ii < 6; ++ii){m_pRobotJointsHorizontalLayout[ii]->addWidget(m_pMyJointLabel[ii]);m_pRobotJointsHorizontalLayout[ii]->addWidget(m_pMySpinBox[ii]);m_pRobotJointsHorizontalLayout[ii]->addWidget(m_pMySlider[ii]);}
}void RobotSimulation::SetRobotJointsVerticalLayout()
{m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[0]);m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[1]);m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[2]);m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[3]);m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[4]);m_pVerticalLayoutRobotJoints->addLayout(m_pRobotJointsHorizontalLayout[5]);
}
void RobotSimulation::InitRobotTargetJointSettingFormat()
{m_pGroupBoxTargetJointsSettingCenter = new QGroupBox(m_pMainWidget);m_pGroupBoxTargetJointsSettingCenter->setObjectName(QString::fromUtf8("groupBox_3"));m_pWidgetTargetJointsSettingCenter = new QWidget(m_pGroupBoxTargetJointsSettingCenter);m_pWidgetTargetJointsSettingCenter->setObjectName(QString::fromUtf8("layoutWidget2"));m_pWidgetTargetJointsSettingCenter->setGeometry(QRect(10, 30, 361, 141));m_pVerticalLayoutTargetJointsSettingCenter = new QVBoxLayout(m_pWidgetTargetJointsSettingCenter);m_pVerticalLayoutTargetJointsSettingCenter->setObjectName(QString::fromUtf8("verticalLayout_2"));m_pVerticalLayoutTargetJointsSettingCenter->setContentsMargins(0, 0, 0, 0);m_pHorizontalLayoutTargetJointsLabel = new QHBoxLayout();m_pHorizontalLayoutTargetJointsLabel->setObjectName(QString::fromUtf8("horizontalLayout_7"));
}void RobotSimulation::InitRobotTargetJointSettingComponent()
{m_pLabelSettingJoints = new QLabel(m_pWidgetTargetJointsSettingCenter);m_pLabelSettingJoints->setObjectName(QString::fromUtf8("Target joints"));m_pLabelSettingJoints->setText("目标关节值");m_pCheckBoxDegree = new QCheckBox(m_pWidgetTargetJointsSettingCenter);m_pCheckBoxDegree->setObjectName(QString::fromUtf8("Angular unit about target joint"));m_pCheckBoxDegree->setText("弧度");// m_pTextEditTargetJoints = new QTextEdit(m_pWidgetTargetJointsSettingCenter);// m_pTextEditTargetJoints->setObjectName(QString::fromUtf8("textEdit"));m_pTargetJoints = new InputText(m_pWidgetTargetJointsSettingCenter);m_pTargetJoints->setObjectName(QString::fromUtf8("textEdit"));m_pTargetJoints->setText("0,0,0,0,0,0");
}
void RobotSimulation::SetRobotTargetJointsFormat()
{m_pHorizontalLayoutTargetJointsLabel->addWidget(m_pLabelSettingJoints);m_pHorizontalLayoutTargetJointsLabel->addWidget(m_pCheckBoxDegree);m_pVerticalLayoutTargetJointsSettingCenter->addLayout(m_pHorizontalLayoutTargetJointsLabel);m_pVerticalLayoutTargetJointsSettingCenter->addWidget(m_pTargetJoints);
}
void RobotSimulation::InitLoadOtherModelComponent()
{m_pLabelOtherModelTransformName = new QLabel(m_pWidgetOtherModelSetting);m_pLabelOtherModelTransformName->setObjectName(QString::fromUtf8("Transform from other model to robot"));m_pLabelOtherModelTransformName->setText("到机器人坐标系的转换矩阵");m_pCheckBoxTransformUnitOfLength = new QCheckBox(m_pWidgetOtherModelSetting);m_pCheckBoxTransformUnitOfLength->setObjectName(QString::fromUtf8("Unit Of Length"));m_pCheckBoxTransformUnitOfLength->setText("毫米");m_pCheckBoxTransformUnitOfLength->setChecked(true);m_pCheckBoxOtherModelDegree = new QCheckBox(m_pWidgetOtherModelSetting);m_pCheckBoxOtherModelDegree->setObjectName(QString::fromUtf8("Angular Unit"));m_pCheckBoxOtherModelDegree->setText("弧度");m_pOtherModelTrans = new OtherModelTrans(m_pWidgetOtherModelSetting);m_pOtherModelTrans->setObjectName(QString::fromUtf8("textEdit_2"));m_pOtherModelTrans->setText("Transform(Vector3D(0, -1000, 0), Rotation({1, 0, ""0},{0, 1, 0},{0, 0, 1}))");
}
void RobotSimulation::InitLoadOtherModelFormat()
{m_pGroupBoxOtherModelSetting = new QGroupBox(m_pMainWidget);m_pGroupBoxOtherModelSetting->setObjectName(QString::fromUtf8("groupBox_2"));m_pWidgetOtherModelSetting = new QWidget(m_pGroupBoxOtherModelSetting);m_pWidgetOtherModelSetting->setObjectName(QString::fromUtf8("layoutWidget3"));m_pWidgetOtherModelSetting->setGeometry(QRect(10, 30, 361, 151));m_pVerticalLayoutOtherModel = new QVBoxLayout(m_pWidgetOtherModelSetting);m_pVerticalLayoutOtherModel->setObjectName(QString::fromUtf8("verticalLayout_3"));m_pVerticalLayoutOtherModel->setContentsMargins(0, 0, 0, 0);m_pHorizontalLayoutOtherModel = new QHBoxLayout();m_pHorizontalLayoutOtherModel->setObjectName(QString::fromUtf8("horizontalLayout_8"));
}void RobotSimulation::SetLoadOtherModelFormat()
{m_pHorizontalLayoutOtherModel->addWidget(m_pLabelOtherModelTransformName);m_pHorizontalLayoutOtherModel->addWidget(m_pCheckBoxTransformUnitOfLength);m_pHorizontalLayoutOtherModel->addWidget(m_pCheckBoxOtherModelDegree);m_pVerticalLayoutOtherModel->addLayout(m_pHorizontalLayoutOtherModel);m_pVerticalLayoutOtherModel->addWidget(m_pOtherModelTrans);
}void RobotSimulation::keyPressEvent(QKeyEvent *ev)
{if (ev->key() == Qt::Key_Escape){close();}else if (ev->key() == Qt::Key_E){m_pTargetJoints->emitValue();}
}} // namespace UiQT_END_NAMESPACE#endif // NEWTRAVEL_SIMULATION_H
ui_robot_simulation_platform.h
/********************************************************************************
** Form generated from reading UI file 'robot_simulation_platform.ui'
**
** Created by: Qt User Interface Compiler version 5.12.8
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/#ifndef UI_ROBOT_SIMULATION_PLATFORM_H
#define UI_ROBOT_SIMULATION_PLATFORM_H#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QOpenGLWidget>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSlider>
#include <QtWidgets/QSplitter>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>QT_BEGIN_NAMESPACEclass Ui_RobotSimulationPlatform
{
public:QWidget *m_pMainWidget;QGridLayout *m_pMainGridLayout;QVBoxLayout *m_pRobotShowAndButtonVerticalLayout;QGroupBox *m_pRobotGroup;QOpenGLWidget *openGLWidget;QGroupBox *m_pPushButtonGroup;QSplitter *m_pSplitterPushButton;QPushButton *pushButton;QPushButton *pushButton_2;QVBoxLayout *m_pVerticalLayoutRobotController;QGroupBox *m_pGroupBoxRobotJoints;QWidget *m_pQWidgetRobotJoint;QVBoxLayout *m_pVerticalLayoutRobotJoints;QHBoxLayout *m_pHorizontalLayoutJoint_1;QLabel *m_pLabelRobotJoint_1;QDoubleSpinBox *m_pDoubleSpinBoxJoint_1;QSlider *m_pHorizontalSliderJoint_1;QHBoxLayout *m_pHorizontalLayoutJoint_2;QLabel *m_pLabelRobotJoint_2;QDoubleSpinBox *m_pDoubleSpinBoxJoint_2;QSlider *m_pHorizontalSliderJoint_2;QHBoxLayout *m_pHorizontalLayoutJoint_3;QLabel *m_pLabelRobotJoint_3;QDoubleSpinBox *m_pDoubleSpinBoxJoint_3;QSlider *m_pHorizontalSliderJoint_3;QHBoxLayout *m_pHorizontalLayoutJoint_4;QLabel *m_pLabelRobotJoint_4;QDoubleSpinBox *m_pDoubleSpinBoxJoint_4;QSlider *m_pHorizontalSliderJoint_4;QHBoxLayout *m_pHorizontalLayoutJoint_5;QLabel *m_pLabelRobotJoint_5;QDoubleSpinBox *m_pDoubleSpinBoxJoint_5;QSlider *m_pHorizontalSliderJoint_5;QHBoxLayout *m_pHorizontalLayoutJoint_6;QLabel *m_pLabelRobotJoint_6;QDoubleSpinBox *m_pDoubleSpinBoxJoint_6;QSlider *m_pHorizontalSliderJoint_6;QGroupBox *m_pGroupBoxTargetJointsSettingCenter;QWidget *m_pWidgetTargetJointsSettingCenter;QVBoxLayout *m_pVerticalLayoutTargetJointsSettingCenter;QHBoxLayout *m_pHorizontalLayoutTargetJointsLabel;QLabel *m_pLabelSettingJoints;QCheckBox *m_pCheckBoxDegree;QTextEdit *m_pTextEditTargetJoints;QGroupBox *m_pGroupBoxOtherModelSetting;QWidget *m_pWidgetOtherModelSetting;QVBoxLayout *m_pVerticalLayoutOtherModel;QHBoxLayout *m_pHorizontalLayoutOtherModel;QLabel *m_pLabelOtherModelTransformName;QCheckBox *m_pCheckBoxTransformUnitOfLength;QCheckBox *m_pCheckBoxOtherModelDegree;QTextEdit *m_pTextEditOtherModelTransform;void setupUi(QWidget *RobotSimulationPlatform){if (RobotSimulationPlatform->objectName().isEmpty())RobotSimulationPlatform->setObjectName(QString::fromUtf8("RobotSimulationPlatform"));RobotSimulationPlatform->resize(1210, 916);m_pMainWidget = new QWidget(RobotSimulationPlatform);m_pMainWidget->setObjectName(QString::fromUtf8("layoutWidget"));m_pMainWidget->setGeometry(QRect(10, 10, 1151, 791));m_pMainGridLayout = new QGridLayout(m_pMainWidget);m_pMainGridLayout->setObjectName(QString::fromUtf8("gridLayout"));m_pMainGridLayout->setContentsMargins(0, 0, 0, 0);m_pRobotShowAndButtonVerticalLayout = new QVBoxLayout();m_pRobotShowAndButtonVerticalLayout->setSpacing(6);m_pRobotShowAndButtonVerticalLayout->setObjectName(QString::fromUtf8("verticalLayout_4"));m_pRobotGroup = new QGroupBox(m_pMainWidget);m_pRobotGroup->setObjectName(QString::fromUtf8("groupBox_4"));openGLWidget = new QOpenGLWidget(m_pRobotGroup);openGLWidget->setObjectName(QString::fromUtf8("openGLWidget"));openGLWidget->setEnabled(true);openGLWidget->setGeometry(QRect(20, 40, 721, 611));openGLWidget->setMinimumSize(QSize(650, 600));m_pRobotShowAndButtonVerticalLayout->addWidget(m_pRobotGroup);m_pPushButtonGroup = new QGroupBox(m_pMainWidget);m_pPushButtonGroup->setObjectName(QString::fromUtf8("groupBox_5"));m_pSplitterPushButton = new QSplitter(m_pPushButtonGroup);m_pSplitterPushButton->setObjectName(QString::fromUtf8("splitter_3"));m_pSplitterPushButton->setGeometry(QRect(0, 20, 311, 41));m_pSplitterPushButton->setOrientation(Qt::Horizontal);pushButton = new QPushButton(m_pSplitterPushButton);pushButton->setObjectName(QString::fromUtf8("pushButton"));m_pSplitterPushButton->addWidget(pushButton);pushButton_2 = new QPushButton(m_pSplitterPushButton);pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));m_pSplitterPushButton->addWidget(pushButton_2);m_pRobotShowAndButtonVerticalLayout->addWidget(m_pPushButtonGroup);m_pRobotShowAndButtonVerticalLayout->setStretch(0, 6);m_pRobotShowAndButtonVerticalLayout->setStretch(1, 1);m_pMainGridLayout->addLayout(m_pRobotShowAndButtonVerticalLayout, 0, 0, 1, 1);m_pVerticalLayoutRobotController = new QVBoxLayout();m_pVerticalLayoutRobotController->setObjectName(QString::fromUtf8("verticalLayout_5"));m_pGroupBoxRobotJoints = new QGroupBox(m_pMainWidget);m_pGroupBoxRobotJoints->setObjectName(QString::fromUtf8("groupBox"));m_pGroupBoxRobotJoints->setMinimumSize(QSize(2, 12));m_pGroupBoxRobotJoints->setTabletTracking(false);m_pQWidgetRobotJoint = new QWidget(m_pGroupBoxRobotJoints);m_pQWidgetRobotJoint->setObjectName(QString::fromUtf8("layoutWidget1"));m_pQWidgetRobotJoint->setGeometry(QRect(10, 30, 361, 250));m_pVerticalLayoutRobotJoints = new QVBoxLayout(m_pQWidgetRobotJoint);m_pVerticalLayoutRobotJoints->setSpacing(16);m_pVerticalLayoutRobotJoints->setObjectName(QString::fromUtf8("verticalLayout"));m_pVerticalLayoutRobotJoints->setContentsMargins(0, 0, 0, 0);m_pHorizontalLayoutJoint_1 = new QHBoxLayout();m_pHorizontalLayoutJoint_1->setObjectName(QString::fromUtf8("horizontalLayout"));m_pLabelRobotJoint_1 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_1->setObjectName(QString::fromUtf8("label"));m_pHorizontalLayoutJoint_1->addWidget(m_pLabelRobotJoint_1);m_pDoubleSpinBoxJoint_1 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_1->setObjectName(QString::fromUtf8("doubleSpinBox"));m_pHorizontalLayoutJoint_1->addWidget(m_pDoubleSpinBoxJoint_1);m_pHorizontalSliderJoint_1 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_1->setObjectName(QString::fromUtf8("horizontalSlider"));m_pHorizontalSliderJoint_1->setMinimum(-180);m_pHorizontalSliderJoint_1->setMaximum(180);m_pHorizontalSliderJoint_1->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_1->addWidget(m_pHorizontalSliderJoint_1);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_1);m_pHorizontalLayoutJoint_2 = new QHBoxLayout();m_pHorizontalLayoutJoint_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));m_pLabelRobotJoint_2 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_2->setObjectName(QString::fromUtf8("label_2"));m_pHorizontalLayoutJoint_2->addWidget(m_pLabelRobotJoint_2);m_pDoubleSpinBoxJoint_2 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_2->setObjectName(QString::fromUtf8("doubleSpinBox_2"));m_pHorizontalLayoutJoint_2->addWidget(m_pDoubleSpinBoxJoint_2);m_pHorizontalSliderJoint_2 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_2->setObjectName(QString::fromUtf8("horizontalSlider_2"));m_pHorizontalSliderJoint_2->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_2->addWidget(m_pHorizontalSliderJoint_2);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_2);m_pHorizontalLayoutJoint_3 = new QHBoxLayout();m_pHorizontalLayoutJoint_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));m_pLabelRobotJoint_3 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_3->setObjectName(QString::fromUtf8("label_3"));m_pHorizontalLayoutJoint_3->addWidget(m_pLabelRobotJoint_3);m_pDoubleSpinBoxJoint_3 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_3->setObjectName(QString::fromUtf8("doubleSpinBox_3"));m_pHorizontalLayoutJoint_3->addWidget(m_pDoubleSpinBoxJoint_3);m_pHorizontalSliderJoint_3 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_3->setObjectName(QString::fromUtf8("horizontalSlider_3"));m_pHorizontalSliderJoint_3->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_3->addWidget(m_pHorizontalSliderJoint_3);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_3);m_pHorizontalLayoutJoint_4 = new QHBoxLayout();m_pHorizontalLayoutJoint_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));m_pLabelRobotJoint_4 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_4->setObjectName(QString::fromUtf8("label_4"));m_pHorizontalLayoutJoint_4->addWidget(m_pLabelRobotJoint_4);m_pDoubleSpinBoxJoint_4 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_4->setObjectName(QString::fromUtf8("doubleSpinBox_4"));m_pHorizontalLayoutJoint_4->addWidget(m_pDoubleSpinBoxJoint_4);m_pHorizontalSliderJoint_4 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_4->setObjectName(QString::fromUtf8("horizontalSlider_4"));m_pHorizontalSliderJoint_4->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_4->addWidget(m_pHorizontalSliderJoint_4);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_4);m_pHorizontalLayoutJoint_5 = new QHBoxLayout();m_pHorizontalLayoutJoint_5->setObjectName(QString::fromUtf8("horizontalLayout_5"));m_pLabelRobotJoint_5 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_5->setObjectName(QString::fromUtf8("label_5"));m_pHorizontalLayoutJoint_5->addWidget(m_pLabelRobotJoint_5);m_pDoubleSpinBoxJoint_5 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_5->setObjectName(QString::fromUtf8("doubleSpinBox_5"));m_pHorizontalLayoutJoint_5->addWidget(m_pDoubleSpinBoxJoint_5);m_pHorizontalSliderJoint_5 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_5->setObjectName(QString::fromUtf8("horizontalSlider_5"));m_pHorizontalSliderJoint_5->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_5->addWidget(m_pHorizontalSliderJoint_5);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_5);m_pHorizontalLayoutJoint_6 = new QHBoxLayout();m_pHorizontalLayoutJoint_6->setObjectName(QString::fromUtf8("horizontalLayout_6"));m_pLabelRobotJoint_6 = new QLabel(m_pQWidgetRobotJoint);m_pLabelRobotJoint_6->setObjectName(QString::fromUtf8("label_6"));m_pHorizontalLayoutJoint_6->addWidget(m_pLabelRobotJoint_6);m_pDoubleSpinBoxJoint_6 = new QDoubleSpinBox(m_pQWidgetRobotJoint);m_pDoubleSpinBoxJoint_6->setObjectName(QString::fromUtf8("doubleSpinBox_6"));m_pHorizontalLayoutJoint_6->addWidget(m_pDoubleSpinBoxJoint_6);m_pHorizontalSliderJoint_6 = new QSlider(m_pQWidgetRobotJoint);m_pHorizontalSliderJoint_6->setObjectName(QString::fromUtf8("horizontalSlider_6"));m_pHorizontalSliderJoint_6->setOrientation(Qt::Horizontal);m_pHorizontalLayoutJoint_6->addWidget(m_pHorizontalSliderJoint_6);m_pVerticalLayoutRobotJoints->addLayout(m_pHorizontalLayoutJoint_6);m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxRobotJoints);m_pGroupBoxTargetJointsSettingCenter = new QGroupBox(m_pMainWidget);m_pGroupBoxTargetJointsSettingCenter->setObjectName(QString::fromUtf8("groupBox_3"));m_pWidgetTargetJointsSettingCenter = new QWidget(m_pGroupBoxTargetJointsSettingCenter);m_pWidgetTargetJointsSettingCenter->setObjectName(QString::fromUtf8("layoutWidget2"));m_pWidgetTargetJointsSettingCenter->setGeometry(QRect(10, 30, 361, 141));m_pVerticalLayoutTargetJointsSettingCenter = new QVBoxLayout(m_pWidgetTargetJointsSettingCenter);m_pVerticalLayoutTargetJointsSettingCenter->setObjectName(QString::fromUtf8("verticalLayout_2"));m_pVerticalLayoutTargetJointsSettingCenter->setContentsMargins(0, 0, 0, 0);m_pHorizontalLayoutTargetJointsLabel = new QHBoxLayout();m_pHorizontalLayoutTargetJointsLabel->setObjectName(QString::fromUtf8("horizontalLayout_7"));m_pLabelSettingJoints = new QLabel(m_pWidgetTargetJointsSettingCenter);m_pLabelSettingJoints->setObjectName(QString::fromUtf8("label_7"));m_pHorizontalLayoutTargetJointsLabel->addWidget(m_pLabelSettingJoints);m_pCheckBoxDegree = new QCheckBox(m_pWidgetTargetJointsSettingCenter);m_pCheckBoxDegree->setObjectName(QString::fromUtf8("checkBox"));m_pHorizontalLayoutTargetJointsLabel->addWidget(m_pCheckBoxDegree);m_pVerticalLayoutTargetJointsSettingCenter->addLayout(m_pHorizontalLayoutTargetJointsLabel);m_pTextEditTargetJoints = new QTextEdit(m_pWidgetTargetJointsSettingCenter);m_pTextEditTargetJoints->setObjectName(QString::fromUtf8("textEdit"));m_pVerticalLayoutTargetJointsSettingCenter->addWidget(m_pTextEditTargetJoints);m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxTargetJointsSettingCenter);m_pGroupBoxOtherModelSetting = new QGroupBox(m_pMainWidget);m_pGroupBoxOtherModelSetting->setObjectName(QString::fromUtf8("groupBox_2"));m_pWidgetOtherModelSetting = new QWidget(m_pGroupBoxOtherModelSetting);m_pWidgetOtherModelSetting->setObjectName(QString::fromUtf8("layoutWidget3"));m_pWidgetOtherModelSetting->setGeometry(QRect(10, 30, 361, 151));m_pVerticalLayoutOtherModel = new QVBoxLayout(m_pWidgetOtherModelSetting);m_pVerticalLayoutOtherModel->setObjectName(QString::fromUtf8("verticalLayout_3"));m_pVerticalLayoutOtherModel->setContentsMargins(0, 0, 0, 0);m_pHorizontalLayoutOtherModel = new QHBoxLayout();m_pHorizontalLayoutOtherModel->setObjectName(QString::fromUtf8("horizontalLayout_8"));m_pLabelOtherModelTransformName = new QLabel(m_pWidgetOtherModelSetting);m_pLabelOtherModelTransformName->setObjectName(QString::fromUtf8("label_8"));m_pHorizontalLayoutOtherModel->addWidget(m_pLabelOtherModelTransformName);m_pCheckBoxTransformUnitOfLength = new QCheckBox(m_pWidgetOtherModelSetting);m_pCheckBoxTransformUnitOfLength->setObjectName(QString::fromUtf8("checkBox_3"));m_pHorizontalLayoutOtherModel->addWidget(m_pCheckBoxTransformUnitOfLength);m_pCheckBoxOtherModelDegree = new QCheckBox(m_pWidgetOtherModelSetting);m_pCheckBoxOtherModelDegree->setObjectName(QString::fromUtf8("checkBox_2"));m_pHorizontalLayoutOtherModel->addWidget(m_pCheckBoxOtherModelDegree);m_pVerticalLayoutOtherModel->addLayout(m_pHorizontalLayoutOtherModel);m_pTextEditOtherModelTransform = new QTextEdit(m_pWidgetOtherModelSetting);m_pTextEditOtherModelTransform->setObjectName(QString::fromUtf8("textEdit_2"));m_pVerticalLayoutOtherModel->addWidget(m_pTextEditOtherModelTransform);m_pVerticalLayoutRobotController->addWidget(m_pGroupBoxOtherModelSetting);m_pVerticalLayoutRobotController->setStretch(0, 2);m_pVerticalLayoutRobotController->setStretch(1, 1);m_pVerticalLayoutRobotController->setStretch(2, 1);m_pMainGridLayout->addLayout(m_pVerticalLayoutRobotController, 0, 1, 1, 1);m_pMainGridLayout->setColumnStretch(0, 2);m_pMainGridLayout->setColumnStretch(1, 1);retranslateUi(RobotSimulationPlatform);QMetaObject::connectSlotsByName(RobotSimulationPlatform);} // setupUivoid retranslateUi(QWidget *RobotSimulationPlatform){RobotSimulationPlatform->setWindowTitle(QApplication::translate("RobotSimulationPlatform", "RobotSimulationPlatform", nullptr));m_pRobotGroup->setTitle(QString());m_pPushButtonGroup->setTitle(QApplication::translate("RobotSimulationPlatform", "GroupBox", nullptr));pushButton->setText(QApplication::translate("RobotSimulationPlatform", "PushButton", nullptr));pushButton_2->setText(QApplication::translate("RobotSimulationPlatform", "PushButton", nullptr));m_pGroupBoxRobotJoints->setTitle(QString());m_pLabelRobotJoint_1->setText(QApplication::translate("RobotSimulationPlatform", "Joint_1", nullptr));m_pLabelRobotJoint_2->setText(QApplication::translate("RobotSimulationPlatform", "Joint_2", nullptr));m_pLabelRobotJoint_3->setText(QApplication::translate("RobotSimulationPlatform", "Joint_3", nullptr));m_pLabelRobotJoint_4->setText(QApplication::translate("RobotSimulationPlatform", "Joint_4", nullptr));m_pLabelRobotJoint_5->setText(QApplication::translate("RobotSimulationPlatform", "Joint_5", nullptr));m_pLabelRobotJoint_6->setText(QApplication::translate("RobotSimulationPlatform", "Joint_6", nullptr));m_pGroupBoxTargetJointsSettingCenter->setTitle(QString());m_pLabelSettingJoints->setText(QApplication::translate("RobotSimulationPlatform", "\346\234\253\347\253\257\345\205\263\350\212\202\345\200\274", nullptr));m_pCheckBoxDegree->setText(QApplication::translate("RobotSimulationPlatform", "\345\274\247\345\272\246", nullptr));m_pGroupBoxOtherModelSetting->setTitle(QString());m_pLabelOtherModelTransformName->setText(QApplication::translate("RobotSimulationPlatform", "\345\244\264\351\203\250\345\210\260\346\234\272\345\231\250\344\272\272\345\235\220\346\240\207\350\275\254\346\215\242\347\237\251\351\230\265\357\274\232", nullptr));m_pCheckBoxTransformUnitOfLength->setText(QApplication::translate("RobotSimulationPlatform", "\347\261\263", nullptr));m_pCheckBoxOtherModelDegree->setText(QApplication::translate("RobotSimulationPlatform", "\345\274\247\345\272\246", nullptr));} // retranslateUi};namespace Ui {class RobotSimulationPlatform: public Ui_RobotSimulationPlatform {};
} // namespace UiQT_END_NAMESPACE#endif // UI_ROBOT_SIMULATION_PLATFORM_H