├── src ├── icon.rc ├── icon.ico ├── 3DModel │ ├── StlParse.cpp.autosave │ ├── 3DModel - 快捷方式.lnk │ ├── 3DModel.pri │ ├── StlParse.h.autosave │ ├── STLView.h │ ├── OpenGLWidget.h │ └── STLView.cpp ├── Gallery │ ├── Graph.h │ ├── Gallery.pri │ ├── CircularRectangle.cpp │ └── CircularRectangle.h ├── images │ ├── add.png │ ├── add1.png │ ├── back.png │ ├── bold.png │ ├── dec.png │ ├── edit.png │ ├── exit.png │ ├── find.png │ ├── me.png │ ├── new.png │ ├── open.png │ ├── play.png │ ├── save.png │ ├── stop.png │ ├── about.png │ ├── choose.png │ ├── glist.png │ ├── noHide.png │ ├── pause.png │ ├── print.png │ ├── reduce.png │ ├── reset.png │ ├── rotate.png │ ├── saveAs.png │ ├── shape.png │ ├── start.png │ ├── teach.png │ ├── trans.png │ ├── alignment.png │ ├── compile.png │ ├── connect.png │ ├── download.png │ ├── hideLine.png │ ├── hideRobot.png │ ├── parameter.png │ ├── reduction.png │ ├── replace.png │ ├── setting.png │ ├── speedAna.png │ ├── teachShow.png │ ├── trailAna.png │ ├── zeropoint.png │ ├── NarrowDown.png │ ├── clearTrials.png │ ├── disConnect.png │ ├── fileSwitch.png │ ├── modeSwitch.png │ ├── simulation.png │ ├── amplification.png │ └── hideRobotAndTorch.png ├── CodeParse │ ├── libscara.a │ ├── scaralib.h │ ├── NewScaraArgorithmn.h │ ├── CodeParse.pri │ ├── ArcParse.h │ ├── GcodeListDlg.h │ ├── CodeEditDlg.h │ ├── CodeEditDlg.ui │ ├── RobotArgorithmn.h │ ├── NewScaraArgorithmn.cpp │ ├── GCodeConversion.h │ ├── GcodeListDlg.ui │ ├── SimulationParse.h │ ├── ArcParse.cpp │ ├── GcodeListDlg.cpp │ ├── RobotArgorithmn.cpp │ └── CodeEditDlg.cpp ├── stl │ ├── lanxun5JointRobot │ │ ├── 1.STL │ │ ├── 2.STL │ │ ├── 3.STL │ │ ├── 4.STL │ │ ├── 5.STL │ │ └── 6.STL │ ├── lanxunCoordRobot │ │ ├── 2.STL │ │ ├── 3.STL │ │ ├── 4.STL │ │ ├── 5.STL │ │ └── 1.STL │ └── lanxunCoordRobot1 │ │ ├── 0.STL │ │ ├── 1.STL │ │ ├── 2.STL │ │ ├── 3.STL │ │ ├── 4.STL │ │ └── 5.STL ├── CommonFun │ ├── CommonFun.pri │ ├── common.h │ ├── CommonFun.h │ └── CommonFun.cpp ├── Setting │ ├── Setting.pri │ ├── Parameter.h │ ├── ParaDlg.h │ ├── Parameter.cpp │ ├── ParaDlg.cpp │ └── ParaDlg.ui ├── Teach │ ├── Teach.pri │ ├── TeachGlWidget.h │ ├── TeachDlg.h │ ├── TeachGlWidget.cpp │ └── TeachDlg.ui ├── MainWindow │ ├── MainWindow.pri │ ├── Test.h │ ├── Test.cpp │ ├── main.cpp │ ├── MainWindow.h │ └── MainWindow.ui ├── Alignment │ ├── Alignment.pri │ ├── Parser.h │ ├── AnalysisWidget.h │ ├── UdpSocket.h │ ├── Parser.cpp │ ├── AnalysisWidget.ui │ ├── UdpSocket.cpp │ └── AnalysisWidget.cpp ├── RobotOfflineProgram.pro └── res.qrc └── README.md /src/icon.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON ICON DISCARDABLE "icon.ico" 2 | -------------------------------------------------------------------------------- /src/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/icon.ico -------------------------------------------------------------------------------- /src/3DModel/StlParse.cpp.autosave: -------------------------------------------------------------------------------- 1 | #include "STLView.h" 2 | 3 | STLView::STLView() 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/Gallery/Graph.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPH_H 2 | #define GRAPH_H 3 | 4 | 5 | 6 | 7 | #endif // GRAPH_H 8 | -------------------------------------------------------------------------------- /src/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/add.png -------------------------------------------------------------------------------- /src/images/add1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/add1.png -------------------------------------------------------------------------------- /src/images/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/back.png -------------------------------------------------------------------------------- /src/images/bold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/bold.png -------------------------------------------------------------------------------- /src/images/dec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/dec.png -------------------------------------------------------------------------------- /src/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/edit.png -------------------------------------------------------------------------------- /src/images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/exit.png -------------------------------------------------------------------------------- /src/images/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/find.png -------------------------------------------------------------------------------- /src/images/me.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/me.png -------------------------------------------------------------------------------- /src/images/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/new.png -------------------------------------------------------------------------------- /src/images/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/open.png -------------------------------------------------------------------------------- /src/images/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/play.png -------------------------------------------------------------------------------- /src/images/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/save.png -------------------------------------------------------------------------------- /src/images/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/stop.png -------------------------------------------------------------------------------- /src/images/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/about.png -------------------------------------------------------------------------------- /src/images/choose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/choose.png -------------------------------------------------------------------------------- /src/images/glist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/glist.png -------------------------------------------------------------------------------- /src/images/noHide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/noHide.png -------------------------------------------------------------------------------- /src/images/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/pause.png -------------------------------------------------------------------------------- /src/images/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/print.png -------------------------------------------------------------------------------- /src/images/reduce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/reduce.png -------------------------------------------------------------------------------- /src/images/reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/reset.png -------------------------------------------------------------------------------- /src/images/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/rotate.png -------------------------------------------------------------------------------- /src/images/saveAs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/saveAs.png -------------------------------------------------------------------------------- /src/images/shape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/shape.png -------------------------------------------------------------------------------- /src/images/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/start.png -------------------------------------------------------------------------------- /src/images/teach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/teach.png -------------------------------------------------------------------------------- /src/images/trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/trans.png -------------------------------------------------------------------------------- /src/CodeParse/libscara.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/CodeParse/libscara.a -------------------------------------------------------------------------------- /src/CodeParse/scaralib.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/CodeParse/scaralib.h -------------------------------------------------------------------------------- /src/images/alignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/alignment.png -------------------------------------------------------------------------------- /src/images/compile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/compile.png -------------------------------------------------------------------------------- /src/images/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/connect.png -------------------------------------------------------------------------------- /src/images/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/download.png -------------------------------------------------------------------------------- /src/images/hideLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/hideLine.png -------------------------------------------------------------------------------- /src/images/hideRobot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/hideRobot.png -------------------------------------------------------------------------------- /src/images/parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/parameter.png -------------------------------------------------------------------------------- /src/images/reduction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/reduction.png -------------------------------------------------------------------------------- /src/images/replace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/replace.png -------------------------------------------------------------------------------- /src/images/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/setting.png -------------------------------------------------------------------------------- /src/images/speedAna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/speedAna.png -------------------------------------------------------------------------------- /src/images/teachShow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/teachShow.png -------------------------------------------------------------------------------- /src/images/trailAna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/trailAna.png -------------------------------------------------------------------------------- /src/images/zeropoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/zeropoint.png -------------------------------------------------------------------------------- /src/images/NarrowDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/NarrowDown.png -------------------------------------------------------------------------------- /src/images/clearTrials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/clearTrials.png -------------------------------------------------------------------------------- /src/images/disConnect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/disConnect.png -------------------------------------------------------------------------------- /src/images/fileSwitch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/fileSwitch.png -------------------------------------------------------------------------------- /src/images/modeSwitch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/modeSwitch.png -------------------------------------------------------------------------------- /src/images/simulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/simulation.png -------------------------------------------------------------------------------- /src/images/amplification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/amplification.png -------------------------------------------------------------------------------- /src/3DModel/3DModel - 快捷方式.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/3DModel/3DModel - 快捷方式.lnk -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/1.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/1.STL -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/2.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/2.STL -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/3.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/3.STL -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/4.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/4.STL -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/5.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/5.STL -------------------------------------------------------------------------------- /src/stl/lanxun5JointRobot/6.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxun5JointRobot/6.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot/2.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot/2.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot/3.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot/3.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot/4.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot/4.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot/5.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot/5.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/0.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/0.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/1.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/1.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/2.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/2.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/3.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/3.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/4.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/4.STL -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot1/5.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/stl/lanxunCoordRobot1/5.STL -------------------------------------------------------------------------------- /src/Gallery/Gallery.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/CircularRectangle.h 3 | 4 | SOURCES += \ 5 | $$PWD/CircularRectangle.cpp 6 | -------------------------------------------------------------------------------- /src/images/hideRobotAndTorch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trunliu/robot-program-offline/HEAD/src/images/hideRobotAndTorch.png -------------------------------------------------------------------------------- /src/3DModel/3DModel.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/STLView.h \ 3 | $$PWD/OpenGLWidget.h 4 | 5 | SOURCES += \ 6 | $$PWD/STLView.cpp \ 7 | $$PWD/OpenGLWidget.cpp 8 | -------------------------------------------------------------------------------- /src/CommonFun/CommonFun.pri: -------------------------------------------------------------------------------- 1 | 2 | HEADERS += \ 3 | $$PWD/CommonFun.h \ 4 | $$PWD/Common.h 5 | 6 | SOURCES += \ 7 | $$PWD/CommonFun.cpp 8 | 9 | DISTFILES += 10 | -------------------------------------------------------------------------------- /src/Setting/Setting.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/Parameter.h \ 3 | $$PWD/ParaDlg.h 4 | 5 | SOURCES += \ 6 | $$PWD/Parameter.cpp \ 7 | $$PWD/ParaDlg.cpp 8 | 9 | FORMS += \ 10 | $$PWD/ParaDlg.ui 11 | -------------------------------------------------------------------------------- /src/Teach/Teach.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/TeachGlWidget.h \ 3 | $$PWD/TeachDlg.h 4 | 5 | SOURCES += \ 6 | $$PWD/TeachGlWidget.cpp \ 7 | $$PWD/TeachDlg.cpp 8 | 9 | FORMS += \ 10 | $$PWD/TeachDlg.ui 11 | -------------------------------------------------------------------------------- /src/MainWindow/MainWindow.pri: -------------------------------------------------------------------------------- 1 | FORMS += \ 2 | $$PWD/MainWindow.ui 3 | 4 | HEADERS += \ 5 | $$PWD/MainWindow.h \ 6 | $$PWD/Test.h 7 | 8 | SOURCES += \ 9 | $$PWD/MainWindow.cpp \ 10 | $$PWD/main.cpp \ 11 | $$PWD/Test.cpp 12 | -------------------------------------------------------------------------------- /src/3DModel/StlParse.h.autosave: -------------------------------------------------------------------------------- 1 | #ifndef STLPARSE_H 2 | #define STLPARSE_H 3 | #include "CommonFun/Common.h" 4 | class STLView 5 | { 6 | public: 7 | STLView(); 8 | static STLView * [robotNum]; 9 | 10 | }; 11 | 12 | #endif // STLPARSE_H 13 | -------------------------------------------------------------------------------- /src/Alignment/Alignment.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/UdpSocket.h \ 3 | $$PWD/Parser.h \ 4 | $$PWD/qcustomplot.h \ 5 | $$PWD/AnalysisWidget.h 6 | 7 | SOURCES += \ 8 | $$PWD/UdpSocket.cpp \ 9 | $$PWD/Parser.cpp \ 10 | $$PWD/qcustomplot.cpp \ 11 | $$PWD/AnalysisWidget.cpp 12 | 13 | FORMS += \ 14 | $$PWD/AnalysisWidget.ui 15 | -------------------------------------------------------------------------------- /src/Gallery/CircularRectangle.cpp: -------------------------------------------------------------------------------- 1 | #include "CircularRectangle.h" 2 | 3 | CircularRectangle::CircularRectangle() 4 | { 5 | 6 | } 7 | void CircularRectangle::setData(double l,double w,double p1,double p2) 8 | { 9 | length = l; 10 | width = w; 11 | this->p1 = p1; 12 | this->p2 = p2; 13 | } 14 | void CircularRectangle::createGodes() 15 | { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/Gallery/CircularRectangle.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCULARRECTANGLE_H 2 | #define CIRCULARRECTANGLE_H 3 | //环形矩阵 4 | class CircularRectangle 5 | { 6 | public: 7 | CircularRectangle(); 8 | private: 9 | double length,width,p1,p2; 10 | void setData(double l,double w,double p1,double p2); 11 | void createGodes(); 12 | }; 13 | 14 | #endif // CIRCULARRECTANGLE_H 15 | -------------------------------------------------------------------------------- /src/Alignment/Parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H 2 | #define PARSER_H 3 | #include 4 | enum Command 5 | { 6 | CoordJoint, 7 | OpenFire, 8 | CloseFire, 9 | ConnectCmd 10 | }; 11 | class Parser 12 | { 13 | public: 14 | int getValue(const QStringList & list); 15 | int parser(const QString &data); 16 | double coord[6]; //坐标值值包括变位机构 17 | double joint[8]; //关节角的度数 18 | Command cmd; 19 | }; 20 | #endif // PARSER_H 21 | -------------------------------------------------------------------------------- /src/Setting/Parameter.h: -------------------------------------------------------------------------------- 1 | #ifndef PARAMETER_H 2 | #define PARAMETER_H 3 | #include "CommonFun/common.h" 4 | #include 5 | class Parameter 6 | { 7 | public: 8 | static Posture startPosture; //起始点 9 | static bool teachStop; 10 | static double raiseHeight; 11 | static RobotType robotType; 12 | static void readParameter(); 13 | static void writeParameter(); 14 | static QThread thread; 15 | 16 | }; 17 | #endif // PARAMETER_H 18 | -------------------------------------------------------------------------------- /src/Setting/ParaDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef PARADLG_H 2 | #define PARADLG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ParaDlg; 8 | } 9 | 10 | class ParaDlg : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ParaDlg(QWidget *parent = 0); 16 | ~ParaDlg(); 17 | public slots: 18 | void okclikedslot(); 19 | signals: 20 | void typechoosesignal(); 21 | private: 22 | Ui::ParaDlg *ui; 23 | void setInput(); 24 | }; 25 | 26 | #endif // PARADLG_H 27 | -------------------------------------------------------------------------------- /src/MainWindow/Test.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_H 2 | #define TEST_H 3 | #include "Eigen/Dense" 4 | using namespace Eigen; 5 | class Test 6 | { 7 | public: 8 | Test(); 9 | static bool copy(); 10 | static Matrix4d fk_Coord(double joint[6]); 11 | private: 12 | static Matrix4d getT(double o,double d,double a,double i); 13 | static Matrix4d rotZ(double o); 14 | static Matrix4d rotX(double i); 15 | static Matrix4d transZ(double d); 16 | static Matrix4d transX(double a); 17 | }; 18 | 19 | #endif // TEST_H 20 | -------------------------------------------------------------------------------- /src/CodeParse/NewScaraArgorithmn.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWSCARAARGORITHMN_H 2 | #define NEWSCARAARGORITHMN_H 3 | 4 | //使用静态库头文件 5 | #include "scaralib.h" 6 | 7 | class NewScaraArgorithmn 8 | { 9 | public: 10 | static Matrix4d coordTCFmatrix; 11 | static Matrix4d lanxun5JointTCFmatrix; 12 | static Matrix4d lanxun6JointTCFmatrix; 13 | static void initTCF(); 14 | 15 | // 正解: 包含 焊枪标定值 16 | static Matrix4d fksolution(Joint j); 17 | 18 | // 逆解: 包含 焊枪标定值 19 | static Joint NewPositionJointssolution(Matrix4d Matrix); 20 | }; 21 | 22 | 23 | #endif // NEWSCARAARGORITHMN_H 24 | -------------------------------------------------------------------------------- /src/CodeParse/CodeParse.pri: -------------------------------------------------------------------------------- 1 | LIBS += -L$$PWD/ -llibscara #添加静态库 2 | 3 | 4 | HEADERS += \ 5 | $$PWD/GCodeConversion.h \ 6 | $$PWD/ArcParse.h \ 7 | $$PWD/NewScaraArgorithmn.h \ 8 | $$PWD/scaralib.h \ 9 | $$PWD/CodeEditDlg.h \ 10 | $$PWD/GCodeListDlg.h \ 11 | $$PWD/SimulationParse.h \ 12 | $$PWD/RobotArgorithmn.h 13 | 14 | SOURCES += \ 15 | $$PWD/GCodeConversion.cpp \ 16 | $$PWD/ArcParse.cpp \ 17 | $$PWD/NewScaraArgorithmn.cpp \ 18 | $$PWD/CodeEditDlg.cpp \ 19 | $$PWD/GCodeListDlg.cpp \ 20 | $$PWD/SimulationParse.cpp \ 21 | $$PWD/RobotArgorithmn.cpp 22 | 23 | FORMS += \ 24 | $$PWD/CodeEditDlg.ui \ 25 | $$PWD/GCodeListDlg.ui 26 | 27 | -------------------------------------------------------------------------------- /src/RobotOfflineProgram.pro: -------------------------------------------------------------------------------- 1 | QT += core gui opengl network printsupport 2 | RC_FILE = icon.rc 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | TARGET = RobotOfflineProgram 5 | TEMPLATE = app 6 | DEFINES += QT_DEPRECATED_WARNINGS 7 | include (./MainWindow/MainWindow.pri) #导入pri文件 8 | include (./3DModel/3DModel.pri) #导入pri文件 9 | include (./CommonFun/CommonFun.pri) #导入pri文件 10 | include (./Alignment/Alignment.pri) #导入pri文件 11 | include (./CodeParse/CodeParse.pri) #导入pri文件 12 | include (./Gallery/Gallery.pri) #导入pri文件 13 | include (./Setting/Setting.pri) #导入pri文件 14 | include (./Teach/Teach.pri) #导入pri文件 15 | RESOURCES += \ 16 | res.qrc 17 | 18 | HEADERS += 19 | 20 | SOURCES += 21 | 22 | INCLUDEPATH += C:\openLIB\eigen 23 | -------------------------------------------------------------------------------- /src/Teach/TeachGlWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TEACHGLWIDGET_H 2 | #define TEACHGLWIDGET_H 3 | #include "3DModel/OpenGLWidget.h" 4 | #include "CodeParse/scaralib.h" 5 | #include 6 | 7 | class TeachGlWidget : public OpenglWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | TeachGlWidget(RobotType type); 12 | void keyPressEvent(QKeyEvent * e); 13 | public slots: 14 | void homeSlot(); 15 | void moto_SettingJSlot(char ch, double angle,double speed); //单轴移动 16 | void moveLSlot(char ch,double distance,double speed); 17 | void getCoordSlot(); 18 | signals: 19 | void sendCoordSignal(ArrayXd); 20 | private: 21 | void moto_runJ(Joint j,double speed); //先把考虑变位机构 22 | char ch; 23 | double speed; 24 | double angle; 25 | double moveLineInter; 26 | double moveJointInter; 27 | }; 28 | #endif // TEACHGLWIDGET_H 29 | -------------------------------------------------------------------------------- /src/Alignment/AnalysisWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ANALYSISWIDGET_H 2 | #define ANALYSISWIDGET_H 3 | 4 | #include 5 | #include "qcustomplot.h" 6 | #include 7 | namespace Ui { 8 | class AnalysisWidget; 9 | } 10 | 11 | class AnalysisWidget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit AnalysisWidget(QWidget *parent = 0); 17 | ~AnalysisWidget(); 18 | void replot(); 19 | void switchAna(bool isSpeedAna); 20 | public slots: 21 | void setData(double *,double *); 22 | private: 23 | Ui::AnalysisWidget *ui; 24 | bool isSpeedAna; 25 | QColor color[9]; 26 | int axisNum; 27 | void initPlot(); 28 | void init(); 29 | void initReploy(); 30 | QTime updatetime; 31 | bool isFirst; 32 | double lastJoint[6]; 33 | double lastXyzrpw[6]; 34 | }; 35 | 36 | #endif // ANALYSISWIDGET_H 37 | -------------------------------------------------------------------------------- /src/CommonFun/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_H 2 | #define COMMON_H 3 | #include 4 | /*******************常量定义区******************/ 5 | #define robotNum 3 6 | #define Pi 3.14159265358979323846 7 | const int lanxunCoordRobotPartNum = 5; 8 | const int lanxun5JointRobotPartNum = 6; 9 | const int lanxun6JointRobotPartNum = 7; 10 | //机器人类型 11 | enum RobotType 12 | { 13 | LanxunCoordRobot = 0, //蓝讯坐标式机器人 14 | Lanxun5JointRobot = 1, //蓝讯五关节式机器人 15 | Lanxun6JointRobot = 2 //蓝讯六关节式机器人 16 | }; 17 | class MyPoint 18 | { 19 | public: 20 | double x = 0,y = 0,z = 0; 21 | }; 22 | 23 | class Posture 24 | { 25 | public: 26 | double x = 0; 27 | double y = 0; 28 | double z = 0; 29 | double r = 0; 30 | double p = 0; 31 | double w = 0; 32 | double u = 0; 33 | double v = 0; 34 | double s = 3000; 35 | }; 36 | 37 | #endif // COMMON_H 38 | -------------------------------------------------------------------------------- /src/CodeParse/ArcParse.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCPARSE_H 2 | #define ARCPARSE_H 3 | #include "scaralib.h" 4 | 5 | 6 | class ArcParse 7 | { 8 | public: 9 | ArcParse(); 10 | //圆的函数 11 | static bool getCirclePoint(const ArrayXd& p1,const ArrayXd& p2,const ArrayXd& p3,ArrayXd& p4,ArrayXd& p5,ArrayXd& p6); 12 | static void getMidPoint(double x0,double y0,double z0,double r,double x1,double y1,double z1,double x2,double y2,double z2,double &x,double &y,double &z); 13 | static int isSplitArc(const ArrayXd& p1,const ArrayXd& p2,const ArrayXd& p3,ArrayXd& p4,ArrayXd& p5); 14 | static bool getCenterCoordAndRadius(double x1, double y1, double z1,double x2, double y2, double z2, double x3, double y3, double z3,double &x0,double &y0,double &z0,double &r); 15 | static double getArcLength(double x1, double y1, double z1,double x2, double y2, double z2, double x3, double y3, double z3); 16 | }; 17 | #endif // ARCPARSE_H 18 | -------------------------------------------------------------------------------- /src/3DModel/STLView.h: -------------------------------------------------------------------------------- 1 | #ifndef STLPARSE_H 2 | #define STLPARSE_H 3 | #include 4 | #include 5 | #include "CommonFun/Common.h" 6 | #include 7 | #define COORDTYPE 1 //0表示正常 1表示另外一种 8 | 9 | //三角形片类,主要由三个顶点坐标和一个法向量组成 10 | class MyTriangle 11 | { 12 | public: 13 | MyPoint normal,vertex1,vertex2,vertex3; 14 | }; 15 | 16 | //STL解析类 17 | class STLView : public QThread 18 | { 19 | public: 20 | //机器人模型库 一个模型对应一个库 这样就不会释放 21 | //解析类对象指针作为类的静态成员,只用初始化一次 22 | //单例模式 23 | static STLView* Artifacts; 24 | static STLView* lanxunCoordView; 25 | static STLView* lanxun5JointView; 26 | static STLView* lanxun6JointView; 27 | static void init(RobotType); 28 | static STLView* init(); 29 | 30 | virtual void run(); 31 | 32 | //读取stl文件并解析出来 33 | bool readSTL(const QString &fname); 34 | 35 | //保存解析出来的三角片数据 36 | QVector triangleVector; 37 | 38 | private: 39 | static RobotType type; 40 | int n; 41 | }; 42 | #endif // STLPARSE_H 43 | -------------------------------------------------------------------------------- /src/CodeParse/GcodeListDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef GCODELISTDLG_H 2 | #define GCODELISTDLG_H 3 | 4 | #include 5 | #include 6 | #include 7 | namespace Ui { 8 | class GcodeListDlg; 9 | } 10 | 11 | class GCodeListDlg : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit GCodeListDlg(QWidget *parent = 0); 17 | ~GCodeListDlg(); 18 | QListWidget *abs_list; 19 | QListWidget *rel_list; 20 | void loadlist(const QString &fileName); 21 | void setCurLine(int i); 22 | int curtabchoose(); 23 | signals: 24 | void closesignal(); 25 | void tabchangeSignal(int i); 26 | private slots: 27 | void on_tabWidget_currentChanged(int index); 28 | 29 | private: 30 | QString gFileName; 31 | QVector errs; 32 | bool isAbsolute; //是不是绝对的坐标 33 | bool isFireLine; 34 | void readFile(const QString &fname,QVector& content); 35 | void preProcess(QVector& content); //预处理 36 | void confirmCoord(QVector& content); //确定坐标形式是相对还是绝对坐标 37 | bool prerun(const QString&fname,QVector& content); 38 | Ui::GcodeListDlg *ui; 39 | void closeEvent(QCloseEvent *e); 40 | }; 41 | 42 | #endif // GCODELISTDLG_H 43 | -------------------------------------------------------------------------------- /src/Alignment/UdpSocket.h: -------------------------------------------------------------------------------- 1 | #ifndef UDPSOCKET_H 2 | #define UDPSOCKET_H 3 | #include 4 | #include 5 | #include "3DModel/OpenGLWidget.h" 6 | #include "Parser.h" 7 | #include 8 | #include 9 | 10 | //继承OpenglWidget,为了使用渲染 11 | class UdpSoket : public OpenglWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | UdpSoket(RobotType type); 17 | ~UdpSoket(); 18 | 19 | //连接与断开端口 20 | void UdpConnect(); 21 | void UdpDisConnect(); 22 | 23 | public slots: 24 | void checkIsConnect(); 25 | 26 | //串口数据传入处理槽 27 | void processPendingDatagram(); 28 | 29 | signals: 30 | void checkConnectSignal(bool flag); 31 | 32 | //输出数据 33 | void jointcoordSignal(double *,double *); 34 | 35 | private: 36 | //创建客户端,绑定端口 37 | void initSocket(); 38 | 39 | //连接服务器向服务器ip地址发送请求连接信号 40 | void connectServer(); 41 | void sendData(const QString& str,const QString& ipAddress); 42 | 43 | //封装数据包解析出来的数据,发送数据给柱形图分析窗口 44 | void sendJC(); 45 | 46 | void closeEvent(QCloseEvent *e); 47 | void keyPressEvent(QKeyEvent *e); 48 | 49 | private: 50 | //解析句柄 51 | Parser *parser; 52 | bool isConnect; 53 | 54 | //套接字客户端 55 | QUdpSocket *socket; 56 | }; 57 | 58 | #endif // UDPSOCKET_H 59 | -------------------------------------------------------------------------------- /src/Setting/Parameter.cpp: -------------------------------------------------------------------------------- 1 | #include "Parameter.h" 2 | Posture Parameter::startPosture; 3 | double Parameter::raiseHeight = 50; 4 | RobotType Parameter::robotType = LanxunCoordRobot; 5 | bool Parameter::teachStop = false; 6 | QThread Parameter::thread; 7 | #include "CommonFun/CommonFun.h" 8 | void Parameter::readParameter() 9 | { 10 | startPosture.x = CommonFun::ReadSettingsDouble("Para/startX"); 11 | startPosture.y = CommonFun::ReadSettingsDouble("Para/startY"); 12 | startPosture.z = CommonFun::ReadSettingsDouble("Para/startZ"); 13 | startPosture.r = CommonFun::ReadSettingsDouble("Para/startR"); 14 | startPosture.p = CommonFun::ReadSettingsDouble("Para/startP"); 15 | startPosture.w = CommonFun::ReadSettingsDouble("Para/startW"); 16 | robotType = (RobotType)CommonFun::ReadSettingsInt("Para/robotType"); 17 | } 18 | void Parameter::writeParameter() 19 | { 20 | CommonFun::WriteSettingsDouble("Para/startX",startPosture.x); 21 | CommonFun::WriteSettingsDouble("Para/startY",startPosture.y); 22 | CommonFun::WriteSettingsDouble("Para/startZ",startPosture.z); 23 | CommonFun::WriteSettingsDouble("Para/startR",startPosture.r); 24 | CommonFun::WriteSettingsDouble("Para/startP",startPosture.p); 25 | CommonFun::WriteSettingsDouble("Para/startW",startPosture.w); 26 | CommonFun::WriteSettingsInt("Para/robotType",robotType); 27 | } 28 | -------------------------------------------------------------------------------- /src/CodeParse/CodeEditDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEEDITDLG_H 2 | #define CODEEDITDLG_H 3 | 4 | #include 5 | #include "GCodeConversion.h" 6 | #include "SimulationParse.h" 7 | #include 8 | namespace Ui { 9 | class CodeEditDlg; 10 | } 11 | class CodeEditDlg : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit CodeEditDlg(QWidget *parent = 0); 16 | ~CodeEditDlg(); 17 | 18 | //解析g代码的句柄 19 | GCodeConversion codeconversion; 20 | QString saveFileName; 21 | // QString originFileName; 22 | // QString transFileName; 23 | 24 | public: 25 | void closeEvent(QCloseEvent *event); 26 | 27 | //检查切换状态,true为最终焊接文件, 28 | bool checkSwitch(); 29 | 30 | //打开,新建,保存,另存为函数 31 | void openFile(); 32 | void newCreteFile(); 33 | void saveFile(); 34 | void saveAsFile(); 35 | 36 | //开始解析当前文件 37 | void transFile(); 38 | void transFile(const QString & fileName); 39 | 40 | public slots: 41 | //颜色 42 | void colorSlot(); 43 | //字体 44 | void fontSlot(); 45 | //粗体 46 | void boldSlot(); 47 | //打印 48 | void printSlot(); 49 | //切换代码 50 | bool switchSlot(); 51 | 52 | private: 53 | Ui::CodeEditDlg *ui; 54 | void init(); 55 | //void saveFileAsFun(); 56 | //SimulationParse *simulationParse; 57 | QString lastFilePath; 58 | }; 59 | 60 | #endif // CODEEDITDLG_H 61 | -------------------------------------------------------------------------------- /src/Alignment/Parser.cpp: -------------------------------------------------------------------------------- 1 | #include "Parser.h" 2 | #include 3 | 4 | //解析数据包内容 5 | int Parser::parser(const QString &data) 6 | { 7 | QStringList list = data.split(","); 8 | return getValue(list); 9 | } 10 | 11 | //提取数据,数据包结构包括,(指令,指令长度,6个坐标,8关节值) 12 | int Parser::getValue(const QStringList & list) 13 | { 14 | if(list.size() < 2) 15 | return -1; 16 | if(list.size() != list[1].toInt()) 17 | return -1; 18 | 19 | if(list[0] == "UC"){ 20 | cmd = CoordJoint; 21 | for(int i=2;i<16;++i){ 22 | if(i<8){ 23 | coord[i-2] = list[i].toDouble(); 24 | }else{ 25 | joint[i-8] = list[i].toDouble(); 26 | } 27 | } 28 | // for(int i = 2;i < 8;i++){ 29 | // coord[i - 2] = list[i].toDouble(); 30 | // } 31 | // for(int i = 8; i < 16; i++){ 32 | // joint[i - 8] = list[i].toDouble(); 33 | // } 34 | return 0; 35 | } 36 | 37 | if(list[0] == "M7"){ 38 | qDebug() << "开火"; 39 | cmd = OpenFire; 40 | return 0; 41 | } 42 | 43 | if(list[0] == "M8"){ 44 | qDebug() << "关火"; 45 | cmd = CloseFire; 46 | return 0; 47 | } 48 | 49 | if(list[0] == "EE"){ 50 | qDebug() << "连接"; 51 | cmd = ConnectCmd; 52 | return 0; 53 | } 54 | else 55 | return -1; 56 | } 57 | -------------------------------------------------------------------------------- /src/Alignment/AnalysisWidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AnalysisWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 600 10 | 607 11 | 12 | 13 | 14 | 15 | 540 16 | 0 17 | 18 | 19 | 20 | 21 | 620 22 | 16777215 23 | 24 | 25 | 26 | Form 27 | 28 | 29 | 30 | 31 | 32 | 0 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | QCustomPlot 47 | QWidget 48 |
Alignment/qcustomplot.h
49 | 1 50 |
51 |
52 | 53 | 54 |
55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :robot:焊接机器人离线编程软件 2 | 3 | 4 | :pencil:需求分析 5 | =================================================== 6 | 1.三维建模 7 | -------------- 8 | * 提供用户根据焊接实际需求构建焊接机器人、焊枪工具、待焊接的工件的模型。用户使用常规的三维建模软件,导入本软件中生成三维模型图。 9 | 10 | 2.离线编程 11 | ------------ 12 | * 离线编程就是通过在软件中构建焊接虚拟场景,根据用户构建的焊接工件的大小形状和材料,提供某些软件配合操作,自动生成焊接轨迹,并下传到机器人控制器中执行焊接作业。本文研究设计的焊接机器人离线编程和仿真系统,结合自己实习企业的焊接用户的实际需要和工艺要求,提供给用户多种灵活的编程方式。本文设计的软件提供图库、代码转换与编辑、虚拟示教等多种编程方式。 13 | 14 | 3.代码解析 15 | ------------ 16 | * 离线编程生成的代码文件通过代码解析提取出文件轨迹的关键点的姿态信息和类型信息。 17 | 18 | 4.正逆解算法 19 | --------------- 20 | * 焊接机器人正解是根据焊接机器人各个关节的运动参数即关节角度变化量推算出焊枪末端相对于参考坐标系的位姿信息。逆解是根据给定的焊枪末端相对于参考坐标系的位置和姿态来求出机器人各个关节的运动量。 21 | 22 | 5.轨迹规划 23 | ------------ 24 | * 轨迹规划是根据记录的特征点和轨迹类型进行插值,离散成许多碎小线段,同时还要考虑运行过程中的速度变化和加速度变化。轨迹规划由路径规划和速度规划组成。 25 | 26 | 6.仿真 27 | ---------- 28 | * 根据算法生成的关节角度信息运用到机器人的三维模型上,结合速度规划,进行合理的加减速,使虚拟的机器人能够像实际焊接机器人运动一样,模拟焊接运动过程,生成焊接轨迹。 29 | 30 | 7.监测 31 | ------------- 32 | * 能够监测焊接机器人的实际运动过程,能在监测界面使得虚拟焊接机器人模型同步进行焊接运动,并实时分析机器人的各个关节变化量和焊枪姿态变化量以及它们对应的速度变化,并能够生成曲线图。 33 | 34 | :pushpin:辅助功能 35 | =========== 36 | 37 | 1.文本的编辑与保存 38 | -------------------- 39 | * 离线编程的轨迹最终某种离线编程语言以文本的方式保存。需要提供文本的常见操作,比如打开、保存、另存为、打印、设置文本的字体和颜色等功能。 40 | 41 | 2.监测功能 42 | ------------------- 43 | * 在焊接的运动中,实时模拟焊接机器人的运动情况,并分析焊接机器人的各个关节的角度数据、焊枪末端的位姿数据以及关节角速度与轨迹速度数据,并以曲线图的方式直观表达出来,可以实时追踪机器人的运动状态,检查算法的正确性。 44 | 45 | 3.仿真辅助功能 46 | ------------------------ 47 | * 在轨迹仿真过程中,需要添加一些辅助功能,提供仿真效果的直观性。比如可以设置焊接模式,能够进行前进、后退、暂停操作。显示轨迹与代码列表的内容一一对应。能够隐藏空移线或者隐藏机器人使用户更加关注于轨迹运行的过程,这些功能可以提高软件的用户体验。 48 | 49 | 4.视图功能 50 | --------------- 51 | * 对于焊接的虚拟场景,能够提供对三维场景的交互式操作的开发(包括放大、缩小、旋转、平移等多种操作),使用户能够从多种视角去观察焊接机器人虚拟的仿真运动。 52 | -------------------------------------------------------------------------------- /src/CodeParse/CodeEditDlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | CodeEditDlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 824 10 | 539 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | background-color: rgb(255, 255, 255); 18 | 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 37 | 38 | 39 | 40 | 文件名: 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/CodeParse/RobotArgorithmn.h: -------------------------------------------------------------------------------- 1 | #ifndef ROBOTARGORITHMN_H 2 | #define ROBOTARGORITHMN_H 3 | #include "Eigen/Dense" 4 | #include "iostream" 5 | using namespace std; 6 | using namespace Eigen; 7 | 8 | //关节参数 9 | class Joint1 10 | { 11 | public: 12 | double j1; 13 | double j2; 14 | double j3; 15 | double j4; 16 | double j5; 17 | double j6; 18 | 19 | //弧度或者角度打印 20 | void printJointRadians() const; 21 | void printJointDegrees() const; 22 | }; 23 | 24 | class RobotArgorithmn 25 | { 26 | public: 27 | RobotArgorithmn(); 28 | 29 | //坐标式机器人正解,第二种效率更高 30 | static Matrix4d fk_Coord(const Joint1&); 31 | static Matrix4d fk_CoordNew(const Joint1&); 32 | //逆解并判断是否有解,并打印解 33 | static bool ik_Coord(const Matrix4d& m); 34 | 35 | static Matrix4d fk_5JointNew(const Joint1&); 36 | static Matrix4d fk_5Joint(const Joint1&); 37 | static bool ik_5Joint(const Matrix4d& m); 38 | static Matrix4d fk_6Joint(const Joint1&); 39 | 40 | private: 41 | //五轴机器人参数 42 | static double a1_5; 43 | static double a2_5; 44 | static double d2_5; 45 | 46 | //焊枪矩阵 47 | static Matrix4d TCF_Coord; 48 | static Matrix4d TCF_5Joint; 49 | static Matrix4d TCF_6Joint; 50 | 51 | //六轴机器人参数 52 | static double a1_6; 53 | static double a2_6; 54 | static double a3_6; 55 | static double d1_6; 56 | static double d4_6; 57 | 58 | //获得每层joint转换矩阵,参数a,α,d,θ, 59 | static Matrix4d getT(double o,double d,double a,double i); 60 | 61 | //旋转矩阵 62 | static Matrix4d rotZ(double o); 63 | static Matrix4d rotX(double i); 64 | static Matrix4d rotY(double j); 65 | 66 | //移动矩阵 67 | static Matrix4d transZ(double d); 68 | static Matrix4d transX(double a); 69 | 70 | //判断逆解Joint1是否正确 71 | static bool compare(const Joint1& jt,const Matrix4d &m,int i); 72 | }; 73 | 74 | #endif // ROBOTARGORITHMN_H 75 | -------------------------------------------------------------------------------- /src/Setting/ParaDlg.cpp: -------------------------------------------------------------------------------- 1 | #include "ParaDlg.h" 2 | #include "ui_ParaDlg.h" 3 | #include "Parameter.h" 4 | #include 5 | ParaDlg::ParaDlg(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::ParaDlg) 8 | { 9 | ui->setupUi(this); 10 | ui->X_edit->setText(QString::number(Parameter::startPosture.x)); 11 | ui->Y_edit->setText(QString::number(Parameter::startPosture.y)); 12 | ui->Z_edit->setText(QString::number(Parameter::startPosture.z)); 13 | ui->R_edit->setText(QString::number(Parameter::startPosture.r)); 14 | ui->P_edit->setText(QString::number(Parameter::startPosture.p)); 15 | ui->W_edit->setText(QString::number(Parameter::startPosture.w)); 16 | ui->robotTypeBox->setCurrentIndex(Parameter::robotType); 17 | setInput(); 18 | connect(ui->ok_buttton,SIGNAL(clicked()),this,SLOT(okclikedslot())); 19 | connect(ui->cancel_button,SIGNAL(clicked()),this,SLOT(close())); 20 | } 21 | ParaDlg::~ParaDlg() 22 | { 23 | delete ui; 24 | } 25 | void ParaDlg::setInput() 26 | { 27 | QRegExp rx("^(-?[0]|-?[1-9][0-9]{0,5})(?:\\.\\d{1,4})?$|(^\\t?$)"); 28 | QRegExpValidator *pReg = new QRegExpValidator(rx, this); 29 | ui->X_edit->setValidator(pReg); 30 | ui->Y_edit->setValidator(pReg); 31 | ui->Z_edit->setValidator(pReg); 32 | ui->R_edit->setValidator(pReg); 33 | ui->P_edit->setValidator(pReg); 34 | ui->W_edit->setValidator(pReg); 35 | } 36 | void ParaDlg::okclikedslot() 37 | { 38 | Parameter::startPosture.x = (ui->X_edit->text()).toDouble(); 39 | Parameter::startPosture.y = (ui->Y_edit->text()).toDouble(); 40 | Parameter::startPosture.z = (ui->Z_edit->text()).toDouble(); 41 | Parameter::startPosture.r = (ui->R_edit->text()).toDouble(); 42 | Parameter::startPosture.p = (ui->P_edit->text()).toDouble(); 43 | Parameter::startPosture.w = (ui->W_edit->text()).toDouble(); 44 | Parameter::robotType = (RobotType)(ui->robotTypeBox->currentIndex()); 45 | close(); 46 | emit typechoosesignal(); //类型选择 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/CodeParse/NewScaraArgorithmn.cpp: -------------------------------------------------------------------------------- 1 | #include "NewScaraArgorithmn.h" 2 | #include "Setting/Parameter.h" 3 | Matrix4d NewScaraArgorithmn::coordTCFmatrix = Matrix4d::Zero(); 4 | Matrix4d NewScaraArgorithmn::lanxun5JointTCFmatrix = Matrix4d::Zero(); 5 | Matrix4d NewScaraArgorithmn::lanxun6JointTCFmatrix = Matrix4d::Zero(); 6 | void NewScaraArgorithmn::initTCF() //这个TCF值还得测试出来 根据TCF来画杆子 7 | { 8 | dh = 0; 9 | coordTCFmatrix << 1, 0, 0, 220, 10 | 0, 1, 0, -45, 11 | 0, 0, 1, -170, 12 | 0, 0, 0, 1; 13 | 14 | lanxun5JointTCFmatrix << 1, 0, 0,0, 15 | 0, 1, 0, 0, 16 | 0, 0, 1, -233.924, 17 | 0, 0, 0, 1; 18 | lanxun6JointTCFmatrix << 1, 0, 0,0, 19 | 0, 1, 0, 0, 20 | 0, 0, 1, 0, 21 | 0, 0, 0, 1; 22 | float JAAA_min[6] = {-17000000.0, -17000000.0, -500000, -3600.0 / 180 * Pi, -3600.0 / 180 * Pi, -3600.0 / 180 * Pi}; 23 | float JAAA_max[6] = { 17000000.0, 17000000.0, 500000, 3600.0 / 180 * Pi, 3600.0 / 180 * Pi, 3600.0 / 180 * Pi}; 24 | for(int i = 0; i < 6; i++) 25 | { 26 | JA_min[i] = JAAA_min[i]; 27 | JA_max[i] = JAAA_max[i]; 28 | } 29 | } 30 | 31 | // 判断机器人类型,进行正解,包含焊枪标定值 32 | Matrix4d NewScaraArgorithmn::fksolution(Joint j) 33 | { 34 | if(Parameter::robotType == LanxunCoordRobot) 35 | return coo_fk(j) * coordTCFmatrix; 36 | else if(Parameter::robotType == Lanxun5JointRobot) 37 | return fk(j) * lanxun5JointTCFmatrix; 38 | } 39 | 40 | //根据机器人类型,进行逆解 41 | Joint NewScaraArgorithmn::NewPositionJointssolution(Matrix4d Matrix) 42 | { 43 | Matrix4d temp = Matrix4d::Zero(); 44 | //坐标机器人逆解 45 | if(Parameter::robotType == LanxunCoordRobot){ 46 | temp = Matrix * coordTCFmatrix.inverse(); 47 | return coo_ik(temp); 48 | //关节机器人逆解 49 | }else if(Parameter::robotType == Lanxun5JointRobot){ 50 | temp = Matrix * lanxun5JointTCFmatrix.inverse(); 51 | return NewPositionJoints(temp); 52 | } 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/CodeParse/GCodeConversion.h: -------------------------------------------------------------------------------- 1 | #ifndef GCODECONVERSION_H 2 | #define GCODECONVERSION_H 3 | #include 4 | #include 5 | #include "Setting/Parameter.h" 6 | using namespace std; 7 | const int ERR_sfileopenfalse = -2; 8 | const int ERR_fileempty = -3; 9 | const int ERR_G9091 = - 4; 10 | 11 | //G代码类型 12 | enum CodeTypeEnum 13 | { 14 | START_POINT_CODE,METER_CODE,INCH_CODE, //起点 15 | NO_USE_CODE,G99_CODE, 16 | ABSOLUTE_CODE,RELATIVE_CODE, 17 | INTERPOLATION_LINE,MOVE_LINE, 18 | CW_ARC_CODE,ACW_ARC_CODE, 19 | FIRE_ON_CODE,FIRE_OFF_CODE,FINISH_CODE,ARC_CODE, 20 | CIRCLE_CODE 21 | }; 22 | 23 | class GCodeConversion 24 | { 25 | public: 26 | GCodeConversion(); 27 | 28 | //创建最终焊接文件入口函数 29 | int CreateConvertedFile(const QString& filename); 30 | void dspMsg(const QString &preMsg,QWidget*wid); 31 | 32 | //bool CreateConvertedFile(const QVector& content,QString &filename); 33 | 34 | private: 35 | Posture point; 36 | int curNum; 37 | QVector content;//G代码内容(经过预处理) 38 | QVector converedContent;//G代码内容(经过预处理) 39 | QVector errs; 40 | bool isAbsolute; //是不是绝对的坐标 41 | bool isFireLine; 42 | QString currentCode; 43 | bool IsCam; 44 | 45 | private: 46 | //运行主函数 47 | bool run(const QString &fname); 48 | void readFile(const QString &fname); 49 | void preProcess(); //预处理 50 | void confirmCoord(); //确定坐标形式是相对还是绝对坐标 51 | //解析主入口,错误显示tbd 52 | void doParse(); 53 | bool ParserSentence(const QString &sentence); 54 | bool ParserLine(const QVector &words); 55 | bool ParserArc(const QVector &words,const CodeTypeEnum ¤tCode); 56 | void tansvertArcNew(double x1,double y1,double i,double j,bool IsCw,bool isTurn); 57 | 58 | private: 59 | //解析浮点数值,tbd 判断是否为合法浮点数 60 | bool ParserDouble(const QString &word,wchar_t &pre,double &val); 61 | bool getCode(const QString &cmd,CodeTypeEnum ¤tCode); 62 | void writeConveredGcodes(const QString &cmd); 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | //double getAngle(double x,double y); 72 | //void tansvertArc(double x1,double y1,double i,double j,bool IsCw); 73 | 74 | }; 75 | 76 | #endif // GCODECONVERSION_H 77 | -------------------------------------------------------------------------------- /src/MainWindow/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "Test.h" 2 | #include 3 | #include "CommonFun/CommonFun.h" 4 | #include 5 | #include "math.h" 6 | Test::Test() 7 | { 8 | 9 | } 10 | 11 | bool Test::copy() 12 | { 13 | QString ss = "H:\\hs\\"; 14 | QVector all; 15 | QVector content; 16 | all.clear(); 17 | for(int i = 1; i <=2; i++) 18 | { 19 | CommonFun::readTextFile(ss + QString("%1.STL").arg(i),content); 20 | all.append(content); 21 | } 22 | CommonFun::wirteTextFile(ss + "w.STL",all); 23 | return true; 24 | } 25 | Matrix4d Test::rotZ(double o) 26 | { 27 | Matrix4d m = Matrix4d::Zero();; 28 | m << cos(o), -sin(o), 0, 0, 29 | sin(o), cos(o), 0, 0, 30 | 0, 0, 1, 0, 31 | 0, 0, 0, 1; 32 | return m; 33 | } 34 | Matrix4d Test::rotX(double i) 35 | { 36 | Matrix4d m = Matrix4d::Zero(); 37 | m << 1, 0, 0, 0, 38 | 0, cos(i), -sin(i), 0, 39 | 0, sin(i), cos(i), 0, 40 | 0, 0, 0, 1; 41 | return m; 42 | } 43 | Matrix4d Test::transZ(double d) 44 | { 45 | Matrix4d m = Matrix4d::Zero(); 46 | m << 1, 0, 0, 0, 47 | 0, 1, 0, 0, 48 | 0, 0, 1, 0, 49 | 0, 0, 0, d; 50 | return m; 51 | } 52 | Matrix4d Test::transX(double a) 53 | { 54 | Matrix4d m = Matrix4d::Zero();; 55 | m << 1, 0, 0, a, 56 | 0, 1, 0, 0, 57 | 0, 0, 1, 0, 58 | 0, 0, 0, 0; 59 | return m; 60 | } 61 | Matrix4d Test::fk_Coord(double joint[6]) 62 | { 63 | Matrix4d T13 = Matrix4d::Zero(); 64 | T13 << 1,0,0,joint[0], 65 | 0,1,0,joint[1], 66 | 0,0,1,joint[2], 67 | 0,0,0,1; 68 | Matrix4d T4 = getT(joint[3],0,0,-90 / 180.0 * PI); 69 | Matrix4d Th = rotZ(joint[4]) * rotX(90 / 180.0 * PI); 70 | return T13 * T4 * Th; 71 | } 72 | Matrix4d Test::getT(double o,double d,double a,double i) //o是弧度值 73 | { 74 | Matrix4d m = Matrix4d::Zero(); 75 | m << cos(o), -sin(o) * cos(i), sin(o) * sin(i), a * cos(o), 76 | sin(o), cos(o) * cos(i), -cos(o) * sin(i), a * sin(o), 77 | 0, sin(i), cos(i), d, 78 | 0, 0, 0, 1; 79 | return m; 80 | } 81 | -------------------------------------------------------------------------------- /src/CommonFun/CommonFun.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMONFUN_H 2 | #define COMMONFUN_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "CodeParse/scaralib.h" 10 | using namespace std; 11 | typedef long long LL; 12 | enum E_TEXTSIZE 13 | { 14 | E_NORMAL = 0, // 15 | E_SMALL = 1 , //用枚举类型哈哈 16 | E_LITTER = 2, 17 | E_Mid = 3 18 | }; 19 | class CommonFun 20 | { 21 | public: 22 | CommonFun(); 23 | //分割字符串 24 | static Joint lastj; 25 | static QVector listNum; 26 | static string joinstr; 27 | static QSettings settings; 28 | 29 | //读出设置:根据key值返回一个bool类型 30 | static bool ReadSettingsBool(const QString &dataItem); 31 | //写入设置(关键字:dataItem,值:bool类型) 32 | static void WriteSettingsBool(const QString &dataItem,bool data); 33 | //写入设置(关键字:dataItem,值:int类型) 34 | static void WriteSettingsInt(const QString &dataItem,int data); 35 | //读出设置:根据key值返回一个int类型 36 | static int ReadSettingsInt(const QString &dataItem); 37 | //读出设置:根据key值返回一个double类型 38 | static double ReadSettingsDouble(const QString &dataItem); 39 | //写入设置(关键字:dataItem,值:Double类型) 40 | static void WriteSettingsDouble(const QString &dataItem,double data); 41 | //读出设置:根据key值返回一个string类型 42 | static QString ReadSettingsStr(const QString &dataItem); 43 | //写入设置(关键字:dataItem,值:sting类型) 44 | static void WriteSettingsStr(const QString &dataItem,const QString& data); 45 | 46 | 47 | static int splitString(const QString &str, char split, QVector& strArray); 48 | //读取文本文件,每行读取为一个字符串 49 | static bool readTextFile(const QString &fname,QVector&content); 50 | static bool wirteTextFile(const QString &fname,const QVector&content); 51 | //拷贝文件 52 | static bool copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist); 53 | static bool isThreePointInLine(double x1, double y1, double z1,double x2, double y2, double z2, double x3, double y3, double z3); 54 | //得到目录,不带最后的'\' 55 | static QString getExePath(); 56 | static void msgErr(const QString &err,QWidget*wid); 57 | static double round(double number, unsigned int bits); 58 | static void sleep(unsigned int msec); 59 | static void setToolButtonStyle(QToolButton *tbn, const QString &text, 60 | int textSize,const QString iconName); 61 | static QString hextoInt(const QString &str); 62 | static int time_substract(struct timeval *result, struct timeval *begin,struct timeval *end); 63 | 64 | }; 65 | 66 | #endif // COMMONFUN_H 67 | -------------------------------------------------------------------------------- /src/CodeParse/GcodeListDlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GcodeListDlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 420 10 | 406 11 | 12 | 13 | 14 | 15 | 420 16 | 0 17 | 18 | 19 | 20 | 21 | 16777215 22 | 16777215 23 | 24 | 25 | 26 | 程序列表 27 | 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 0 40 | 41 | 42 | 0 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 当前文件行: 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Qt::Horizontal 72 | 73 | 74 | 75 | 40 76 | 20 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 0 87 | 88 | 89 | 90 | Tab 1 91 | 92 | 93 | 94 | 95 | Tab 2 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/CodeParse/SimulationParse.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATIONPARSER_H 2 | #define SIMULATIONPARSER_H 3 | 4 | #include 5 | #include "GCodeConversion.h" 6 | #include "3DModel/OpenGLWidget.h" 7 | //#include "NewScaraArgorithmn.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "Alignment/AnalysisWidget.h" 15 | #define TIMELIST 40 16 | 17 | class SimulationParse : public OpenglWidget 18 | { 19 | Q_OBJECT 20 | public: 21 | SimulationParse(RobotType type); 22 | ~SimulationParse(); 23 | bool run(bool flag); 24 | bool prerun(const QString &fname); 25 | void closeEvent(QCloseEvent * e); 26 | bool IsStop; 27 | int lineIndex; //每一条线段的索引值 28 | int interIndex; //表是直线插补或则圆弧的插补点 29 | bool isFireMode; 30 | bool isFinished; 31 | public: 32 | void modeSwitch(); 33 | private: 34 | 35 | double divideLength; //等分的长度 36 | QVector content;//G代码内容(经过预处理) 37 | QVector errs; 38 | void preProcess(); //预处理 39 | void readFile(const QString &fname); 40 | //解析主入口,错误显示tbd 41 | void doParse(bool flag); //true表示前进 表示后退 42 | bool ParserSentence(const QString &sentence,const QString &sentence1); 43 | bool ParserSentenceback(const QString &sentence,const QString &sentence1); 44 | bool getCode(const QString &cmd,CodeTypeEnum &code); 45 | bool isFireLine; 46 | bool ParserDouble(const QString &word,wchar_t &pre,double &val); 47 | //解析直线,用比较固定的方法直接解析 48 | bool ParserLine(const QVector &words,CodeTypeEnum code,bool flag); 49 | bool ParserArcBack(const QVector &words,const QVector&words1,const CodeTypeEnum &code); 50 | bool ParserArc(const QVector&words,const QVector&words1,const CodeTypeEnum &code); 51 | ArrayXd currentXyzrpw; 52 | Coint curC; 53 | int num; 54 | void moto_runJAbs(Joint j, Coint c,bool flag,double sp); 55 | void sendJC(); 56 | 57 | /**************************圆/圆弧等分算法************************************/ 58 | bool isEndPoint(double x1, double y1, double z1, double x2, double y2, double z2); 59 | //圆弧等分得到等分点的坐标 60 | //num是等分点序号的基数,在等分圆时用,等分圆弧为0 61 | bool getArcDividePoint(double x1, double y1, double z1, double r1, double p1, double w1,double x2, 62 | double y2, double z2, double x3, double y3, double z3, double r3, 63 | double p3,double w3, int num,QList>& pointList); 64 | bool getCircleDividePoint(double x1, double y1, double z1, double r1, double p1,double w1, double x2, 65 | double y2, double z2, double x3, double y3, double z3, double r3, 66 | double p3,double w3,QList>& arcDividePoint); 67 | bool getLineDividePoint(ArrayXd &xyzrpw,Coint& c,bool flag); 68 | unsigned int timelist[TIMELIST]; 69 | signals: 70 | void parseGrogress(int n); 71 | void jointcoordSignal(double *j,double *c); 72 | void runFinished(); 73 | public slots: 74 | void addspeed(); 75 | void decspeed(); 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/3DModel/OpenGLWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENGLWIDGET_H 2 | #define OPENGLWIDGET_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "STLView.h" 11 | #include 12 | #include "CodeParse/scaralib.h" 13 | 14 | enum Mode 15 | { 16 | FireMode, //焊接模式 17 | 18 | ShowMode, //演示模式 19 | NoMode 20 | }; 21 | 22 | enum WidgetName 23 | { 24 | NONAME, 25 | TEACH, //示教 26 | SIMULATION, //仿真 27 | ALIGNMENT //联调 28 | }; 29 | enum ViewMode 30 | { 31 | NOHIDE, 32 | HIDEROBOT, 33 | HIDEROBOTANDTORCH 34 | }; 35 | class MyPoint1 36 | { 37 | public: 38 | MyPoint1() 39 | { 40 | color = Qt::black; 41 | } 42 | double x,y,z; 43 | QColor color; 44 | }; 45 | 46 | //必须继承QGLWidget和QOpenGLFunctions_2_1 47 | class OpenglWidget : public QGLWidget, public QOpenGLFunctions_2_1 48 | { 49 | Q_OBJECT 50 | public: 51 | OpenglWidget(RobotType type); 52 | 53 | //重载paintGL()、initializeGL()、resizeGL() 54 | //调用initializeOpenGLFunctions() 环境的初始化工作 55 | void initializeGL() ; 56 | 57 | //调用updateGL()触发重绘 58 | void paintGL(); 59 | 60 | //当界面的窗口的大小发生变化时,就会触发resizeGL()函数,并调用updateGL()实现重绘 61 | void resizeGL( int w, int h ); 62 | 63 | //事件处理 64 | void keyPressEvent(QKeyEvent * e); 65 | void mousePressEvent(QMouseEvent *event); 66 | void mouseMoveEvent(QMouseEvent *event); 67 | void mouseDoubleClickEvent(QMouseEvent *event); 68 | void wheelEvent(QWheelEvent *event); 69 | 70 | void loadGLTextures(); 71 | double callFrequency(); 72 | double Fps; 73 | 74 | //用于保存关节数据和坐标 75 | GLfloat j1Rot,j2Rot,j4Rot,j3Rot,j5Rot,j6Rot,c1Rot,c2Rot; 76 | double coord[8]; 77 | 78 | void addTrialPoints(); 79 | void decTrialPoints(); 80 | // double dx,dy,dz; 81 | RobotType glType; 82 | void init(); 83 | void home(); 84 | 85 | //根据数据包解析cmd指令获得颜色赋值给linecolor 86 | QColor linecolor; 87 | 88 | QList trailPoints; 89 | GLuint *gllist; 90 | Mode mode; 91 | ViewMode viewmode; 92 | WidgetName widgetname; 93 | int percent; 94 | int speedRate; 95 | bool amplification(); 96 | bool NarrowDown(); 97 | void reduce(); 98 | void xRotateadd(); 99 | void xRotatedec(); 100 | void yRotateadd(); 101 | void yRotatedec(); 102 | bool isHideLine; 103 | void changeViewMode(ViewMode mode); 104 | bool changeIsHideLine(); 105 | void getCurrentCoord(); 106 | void loadArtifacts(const QString &fname,bool flag); 107 | void setJ(const Joint& j); 108 | void getCurrentJ(Joint& j); 109 | static STLView *artifacts; 110 | bool isShowWorkPiece; 111 | private: 112 | double scaleNum; 113 | double d1,a2,a3,a4,d3,dh,d4,d6; 114 | void makeObject(); 115 | STLView *view; 116 | GLfloat xRot,yRot,zRot,zoom; 117 | GLfloat wpxTrans,wpyTrans,wpzTrans; //保证平移方面 118 | QPoint lastPos; 119 | double lastDis; 120 | QColor color[8]; 121 | bool light; 122 | GLuint texture[1]; 123 | int num; 124 | void setText(); 125 | void drawLanxun5JointRobot(); 126 | void drawLanxun6JointRobot(); 127 | void drawLanxunCoordRobot(); 128 | void drawFloor(); 129 | 130 | }; 131 | #endif // OPENGLWIDGET_H 132 | -------------------------------------------------------------------------------- /src/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | stl/lanxunCoordRobot/1.STL 4 | stl/lanxunCoordRobot/2.STL 5 | stl/lanxunCoordRobot/3.STL 6 | stl/lanxunCoordRobot/4.STL 7 | stl/lanxun5JointRobot/1.STL 8 | stl/lanxun5JointRobot/2.STL 9 | stl/lanxun5JointRobot/3.STL 10 | stl/lanxun5JointRobot/4.STL 11 | stl/lanxun5JointRobot/5.STL 12 | stl/lanxun5JointRobot/6.STL 13 | images/simulation.png 14 | images/about.png 15 | images/exit.png 16 | images/find.png 17 | images/new.png 18 | images/open.png 19 | images/print.png 20 | images/replace.png 21 | images/save.png 22 | images/bold.png 23 | images/alignment.png 24 | images/setting.png 25 | images/start.png 26 | images/teach.png 27 | images/download.png 28 | images/edit.png 29 | stl/lanxun6JointRobot/0.STL 30 | stl/lanxun6JointRobot/1.STL 31 | stl/lanxun6JointRobot/2.STL 32 | stl/lanxun6JointRobot/3.STL 33 | stl/lanxun6JointRobot/4.STL 34 | stl/lanxun6JointRobot/5.STL 35 | stl/lanxun6JointRobot/6.STL 36 | images/trans.png 37 | images/back.png 38 | images/choose.png 39 | images/pause.png 40 | images/play.png 41 | images/reset.png 42 | images/zeropoint.png 43 | images/stop.png 44 | images/modeSwitch.png 45 | images/fileSwitch.png 46 | images/glist.png 47 | images/add.png 48 | images/reduce.png 49 | images/amplification.png 50 | images/NarrowDown.png 51 | images/reduction.png 52 | images/rotate.png 53 | images/hideRobot.png 54 | images/hideRobotAndTorch.png 55 | images/noHide.png 56 | images/parameter.png 57 | images/connect.png 58 | images/clearTrials.png 59 | images/disConnect.png 60 | images/hideLine.png 61 | images/teachShow.png 62 | images/saveAs.png 63 | images/shape.png 64 | images/add1.png 65 | images/dec.png 66 | images/compile.png 67 | images/trailAna.png 68 | images/speedAna.png 69 | stl/lanxunCoordRobot1/0.STL 70 | stl/lanxunCoordRobot1/1.STL 71 | stl/lanxunCoordRobot1/2.STL 72 | stl/lanxunCoordRobot1/3.STL 73 | stl/lanxunCoordRobot1/4.STL 74 | stl/lanxunCoordRobot1/5.STL 75 | stl/lanxunCoordRobot/5.STL 76 | icon.ico 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/MainWindow/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include 3 | #include "3DModel/STLView.h" 4 | #include "CommonFun/common.h" 5 | #include "CommonFun/CommonFun.h" 6 | #include "3DModel/OpenGLWidget.h" 7 | #include "Test.h" 8 | #include "Alignment/UdpSocket.h" 9 | #include "CodeParse/GCodeConversion.h" 10 | #include "CodeParse/CodeEditDlg.h" 11 | #include "CodeParse/GCodeListDlg.h" 12 | #include "Teach/TeachDlg.h" 13 | #include "Alignment/AnalysisWidget.h" 14 | #include 15 | #include "CodeParse/RobotArgorithmn.h" 16 | #include "math.h" 17 | using namespace std; 18 | Coint currentC = { 0, 0 }; 19 | int main(int argc, char *argv[]) 20 | { 21 | 22 | QApplication a(argc, argv); 23 | Test::copy(); 24 | // //OpenglWidget w(Lanxun6JointRobot,STLView::lanxun6JointView); 25 | // // GCodeConversion c; 26 | // // c.CreateConvertedFile("H:\\1.cnc",true); 27 | // // UdpSoket w(Lanxun5JointRobot,STLView::lanxun5JointView); 28 | // // w.show(); 29 | // //CodeEditDlg c; 30 | // //c.show(); 31 | // STLView::init(LanxunCoordRobot); 32 | // SimulationParser * parse = new SimulationParser(LanxunCoordRobot,STLView::lanxunCoordView); 33 | // OpenglWidget w(LanxunCoordRobot,STLView::lanxunCoordView); 34 | // w.show(); 35 | // parse->show(); 36 | // parse->run("C:\\simulation.cnc"); 37 | // QTime time,time1,time2; 38 | // time.start(); 39 | // STLView::init(LanxunCoordRobot); 40 | // qDebug()< 5 | #include "CodeParse/CodeEditDlg.h" 6 | #include "CodeParse/GCodeListDlg.h" 7 | #include "Alignment/UdpSocket.h" 8 | #include 9 | #include "CodeParse/SimulationParse.h" 10 | #include 11 | #include "Teach/TeachGlWidget.h" 12 | #include "Teach/TeachDlg.h" 13 | #include 14 | #include "Alignment/AnalysisWidget.h" 15 | class ParaDlg; 16 | namespace Ui 17 | { 18 | class MainWindow; 19 | } 20 | 21 | class MainWindow : public QMainWindow 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit MainWindow(QWidget *parent = 0); 27 | ~MainWindow(); 28 | void closeEvent(QCloseEvent *e); 29 | private slots: 30 | 31 | void on_editText_button_clicked(); 32 | 33 | void on_alignment_button_clicked(); 34 | 35 | void on_simulation_button_clicked(); 36 | 37 | void on_playAct_triggered(); 38 | 39 | void on_pauseAct_triggered(); 40 | 41 | void on_backAct_triggered(); 42 | 43 | void on_resetAct_triggered(); 44 | 45 | void on_modelSwitchAct_triggered(); 46 | 47 | void on_newAct_triggered(); 48 | 49 | void on_openAct_triggered(); 50 | 51 | void on_saveAct_triggered(); 52 | 53 | void on_saveAsAct_triggered(); 54 | 55 | void changelistIndex(int i); 56 | 57 | void runFinishedSlot(); 58 | 59 | void on_amplificationAct_triggered(); 60 | 61 | void on_narrowdownAct_triggered(); 62 | 63 | void on_reductionAct_triggered(); 64 | 65 | void on_rotate_Xa_triggered(); 66 | 67 | void on_rotate_Xd_triggered(); 68 | 69 | void on_rotate_Ya_triggered(); 70 | 71 | void on_rotate_Yd_triggered(); 72 | 73 | void on_hideRobotAct_triggered(); 74 | 75 | void on_paraAct_triggered(); 76 | 77 | void typeChooseSlot(); 78 | 79 | void on_connectAct_triggered(); 80 | 81 | void checkConnectSlot(bool flag); 82 | 83 | void on_clearTrials_triggered(); 84 | 85 | void on_hideLineAct_triggered(); 86 | 87 | void on_teach_button_clicked(); 88 | 89 | void on_load_workPiece_triggered(); 90 | 91 | void tabChangeSlot(int); 92 | 93 | void on_compile_button_clicked(); 94 | 95 | 96 | void on_analyAct_triggered(); 97 | 98 | private: 99 | void keyPressEvent(QKeyEvent * e); 100 | Ui::MainWindow *ui; 101 | bool isCompile; 102 | CodeEditDlg * codeEditDlg; 103 | SimulationParse *parse; 104 | TeachGlWidget * teachGLWidget; 105 | UdpSoket*robot_udp; 106 | GCodeListDlg *listdlg; 107 | TeachDlg * teachDlg; 108 | AnalysisWidget *analysisWdg; 109 | QLabel * statusLabel; 110 | void init(); 111 | void setButtonStyle(); 112 | void connectSlot(); 113 | bool isfirstSimulation; 114 | void setSimulationStatus(bool flag); 115 | void setSimulationBtnBool(bool flag); 116 | void checkSwitchStatus(); 117 | void initWorkpiece(); 118 | void createTeachConnect(); 119 | void setSimulation_buttonTrue(); 120 | int firei; 121 | int curi; 122 | int lasti; 123 | bool isback; 124 | QString lastStlFile; 125 | RobotType lastSimultype; 126 | RobotType lastAlitype; 127 | RobotType lastTeachtype; 128 | ParaDlg *paradlg; 129 | int last_cur_i; 130 | bool isFinished; 131 | bool isFirstCompile; 132 | QString compileFileName; 133 | bool playBool; 134 | bool pauseBool; 135 | bool backBool; 136 | bool resetBool; 137 | bool connectflag; 138 | }; 139 | 140 | #endif // MAINWINDOW_H 141 | -------------------------------------------------------------------------------- /src/Teach/TeachDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef TEACHDLG_H 2 | #define TEACHDLG_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "CodeParse/scaralib.h" 8 | #include 9 | #include 10 | namespace Ui { 11 | class TeachDlg; 12 | } 13 | 14 | class TeachDlg : public QWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit TeachDlg(QWidget *parent = 0); 20 | 21 | ~TeachDlg(); 22 | 23 | void saveAsFileFun(); 24 | 25 | void saveFileFun(); 26 | 27 | void openFileFun(); 28 | 29 | void newFileFun(); 30 | 31 | QString teachFileName; 32 | public slots: 33 | signals: 34 | void closesignal(); 35 | void getCoordSignal(); 36 | void moto_SettingJSignal(char ch, double angle,double speed); 37 | void movelSignal(char ch,double distance,double speed); 38 | private slots: 39 | 40 | void on_j1dec_button_pressed(); 41 | 42 | void on_j1dec_button_released(); 43 | 44 | void on_j1add_button_pressed(); 45 | 46 | void on_j1add_button_released(); 47 | 48 | void on_j2dec_button_pressed(); 49 | 50 | void on_j2dec_button_released(); 51 | 52 | void on_j2add_button_pressed(); 53 | 54 | void on_j2add_button_released(); 55 | 56 | void on_j3dec_button_pressed(); 57 | 58 | void on_j3dec_button_released(); 59 | 60 | void on_j3add_button_pressed(); 61 | 62 | void on_j3add_button_released(); 63 | 64 | void on_j4dec_button_pressed(); 65 | 66 | void on_j4dec_button_released(); 67 | 68 | void on_j4add_button_pressed(); 69 | 70 | void on_j4add_button_released(); 71 | 72 | void on_j5dec_button_pressed(); 73 | 74 | void on_j5dec_button_released(); 75 | 76 | void on_j5add_button_pressed(); 77 | 78 | void on_j5add_button_released(); 79 | 80 | void on_j6dec_button_pressed(); 81 | 82 | void on_j6dec_button_released(); 83 | 84 | void on_j6add_button_pressed(); 85 | 86 | void on_j6add_button_released(); 87 | void on_xdec_button_pressed(); 88 | 89 | void on_xdec_button_released(); 90 | 91 | void on_xadd_button_pressed(); 92 | 93 | void on_xadd_button_released(); 94 | 95 | void on_ydec_button_pressed(); 96 | 97 | void on_ydec_button_released(); 98 | 99 | void on_yadd_button_pressed(); 100 | 101 | void on_yadd_button_released(); 102 | 103 | void on_zdec_button_pressed(); 104 | 105 | void on_zdec_button_released(); 106 | 107 | void on_zadd_button_pressed(); 108 | 109 | void on_zadd_button_released(); 110 | 111 | void on_rdec_button_pressed(); 112 | 113 | void on_rdec_button_released(); 114 | 115 | void on_radd_button_pressed(); 116 | 117 | void on_radd_button_released(); 118 | 119 | void on_pdec_button_pressed(); 120 | 121 | void on_pdec_button_released(); 122 | 123 | void on_padd_button_pressed(); 124 | 125 | void on_padd_button_released(); 126 | 127 | void on_wdec_button_pressed(); 128 | 129 | void on_wdec_button_released(); 130 | 131 | void on_wadd_button_pressed(); 132 | 133 | void on_wadd_button_released(); 134 | 135 | void on_toolButton_clicked(); 136 | 137 | void on_order_listWidget_itemClicked(QListWidgetItem *item); 138 | 139 | void receiveCoordSlot(ArrayXd); 140 | 141 | void customContextSlot(QPoint); 142 | 143 | void deleteSeedSlot(); 144 | 145 | void clearSeedsSlot(); 146 | 147 | void insertActSlot(); 148 | 149 | void updateCurrentRowSlot(int); 150 | 151 | 152 | 153 | 154 | private: 155 | void closeEvent(QCloseEvent *e); 156 | Ui::TeachDlg *ui; 157 | void moto_SettingJ12(char ch,bool isAdd); 158 | void moto_SettingJ3(bool isAdd); 159 | void moto_SettingJ456(char ch,bool isAdd); 160 | QListWidget *absG_list; 161 | QListWidget *teach_list; 162 | void setstyle(); 163 | void initTeachlist(); 164 | QStringList content; 165 | double weldSpeed; 166 | int arcNum; 167 | int circleNum; 168 | bool isMoveLine; 169 | double lastCoord[6]; 170 | void setLastCoord(double coord[6]); 171 | bool isCoordChange(double coord[6]); 172 | void loadFile(const QString & fileName); 173 | double arcStartPoint[3]; 174 | 175 | }; 176 | 177 | #endif // TEACHDLG_H 178 | -------------------------------------------------------------------------------- /src/CodeParse/ArcParse.cpp: -------------------------------------------------------------------------------- 1 | #include "ArcParse.h" 2 | #include "CommonFun/Common.h" 3 | #include "CommonFun/CommonFun.h" 4 | ArcParse::ArcParse() 5 | { 6 | 7 | } 8 | bool ArcParse::getCirclePoint(const ArrayXd& p1,const ArrayXd& p2,const ArrayXd& p3,ArrayXd& p4,ArrayXd& p5,ArrayXd& p6) 9 | { 10 | double x1 = p1[0]; 11 | double y1 = p1[1]; 12 | double z1 = p1[2]; 13 | double x2 = p2[0]; 14 | double y2 = p2[1]; 15 | double z2 = p2[2]; 16 | double x3 = p3[0]; 17 | double y3 = p3[1]; 18 | double z3 = p3[2]; 19 | double x0, y0, z0,r; 20 | if(!getCenterCoordAndRadius(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0,r)) 21 | return false; 22 | double x,y,z; 23 | getMidPoint(x0,y0,z0,r,x1,y1,z1,x2,y2,z2,x,y,z); 24 | p4[0] = x; 25 | p4[1] = y; 26 | p4[2] = z; 27 | getMidPoint(x0,y0,z0,r,x2,y2,z2,x3,y3,z3,x,y,z); 28 | p5[0] = x; 29 | p5[1] = y; 30 | p5[2] = z; 31 | getMidPoint(x0,y0,z0,r,x3,y3,z3,x1,y1,z1,x,y,z); 32 | p6[0] = x; 33 | p6[1] = y; 34 | p6[2] = z; 35 | return true; 36 | } 37 | void ArcParse::getMidPoint(double x0,double y0,double z0,double r,double x1,double y1,double z1,double x2,double y2,double z2,double &x,double &y,double &z) 38 | { 39 | Vector3d v1(x1 - x0,y1 - y0,z1 - z0); 40 | Vector3d v2(x2 - x0,y2 - y0,z2 - z0); 41 | v1.normalize(); 42 | v2.normalize(); 43 | Vector3d v = v1 + v2; 44 | v = v.normalized() * r; 45 | x = v[0] + x0; 46 | y = v[1] + y0; 47 | z = v[2] + z0; 48 | } 49 | 50 | int ArcParse::isSplitArc(const ArrayXd& p1,const ArrayXd& p2,const ArrayXd& p3,ArrayXd& p4,ArrayXd& p5) 51 | { 52 | double x1 = p1[0]; 53 | double y1 = p1[1]; 54 | double z1 = p1[2]; 55 | double x2 = p2[0]; 56 | double y2 = p2[1]; 57 | double z2 = p2[2]; 58 | double x3 = p3[0]; 59 | double y3 = p3[1]; 60 | double z3 = p3[2]; 61 | double x0, y0, z0,r; 62 | if(!getCenterCoordAndRadius(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0,r)) 63 | return -1; 64 | double OAOB = (x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0) + (z1 - z0) * (z2 - z0); 65 | double OBOC = (x2 - x0) * (x3 - x0) + (y2 - y0) * (y3 - y0) + (z2 - z0) * (z3 - z0); 66 | double angle1 = acos(OAOB / (r * r)); 67 | double angle2 = acos(OBOC / (r * r)); 68 | double angle = (angle1 + angle2) * 180 / Pi; 69 | if(angle < 180) 70 | return 1; 71 | else 72 | { 73 | double x,y,z; 74 | getMidPoint(x0,y0,z0,r,x1,y1,z1,x2,y2,z2,x,y,z); 75 | p4[0] = x; 76 | p4[1] = y; 77 | p4[2] = z; 78 | qDebug() << "中点1:" << x << " " << y << " " << z ; 79 | getMidPoint(x0,y0,z0,r,x2,y2,z2,x3,y3,z3,x,y,z); 80 | p5[0] = x; 81 | p5[1] = y; 82 | p5[2] = z; 83 | qDebug() << "中点2:" << x << " " << y << " " << z ; 84 | return 2; 85 | } 86 | } 87 | 88 | bool ArcParse::getCenterCoordAndRadius(double x1, double y1, double z1,double x2, double y2, double z2, double x3, double y3, double z3,double &x0,double &y0,double &z0,double &r) 89 | { 90 | if (CommonFun::isThreePointInLine(x1, y1, z1, x2, y2, z2, x3, y3, z3)) 91 | { 92 | qDebug() << "三点共线" ; 93 | return false; 94 | } 95 | double ABAB, ABAC, ACAC, a, b; 96 | ABAB = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1); 97 | ABAC = (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1) + (z2 - z1) * (z3 - z1); 98 | ACAC = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) + (z3 - z1) * (z3 - z1); 99 | a = ACAC * (ABAB - ABAC) / (ACAC * ABAB - ABAC * ABAC) / 2.0; 100 | b = (ABAB * ABAC - ABAB * ACAC) / (ABAC * ABAC - ACAC * ABAB) / 2.0; 101 | //圆心坐标和半径 102 | x0 = x1 + a * (x2 - x1) + b * (x3 - x1); 103 | y0 = y1 + a * (y2 - y1) + b * (y3 - y1); 104 | z0 = z1 + a * (z2 - z1) + b * (z3 - z1); 105 | r = sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1) + (z0 - z1) * (z0 - z1)); 106 | return true; 107 | } 108 | 109 | double ArcParse::getArcLength(double x1, double y1, double z1,double x2, double y2, double z2, double x3, double y3, double z3) 110 | { 111 | double x0,y0,z0,r; 112 | getCenterCoordAndRadius(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0,r); 113 | double OAOB = (x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0) + (z1 - z0) * (z2 - z0); 114 | double OBOC = (x2 - x0) * (x3 - x0) + (y2 - y0) * (y3 - y0) + (z2 - z0) * (z3 - z0); 115 | double angle1 = acos(OAOB / (r * r)); 116 | double angle2 = acos(OBOC / (r * r)); 117 | double angle = (angle1 + angle2); 118 | qDebug() << "圆心角:" << angle * 180 / Pi ; 119 | qDebug() << "半径:" << r ; 120 | return angle * r; 121 | } 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/CodeParse/GcodeListDlg.cpp: -------------------------------------------------------------------------------- 1 | #include "GCodeListDlg.h" 2 | #include "ui_GcodeListDlg.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | GCodeListDlg::GCodeListDlg(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::GcodeListDlg) 10 | { 11 | ui->setupUi(this); 12 | abs_list = NULL; 13 | rel_list = NULL; 14 | ui->tabWidget->clear(); 15 | setWindowIcon(QIcon(":/images/glist.png")); 16 | } 17 | GCodeListDlg::~GCodeListDlg() 18 | { 19 | if(abs_list) 20 | delete abs_list; 21 | if(rel_list) 22 | delete rel_list; 23 | delete ui; 24 | } 25 | void GCodeListDlg::loadlist(const QString &fileName) 26 | { 27 | QString filename = fileName; 28 | if(!abs_list) 29 | abs_list = new QListWidget(); 30 | if(!rel_list) 31 | rel_list = new QListWidget(); 32 | abs_list->clear(); 33 | rel_list->clear(); 34 | ui->tabWidget->clear(); 35 | QVector content; 36 | if(filename != "C:\\simulation.cnc") 37 | { 38 | if(filename.endsWith("_abs.cnc")) //表示是绝对的 39 | { 40 | QString filename1 = filename.remove("_abs.cnc"); 41 | QFile file1(filename1 + ".cnc"); 42 | QFile file2(filename1 + ".txt"); 43 | if(file1.open(QIODevice::ReadOnly)) //相对的表示能够打开 44 | { 45 | content.clear(); 46 | prerun(filename1 + ".cnc",content); //预处理验证坐标 47 | foreach(QString line,content) 48 | rel_list->addItem(new QListWidgetItem(line,rel_list)); 49 | file1.close(); 50 | } 51 | else if(file2.open(QIODevice::ReadOnly)) //相对的 52 | { 53 | content.clear(); 54 | prerun(filename1 + ".txt",content); //预处理验证坐标 55 | foreach(QString line,content) 56 | rel_list->addItem(new QListWidgetItem(line,rel_list)); 57 | file2.close(); 58 | } 59 | } 60 | else 61 | { 62 | content.clear(); 63 | if(!prerun(filename,content)) //相对的 64 | { 65 | foreach(QString line,content) 66 | rel_list->addItem(new QListWidgetItem(line,rel_list)); 67 | } 68 | 69 | } 70 | } 71 | QFile file("C:\\simulation.cnc"); 72 | if(file.open(QIODevice::ReadOnly)) //绝对的 73 | { 74 | QTextStream stream(&file); //将文件入流 75 | QString line; 76 | while ( !stream.atEnd() ) //当流不到最后的时候 一直读取一行 77 | { 78 | line = stream.readLine(); // 不包括“\n”的一行文本 79 | abs_list->addItem(new QListWidgetItem(line,abs_list)); 80 | } 81 | file.close(); 82 | } 83 | if(rel_list->count() > 0) 84 | { 85 | ui->tabWidget->addTab(rel_list,"相对"); 86 | rel_list->setCurrentRow(0); 87 | 88 | } 89 | if(abs_list->count() > 0) 90 | { 91 | ui->tabWidget->addTab(abs_list,"绝对"); 92 | abs_list->setCurrentRow(0); 93 | } 94 | ui->tabWidget->setCurrentIndex(0); 95 | } 96 | 97 | bool GCodeListDlg::prerun(const QString&fname,QVector& content) 98 | { 99 | readFile(fname,content); 100 | preProcess(content); 101 | confirmCoord(content); 102 | if(isAbsolute) //绝对坐标 103 | return true; 104 | else 105 | return false; //相对坐标 106 | } 107 | //读取文件内容到content中 108 | void GCodeListDlg::readFile(const QString &fname,QVector& content) 109 | { 110 | CommonFun::readTextFile(fname,content); //读取数据 111 | } 112 | void GCodeListDlg::closeEvent(QCloseEvent *e) 113 | { 114 | emit closesignal(); 115 | qDebug() << "关闭"; 116 | return QWidget::closeEvent(e); 117 | } 118 | void GCodeListDlg::preProcess(QVector& content) 119 | { 120 | QString line; 121 | for(int i = content.size() - 1;i > -1;i--)//m_content.GetSize()改m_content.size()都是获取数组中元素的个数 122 | { 123 | line = content[i].trimmed();//去掉前后的空格 .Trim(_T(" ")改.trimmed() 124 | line = line.toUpper(); //转换为大写.MakeUpper()改.toUpper( 125 | if(line.length() < 1) //这个CString对象中的字节计数。这个计数不包括结尾的空字符。.GetLength()改.length() 126 | content.remove(i);//.RemoveAt(i)改removeAt(i) 127 | else 128 | content[i] = line; 129 | } 130 | } 131 | void GCodeListDlg::confirmCoord(QVector& content) 132 | { 133 | isAbsolute = false; //缺省是相对坐标 134 | int relative_num = 0; 135 | int absolute_num = 0; 136 | for(int i=0;i < content.size();i++) 137 | { 138 | if(content[i] == "G91") 139 | relative_num++; 140 | else if(content[i] == "G90") 141 | absolute_num++; 142 | } 143 | if(absolute_num > 0) //如果是绝对的 144 | isAbsolute = true; 145 | } 146 | void GCodeListDlg::setCurLine(int i) 147 | { 148 | ui->curLine_label->setText(QString::number(i)); 149 | } 150 | int GCodeListDlg::curtabchoose() 151 | { 152 | if(ui->tabWidget->currentWidget() == abs_list) 153 | return 1; 154 | else 155 | return 0; 156 | } 157 | 158 | void GCodeListDlg::on_tabWidget_currentChanged(int index) 159 | { 160 | emit tabchangeSignal(index); 161 | } 162 | -------------------------------------------------------------------------------- /src/Alignment/UdpSocket.cpp: -------------------------------------------------------------------------------- 1 | #include "UdpSocket.h" 2 | #include "CommonFun/CommonFun.h" 3 | #include "CodeParse/NewScaraArgorithmn.h" 4 | UdpSoket::UdpSoket(RobotType type):OpenglWidget(type) 5 | { 6 | parser = new Parser; 7 | socket = new QUdpSocket(this); 8 | widgetname = ALIGNMENT; 9 | initSocket(); 10 | setWindowTitle("坐标机器人联调"); 11 | isConnect = false; 12 | } 13 | 14 | //将解析的数据包数据封装,发送信号给analysisWidget窗口 15 | void UdpSoket::sendJC() 16 | { 17 | double joint[6] = {j1Rot,j2Rot,j3Rot,j4Rot,j5Rot,j6Rot}; 18 | 19 | //发送6个关节8个坐标 20 | emit jointcoordSignal(joint,coord); 21 | } 22 | 23 | /*************************************** 24 | * 1、创建UDP客户端对象 25 | * 2、绑定端口 26 | * 3、连接端口(当有数据过来的时候就对应执行槽函数) 27 | ****************************************/ 28 | void UdpSoket::initSocket() 29 | { 30 | //UDP创建和绑定端口号 31 | socket = new QUdpSocket(this); 32 | socket->bind(8080); 33 | } 34 | 35 | //连接端口号 36 | void UdpSoket::UdpConnect() 37 | { 38 | //连接socket的readRead信号,当有数据过来的时候就执行槽函数。 39 | QObject::connect(socket,SIGNAL(readyRead()),this,SLOT(processPendingDatagram())); 40 | 41 | //connect(socket,&QUdpSocket::readyRead,this,&UdpSoket::processPendingDatagram); 42 | qDebug() << "绑定连接udp端口"; 43 | 44 | connectServer(); 45 | } 46 | 47 | //向服务器发送消息 请示连接 48 | void UdpSoket::connectServer() 49 | { 50 | //向此ip地址发送EE字符数据 51 | sendData("EE","192.168.1.250"); 52 | 53 | //单singleShot,表示它只会触发一次, 54 | //2s发出一次信号,然后来执行槽函数,检查是否连接 55 | QTimer::singleShot(2000, this, SLOT(checkIsConnect())); 56 | } 57 | 58 | void UdpSoket::UdpDisConnect() 59 | { 60 | disconnect(socket,SIGNAL(readyRead()),this,SLOT(processPendingDatagram())); 61 | isConnect = false; 62 | } 63 | 64 | UdpSoket::~UdpSoket() 65 | { 66 | 67 | } 68 | 69 | void UdpSoket::processPendingDatagram() 70 | { 71 | //用于存放接收的数据 72 | QByteArray datagram; 73 | 74 | //让datagram的大小为等待处理的数据报的大小,这样才能接收到完整的数据 75 | datagram.resize(socket->pendingDatagramSize()); 76 | 77 | //读取数据包,将其存放在datagram中 78 | socket->readDatagram(datagram.data(),datagram.size()); 79 | 80 | //解析数据包 81 | int ret = parser->parser(QString(datagram.data())); 82 | qDebug() << QString(datagram.data()); 83 | 84 | //0表示解析成功 85 | if(ret == 0){ 86 | //如果数据包是坐标和关节值 87 | if(parser->cmd == CoordJoint){ 88 | if(glType == LanxunCoordRobot){ 89 | j1Rot = parser->joint[0]; //大臂 90 | j2Rot = parser->joint[1]; //小臂 91 | }else{ 92 | j1Rot = parser->joint[0] * 180 / Pi; //大臂 转化为度 93 | j2Rot = parser->joint[1] * 180 / Pi; //小臂 转化为度 94 | } 95 | 96 | if(glType == Lanxun6JointRobot){ 97 | j3Rot = parser->joint[2] * 180 / Pi; 98 | }else{ 99 | j3Rot = parser->joint[2]; 100 | } 101 | 102 | j4Rot = parser->joint[3] * 180 / Pi; 103 | j5Rot = parser->joint[4] * 180 / Pi; 104 | j6Rot = parser->joint[5] * 180 / Pi; 105 | 106 | //变位机构 107 | c1Rot = parser->joint[6] * 180 / Pi; 108 | c2Rot = parser->joint[7] * 180 / Pi; 109 | 110 | //保存坐标 111 | for(int i = 0; i < 6;i++){ 112 | coord[i] = parser->coord[i]; 113 | } 114 | //坐标值包括两个变位机构 115 | coord[6] = c1Rot; 116 | coord[7] = c2Rot; 117 | 118 | //添加入轨迹坐标 119 | addTrialPoints(); 120 | 121 | //重绘 122 | updateGL(); 123 | 124 | //发送关节角度值 125 | sendJC(); 126 | qDebug() << "j1Rot: " << j1Rot << " j2Rot: " << j2Rot << " j3Rot: " << j3Rot << " j4Rot: " << j4Rot << " j5Rot: " << j5Rot; 127 | }else if(parser->cmd == OpenFire){ 128 | linecolor = Qt::red; 129 | }else if(parser->cmd == CloseFire){ 130 | linecolor = Qt::white; 131 | }else if(parser->cmd == ConnectCmd){ 132 | qDebug() << "连接成功"; 133 | isConnect = true; //为true 134 | } 135 | } 136 | } 137 | 138 | 139 | void UdpSoket::sendData(const QString& str,const QString& ipAddress){ 140 | //发送数据函数必须发送数据到指定的对方的地址和端口 141 | //串口读取一般使用QByteArray数据,读取需要进行提取和解析,需要QByteArray转换为各类型数据 142 | //toLocal8Bit()返回的是一个字节数组类型QByteArray,使用[]、data()可读可写,at()只能读 143 | //string是基于16位unicode编码的字符数组 144 | socket->writeDatagram(str.toLocal8Bit().data(),str.size(),QHostAddress(ipAddress),8080); 145 | } 146 | 147 | 148 | void UdpSoket::closeEvent(QCloseEvent *e) 149 | { 150 | //关闭套接字的I / O设备,并调用DisconnectFromHost()关闭套接字的连接。 151 | socket->close(); 152 | return OpenglWidget::closeEvent(e); 153 | } 154 | 155 | //这个还得测试去 156 | void UdpSoket::keyPressEvent(QKeyEvent *e) 157 | { 158 | switch(e->key()) 159 | { 160 | case Qt::Key_Escape: 161 | trailPoints.clear(); 162 | updateGL(); 163 | break; 164 | } 165 | return OpenglWidget::keyPressEvent(e); 166 | } 167 | 168 | //校验连接 169 | void UdpSoket::checkIsConnect() 170 | { 171 | if(!isConnect) // 连接失败 172 | { 173 | CommonFun::msgErr("连接失败,请检查!",this); 174 | UdpDisConnect(); 175 | emit checkConnectSignal(false); 176 | } 177 | else 178 | emit checkConnectSignal(true); 179 | } 180 | -------------------------------------------------------------------------------- /src/Teach/TeachGlWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "TeachGlWidget.h" 2 | #include "CodeParse/NewScaraArgorithmn.h" 3 | #include "CommonFun/CommonFun.h" 4 | #include "Setting/Parameter.h" 5 | #include "math.h" 6 | #include 7 | TeachGlWidget::TeachGlWidget(RobotType type) : OpenglWidget(type) 8 | { 9 | 10 | widgetname = TEACH; 11 | moveLineInter = 1; 12 | moveJointInter = 1; 13 | isShowWorkPiece = true; 14 | NewScaraArgorithmn::initTCF(); 15 | home(); 16 | qDebug()<<"TeachGlWidget构造函数"; 17 | } 18 | 19 | void TeachGlWidget::keyPressEvent(QKeyEvent * e) 20 | { 21 | return OpenglWidget::keyPressEvent(e); 22 | } 23 | 24 | void TeachGlWidget::homeSlot() 25 | { 26 | home(); 27 | } 28 | //单轴移动函数 29 | void TeachGlWidget::moto_runJ(Joint j,double speed) 30 | { 31 | moveJointInter = speed / 4000; 32 | if(moveJointInter > 1) 33 | moveJointInter = 1; 34 | double j1,j2,j3,j4,j5,j6; //这个要走的角度 35 | //gl目前的角度和需要转动角度的差距 36 | Joint lastJ; 37 | getCurrentJ(lastJ); 38 | lastJ.j1 += j.j1; 39 | lastJ.j2 += j.j2; 40 | lastJ.j3 += j.j3; 41 | lastJ.j4 += j.j4; 42 | lastJ.j5 += j.j5; 43 | lastJ.j6 += j.j6; 44 | if(glType == Lanxun5JointRobot) 45 | { 46 | j1 = j.j1 * 180 / PI ; //角度值 47 | j2 = j.j2 * 180 / PI; 48 | } 49 | else 50 | { 51 | j1 = j.j1; 52 | j2 = j.j2; 53 | } 54 | if(glType == Lanxun6JointRobot) 55 | j3 = j.j3 * 180 / PI; 56 | else 57 | j3 = j.j3; 58 | j4 = j.j4 * 180 / PI; 59 | j5 = j.j5 * 180 / PI ; 60 | j6 = j.j6 * 180 / PI; 61 | double contia = sqrt(j1 * j1 + j2 * j2 + j3 * j3 + j4 * j4 + j5 * j5 + j6 * j6); 62 | if(contia == 0) 63 | { 64 | return; 65 | } 66 | double rate = 1.0 / contia * moveJointInter; 67 | double vs = 1000; //初始速度 68 | Parameter::teachStop = false; 69 | for(double i = 0; i < contia; i+= moveJointInter) //每次转一度 10度的加减速 70 | { 71 | QElapsedTimer et; 72 | et.start(); 73 | if(!Parameter::teachStop) 74 | vs += 200; 75 | if(vs > speed) 76 | vs = speed; 77 | QCoreApplication::processEvents(); 78 | j1Rot += j1 * rate; 79 | j2Rot += j2 * rate; 80 | j3Rot += j3 * rate; 81 | j4Rot += j4 * rate; 82 | j5Rot += j5 * rate; 83 | j6Rot += j6 * rate; 84 | getCurrentCoord(); 85 | if(Parameter::teachStop) 86 | { 87 | Parameter::teachStop = false; 88 | return; 89 | } 90 | while(et.elapsed() < (60.0 * 1000.0 * moveJointInter / vs)) 91 | QCoreApplication::processEvents(); 92 | } 93 | /***************为了保证精度,最后一个点要走到**************/ 94 | setJ(lastJ); 95 | Parameter::teachStop = false; 96 | } 97 | //单轴移动指令 98 | void TeachGlWidget::moto_SettingJSlot(char ch, double angle,double speed) //单轴移动 99 | { 100 | Joint j = {0,0,0,0,0,0}; 101 | switch(ch) 102 | { 103 | case 1: 104 | if(glType == LanxunCoordRobot) 105 | j.j1 = angle; 106 | else 107 | j.j1 = angle / 180.0 * Pi; 108 | break; 109 | case 2: 110 | if(glType == LanxunCoordRobot) 111 | j.j2 = angle ; 112 | else 113 | j.j2 = angle / 180.0 * Pi; 114 | break; 115 | case 3: 116 | if(glType == Lanxun6JointRobot) 117 | j.j3 = angle / 180.0 * Pi; 118 | else 119 | j.j3 = angle ; 120 | break; 121 | case 4: j.j4 = angle / 180.0 * Pi; break; 122 | case 5: j.j5 = angle / 180.0 * Pi; break; 123 | case 6: j.j6 = angle / 180.0 * Pi; break; 124 | default:break; 125 | } 126 | moto_runJ(j,speed);//旋转一个角度 127 | } 128 | //还是做一个梯形的加减速的过程 129 | void TeachGlWidget::moveLSlot(char ch,double distance,double speed) 130 | { 131 | moveLineInter = speed / 4000; 132 | if(moveLineInter > 1) 133 | moveLineInter = 1; 134 | double d[6] = {0}; 135 | if(distance > 0) 136 | d[ch-1] = moveLineInter; 137 | else 138 | d[ch-1] = -moveLineInter; 139 | ArrayXd xyzrpw(6); 140 | ArrayXd lastxyzrpw(6); 141 | for(int i = 0; i < 6;i++) 142 | lastxyzrpw[i] = coord[i]; 143 | double vs = 1000; 144 | double ss = fabs(distance); 145 | Parameter::teachStop = false; 146 | for(double i = 0; i < ss; i += fabs(moveLineInter)) 147 | { 148 | QElapsedTimer et; 149 | et.start(); 150 | if(!Parameter::teachStop) 151 | vs += 500; 152 | if(vs > speed) 153 | vs = speed; 154 | QCoreApplication::processEvents(); 155 | for(int i = 0; i < 6;i++) 156 | { 157 | if(i != ch -1) 158 | coord[i] = lastxyzrpw[i]; 159 | xyzrpw[i] = coord[i] + d[i]; 160 | } 161 | Joint j = NewScaraArgorithmn::NewPositionJointssolution(xyzrpw_2_pose(xyzrpw)); 162 | setJ(j); 163 | if(Parameter::teachStop) 164 | { 165 | Parameter::teachStop = false; 166 | return; 167 | } 168 | while(et.elapsed()< 60.0 * 1000.0 * moveLineInter / speed) 169 | QCoreApplication::processEvents(); 170 | } 171 | d[ch-1] = distance; 172 | for(int i = 0; i < 6;i++) 173 | xyzrpw[i] = lastxyzrpw[i] + d[i]; 174 | Joint j = NewScaraArgorithmn::NewPositionJointssolution(xyzrpw_2_pose(xyzrpw)); 175 | setJ(j); 176 | for(int i = 0;i < 6;i++) 177 | coord[i] = CommonFun::round(xyzrpw[i],2); 178 | updateGL(); 179 | Parameter::teachStop = false; 180 | } 181 | void TeachGlWidget::getCoordSlot() 182 | { 183 | ArrayXd xyzrpw(6); 184 | for(int i = 0; i < 6;i++) 185 | xyzrpw[i] = coord[i]; 186 | emit sendCoordSignal(xyzrpw); 187 | } 188 | -------------------------------------------------------------------------------- /src/3DModel/STLView.cpp: -------------------------------------------------------------------------------- 1 | #include "STLView.h" 2 | #include 3 | #include 4 | #include 5 | #include "CommonFun/CommonFun.h" 6 | #include 7 | STLView* STLView::lanxunCoordView = NULL; 8 | STLView* STLView::lanxun5JointView = NULL; 9 | STLView* STLView::lanxun6JointView = NULL; 10 | STLView* STLView::Artifacts=NULL; 11 | RobotType STLView::type = LanxunCoordRobot; 12 | 13 | //解析STL文件生成triangleVector数组 14 | bool STLView::readSTL(const QString &fname){ 15 | QFile file(fname); 16 | if ( file.open(QFile::ReadOnly | QFile::Text)) //仅读和文字 17 | { 18 | QTextStream in( &file ); 19 | MyTriangle triangle; 20 | QString line; 21 | int trianglePartNums = 0; 22 | 23 | while ( !in.atEnd() ) 24 | { 25 | line = in.readLine(); 26 | QVector words; 27 | 28 | //分割一行,生成words字符串数组返回字符个数 29 | int num = CommonFun::splitString(line,' ',words); 30 | 31 | //解析一行 32 | for(int i = 0; i < num; i++) 33 | { 34 | //集齐4个参数,添加一个三角片 35 | if(trianglePartNums == 4) 36 | { 37 | triangleVector.push_back(triangle); 38 | trianglePartNums = 0; 39 | } 40 | if(words[i] == "normal") 41 | { 42 | triangle.normal.x = words[i+1].toDouble(); 43 | triangle.normal.y = words[i+2].toDouble(); 44 | triangle.normal.z = words[i+3].toDouble(); 45 | trianglePartNums++; 46 | break; 47 | } 48 | if(words[i] == "vertex") 49 | { 50 | if(trianglePartNums == 1) 51 | { 52 | triangle.vertex1.x = words[i+1].toDouble(); 53 | triangle.vertex1.y = words[i+2].toDouble(); 54 | triangle.vertex1.z = words[i+3].toDouble(); 55 | } 56 | if(trianglePartNums == 2) 57 | { 58 | triangle.vertex2.x = words[i+1].toDouble(); 59 | triangle.vertex2.y = words[i+2].toDouble(); 60 | triangle.vertex2.z = words[i+3].toDouble(); 61 | 62 | } 63 | if(trianglePartNums == 3) 64 | { 65 | triangle.vertex3.x = words[i+1].toDouble(); 66 | triangle.vertex3.y = words[i+2].toDouble(); 67 | triangle.vertex3.z = words[i+3].toDouble(); 68 | } 69 | trianglePartNums++; 70 | break; 71 | } 72 | } 73 | } 74 | file.close(); 75 | return true; 76 | } 77 | else 78 | { 79 | qWarning() << fname << ": STL 文件打开失败"; 80 | return false; 81 | } 82 | 83 | } 84 | 85 | //初始化工件 86 | STLView* STLView::init(){ 87 | if(!Artifacts){ 88 | Artifacts=new STLView(); 89 | } 90 | return Artifacts; 91 | } 92 | 93 | //初始化工作,根据机器人类型,创建多线程分别解析不同部位的stl文件 94 | void STLView::init(RobotType rtype) 95 | { 96 | type = rtype; 97 | switch (type) 98 | { 99 | case LanxunCoordRobot: 100 | { 101 | //为空的情况,没有初始化 就让他初始化一次 102 | if(!lanxunCoordView) 103 | { 104 | //创建STLView[5]数组,开始5个线程 105 | //run()函数的开始运行是通过start()函数执行的, 106 | //停止是通过stop()函数,等待线程完成是通过wait()函数 107 | lanxunCoordView = new STLView[lanxunCoordRobotPartNum]; 108 | for(int i = 0; i < lanxunCoordRobotPartNum;i++) 109 | { 110 | lanxunCoordView[i].n = i; 111 | lanxunCoordView[i].start(); 112 | } 113 | for(int i = 0; i < lanxunCoordRobotPartNum;i++) 114 | lanxunCoordView[i].wait(); 115 | } 116 | break; 117 | } 118 | case Lanxun5JointRobot: //5关节式的机器人 119 | if(!lanxun5JointView) //为空的情况 120 | { 121 | lanxun5JointView = new STLView[lanxun5JointRobotPartNum]; //读取文件 122 | for(int i = 0; i < lanxun5JointRobotPartNum;i++) 123 | { 124 | lanxun5JointView[i].n = i; 125 | lanxun5JointView[i].start(); 126 | } 127 | for(int i = 0; i < lanxun5JointRobotPartNum;i++) 128 | lanxun5JointView[i].wait(); 129 | } 130 | break; 131 | case Lanxun6JointRobot: 132 | if(!lanxun6JointView) //为空的情况 133 | { 134 | lanxun6JointView = new STLView[lanxun6JointRobotPartNum]; //读取文件 135 | for(int i = 0; i < lanxun6JointRobotPartNum;i++) 136 | { 137 | lanxun6JointView[i].n = i; 138 | lanxun6JointView[i].start(); 139 | } 140 | for(int i = 0; i < lanxun6JointRobotPartNum;i++) 141 | lanxun6JointView[i].wait(); 142 | } 143 | break; 144 | default: 145 | break; 146 | } 147 | } 148 | 149 | void STLView::run() 150 | { 151 | switch(type) 152 | { 153 | case LanxunCoordRobot: 154 | lanxunCoordView[n].readSTL(QString(":/stl/lanxunCoordRobot/%1.STL").arg(n+1)); 155 | break; 156 | case Lanxun5JointRobot: 157 | lanxun5JointView[n].readSTL(QString(":/stl/lanxun5JointRobot/%1.STL").arg(n+1)); 158 | break; 159 | case Lanxun6JointRobot: 160 | lanxun6JointView[n].readSTL(QString(":/stl/lanxun6JointRobot/%1.STL").arg(n)); 161 | break; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /src/Setting/ParaDlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ParaDlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 283 10 | 346 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 机器人类型: 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 蓝讯坐标式机器人 31 | 32 | 33 | 34 | 35 | 蓝讯五关节机器人 36 | 37 | 38 | 39 | 40 | 蓝讯六关节机器人 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Qt::Horizontal 49 | 50 | 51 | 52 | 40 53 | 20 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 起点坐标 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | X: 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Y: 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | Z: 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | R: 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | P: 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | W: 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | Qt::Horizontal 163 | 164 | 165 | QSizePolicy::Fixed 166 | 167 | 168 | 169 | 40 170 | 20 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | Qt::Horizontal 183 | 184 | 185 | 186 | 40 187 | 20 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 取消 196 | 197 | 198 | 199 | 200 | 201 | 202 | 确定 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /src/CommonFun/CommonFun.cpp: -------------------------------------------------------------------------------- 1 | #include "CommonFun.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | Joint CommonFun::lastj = {0,0,0,0,0,0}; 14 | QSettings CommonFun::settings("Statics.ini"); 15 | QVector CommonFun::listNum; 16 | CommonFun::CommonFun() 17 | { 18 | 19 | } 20 | bool CommonFun::ReadSettingsBool(const QString &dataItem) 21 | { 22 | return settings.value(dataItem).toBool(); 23 | } 24 | void CommonFun::WriteSettingsBool(const QString &dataItem,bool data) 25 | { 26 | settings.setValue(dataItem, data); 27 | } 28 | 29 | QString CommonFun::ReadSettingsStr(const QString &dataItem) 30 | { 31 | return settings.value(dataItem).toString(); 32 | } 33 | 34 | double CommonFun::ReadSettingsDouble(const QString &dataItem) 35 | { 36 | return settings.value(dataItem).toDouble(); 37 | } 38 | 39 | void CommonFun::WriteSettingsStr(const QString &dataItem,const QString& data) 40 | { 41 | settings.setValue(dataItem, data); 42 | 43 | } 44 | int CommonFun::ReadSettingsInt(const QString &dataItem) 45 | { 46 | return settings.value(dataItem).toInt(); 47 | } 48 | 49 | void CommonFun::WriteSettingsInt(const QString &dataItem,int data) 50 | { 51 | settings.setValue(dataItem, data); 52 | 53 | } 54 | 55 | void CommonFun::WriteSettingsDouble(const QString &dataItem,double data) 56 | { 57 | settings.setValue(dataItem, data); 58 | } 59 | bool CommonFun::copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist) 60 | { 61 | //toDir.replace("\\","/"); 62 | if (sourceDir == toDir) 63 | { 64 | return true; 65 | } 66 | if (!QFile::exists(sourceDir)) 67 | { 68 | return false; 69 | } 70 | QDir *createfile = new QDir; 71 | bool exist = createfile->exists(toDir); 72 | if (exist) 73 | { 74 | if(coverFileIfExist) 75 | { 76 | createfile->remove(toDir); 77 | } 78 | } 79 | if(!QFile::copy(sourceDir, toDir)) 80 | { 81 | return false; 82 | } 83 | return true; 84 | } 85 | 86 | int CommonFun::splitString(const QString &str, char split, QVector& strArray) 87 | { 88 | strArray.clear(); 89 | QString strTemp = str; //此赋值不能少 90 | int nIndex = 0; 91 | while( 1 ){ 92 | nIndex = strTemp.indexOf(split); //QString 采用 x.indexOf(y)获取字符在字符中的位置;strTemp.Find( split )改.indexOf(split); 93 | if(nIndex==0){//合并分割符 94 | if(strTemp.length()<1) 95 | break; 96 | strTemp=strTemp.right(strTemp.length()-1); 97 | } 98 | else if( nIndex > 0 ) { 99 | strArray.push_back( strTemp.left( nIndex ) ); 100 | strTemp = strTemp.right( strTemp.length() - nIndex - 1 ); 101 | } 102 | else break; 103 | } 104 | 105 | //必须加判断 106 | if(strTemp.length() > 0) 107 | strArray.push_back(strTemp);//add 改pushback 好像改append也可以 108 | return strArray.size(); 109 | } 110 | 111 | //每行读取文件出来 112 | bool CommonFun::readTextFile(const QString &fname,QVector&content) 113 | { 114 | //清空content 115 | content.clear(); 116 | QFile file(fname); 117 | //读取文件内容到content 118 | if (file.open(QFile::ReadOnly | QFile::Text)) 119 | { 120 | QTextStream in(&file); //将文件入流 121 | QString line; 122 | while ( !in.atEnd() ) //当流不到最后的时候 一直读取一行 123 | { 124 | line = in.readLine(); // 不包括“\n”的一行文本 125 | content.push_back(line); //加入内容到content中 126 | } 127 | file.close(); 128 | return true; 129 | } 130 | else 131 | { 132 | qWarning() << fname << ": 读文件打开失败"; 133 | return false; 134 | } 135 | } 136 | 137 | bool CommonFun::wirteTextFile(const QString &fname,const QVector &content) 138 | { 139 | QFile file(fname); 140 | if(file.open(QFile::WriteOnly | QIODevice::Truncate | QFile::Text)) 141 | { 142 | QTextStream out(&file); 143 | QString str; 144 | foreach (str, content) 145 | { 146 | out << str << endl; 147 | } 148 | file.close(); 149 | return true; 150 | } 151 | else 152 | { 153 | qWarning() << fname << ": 写文件打开失败"; 154 | return false; 155 | } 156 | } 157 | 158 | //判断是否共线 159 | bool CommonFun::isThreePointInLine(double x1, double y1, double z1, 160 | double x2, double y2, double z2, double x3, double y3, double z3) 161 | { 162 | //法向量的值 n = AB x AC (叉乘) 163 | double i, j, k; 164 | i = (y2 - y1) * (z3 - z1) - (z2 - z1) * (y3 - y1); 165 | j = (z2 - z1) * (x3 - x1) - (x2 - x1) * (z3 - z1); 166 | k = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1); 167 | //先判断是否共线,根据三角形面积,S = 1/2|AB x AC| ,向量叉乘的模 168 | return i == 0.0 && j == 0.0 && k == 0.0; 169 | } 170 | 171 | //得到目录,不带最后的'\' 172 | QString CommonFun::getExePath() 173 | { 174 | QString path; 175 | QDir dir; 176 | path=dir.absolutePath(); 177 | reverse(path.begin(),path.end()); 178 | int pos=path.indexOf("/"); 179 | path=path.right(path.length()-1-pos); 180 | reverse(path.begin(),path.end()); 181 | return path; 182 | } 183 | 184 | void CommonFun::msgErr(const QString &err,QWidget*wid) 185 | { 186 | QMessageBox::warning(wid,"出错",err); 187 | 188 | } 189 | double CommonFun::round(double number, unsigned int bits) 190 | { 191 | LL integerPart = number; 192 | number -= integerPart; 193 | for (unsigned int i = 0; i < bits; ++i) 194 | number *= 10; 195 | number = (LL) (number + 0.5); 196 | for (unsigned int i = 0; i < bits; ++i) 197 | number /= 10; 198 | return integerPart + number; 199 | } 200 | void CommonFun::sleep(unsigned int msec) 201 | { 202 | 203 | QTime dieTime = QTime::currentTime().addMSecs(msec); 204 | 205 | while( QTime::currentTime() < dieTime ) 206 | 207 | QCoreApplication::processEvents(QEventLoop::AllEvents, 100); 208 | } 209 | void CommonFun::setToolButtonStyle(QToolButton *tbn, const QString &text,int textSize,const QString iconName) //设置统一按钮样式的形式 210 | { 211 | tbn->setStyleSheet("selection-background-color: rgb(0, 0, 0);color: rgb(255, 255, 255);border-radius:5px;border-width:0px"); 212 | //设置显示的文本 213 | tbn->setText(text); 214 | if (textSize == E_SMALL)//大尺寸 215 | { 216 | tbn->setFont(QFont("文泉驿雅黑",8,QFont::Bold)); 217 | tbn->setIconSize(QSize(40,38));//设置图标尺寸 哈哈根据图片的尺寸去设置图标的尺寸 218 | } 219 | else if (textSize == E_NORMAL)//正常尺寸做法 220 | { 221 | tbn->setFont(QFont("文泉驿雅黑",12,QFont::Bold));//设置字体颜色哈哈 222 | tbn->setIconSize(QSize(60,60));//设置图标尺寸 哈哈根据图片的尺寸去设置图标的尺寸 223 | } 224 | else if (textSize == E_Mid)//正常尺寸做法 225 | { 226 | tbn->setFont(QFont("文泉驿雅黑",9,QFont::Bold));//设置字体颜色哈哈 227 | tbn->setIconSize(QSize(52,52));//设置图标尺寸 哈哈根据图片的尺寸去设置图标的尺寸 228 | } 229 | tbn->setAutoRaise(true);//自动适应变化 230 | //设置按钮图标 231 | tbn->setIcon(QPixmap(QString("%1").arg(iconName)));//设置图标从资源文件的位置上去加载哈哈 232 | //设置文本在图标下边 233 | tbn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);//懂啦哈哈 234 | } 235 | QString CommonFun::hextoInt(const QString &str) 236 | { 237 | string cmd=str.toStdString(); 238 | int n1,n2; 239 | if((cmd[0] >= 'a' && cmd[0] <= 'f')|| (cmd[0] >= 'A' && cmd[0]<= 'F')) 240 | n1 = (cmd[0] & 0x0f) + 9; 241 | else 242 | n1 = cmd[0] & 0x0f; 243 | if((cmd[1] >= 'a' && cmd[1] <= 'f')|| (cmd[1] >= 'A' && cmd[1]<= 'F')) 244 | n2 = (cmd[1] & 0x0f) + 9; 245 | else 246 | n2 = cmd[1] & 0x0f; 247 | int n=16*n1+n2; 248 | QString ss=QString("%1").arg(n); 249 | return ss; 250 | } 251 | //求出分割时间的函数 252 | int CommonFun::time_substract(struct timeval *result, struct timeval *begin,struct timeval *end) 253 | { 254 | if(begin->tv_sec > end->tv_sec) 255 | return -1; 256 | if((begin->tv_sec == end->tv_sec) && (begin->tv_usec > end->tv_usec)) 257 | return -2; 258 | result->tv_sec = (end->tv_sec - begin->tv_sec); 259 | result->tv_usec = (end->tv_usec - begin->tv_usec); 260 | if(result->tv_usec < 0) 261 | { 262 | result->tv_sec--; 263 | result->tv_usec += 1000000; 264 | } 265 | return 0; 266 | } 267 | -------------------------------------------------------------------------------- /src/stl/lanxunCoordRobot/1.STL: -------------------------------------------------------------------------------- 1 | solid coor - leg-1 2 | facet normal 2.605087e-013 -1.000000e+000 -1.982485e-016 3 | outer loop 4 | vertex 1.900000e+003 -4.261830e-006 -8.881784e-013 5 | vertex 2.000000e+003 -4.261804e-006 -8.881784e-013 6 | vertex 1.900000e+003 -4.261830e-006 1.000000e+003 7 | endloop 8 | endfacet 9 | facet normal 2.605087e-013 -1.000000e+000 -1.982485e-016 10 | outer loop 11 | vertex 1.900000e+003 -4.261830e-006 1.000000e+003 12 | vertex 2.000000e+003 -4.261804e-006 -8.881784e-013 13 | vertex 2.000000e+003 -4.261804e-006 1.000000e+003 14 | endloop 15 | endfacet 16 | facet normal -1.000000e+000 -2.603977e-013 4.206239e-016 17 | outer loop 18 | vertex 1.900000e+003 2.500000e+002 -8.881784e-013 19 | vertex 1.900000e+003 -4.261830e-006 -8.881784e-013 20 | vertex 1.900000e+003 2.500000e+002 1.000000e+003 21 | endloop 22 | endfacet 23 | facet normal -1.000000e+000 -2.603977e-013 4.206239e-016 24 | outer loop 25 | vertex 1.900000e+003 2.500000e+002 1.000000e+003 26 | vertex 1.900000e+003 -4.261830e-006 -8.881784e-013 27 | vertex 1.900000e+003 -4.261830e-006 1.000000e+003 28 | endloop 29 | endfacet 30 | facet normal -2.605087e-013 1.000000e+000 1.982485e-016 31 | outer loop 32 | vertex 2.000000e+003 2.500000e+002 -8.881784e-013 33 | vertex 1.900000e+003 2.500000e+002 -8.881784e-013 34 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 35 | endloop 36 | endfacet 37 | facet normal -2.605087e-013 1.000000e+000 1.982485e-016 38 | outer loop 39 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 40 | vertex 1.900000e+003 2.500000e+002 -8.881784e-013 41 | vertex 1.900000e+003 2.500000e+002 1.000000e+003 42 | endloop 43 | endfacet 44 | facet normal 1.000000e+000 2.603977e-013 -4.206239e-016 45 | outer loop 46 | vertex 2.000000e+003 -4.261804e-006 -8.881784e-013 47 | vertex 2.000000e+003 2.500000e+002 -8.881784e-013 48 | vertex 2.000000e+003 -4.261804e-006 1.000000e+003 49 | endloop 50 | endfacet 51 | facet normal 1.000000e+000 2.603977e-013 -4.206239e-016 52 | outer loop 53 | vertex 2.000000e+003 -4.261804e-006 1.000000e+003 54 | vertex 2.000000e+003 2.500000e+002 -8.881784e-013 55 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 56 | endloop 57 | endfacet 58 | facet normal -4.206239e-016 1.982485e-016 -1.000000e+000 59 | outer loop 60 | vertex 1.900000e+003 2.500000e+002 -8.881784e-013 61 | vertex 2.000000e+003 2.500000e+002 -8.881784e-013 62 | vertex 1.900000e+003 -4.261830e-006 -8.881784e-013 63 | endloop 64 | endfacet 65 | facet normal -4.206239e-016 1.982485e-016 -1.000000e+000 66 | outer loop 67 | vertex 1.900000e+003 -4.261830e-006 -8.881784e-013 68 | vertex 2.000000e+003 2.500000e+002 -8.881784e-013 69 | vertex 2.000000e+003 -4.261804e-006 -8.881784e-013 70 | endloop 71 | endfacet 72 | facet normal 4.206239e-016 -1.982485e-016 1.000000e+000 73 | outer loop 74 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 75 | vertex 1.900000e+003 2.500000e+002 1.000000e+003 76 | vertex 2.000000e+003 -4.261804e-006 1.000000e+003 77 | endloop 78 | endfacet 79 | facet normal 4.206239e-016 -1.982485e-016 1.000000e+000 80 | outer loop 81 | vertex 2.000000e+003 -4.261804e-006 1.000000e+003 82 | vertex 1.900000e+003 2.500000e+002 1.000000e+003 83 | vertex 1.900000e+003 -4.261830e-006 1.000000e+003 84 | endloop 85 | endfacet 86 | endsolid 87 | solid coor - leg-2 88 | facet normal -1.985793e-016 -1.000000e+000 7.398869e-017 89 | outer loop 90 | vertex -5.160246e-007 -4.261835e-006 0.000000e+000 91 | vertex 1.000000e+002 -4.261835e-006 0.000000e+000 92 | vertex -5.160241e-007 -4.261835e-006 1.000000e+003 93 | endloop 94 | endfacet 95 | facet normal -1.985793e-016 -1.000000e+000 7.398869e-017 96 | outer loop 97 | vertex -5.160241e-007 -4.261835e-006 1.000000e+003 98 | vertex 1.000000e+002 -4.261835e-006 0.000000e+000 99 | vertex 1.000000e+002 -4.261835e-006 1.000000e+003 100 | endloop 101 | endfacet 102 | facet normal -1.000000e+000 3.096016e-016 4.206239e-016 103 | outer loop 104 | vertex -5.160246e-007 2.500000e+002 0.000000e+000 105 | vertex -5.160246e-007 -4.261835e-006 0.000000e+000 106 | vertex -5.160241e-007 2.500000e+002 1.000000e+003 107 | endloop 108 | endfacet 109 | facet normal -1.000000e+000 3.096016e-016 4.206239e-016 110 | outer loop 111 | vertex -5.160241e-007 2.500000e+002 1.000000e+003 112 | vertex -5.160246e-007 -4.261835e-006 0.000000e+000 113 | vertex -5.160241e-007 -4.261835e-006 1.000000e+003 114 | endloop 115 | endfacet 116 | facet normal 1.985793e-016 1.000000e+000 -7.398869e-017 117 | outer loop 118 | vertex 1.000000e+002 2.500000e+002 0.000000e+000 119 | vertex -5.160246e-007 2.500000e+002 0.000000e+000 120 | vertex 1.000000e+002 2.500000e+002 1.000000e+003 121 | endloop 122 | endfacet 123 | facet normal 1.985793e-016 1.000000e+000 -7.398869e-017 124 | outer loop 125 | vertex 1.000000e+002 2.500000e+002 1.000000e+003 126 | vertex -5.160246e-007 2.500000e+002 0.000000e+000 127 | vertex -5.160241e-007 2.500000e+002 1.000000e+003 128 | endloop 129 | endfacet 130 | facet normal 1.000000e+000 -3.096016e-016 -4.206239e-016 131 | outer loop 132 | vertex 1.000000e+002 -4.261835e-006 0.000000e+000 133 | vertex 1.000000e+002 2.500000e+002 0.000000e+000 134 | vertex 1.000000e+002 -4.261835e-006 1.000000e+003 135 | endloop 136 | endfacet 137 | facet normal 1.000000e+000 -3.096016e-016 -4.206239e-016 138 | outer loop 139 | vertex 1.000000e+002 -4.261835e-006 1.000000e+003 140 | vertex 1.000000e+002 2.500000e+002 0.000000e+000 141 | vertex 1.000000e+002 2.500000e+002 1.000000e+003 142 | endloop 143 | endfacet 144 | facet normal -4.206239e-016 -7.398869e-017 -1.000000e+000 145 | outer loop 146 | vertex -5.160246e-007 2.500000e+002 0.000000e+000 147 | vertex 1.000000e+002 2.500000e+002 0.000000e+000 148 | vertex -5.160246e-007 -4.261835e-006 0.000000e+000 149 | endloop 150 | endfacet 151 | facet normal -4.206239e-016 -7.398869e-017 -1.000000e+000 152 | outer loop 153 | vertex -5.160246e-007 -4.261835e-006 0.000000e+000 154 | vertex 1.000000e+002 2.500000e+002 0.000000e+000 155 | vertex 1.000000e+002 -4.261835e-006 0.000000e+000 156 | endloop 157 | endfacet 158 | facet normal 4.206239e-016 7.398869e-017 1.000000e+000 159 | outer loop 160 | vertex 1.000000e+002 2.500000e+002 1.000000e+003 161 | vertex -5.160241e-007 2.500000e+002 1.000000e+003 162 | vertex 1.000000e+002 -4.261835e-006 1.000000e+003 163 | endloop 164 | endfacet 165 | facet normal 4.206239e-016 7.398869e-017 1.000000e+000 166 | outer loop 167 | vertex 1.000000e+002 -4.261835e-006 1.000000e+003 168 | vertex -5.160241e-007 2.500000e+002 1.000000e+003 169 | vertex -5.160241e-007 -4.261835e-006 1.000000e+003 170 | endloop 171 | endfacet 172 | endsolid 173 | solid coor - midd-1 174 | facet normal -4.206239e-016 -7.398869e-017 -1.000000e+000 175 | outer loop 176 | vertex 4.440892e-013 1.112056e-005 1.000000e+003 177 | vertex 4.440892e-013 2.500000e+002 1.000000e+003 178 | vertex 2.000000e+003 1.112056e-005 1.000000e+003 179 | endloop 180 | endfacet 181 | facet normal -4.206239e-016 -7.398869e-017 -1.000000e+000 182 | outer loop 183 | vertex 2.000000e+003 1.112056e-005 1.000000e+003 184 | vertex 4.440892e-013 2.500000e+002 1.000000e+003 185 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 186 | endloop 187 | endfacet 188 | facet normal -3.096016e-016 -1.000000e+000 -3.703362e-017 189 | outer loop 190 | vertex 4.440892e-013 1.112056e-005 1.180000e+003 191 | vertex 4.440892e-013 1.112056e-005 1.000000e+003 192 | vertex 2.000000e+003 1.112056e-005 1.180000e+003 193 | endloop 194 | endfacet 195 | facet normal -3.096016e-016 -1.000000e+000 -3.703362e-017 196 | outer loop 197 | vertex 2.000000e+003 1.112056e-005 1.180000e+003 198 | vertex 4.440892e-013 1.112056e-005 1.000000e+003 199 | vertex 2.000000e+003 1.112056e-005 1.000000e+003 200 | endloop 201 | endfacet 202 | facet normal 4.206239e-016 1.850110e-016 1.000000e+000 203 | outer loop 204 | vertex 4.440892e-013 2.500000e+002 1.180000e+003 205 | vertex 4.440892e-013 1.112056e-005 1.180000e+003 206 | vertex 2.000000e+003 2.500000e+002 1.180000e+003 207 | endloop 208 | endfacet 209 | facet normal 4.206239e-016 1.850110e-016 1.000000e+000 210 | outer loop 211 | vertex 2.000000e+003 2.500000e+002 1.180000e+003 212 | vertex 4.440892e-013 1.112056e-005 1.180000e+003 213 | vertex 2.000000e+003 1.112056e-005 1.180000e+003 214 | endloop 215 | endfacet 216 | facet normal 3.096016e-016 1.000000e+000 3.703362e-017 217 | outer loop 218 | vertex 4.440892e-013 2.500000e+002 1.000000e+003 219 | vertex 4.440892e-013 2.500000e+002 1.180000e+003 220 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 221 | endloop 222 | endfacet 223 | facet normal 3.096016e-016 1.000000e+000 3.703362e-017 224 | outer loop 225 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 226 | vertex 4.440892e-013 2.500000e+002 1.180000e+003 227 | vertex 2.000000e+003 2.500000e+002 1.180000e+003 228 | endloop 229 | endfacet 230 | facet normal -1.000000e+000 3.096016e-016 4.206239e-016 231 | outer loop 232 | vertex 4.440892e-013 1.112056e-005 1.180000e+003 233 | vertex 4.440892e-013 2.500000e+002 1.180000e+003 234 | vertex 4.440892e-013 1.112056e-005 1.000000e+003 235 | endloop 236 | endfacet 237 | facet normal -1.000000e+000 3.096016e-016 4.206239e-016 238 | outer loop 239 | vertex 4.440892e-013 1.112056e-005 1.000000e+003 240 | vertex 4.440892e-013 2.500000e+002 1.180000e+003 241 | vertex 4.440892e-013 2.500000e+002 1.000000e+003 242 | endloop 243 | endfacet 244 | facet normal 1.000000e+000 -3.096016e-016 -4.206239e-016 245 | outer loop 246 | vertex 2.000000e+003 2.500000e+002 1.180000e+003 247 | vertex 2.000000e+003 1.112056e-005 1.180000e+003 248 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 249 | endloop 250 | endfacet 251 | facet normal 1.000000e+000 -3.096016e-016 -4.206239e-016 252 | outer loop 253 | vertex 2.000000e+003 2.500000e+002 1.000000e+003 254 | vertex 2.000000e+003 1.112056e-005 1.180000e+003 255 | vertex 2.000000e+003 1.112056e-005 1.000000e+003 256 | endloop 257 | endfacet 258 | endsolid -------------------------------------------------------------------------------- /src/CodeParse/RobotArgorithmn.cpp: -------------------------------------------------------------------------------- 1 | #include "RobotArgorithmn.h" 2 | #include 3 | #include 4 | #define PI M_PI 5 | #define ZERO_THRESH (2) 6 | #define EPSINON 0.00000001 7 | double RobotArgorithmn::a1_5 = 700; 8 | double RobotArgorithmn::a2_5 = 600; 9 | double RobotArgorithmn::d2_5 = 703.2; 10 | double RobotArgorithmn::a1_6 = 109; 11 | double RobotArgorithmn::a2_6 = 250.5; 12 | double RobotArgorithmn::a3_6 = 115.5; 13 | double RobotArgorithmn::d1_6 = 215; 14 | double RobotArgorithmn::d4_6 = 239.5; 15 | 16 | //Identity(4x4)的单位阵 17 | Matrix4d RobotArgorithmn::TCF_Coord = Matrix4d::Identity(4,4); 18 | Matrix4d RobotArgorithmn::TCF_5Joint = Matrix4d::Identity(4,4); 19 | Matrix4d RobotArgorithmn::TCF_6Joint= Matrix4d::Identity(4,4); 20 | 21 | //弧度单位打印 22 | void Joint1::printJointRadians() const{ 23 | cout << j1 << " "<< j2 << " "<< j3 << " "<< j4 << " "<< j5 << " "<< j6 << endl; 24 | } 25 | 26 | //角度单位打印 27 | void Joint1::printJointDegrees() const{ 28 | cout << j1 * 180.0 / PI << " "<< j2 * 180.0 / PI<< " "<< j3 << " " << j4 * 180.0 / PI << " "<< j5 * 180.0 / PI << " "<< j6 << endl; 29 | } 30 | 31 | RobotArgorithmn::RobotArgorithmn() 32 | { 33 | 34 | } 35 | 36 | //绕z轴的旋转矩阵 37 | Matrix4d RobotArgorithmn::rotZ(double o) 38 | { 39 | //初始化 40 | Matrix4d m = Matrix4d::Zero();//4x4的零矩阵 41 | m << cos(o), -sin(o), 0, 0, 42 | sin(o), cos(o), 0, 0, 43 | 0, 0, 1, 0, 44 | 0, 0, 0, 1; 45 | return m; 46 | } 47 | 48 | //绕y轴的旋转矩阵 49 | Matrix4d RobotArgorithmn::rotY(double j) 50 | { 51 | Matrix4d m = Matrix4d::Zero();; 52 | m << cos(j), 0, sin(j), 0, 53 | 0, 1, 0, 0, 54 | -sin(j),0,cos(j), 0, 55 | 0, 0, 0, 1; 56 | return m; 57 | } 58 | 59 | //绕x轴的旋转矩阵 60 | Matrix4d RobotArgorithmn::rotX(double i) 61 | { 62 | Matrix4d m = Matrix4d::Zero(); 63 | m << 1, 0, 0, 0, 64 | 0, cos(i), -sin(i), 0, 65 | 0, sin(i), cos(i), 0, 66 | 0, 0, 0, 1; 67 | return m; 68 | } 69 | 70 | //z轴移动d距离 71 | Matrix4d RobotArgorithmn::transZ(double d) 72 | { 73 | Matrix4d m = Matrix4d::Zero(); 74 | m << 1, 0, 0, 0, 75 | 0, 1, 0, 0, 76 | 0, 0, 1, d, 77 | 0, 0, 0, 1; 78 | return m; 79 | } 80 | 81 | //x轴移动a距离 82 | Matrix4d RobotArgorithmn::transX(double a) 83 | { 84 | Matrix4d m = Matrix4d::Zero(); 85 | m << 1, 0, 0, a, 86 | 0, 1, 0, 0, 87 | 0, 0, 1, 0, 88 | 0, 0, 0, 1; 89 | return m; 90 | } 91 | 92 | //坐标机器人的正解,缺点每次都要进行矩阵的乘法,浪费资源 93 | Matrix4d RobotArgorithmn::fk_Coord(const Joint1& joint) 94 | { 95 | 96 | Matrix4d T1_3 = Matrix4d::Zero(); 97 | //T1~3只是移动 98 | T1_3 << 1,0,0,joint.j1, 99 | 0,1,0,joint.j2, 100 | 0,0,1,joint.j3, 101 | 0,0,0,1; 102 | //参数都是弧度 103 | Matrix4d T4 = getT(joint.j4,0,0,-90 / 180.0 * PI); 104 | Matrix4d T5= getT(joint.j5,0,0,90/180*PI); 105 | //Matrix4d T5 = rotZ(joint.j5) * rotX(90 / 180.0 * PI); 106 | return T1_3 * T4 * T5 * TCF_Coord; 107 | } 108 | 109 | //坐标式机器人正解,输入关节输出矩阵 110 | Matrix4d RobotArgorithmn::fk_CoordNew(const Joint1& joint) 111 | { 112 | Matrix4d m; 113 | m << cos(joint.j4) * cos(joint.j5), -sin(joint.j4), cos(joint.j4) * sin(joint.j5), joint.j1, 114 | sin(joint.j4) * cos(joint.j5), cos(joint.j4), sin(joint.j4) * sin(joint.j5), joint.j2, 115 | -sin(joint.j5),0, cos(joint.j5), joint.j3, 116 | 0, 0, 0, 1; 117 | return m * TCF_Coord; 118 | } 119 | 120 | //坐标式机器人逆解,输入矩阵输出关节 121 | bool RobotArgorithmn::ik_Coord(const Matrix4d& m) 122 | { 123 | //右乘焊枪矩阵的逆才是1~5关节的T矩阵 124 | const Matrix4d T1_5 = m * TCF_Coord.inverse(); 125 | Joint1 tmpJoint; 126 | vector res; 127 | 128 | //提取矩阵中的位移值dx,dy,dz 129 | tmpJoint.j1 = T1_5(0,3); 130 | tmpJoint.j2 = T1_5(1,3); 131 | tmpJoint.j3 = T1_5(2,3); 132 | //无第六关节 133 | tmpJoint.j6 = 0; 134 | 135 | //θ5 根据公式中的 nz=-sin(θ5) az=cos(θ5) 136 | double nz=T1_5(2,0); 137 | double az=T1_5(2,2); 138 | tmpJoint.j5=-atan2(nz,az); 139 | 140 | //θ4可能有两个解 az=cos(θ4) 141 | tmpJoint.j4=acos(T1_5(1,1)); 142 | //0代表是坐标机器人,将tmpJoint正解后与T1_5比较 143 | if(compare(tmpJoint,T1_5,0)){ 144 | res.push_back(tmpJoint); 145 | } 146 | 147 | tmpJoint.j4=-acos(T1_5(1,1)); 148 | if(compare(tmpJoint,T1_5,0)){ 149 | res.push_back(tmpJoint); 150 | } 151 | 152 | 153 | /**************************** 154 | //θ4,θ5都可能有两个 155 | v4.push_back(acos(t(1,1))); 156 | v5.push_back(acos(t(2,2))); 157 | //判断是否大于1 158 | if(fabs(t(1,1) - 1) > EPSINON ) 159 | v4.push_back(-acos(t(1,1))); 160 | 161 | if(fabs(t(2,2) - 1) > EPSINON) 162 | v5.push_back(-acos(t(2,2))); 163 | 164 | //暴力解法,测试关节4,5值带入后的正解是否与传入参数矩阵相等 165 | //可能有多个解 166 | for(int i = 0; i < v4.size();i++){ 167 | for(int j = 0; j < v5.size();j++){ 168 | tmpJoint.j4 = v4[i]; 169 | tmpJoint.j5 = v5[j]; 170 | //判断解对不对 171 | if(compare(tmpJoint,t,0)) 172 | res.push_back(tmpJoint); 173 | } 174 | } 175 | *************/ 176 | 177 | if(res.size() < 1){ 178 | cout << "无解" << endl; 179 | return false; 180 | }else{ 181 | //打印所有解 182 | cout << "解为:"<< endl; 183 | for(int i = 0; i < res.size();++i){ 184 | res[i].printJointDegrees(); 185 | } 186 | } 187 | return true; 188 | } 189 | 190 | //求5关节机器人逆解 191 | bool RobotArgorithmn::ik_5Joint(const Matrix4d& m) 192 | { 193 | Matrix4d t = m * TCF_Coord.inverse(); //终点坐标乘以TCF_Coord矩阵的 194 | Joint1 jt; 195 | jt.j6 = 0; 196 | //第一个解 197 | jt.j3 = t(2,3) - d2_5; //0 198 | vector v; 199 | vector v5; //角5的集合 有两个解 200 | vector v2; //两个解 201 | //第二个解 可能有两组 202 | v5.push_back(acos(t(2,2))); 203 | if(fabs(t(2,2) - 1) > EPSINON) 204 | v5.push_back(-acos(t(2,2))); 205 | 206 | //角2的解 207 | double sv2 = (t(0,3) * t(0,3) + t(1,3) * t(1,3) - a1_5 * a1_5 - a2_5 * a2_5) / (2.0 * a1_5 * a2_5); 208 | v2.push_back(acos(sv2)); 209 | if(fabs(sv2 - 1) > EPSINON) 210 | v2.push_back(-acos(sv2)); 211 | for(unsigned int i = 0; i < v5.size();i++) 212 | { 213 | for(unsigned int j = 0; j < v2.size();j++) //从角2出发来看情况 可能有四组解 214 | { 215 | //角1的解 216 | jt.j2 = v2[j]; 217 | jt.j5 = v5[i]; 218 | cout << ":: " << (((a1_5 + a2_5 * sv2) * t(1,3) - a2_5 * sin(v2[j]) * t(0,3)) / ((a1_5 + a2_5 * sv2) * t(0,3) + a2_5 * sin(v2[j]) * t(1,3))) < EPSINON) 227 | { 228 | jt.j4 = -sv1 - v2[j] - acos(t(1,1)); 229 | if(compare(jt,t,1)) 230 | v.push_back(jt); 231 | } 232 | 233 | 234 | 235 | /**************************************/ 236 | if(sv1 > 0) 237 | { 238 | jt.j1 = sv1 - PI; 239 | cout << "++: " << jt.j1 << endl; 240 | /**************************************/ 241 | jt.j4 = -sv1 - v2[j] + acos(t(1,1)); 242 | if(compare(jt,t,1)) 243 | v.push_back(jt); 244 | if(fabs(t(1,1) - 1) > EPSINON) 245 | { 246 | jt.j4 = -sv1 - v2[j] - acos(t(1,1)); 247 | if(compare(jt,t,1)) 248 | v.push_back(jt); 249 | } 250 | /**************************************/ 251 | } 252 | if(sv1 < 0) 253 | { 254 | jt.j1 = sv1 + PI; 255 | cout << "--: " << jt.j1 << endl; 256 | /**************************************/ 257 | jt.j4 = -sv1 - v2[j] + acos(t(1,1)); 258 | if(compare(jt,t,1)) 259 | v.push_back(jt); 260 | if(fabs(t(1,1) - 1) > EPSINON) 261 | { 262 | jt.j4 = -sv1 - v2[j] - acos(t(1,1)); 263 | if(compare(jt,t,1)) 264 | v.push_back(jt); 265 | } 266 | /**************************************/ 267 | } 268 | 269 | } 270 | } 271 | if(v.size() < 1) 272 | { 273 | cout << "wujie" << endl; 274 | return false; 275 | } 276 | else 277 | { 278 | cout << "jiewei:"<< endl; 279 | for(unsigned int i = 0; i < v.size();i++) 280 | v[i].printJointDegrees(); 281 | } 282 | } 283 | 284 | 285 | //通过关节值正解得到的矩阵与矩阵m比较 286 | bool RobotArgorithmn::compare(const Joint1& jt,const Matrix4d &m,int i) 287 | { 288 | Matrix4d res; 289 | switch(i){ 290 | case 0: res = fk_CoordNew(jt); 291 | break; 292 | case 1: res = fk_5Joint(jt); 293 | break; 294 | case 2: //res = fk_6JointNew(jt); 295 | break; 296 | } 297 | 298 | //比较两个矩阵,让每个元素相减,fabs()返回绝对值 299 | for(int i = 0; i < 4;i++){ 300 | for(int j = 0; j < 4;j++){ 301 | if(fabs(res(i,j) - m(i,j)) > ZERO_THRESH) 302 | return false; 303 | } 304 | } 305 | return true; 306 | } 307 | 308 | //返回正解5关节矩阵位字旋转矩阵 309 | Matrix4d RobotArgorithmn::fk_5Joint(const Joint1& joint) 310 | { 311 | Matrix4d T1 = getT(joint.j1,0,a1_5,0); 312 | Matrix4d T2 = getT(joint.j2,d2_5,a2_5,0); 313 | Matrix4d T3 = getT(0,joint.j3,0,0); 314 | Matrix4d T4 = getT(joint.j4,0,0,-90 / 180.0 * PI); 315 | Matrix4d T5 = getT(joint.j5,0,0,90 / 180.0 * PI); 316 | return T1 * T2 * T3 * T4 * T5 * TCF_5Joint; 317 | } 318 | 319 | //返回正解5关节矩阵位字旋转矩阵(提前算好)效率更高 320 | Matrix4d RobotArgorithmn::fk_5JointNew(const Joint1& joint) 321 | { 322 | Matrix4d m; 323 | m << cos(joint.j1 + joint.j2 + joint.j4) * cos(joint.j5), -sin(joint.j1 + joint.j2 + joint.j4), cos(joint.j1 + joint.j2 + joint.j4) * sin(joint.j5), a1_5 * cos(joint.j1) + a2_5 * cos(joint.j1 + joint.j2), 324 | sin(joint.j1 + joint.j2 + joint.j4) * cos(joint.j5), cos(joint.j1 + joint.j2 + joint.j4), sin(joint.j1 + joint.j2 + joint.j4) * sin(joint.j5), a1_5 * sin(joint.j1) + a2_5 * sin(joint.j1 + joint.j2), 325 | -sin(joint.j5),0, cos(joint.j5), d2_5 + joint.j3, 326 | 0, 0, 0, 1; 327 | return m * TCF_5Joint; 328 | } 329 | 330 | //返回正解6关节矩阵位字旋转矩阵 331 | Matrix4d RobotArgorithmn::fk_6Joint(const Joint1& joint) 332 | { 333 | Matrix4d T1 = getT(joint.j1,d1_6,a1_6,-90 / 180.0 * PI); 334 | Matrix4d T2 = getT(joint.j2 - (90 / 180.0 * PI),0,a2_6,0); 335 | Matrix4d T3 = getT(joint.j3,0,a3_6,-90 / 180.0 * PI); 336 | Matrix4d T4 = getT(joint.j4,d4_6,0,90 / 180.0 * PI); 337 | Matrix4d T5 = getT(joint.j5,0,0,-90 / 180.0 * PI); 338 | Matrix4d T6 = getT(joint.j6,0,0,0); 339 | Matrix4d Ts = rotZ(180 / 180.0 * PI); 340 | return T1 * T2 * T3 * T4 * T5 * T6 * Ts * TCF_6Joint; 341 | } 342 | 343 | //求每个关节的转换矩阵,参数分别是a,α,d,Θ (单位弧度) Standard DH法 344 | Matrix4d RobotArgorithmn::getT(double o,double d,double a,double i) 345 | { 346 | Matrix4d m = Matrix4d::Zero(); 347 | m << cos(o), -sin(o) * cos(i), sin(o) * sin(i), a * cos(o), 348 | sin(o), cos(o) * cos(i), -cos(o) * sin(i), a * sin(o), 349 | 0, sin(i), cos(i), d, 350 | 0, 0, 0, 1; 351 | return m; 352 | } 353 | 354 | -------------------------------------------------------------------------------- /src/CodeParse/CodeEditDlg.cpp: -------------------------------------------------------------------------------- 1 | #include "CodeEditDlg.h" 2 | #include "ui_CodeEditDlg.h" 3 | #include "CommonFun/CommonFun.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | CodeEditDlg::CodeEditDlg(QWidget *parent) : 15 | QWidget(parent), 16 | ui(new Ui::CodeEditDlg) 17 | { 18 | ui->setupUi(this); 19 | init(); 20 | 21 | //读取上次保存的xyzrpw参数以及机器人类型 22 | Parameter::readParameter(); 23 | } 24 | 25 | CodeEditDlg::~CodeEditDlg() 26 | { 27 | //记录最后保存的文件名到QSettings对象中便于初始化,key:"Para/saveFileName",value:saveFileName 28 | CommonFun::WriteSettingsStr("Para/saveFileName",saveFileName); 29 | //记录文件打开时的路径 30 | CommonFun::WriteSettingsStr("Para/lastFilePath",lastFilePath); 31 | 32 | Parameter::writeParameter(); 33 | delete ui; 34 | } 35 | 36 | //从ini文件中获取上次保存的文件名,并初始化到textEdit中 37 | void CodeEditDlg::init() 38 | { 39 | //获取上次保存的文件名 40 | saveFileName = CommonFun::ReadSettingsStr("Para/saveFileName"); 41 | //获取上次打开文件的路径 42 | lastFilePath = CommonFun::ReadSettingsStr("Para/lastFilePath"); 43 | //如果文件路径为空,则设置为应用程序当前目录的绝对路径。 44 | if(lastFilePath.isEmpty()) 45 | lastFilePath = QDir::currentPath(); 46 | 47 | ui->filename_label->setText(saveFileName); 48 | 49 | if(saveFileName.isEmpty()) 50 | return; 51 | 52 | //1、获取上次保存文件名 2、打开先前的保存文件 3、读取到代码编辑区 53 | QFile *file = new QFile(saveFileName); 54 | if (file->open(QIODevice::ReadOnly)) 55 | { 56 | QTextStream in(file); 57 | ui->textEdit->setText(in.readAll()); 58 | file->close(); 59 | delete file; 60 | } 61 | } 62 | 63 | //新建槽函数,并询问是否需要保存文本? 64 | void CodeEditDlg::newCreteFile() 65 | { 66 | if (ui->textEdit->document()->isModified()) 67 | { 68 | QMessageBox::StandardButton button = QMessageBox::information(this, "尚未保存", "是否要保存?", 69 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); 70 | switch (button) 71 | { 72 | case QMessageBox::Save: 73 | saveFile(); 74 | if (ui->textEdit->document()->isModified()) 75 | return; 76 | break; 77 | case QMessageBox::Discard: 78 | break; 79 | case QMessageBox::Cancel: 80 | return; 81 | break; 82 | default: 83 | break; 84 | } 85 | } 86 | 87 | //text清空 88 | ui->textEdit->clear(); 89 | //文件名清空 90 | saveFileName.clear(); 91 | //设置为无名 92 | ui->filename_label->setText("untitled.txt....."); 93 | //设置为字体 94 | ui->textEdit->setCurrentFont(QFont("宋体", 13, QFont::Normal)); 95 | 96 | } 97 | 98 | void CodeEditDlg::openFile() 99 | { 100 | if (ui->textEdit->document()->isModified()) 101 | { 102 | QMessageBox::StandardButton button = QMessageBox::information(this, "尚未保存", "是否要保存?", 103 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); 104 | switch (button) 105 | { 106 | case QMessageBox::Save: 107 | saveFile(); 108 | if (ui->textEdit->document()->isModified()) 109 | return; 110 | break; 111 | case QMessageBox::Discard: 112 | break; 113 | case QMessageBox::Cancel: 114 | return; 115 | break; 116 | } 117 | } 118 | QString Name = QFileDialog::getOpenFileName(this, "打开",lastFilePath, "焊接离线文件 (*.txt *.cnc)"); 119 | if (Name.isEmpty()) 120 | return; 121 | saveFileName = Name; 122 | QFile file(saveFileName); 123 | ui->textEdit->clear(); 124 | ui->textEdit->setCurrentFont(QFont("宋体", 13, QFont::Normal)); 125 | if (!file.open(QIODevice::ReadOnly)) 126 | { 127 | QMessageBox::warning(this, "错误", "不能打开文件", QMessageBox::Yes); 128 | return; 129 | } 130 | QTextStream in(&file); 131 | ui->textEdit->setText(in.readAll()); 132 | file.close(); 133 | 134 | //设置打开文件的label 135 | ui->filename_label->setText(saveFileName); 136 | 137 | //构建一个QFileInfo,包含文件的信息:绝对路径和相对路径 138 | lastFilePath = QFileInfo(saveFileName).absolutePath(); 139 | } 140 | 141 | 142 | void CodeEditDlg::saveFile() 143 | { 144 | //如果不是通过打开的文件(例如:新建文件),没有saveFileName值,则调用saveAsFile另存为函数 145 | if (saveFileName.isEmpty()) 146 | saveAsFile(); 147 | else 148 | { 149 | //打开saveFileName文件,写入数据 150 | QFile file(saveFileName); 151 | if(!file.open(QIODevice::WriteOnly)) 152 | { 153 | QMessageBox::warning(this, "ERROR", "Can't save the file", QMessageBox::Yes); 154 | return; 155 | } 156 | QTextStream out(&file); 157 | out << ui->textEdit->toPlainText(); 158 | //保存后重置 已修改 状态 159 | ui->textEdit->document()->setModified(false); 160 | file.close(); 161 | } 162 | } 163 | 164 | //解析代码 165 | void CodeEditDlg::transFile() 166 | { 167 | saveFile(); 168 | int n = codeconversion.CreateConvertedFile(saveFileName); 169 | if(n == -2) //表示解析有错误 170 | { 171 | codeconversion.dspMsg("解析错误:\n",this); 172 | } 173 | else if(n == 0) 174 | { 175 | QMessageBox::information(this,"提示","文本G代码转换及编译成功!"); 176 | } 177 | else if(n == 1) 178 | { 179 | QMessageBox::information(this,"提示","文本G代码编译成功!"); 180 | } 181 | } 182 | 183 | //解析代码 184 | void CodeEditDlg::transFile(const QString & fileName) 185 | { 186 | int n = codeconversion.CreateConvertedFile(fileName); 187 | if(n == -2) //表示解析有错误 188 | { 189 | codeconversion.dspMsg("解析错误:\n",this); 190 | } 191 | else if(n == 1) 192 | { 193 | QMessageBox::information(this,"提示","示教G代码编译成功!"); 194 | } 195 | } 196 | 197 | //另存为 198 | void CodeEditDlg::saveAsFile() 199 | { 200 | //新获得保存文件的名称 201 | QString Name = QFileDialog::getSaveFileName(this, "保存",lastFilePath, "焊接离线文件 (*.cnc)"); 202 | if(Name.isEmpty()) 203 | return; 204 | saveFileName = Name; 205 | 206 | //若文件不是.txt或者.cnc文件例如(新建的文件另存为时) 207 | //把保存文件都变为.cnc,默认Qt::CaseSensitive区分大小写 208 | //Qt::CaseInsensitive不区分大小写 209 | if(!saveFileName.endsWith(".txt", Qt::CaseInsensitive) && !saveFileName.endsWith(".cnc", Qt::CaseInsensitive)) 210 | saveFileName.append(".cnc"); 211 | 212 | QFile file(saveFileName); 213 | if(!file.open(QIODevice::WriteOnly)) 214 | { 215 | QMessageBox::warning(this, "错误", "不能打开文件", QMessageBox::Yes); 216 | return; 217 | } 218 | QTextStream out(&file); 219 | out << ui->textEdit->toPlainText(); 220 | ui->textEdit->document()->setModified(false); 221 | file.close(); 222 | 223 | ui->filename_label->setText(saveFileName); 224 | //记录本次文件的绝对路径 225 | lastFilePath = QFileInfo(saveFileName).absolutePath(); 226 | } 227 | 228 | void CodeEditDlg::colorSlot() 229 | { 230 | QColor color = QColorDialog::getColor(Qt::green, this, "颜色"); 231 | if (color.isValid()) 232 | { 233 | ui->textEdit->setTextColor(color); 234 | ui->textEdit->document()->setModified(true); 235 | } 236 | } 237 | void CodeEditDlg::fontSlot() 238 | { 239 | bool ok; 240 | QFont font = QFontDialog::getFont(&ok, ui->textEdit->font(), this, "字体"); 241 | if (ok) 242 | { 243 | ui->textEdit->setCurrentFont(font); 244 | ui->textEdit->document()->setModified(true); 245 | } 246 | } 247 | 248 | //重写关闭事件 249 | void CodeEditDlg::closeEvent(QCloseEvent *event) 250 | { 251 | //判断修改后是否保存 252 | if (ui->textEdit->document()->isModified()) 253 | { 254 | QMessageBox::StandardButton button = QMessageBox::information(this, "尚未保存", "是否要保存?", 255 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); 256 | switch (button) 257 | { 258 | case QMessageBox::Save: 259 | saveFile(); 260 | //如果还存在修改,忽略退出信号,程序继续进行 261 | if (ui->textEdit->document()->isModified()) 262 | event->ignore(); 263 | else 264 | event->accept();// 接受退出信号,程序退出 265 | break; 266 | case QMessageBox::Discard: 267 | event->accept(); 268 | break; 269 | case QMessageBox::Cancel: 270 | event->ignore();//忽略退出信号,程序继续进行 271 | break; 272 | } 273 | } 274 | } 275 | 276 | //切换代码,通过QFile切换文件输出textEdit上,所以前提必须先编译代码生成_abs.cnc文件才能切换 277 | bool CodeEditDlg::switchSlot() 278 | { 279 | QString filename = saveFileName; 280 | //判断是否是机器人能使识别的绝对路径焊接文件_abs.cnc 281 | //若是最终生成的焊接文件,则切换打开.cnc,或.txt文件 282 | if(filename.endsWith("_abs.cnc")) 283 | { 284 | QString filename1 = filename.remove("_abs.cnc"); 285 | qDebug() << filename1; 286 | QString filename2 = filename1 + ".cnc"; 287 | QString filename3 = filename1 + ".txt"; 288 | QFile file2(filename2); 289 | QFile file3(filename3); 290 | if(file2.open(QIODevice::ReadOnly)) 291 | { 292 | saveFileName = filename2; 293 | ui->textEdit->clear(); 294 | ui->textEdit->setCurrentFont(QFont("宋体", 13, QFont::Normal)); 295 | QTextStream in(&file2); 296 | ui->textEdit->setText(in.readAll()); 297 | file2.close(); 298 | ui->filename_label->setText(saveFileName); 299 | return true; 300 | } 301 | else if(file3.open(QIODevice::ReadOnly)) 302 | { 303 | saveFileName = filename3; 304 | ui->textEdit->clear(); 305 | ui->textEdit->setCurrentFont(QFont("宋体", 13, QFont::Normal)); 306 | QTextStream in(&file3); 307 | ui->textEdit->setText(in.readAll()); 308 | file3.close(); 309 | ui->filename_label->setText(saveFileName); 310 | return true; 311 | }else 312 | return false; 313 | }else{ 314 | //若当前切换文件是.cnc或.txt文件,则切换为最终的焊接文件_abs.cnc输出 315 | if(filename.endsWith(".cnc")) 316 | filename.remove(".cnc"); 317 | else if(filename.endsWith(".txt")) 318 | filename.remove(".txt"); 319 | else 320 | return false; 321 | filename += "_abs.cnc"; 322 | qDebug() << filename; 323 | QFile file(filename); 324 | if(file.open(QIODevice::ReadOnly)) 325 | { 326 | saveFileName = filename; 327 | ui->textEdit->clear(); 328 | ui->textEdit->setCurrentFont(QFont("宋体", 13, QFont::Normal)); 329 | QTextStream in(&file); 330 | ui->textEdit->setText(in.readAll()); 331 | file.close(); 332 | ui->filename_label->setText(saveFileName); 333 | return true; 334 | } 335 | else 336 | return false; 337 | } 338 | } 339 | 340 | void CodeEditDlg::boldSlot() 341 | { 342 | if (QFont::Bold == ui->textEdit->fontWeight()) 343 | ui->textEdit->setFontWeight(QFont::Normal); 344 | else 345 | ui->textEdit->setFontWeight(QFont::Bold); 346 | } 347 | 348 | void CodeEditDlg::printSlot() 349 | { 350 | qDebug() << "打印"; 351 | QPrinter printer; 352 | QString printer_name = printer.printerName(); 353 | if( printer_name.size() == 0) 354 | { 355 | qDebug() << "没有打印"; 356 | return; 357 | } 358 | QPrintDialog dlg(&printer, this); 359 | if (ui->textEdit->textCursor().hasSelection()) 360 | { 361 | dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); 362 | } 363 | if(dlg.exec() == QDialog::Accepted) 364 | { 365 | ui->textEdit->print(&printer); 366 | } 367 | } 368 | 369 | //检查切换的状态 这个要做预处理来检查是否有问题 370 | bool CodeEditDlg::checkSwitch() 371 | { 372 | QString filename = saveFileName; 373 | if(filename.endsWith("_abs.cnc")) 374 | { 375 | QString filename1 = filename.remove("_abs.cnc"); 376 | qDebug() << filename1; 377 | QString filename2 = filename + ".cnc"; 378 | QString filename3 = filename + ".txt"; 379 | QFile file2(filename2); 380 | QFile file3(filename3); 381 | if(file2.open(QIODevice::ReadOnly)) 382 | return true; 383 | else if(file3.open(QIODevice::ReadOnly)) 384 | return true; 385 | else 386 | return false; 387 | } 388 | else 389 | { 390 | if(filename.endsWith(".cnc")) 391 | filename.remove(".cnc"); 392 | else if(filename.endsWith(".txt")) 393 | filename.remove(".txt"); 394 | else 395 | return false; 396 | filename += "_abs.cnc"; 397 | qDebug() << filename; 398 | QFile file(filename); 399 | if(file.open(QIODevice::ReadOnly)) 400 | return true; 401 | else 402 | return false; 403 | } 404 | } 405 | -------------------------------------------------------------------------------- /src/Alignment/AnalysisWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "AnalysisWidget.h" 2 | #include "ui_AnalysisWidget.h" 3 | #include 4 | #include "Setting/Parameter.h" 5 | #define Plot_Count 10 6 | #define TextColor1 QColor(255,255,255) //黄色 7 | #define TextColor QColor(255,255,0) //黄色 8 | #define Plot_NoColor QColor(0,0,0,0) //黑色 9 | 10 | #define Plot1_DotColor QColor(5,189,251) 11 | #define Plot1_LineColor QColor(41,138,220) 12 | #define Plot1_BGColor QColor(41,138,220,80) 13 | 14 | #define Plot2_DotColor QColor(236,110,0) 15 | #define Plot2_LineColor QColor(246,98,0) 16 | #define Plot2_BGColor QColor(246,98,0,80) 17 | 18 | #define Plot3_DotColor QColor(204,0,0) 19 | #define Plot3_LineColor QColor(246,0,0,200) 20 | #define Plot3_BGColor QColor(246,98,0,80) 21 | #define TextWidth 2 22 | #define TextWidth1 1 23 | #define LineWidth 2 24 | #define DotWidth 0 25 | AnalysisWidget::AnalysisWidget(QWidget *parent) : 26 | QWidget(parent), 27 | ui(new Ui::AnalysisWidget) 28 | { 29 | ui->setupUi(this); 30 | isSpeedAna = false; 31 | isFirst = true; 32 | color[0] = Qt::cyan; 33 | color[1] = Qt::red; 34 | color[2] = Qt::blue; 35 | color[3] = Qt::yellow; 36 | color[4] = Qt::green; 37 | color[5] = Qt::magenta; 38 | color[6] = Qt::white; 39 | color[7] = Qt::gray; 40 | color[8] = Qt::lightGray; 41 | for(int i = 0; i < 6;i++) 42 | { 43 | lastJoint[i] = 0; 44 | lastXyzrpw[i] = 0; 45 | } 46 | initPlot(); 47 | } 48 | 49 | AnalysisWidget::~AnalysisWidget() 50 | { 51 | delete ui; 52 | } 53 | void AnalysisWidget::init() 54 | { 55 | ui->xyzrpw_plot->legend->setVisible(true); //设置图例可以显示 56 | ui->joint_plot->legend->setVisible(true); //设置关节显示 57 | 58 | ui->xyzrpw_plot->xAxis->setTickLabelFont(QFont(QFont().family(),5)); //将显示时间可以显示小一点 59 | ui->joint_plot->xAxis->setTickLabelFont(QFont(QFont().family(),5)); //显示时间显示小一点 60 | 61 | ui->joint_plot->yAxis->setLabelColor(TextColor); 62 | ui->joint_plot->yAxis->setTickLabelColor(TextColor); //Y轴标签颜色 63 | ui->joint_plot->yAxis2->setLabelColor(TextColor); 64 | ui->joint_plot->yAxis2->setTickLabelColor(TextColor); //Y轴标签颜色 65 | 66 | ui->joint_plot->xAxis->setTickLabelColor(TextColor); 67 | ui->joint_plot->xAxis->setBasePen(QPen(TextColor,TextWidth)); 68 | ui->joint_plot->yAxis->setBasePen(QPen(TextColor,TextWidth)); 69 | ui->joint_plot->xAxis->setBasePen(QPen(TextColor,TextWidth)); 70 | ui->joint_plot->yAxis2->setBasePen(QPen(TextColor,TextWidth)); 71 | 72 | 73 | ui->joint_plot->xAxis->setTickPen(QPen(TextColor,TextWidth)); 74 | ui->joint_plot->yAxis->setTickPen(QPen(TextColor,TextWidth1)); 75 | ui->joint_plot->yAxis2->setTickPen(QPen(TextColor,TextWidth1)); 76 | 77 | 78 | ui->joint_plot->xAxis->setSubTickPen(QPen(TextColor,TextWidth)); 79 | ui->joint_plot->yAxis->setSubTickPen(QPen(TextColor,TextWidth)); 80 | ui->joint_plot->yAxis2->setSubTickPen(QPen(TextColor,TextWidth)); 81 | 82 | 83 | 84 | ui->xyzrpw_plot->yAxis->setLabelColor(TextColor); 85 | ui->xyzrpw_plot->yAxis->setTickLabelColor(TextColor); //Y轴标签颜色 86 | 87 | ui->xyzrpw_plot->yAxis2->setLabelColor(TextColor); 88 | ui->xyzrpw_plot->yAxis2->setTickLabelColor(TextColor); //Y轴标签颜色 89 | ui->xyzrpw_plot->xAxis->setTickLabelColor(TextColor); 90 | 91 | ui->xyzrpw_plot->xAxis->setBasePen(QPen(TextColor,TextWidth)); 92 | ui->xyzrpw_plot->yAxis->setBasePen(QPen(TextColor,TextWidth)); 93 | ui->xyzrpw_plot->yAxis2->setBasePen(QPen(TextColor,TextWidth)); 94 | 95 | 96 | ui->xyzrpw_plot->xAxis->setTickPen(QPen(TextColor,TextWidth)); 97 | ui->xyzrpw_plot->yAxis->setTickPen(QPen(TextColor,TextWidth)); 98 | ui->xyzrpw_plot->yAxis2->setTickPen(QPen(TextColor,TextWidth)); 99 | 100 | ui->xyzrpw_plot->xAxis->setSubTickPen(QPen(TextColor,TextWidth)); 101 | ui->xyzrpw_plot->yAxis->setSubTickPen(QPen(TextColor,TextWidth)); 102 | ui->xyzrpw_plot->yAxis2->setSubTickPen(QPen(TextColor,TextWidth)); 103 | 104 | //设置画布背景 105 | QLinearGradient plotGradient; 106 | plotGradient.setStart(0,0); 107 | plotGradient.setFinalStop(0,350); 108 | plotGradient.setColorAt(0,QColor(80,80,80)); 109 | plotGradient.setColorAt(1,QColor(50,50,50)); 110 | ui->joint_plot->setBackground(plotGradient); 111 | ui->xyzrpw_plot->setBackground(plotGradient); 112 | //设置坐标背景色 113 | QLinearGradient axisRectGradient; 114 | axisRectGradient.setStart(0,0); 115 | axisRectGradient.setFinalStop(0,350); 116 | axisRectGradient.setColorAt(0,QColor(80,80,80)); 117 | axisRectGradient.setColorAt(1,QColor(30,30,30)); 118 | ui->joint_plot->axisRect()->setBackground(axisRectGradient); 119 | ui->xyzrpw_plot->axisRect()->setBackground(axisRectGradient); 120 | 121 | //设置图例提示位置以及背景色 122 | ui->joint_plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignRight); 123 | ui->joint_plot->legend->setBrush(QColor(255, 255, 255, 200)); 124 | ui->xyzrpw_plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignRight); 125 | ui->xyzrpw_plot->legend->setBrush(QColor(255, 255, 255, 200)); 126 | //设置动态曲线的横坐标格式及范围 127 | ui->joint_plot->xAxis->setTickLabelType(QCPAxis::ltDateTime); 128 | ui->joint_plot->xAxis->setDateTimeFormat("hh:mm:ss"); 129 | ui->joint_plot->xAxis->setAutoTickStep(false); 130 | ui->joint_plot->xAxis->setTickStep(1); 131 | ui->joint_plot->xAxis->setRange(0, Plot_Count, Qt::AlignRight); 132 | ui->xyzrpw_plot->xAxis->setTickLabelType(QCPAxis::ltDateTime); 133 | ui->xyzrpw_plot->xAxis->setDateTimeFormat("hh:mm:ss"); 134 | ui->xyzrpw_plot->xAxis->setAutoTickStep(false); 135 | ui->xyzrpw_plot->xAxis->setTickStep(1); 136 | ui->xyzrpw_plot->xAxis->setRange(0, Plot_Count, Qt::AlignRight); 137 | 138 | // ui->joint_plot->setInteractions(QCP::iRangeDrag |QCP::iRangeZoom); 139 | // ui->xyzrpw_plot->setInteractions(QCP::iRangeDrag |QCP::iRangeZoom); 140 | } 141 | 142 | void AnalysisWidget::initReploy() 143 | { 144 | ui->xyzrpw_plot->clearGraphs(); //清除数据 145 | ui->joint_plot->clearGraphs(); 146 | if(!isSpeedAna) 147 | { 148 | ui->joint_plot->yAxis2->setVisible(true); //第二个轴可见 149 | ui->xyzrpw_plot->yAxis2->setVisible(true); //第二个轴可见 150 | } 151 | else 152 | { 153 | ui->joint_plot->yAxis2->setVisible(false); //第二个轴可见 154 | ui->xyzrpw_plot->yAxis2->setVisible(false); //第二个轴可见 155 | } 156 | QStringList xyzrpwName,jointName; 157 | double limit; 158 | int num; 159 | switch(Parameter::robotType) 160 | { 161 | case LanxunCoordRobot: //p w a b 162 | xyzrpwName << "X" << "Y" << "Z" << "P" << "W"; 163 | jointName << "X轴" << "Y轴" << "Z轴" << "A轴" << "B轴"; 164 | num = 2; 165 | limit = 1400; 166 | if(!isSpeedAna) 167 | { 168 | for(int i = 0; i < 3; i++) 169 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis2); 170 | for(int i = 0; i < 2; i++) 171 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis); 172 | } 173 | break; 174 | case Lanxun5JointRobot: //p w j1 j2 j4 j5 175 | xyzrpwName << "X" << "Y" << "Z" << "P" << "W"; 176 | jointName << "大臂" << "小臂" << "升降" << "旋转" << "摆枪"; 177 | limit = 1400; 178 | num = 2; 179 | if(!isSpeedAna) 180 | { 181 | for(int i = 0; i < 2; i++) 182 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis); 183 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis2); 184 | for(int i = 0; i < 2; i++) 185 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis); 186 | } 187 | break; 188 | case Lanxun6JointRobot: //r p w j1 - j6 189 | xyzrpwName << "X" << "Y" << "Z" << "R" << "P" << "W"; 190 | jointName <<"J1" << "J2" << "J3" << "J4" << "J5" << "J6"; 191 | limit = 1400; 192 | num = 3; 193 | if(!isSpeedAna) 194 | { 195 | ui->joint_plot->yAxis2->setVisible(false); 196 | for(int i = 0; i < 6; i++) 197 | ui->joint_plot->addGraph(ui->joint_plot->xAxis,ui->joint_plot->yAxis); 198 | } 199 | } 200 | axisNum = 3 + num; 201 | if(!isSpeedAna) 202 | { 203 | for(int i = 0; i < 3; i++) 204 | ui->xyzrpw_plot->addGraph(ui->xyzrpw_plot->xAxis,ui->xyzrpw_plot->yAxis2); 205 | for(int i = 0; i < num;i++) 206 | ui->xyzrpw_plot->addGraph(ui->xyzrpw_plot->xAxis,ui->xyzrpw_plot->yAxis); 207 | } 208 | for(int i = 0; i < axisNum;i++) 209 | { 210 | if(isSpeedAna) 211 | { 212 | ui->joint_plot->addGraph(); 213 | ui->xyzrpw_plot->addGraph(); 214 | } 215 | ui->xyzrpw_plot->graph(i)->setName(xyzrpwName[i]); 216 | ui->xyzrpw_plot->graph(i)->setPen(QPen(color[i],LineWidth)); 217 | ui->xyzrpw_plot->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle,QPen(color[i], LineWidth),QBrush(color[i]), DotWidth)); 218 | ui->joint_plot->graph(i)->setName(jointName[i]); 219 | ui->joint_plot->graph(i)->setPen(QPen(color[i],LineWidth)); 220 | ui->joint_plot->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle,QPen(color[i], LineWidth),QBrush(color[i]), DotWidth)); 221 | } 222 | if(isSpeedAna) 223 | { 224 | ui->joint_plot->yAxis->setLabel("关节速度(单位:度(mm)/min)"); 225 | ui->joint_plot->yAxis->setRange(-10000,10000); 226 | //长度永远只是xyz 227 | ui->xyzrpw_plot->yAxis->setLabel("位姿速度(单位:度(mm)/min)"); 228 | // ui->xyzrpw_plot->yAxis->setAutoTicks(false); 229 | // ui->xyzrpw_plot->yAxis->setAutoTickLabels(false); 230 | ui->xyzrpw_plot->yAxis->setRange(-10000,10000); 231 | } 232 | else 233 | { 234 | ui->joint_plot->yAxis->setLabel("关节角度(单位:°)"); 235 | ui->joint_plot->yAxis->setRange(-180,180); 236 | ui->joint_plot->yAxis2->setLabel("移动距离(单位:mm)"); 237 | ui->joint_plot->yAxis2->setRange(-limit,limit); 238 | //长度永远只是xyz 239 | ui->xyzrpw_plot->yAxis->setLabel("姿态角度(单位:°)"); 240 | // ui->xyzrpw_plot->yAxis->setAutoTicks(false); 241 | // ui->xyzrpw_plot->yAxis->setAutoTickLabels(false); 242 | ui->xyzrpw_plot->yAxis->setRange(-180,180); 243 | ui->xyzrpw_plot->yAxis2->setLabel("坐标值(单位:mm)"); 244 | ui->xyzrpw_plot->yAxis2->setRange(-limit,limit); 245 | } 246 | } 247 | void AnalysisWidget::initPlot() 248 | { 249 | init(); 250 | initReploy(); 251 | } 252 | void AnalysisWidget::setData(double *joint,double *xyzrpw) 253 | { 254 | // int time = updatetime.elapsed(); 255 | // qDebug() << time; 256 | // updatetime.restart(); 257 | int time = 50; 258 | double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0; 259 | for(int i = 0; i < axisNum;i++) 260 | { 261 | if(axisNum == 5) 262 | { 263 | for(int i = 0; i < 3;i++) 264 | { 265 | if(isSpeedAna) 266 | { 267 | if(!isFirst) 268 | ui->xyzrpw_plot->graph(i)->addData(key,(xyzrpw[i] - lastXyzrpw[i]) / (time / 1000.0 / 60)); 269 | } 270 | else 271 | ui->xyzrpw_plot->graph(i)->addData(key,xyzrpw[i]); 272 | 273 | ui->xyzrpw_plot->graph(i)->removeDataBefore(key - Plot_Count - 1); 274 | } 275 | for(int i = 4; i < 6;i++) 276 | { 277 | if(isSpeedAna) 278 | { 279 | if(!isFirst) 280 | ui->xyzrpw_plot->graph(i-1)->addData(key,(xyzrpw[i] - lastXyzrpw[i]) / (time / 1000.0 / 60)); 281 | } 282 | else 283 | ui->xyzrpw_plot->graph(i-1)->addData(key,xyzrpw[i]); 284 | ui->xyzrpw_plot->graph(i-1)->removeDataBefore(key - Plot_Count - 1); 285 | } 286 | } 287 | else 288 | { 289 | for(int i = 0; i < 6;i++) 290 | { 291 | if(isSpeedAna) 292 | { 293 | if(!isFirst) 294 | ui->xyzrpw_plot->graph(i)->addData(key,(xyzrpw[i] - lastXyzrpw[i]) / (time / 1000.0 / 60)); 295 | } 296 | else 297 | ui->xyzrpw_plot->graph(i)->addData(key,xyzrpw[i]); 298 | ui->xyzrpw_plot->graph(i)->removeDataBefore(key - Plot_Count - 1); 299 | } 300 | } 301 | for(int i = 0; i < axisNum;i++) 302 | { 303 | if(isSpeedAna) 304 | { 305 | if(!isFirst) 306 | ui->joint_plot->graph(i)->addData(key,(joint[i] - lastJoint[i]) / (time / 1000.0 / 60)); 307 | } 308 | else 309 | ui->joint_plot->graph(i)->addData(key,joint[i]); 310 | ui->joint_plot->graph(i)->removeDataBefore(key - Plot_Count - 1); 311 | } 312 | } 313 | ui->joint_plot->xAxis->setRange(key, Plot_Count , Qt::AlignRight); 314 | ui->xyzrpw_plot->xAxis->setRange(key, Plot_Count , Qt::AlignRight); 315 | ui->joint_plot->replot(); 316 | ui->xyzrpw_plot->replot(); 317 | isFirst = false; 318 | for(int i = 0; i < 6;i++) 319 | { 320 | lastJoint[i] = joint[i]; 321 | lastXyzrpw[i] = xyzrpw[i]; 322 | } 323 | } 324 | 325 | void AnalysisWidget::replot() 326 | { 327 | initReploy(); 328 | ui->joint_plot->replot(); 329 | ui->xyzrpw_plot->replot(); 330 | } 331 | void AnalysisWidget::switchAna(bool isSpeedAna) 332 | { 333 | this->isSpeedAna = isSpeedAna; 334 | replot(); 335 | } 336 | -------------------------------------------------------------------------------- /src/MainWindow/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 1400 13 | 1000 14 | 15 | 16 | 17 | LXRobot 18 | 19 | 20 | 21 | :/icon.ico:/icon.ico 22 | 23 | 24 | 1.000000000000000 25 | 26 | 27 | -1 28 | 29 | 30 | background-color: rgb(113, 113, 113); 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 编辑 43 | 44 | 45 | 46 | 47 | 48 | 49 | color: rgb(255, 255, 255); 50 | 51 | 52 | 图库 53 | 54 | 55 | 56 | 57 | 58 | 59 | color: rgb(255, 255, 255); 60 | 61 | 62 | 63 | 示教 64 | 65 | 66 | 67 | 68 | 69 | 70 | border-color: rgb(0, 0, 255); 71 | 72 | 73 | 联调 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 编译 94 | 95 | 96 | 97 | 98 | 99 | 100 | 仿真 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | selection-color: rgb(0, 0, 0); 110 | 111 | 112 | 1 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 0 124 | 0 125 | 1400 126 | 25 127 | 128 | 129 | 130 | 131 | 9 132 | 75 133 | true 134 | 135 | 136 | 137 | background-color: rgb(216, 217, 208); 138 | selection-background-color: rgb(0, 146, 255); 139 | 140 | 141 | 142 | 143 | 144 | 145 | 9 146 | 50 147 | false 148 | 149 | 150 | 151 | background-color: rgb(255, 255, 255); 152 | 153 | 154 | 文本(T) 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 9 165 | 50 166 | false 167 | 168 | 169 | 170 | background-color: rgb(255, 255, 255); 171 | 172 | 173 | 文件(F) 174 | 175 | 176 | false 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | background-color: rgb(255, 255, 255); 189 | 190 | 191 | 仿真 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | background-color: rgb(255, 255, 255); 204 | 205 | 206 | 视图 207 | 208 | 209 | 210 | 隐藏 211 | 212 | 213 | 214 | 215 | 216 | 217 | 旋转 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 示教 233 | 234 | 235 | 236 | 示教器 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 联调 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 帮助 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | toolBar 268 | 269 | 270 | background-color: rgb(216, 217, 208); 271 | selection-background-color: rgb(0, 146, 255); 272 | 273 | 274 | TopToolBarArea 275 | 276 | 277 | false 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 文件名 310 | 311 | 312 | 313 | 314 | 315 | background-color: rgb(240, 240, 240); 316 | 317 | 318 | QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable 319 | 320 | 321 | Qt::RightDockWidgetArea 322 | 323 | 324 | 2 325 | 326 | 327 | 328 | 329 | 330 | 331 | :/images/new.png:/images/new.png 332 | 333 | 334 | 新建 335 | 336 | 337 | Ctrl+N 338 | 339 | 340 | QAction::NormalPriority 341 | 342 | 343 | 344 | 345 | 346 | :/images/open.png:/images/open.png 347 | 348 | 349 | 打开 350 | 351 | 352 | Ctrl+O 353 | 354 | 355 | 356 | 357 | 358 | :/images/save.png:/images/save.png 359 | 360 | 361 | 保存 362 | 363 | 364 | Ctrl+S 365 | 366 | 367 | 368 | 369 | 370 | :/images/saveAs.png:/images/saveAs.png 371 | 372 | 373 | 另存为 374 | 375 | 376 | 377 | 378 | 379 | :/images/print.png:/images/print.png 380 | 381 | 382 | 打印 383 | 384 | 385 | Ctrl+P 386 | 387 | 388 | 389 | 390 | 391 | :/images/exit.png:/images/exit.png 392 | 393 | 394 | 退出 395 | 396 | 397 | 398 | 399 | 400 | :/images/bold.png:/images/bold.png 401 | 402 | 403 | 粗体 404 | 405 | 406 | Ctrl+B 407 | 408 | 409 | 410 | 411 | 颜色 412 | 413 | 414 | Ctrl+C 415 | 416 | 417 | 418 | 419 | 字体 420 | 421 | 422 | Ctrl+F 423 | 424 | 425 | 426 | 427 | 428 | :/images/play.png:/images/play.png 429 | 430 | 431 | 播放 432 | 433 | 434 | 435 | 436 | 437 | :/images/pause.png:/images/pause.png 438 | 439 | 440 | 暂停 441 | 442 | 443 | 444 | 445 | 446 | :/images/back.png:/images/back.png 447 | 448 | 449 | 后退 450 | 451 | 452 | 453 | 454 | 455 | :/images/reset.png:/images/reset.png 456 | 457 | 458 | 重置 459 | 460 | 461 | 462 | 463 | 464 | :/images/reduction.png:/images/reduction.png 465 | 466 | 467 | 还原 468 | 469 | 470 | 471 | 472 | 473 | :/images/amplification.png:/images/amplification.png 474 | 475 | 476 | 放大 477 | 478 | 479 | 480 | 481 | 482 | :/images/NarrowDown.png:/images/NarrowDown.png 483 | 484 | 485 | 缩小 486 | 487 | 488 | 489 | 490 | 491 | :/images/hideRobot.png:/images/hideRobot.png 492 | 493 | 494 | 隐藏机器人 495 | 496 | 497 | 498 | 499 | 500 | :/images/modeSwitch.png:/images/modeSwitch.png 501 | 502 | 503 | 模式切换 504 | 505 | 506 | 507 | 508 | 509 | :/images/fileSwitch.png:/images/fileSwitch.png 510 | 511 | 512 | 切换代码 513 | 514 | 515 | 516 | 517 | 518 | :/images/add.png:/images/add.png 519 | 520 | 521 | 加速 522 | 523 | 524 | 525 | 526 | 527 | :/images/reduce.png:/images/reduce.png 528 | 529 | 530 | 减速 531 | 532 | 533 | 534 | 535 | 绕X+ 536 | 537 | 538 | 539 | 540 | 绕X- 541 | 542 | 543 | 544 | 545 | 绕Y+ 546 | 547 | 548 | 549 | 550 | 绕Y- 551 | 552 | 553 | 554 | 555 | 556 | :/images/parameter.png:/images/parameter.png 557 | 558 | 559 | 参数 560 | 561 | 562 | 563 | 564 | 565 | :/images/connect.png:/images/connect.png 566 | 567 | 568 | 连接 569 | 570 | 571 | 572 | 573 | 574 | :/images/clearTrials.png:/images/clearTrials.png 575 | 576 | 577 | 清除轨迹 578 | 579 | 580 | 581 | 582 | 583 | :/images/hideLine.png:/images/hideLine.png 584 | 585 | 586 | 隐藏空移线 587 | 588 | 589 | 590 | 591 | 连接机器人 592 | 593 | 594 | 595 | 596 | 导入工件 597 | 598 | 599 | 600 | 601 | 移除工件 602 | 603 | 604 | 605 | 606 | 断开连接 607 | 608 | 609 | 610 | 611 | 实体示教器 612 | 613 | 614 | 615 | 616 | 617 | :/images/speedAna.png:/images/speedAna.png 618 | 619 | 620 | 速度分析 621 | 622 | 623 | 624 | 625 | 626 | 627 | -------------------------------------------------------------------------------- /src/Teach/TeachDlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TeachDlg 4 | 5 | 6 | 7 | 0 8 | 0 9 | 420 10 | 630 11 | 12 | 13 | 14 | 15 | 420 16 | 16777215 17 | 18 | 19 | 20 | 虚拟示教器 21 | 22 | 23 | 24 | :/images/teachShow.png:/images/teachShow.png 25 | 26 | 27 | 28 | 0 29 | 30 | 31 | 0 32 | 33 | 34 | 0 35 | 36 | 37 | 0 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 文件名: 51 | 52 | 53 | 54 | 55 | 56 | 57 | TextLabel 58 | 59 | 60 | 61 | 62 | 63 | 64 | Qt::Horizontal 65 | 66 | 67 | 68 | 40 69 | 20 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 38 83 | 16777215 84 | 85 | 86 | 87 | background:rgba(240,240,240,255);color:#000000;border:0px solid gray;padding:0px; 88 | item{width:94px;height:38px;border:0px solid gray;padding-left:24px;} 89 | item:selected:active{background:#FFFFFF;color:#19649F;border-width:-1;} 90 | item:selected{background:#FFFFFF;color:#19649F;} 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 空移 100 | 101 | 102 | 103 | 104 | 插补 105 | 106 | 107 | 108 | 109 | 圆弧 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 开火 120 | 121 | 122 | 123 | 124 | 关火 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 1 133 | 134 | 135 | 136 | Tab 1 137 | 138 | 139 | 140 | 141 | Tab 2 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 1- 158 | 159 | 160 | 161 | 162 | 163 | 164 | 1+ 165 | 166 | 167 | 168 | 169 | 170 | 171 | Qt::Horizontal 172 | 173 | 174 | 175 | 28 176 | 20 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | X- 185 | 186 | 187 | 188 | 189 | 190 | 191 | X+ 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 2- 203 | 204 | 205 | 206 | 207 | 208 | 209 | 2+ 210 | 211 | 212 | 213 | 214 | 215 | 216 | Qt::Horizontal 217 | 218 | 219 | 220 | 28 221 | 20 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | Y- 230 | 231 | 232 | 233 | 234 | 235 | 236 | Y+ 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 3- 248 | 249 | 250 | 251 | 252 | 253 | 254 | 3+ 255 | 256 | 257 | 258 | 259 | 260 | 261 | Qt::Horizontal 262 | 263 | 264 | 265 | 40 266 | 20 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | Z- 275 | 276 | 277 | 278 | 279 | 280 | 281 | Z+ 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 4- 293 | 294 | 295 | 296 | 297 | 298 | 299 | 4+ 300 | 301 | 302 | 303 | 304 | 305 | 306 | Qt::Horizontal 307 | 308 | 309 | 310 | 28 311 | 20 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | R- 320 | 321 | 322 | 323 | 324 | 325 | 326 | R+ 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 5- 338 | 339 | 340 | 341 | 342 | 343 | 344 | 5+ 345 | 346 | 347 | 348 | 349 | 350 | 351 | Qt::Horizontal 352 | 353 | 354 | 355 | 28 356 | 20 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | P- 365 | 366 | 367 | 368 | 369 | 370 | 371 | P+ 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 6- 383 | 384 | 385 | 386 | 387 | 388 | 389 | 6+ 390 | 391 | 392 | 393 | 394 | 395 | 396 | Qt::Horizontal 397 | 398 | 399 | 400 | 28 401 | 20 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | W- 410 | 411 | 412 | 413 | 414 | 415 | 416 | W+ 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | Qt::Horizontal 428 | 429 | 430 | 431 | 40 432 | 20 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | Qt::Vertical 443 | 444 | 445 | 446 | 20 447 | 40 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | Qt::Vertical 462 | 463 | 464 | 465 | 20 466 | 40 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 点动 475 | 476 | 477 | true 478 | 479 | 480 | true 481 | 482 | 483 | 484 | 485 | 486 | 487 | 定长 488 | 489 | 490 | true 491 | 492 | 493 | false 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | Qt::Horizontal 503 | 504 | 505 | 506 | 40 507 | 20 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | Qt::Vertical 518 | 519 | 520 | 521 | 20 522 | 40 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 停止 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 速度: 546 | 547 | 548 | 549 | 550 | 551 | 552 | 3000 553 | 554 | 555 | 556 | 557 | 558 | 559 | 度(mm)/min 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 距离: 571 | 572 | 573 | 574 | 575 | 576 | 577 | 0 578 | 579 | 580 | 581 | 582 | 583 | 584 | 度(mm) 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | --------------------------------------------------------------------------------