CN117754587A - Method for converting DXF file into mechanical arm movement track - Google Patents
Method for converting DXF file into mechanical arm movement track Download PDFInfo
- Publication number
- CN117754587A CN117754587A CN202311852806.9A CN202311852806A CN117754587A CN 117754587 A CN117754587 A CN 117754587A CN 202311852806 A CN202311852806 A CN 202311852806A CN 117754587 A CN117754587 A CN 117754587A
- Authority
- CN
- China
- Prior art keywords
- interpolation
- arc
- file
- coordinates
- starting point
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000004458 analytical method Methods 0.000 claims abstract description 20
- 230000003321 amplification Effects 0.000 claims description 4
- 238000003199 nucleic acid amplification method Methods 0.000 claims description 4
- 238000012827 research and development Methods 0.000 abstract description 10
- 238000004891 communication Methods 0.000 abstract description 4
- 238000012423 maintenance Methods 0.000 abstract description 4
- 238000012545 processing Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 239000003292 glue Substances 0.000 description 4
- 238000003491 array Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000009826 distribution Methods 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 238000003860 storage Methods 0.000 description 2
- 238000004026 adhesive bonding Methods 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
- 238000003892 spreading Methods 0.000 description 1
- 230000007480 spreading Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Landscapes
- Numerical Control (AREA)
Abstract
The invention provides a method for converting a DXF file into a mechanical arm motion track, which comprises the following steps: analyzing the DXF file; classifying and interpolating different graphic data according to the analyzed DXF file to obtain a starting point coordinate and an end point coordinate of an interpolated graphic; converting the analyzed DXF file, the starting point coordinates and the ending point coordinates of all the interpolation graphs into G code files; and analyzing the G code file, and obtaining the motion trail of the mechanical arm based on the analysis result. Therefore, DXF files can be converted into mechanical arm movement tracks without plug-in units, time cost caused by communication with plug-in unit developers and plug-in unit price and maintenance cost can be avoided, and accordingly research and development time and research and development cost can be reduced.
Description
Technical Field
The invention relates to the technical field of mechanical arm movement tracks, in particular to a method for converting a DXF file into a mechanical arm movement track.
Background
DXF files are CAD data file formats for CAD data exchange between AutoCAD and other software. At present, the method for converting the DXF file into the motion trail of the mechanical arm comprises the following steps: CAD software manufacturers and third party manufacturers provide plug-in extensions that can import DXF files into the robotic arm control software.
However, the way in which expansion is performed by plug-ins has the following drawbacks:
(1) When the motion trail generated by the plug-in is used for carrying out related test of the mechanical arm, problems are difficult to debug, communication with a plug-in developer is needed, and the research and development period is prolonged;
(2) The price of the plug-in itself and the later maintenance costs are too high, increasing the cost of development.
Disclosure of Invention
The invention provides the following technical scheme for solving the problems of long research and development period and high cost in the related technology.
An embodiment of a first aspect of the present invention provides a method for converting a DXF file into a motion trail of a robotic arm, including: obtaining a DXF file and analyzing the DXF file, wherein the DXF file comprises different graphic data; classifying and interpolating different graphic data according to the analyzed DXF file respectively to obtain a starting point coordinate and an end point coordinate of each section of interpolation graphic in the multi-section interpolation graphic corresponding to each graphic data; converting the analyzed DXF file, the starting point coordinates and the ending point coordinates of all the interpolation graphs into G code files; and analyzing the G code file, and obtaining the motion trail of the mechanical arm based on the analysis result.
In addition, the method for converting the DXF file into the motion trail of the mechanical arm according to the above embodiment of the present invention may further have the following additional technical features.
According to one embodiment of the present invention, the different graphic data includes a straight line and an arc, and the different graphic data is respectively classified and interpolated according to the parsed DXF file to obtain a start point coordinate and an end point coordinate of each of the multiple segments of interpolation graphics corresponding to each of the graphic data, including: and respectively performing linear interpolation and circular interpolation according to the analyzed DXF file to obtain the starting point coordinates and the end point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line and the starting point coordinates and the end point coordinates of each interpolation circular arc in the multi-section interpolation circular arc corresponding to the circular arc.
According to one embodiment of the present invention, linear interpolation and circular arc interpolation are performed according to the parsed DXF file, so as to obtain start point coordinates and end point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line, and start point coordinates and end point coordinates of each interpolation circular arc in the multi-section interpolation circular arc corresponding to the circular arc, including: performing linear interpolation based on the starting point coordinates and the ending point coordinates of the straight line to obtain the starting point coordinates and the ending point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line; and performing arc interpolation based on the circle center angle, the radius, the starting point coordinates and the end point coordinates of the arc to obtain the starting point coordinates and the end point coordinates of each section of interpolation arc in the plurality of sections of interpolation arcs corresponding to the arc.
According to one embodiment of the present invention, performing the arc interpolation based on the center angle, the radius, the start point coordinate and the end point coordinate of the arc to obtain the start point coordinate and the end point coordinate of each of the multiple sections of interpolation arcs corresponding to the arc, includes: calculating the total arc length of the arc according to the circle center angle and the radius of the arc; calculating the number of segments of the interpolation arc of the arc based on the total arc length of the arc; calculating the offset angle of each interpolation arc according to the circle center angle of the arc and the number of segments; and calculating the starting point coordinates and the end point coordinates of each section of interpolation arc according to the radius, the starting point coordinates and the end point coordinates of the arc and the offset angle of each section of interpolation arc.
According to one embodiment of the present invention, the G code file includes start point coordinates and end point coordinates of all interpolation lines corresponding to the line, start point coordinates and end point coordinates of all interpolation arcs corresponding to the arc, and center coordinates of the arc.
Parsing the G code file includes: analyzing the coordinates of the starting points and the ending points of all the interpolation straight lines, the coordinates of the starting points and the ending points of all the interpolation circular arcs and the circle center coordinates of the circular arcs in the G code file; and calculating the coordinates of any point between the starting point and the end point of each interpolation arc according to the G code file.
According to one embodiment of the present invention, calculating coordinates of any point between a start point and an end point of each of the interpolation arcs according to the G-code file includes: calculating the abscissa of any point between the starting point and the end point of the interpolation arc according to the abscissa of the starting point and the abscissa of the end point of each section of the interpolation arc; and calculating the ordinate of any point between the starting point and the end point of the interpolation arc according to the circle center coordinates of the arc, the coordinates of the starting point of each section of the interpolation arc and the abscissa of any point between the starting point and the end point of the interpolation arc.
According to one embodiment of the present invention, any point between the starting point and the ending point of the interpolation arc is a midpoint between the starting point and the ending point of the interpolation arc, and an abscissa of the midpoint between the starting point and the ending point of the interpolation arc is calculated by the following formula:
x3=(x1+x2)/2
wherein x3 represents the abscissa of the midpoint between the starting point and the ending point of the interpolation arc, x1 represents the abscissa of the starting point of the interpolation arc, and x2 represents the abscissa of the ending point of the interpolation arc.
According to one embodiment of the invention, the ordinate of the midpoint between the starting and ending points of the interpolation arc is calculated by the following formula:
(y3-b) 2 =r 2 +(x3-a) 2
wherein r represents the radius of the circular arc, x1 and y1 represent the abscissa and the ordinate of the starting point of the interpolation circular arc respectively, a and b represent the abscissa and the ordinate of the center of the circular arc respectively, and x3 and y3 represent the abscissa and the ordinate of the midpoint between the starting point and the end point of the interpolation circular arc respectively.
According to one embodiment of the present invention, obtaining a motion trajectory of a robot arm based on an analysis result includes: acquiring preset parameters and a mechanical arm track generation algorithm, wherein the preset parameters comprise a user coordinate system, mechanical arm tail end tool parameters and an amplification factor; and converting the analysis result into a motion track of the mechanical arm according to the preset parameters and the mechanical arm track generation algorithm.
According to one embodiment of the invention, before the DXF file is obtained, further comprising: acquiring an original track file of a mechanical arm, and judging whether the original track file is a G code file or not; if the original track file is a G code file, analyzing the G code file, and obtaining the motion track of the mechanical arm based on an analysis result; and if the original track file is not a G code file, saving the original track file, wherein the original track file comprises a DXF file.
According to the technical scheme, the DXF file is analyzed, different graphic data are classified and interpolated according to the analyzed DXF file, so that starting point coordinates and end point coordinates of each section of interpolation graphics in the multi-section interpolation graphics corresponding to each graphic data are obtained, the analyzed DXF file, starting point coordinates and end point coordinates of all the interpolation graphics are converted into G code files, the G code files are analyzed, and the movement track of the mechanical arm is obtained based on analysis results. Therefore, DXF files can be converted into mechanical arm movement tracks without plug-in units, time cost caused by communication with plug-in unit developers and plug-in unit price and maintenance cost can be avoided, and accordingly research and development time and research and development cost can be reduced.
Drawings
Fig. 1 is a flowchart of a method for converting DXF files into motion trajectories of a robotic arm according to an embodiment of the invention.
Fig. 2 is a schematic diagram of linear interpolation according to an example of the present invention.
Fig. 3 is a schematic diagram of arc interpolation according to an example of the present invention.
Fig. 4 is a schematic view of a clockwise arc of an example of the invention.
Fig. 5 is a schematic view of a clockwise arc of another example of the invention.
Fig. 6 is a schematic diagram of resolving a circular arc G code according to an example of the present invention.
Fig. 7 is a schematic diagram of a circular arc G code according to one embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of a method for converting DXF files into motion trajectories of a robotic arm according to an embodiment of the invention.
As shown in fig. 1, the method for converting the DXF file into the motion trail of the mechanical arm includes the following steps S1 to S4.
S1, acquiring a DXF file and analyzing the DXF file, wherein the DXF file comprises different graphic data.
It is understood that DXF files (also referred to as DXF sketches) include a wide variety of graphics and their data, including, for example, graphics such as straight lines and arcs, as well as other information such as descriptive fields.
The parsed DXF file includes data, such as size, position, etc., of each graphic data, such as start coordinates and end coordinates.
Specifically, firstly, a DXF file including different graphic data such as a straight line and an arc is obtained, the content of the file is a geometric figure and parameters thereof, and the file can be analyzed in any feasible manner to obtain the starting point coordinate and the end point coordinate of the straight line, and the starting point coordinate, the end point coordinate, the center angle and the radius of the arc. The parsing mode may be open source C++ parsing library dxflib, CAM software (such as MASTER-CAM), etc.
In order to facilitate the analysis of DXF files, an open source c++ analysis library dxflib may be used, and by using functions and classes provided by the dxflib library, the content of DXF files is read, and the structure thereof is analyzed, so as to extract the required graphic data, such as points, lines, circles, polygons, and the like. The library defines primitive data, such as straight line primitive data defined as DLLineData structure, stores the start and end coordinates of straight lines, and circle primitive data defined as DLCircleData structure, stores the center coordinates and radius.
In the code implementation, the DXF file is analyzed by using the library related function, a file reading and writing module is constructed, and classification processing is carried out according to different primitive data. Taking a multi-segment line (multi) primitive as an example, add multi-segment lines to two methods addPolyline and addsertex, where addPolyline is used to hold multi-segment lines and addVertex is used to hold vertices of multi-segment lines. And the primitives in the file stream are all saved through the corresponding primitive objects. When all the graphic elements in the file stream are read, all the graphic elements, such as POLYLINE, CIRCLE (circular arcs and the like) contained in the graphic elements, are stored in the BLOCKs, and finally the custom class is used for storing corresponding graphic data and drawing the graphic data on a user interface.
S2, classifying and interpolating different graphic data according to the analyzed DXF file respectively to obtain a starting point coordinate and an end point coordinate of each section of interpolation graphic in the multi-section interpolation graphic corresponding to each graphic data.
It should be noted that, for the graph in the file, since the parsed DXF file does not directly provide all points, but provides a starting point and an ending point, in order to complete the track of the mechanical arm, the rest points in the graph need to be calculated by an interpolation algorithm. Here, the analysis precision parameter set in advance is needed to be manually set, and the parameter affects the dot density and the smoothness of the converted graph, so that the endpoint distribution is uniform.
Specifically, classifying and interpolating according to the graph related parameters in the analyzed DXF file to obtain the starting point coordinates and the end point coordinates of each segment of interpolation graph in the multi-segment interpolation graph corresponding to each graph.
S3, converting the analyzed DXF file, the starting point coordinates and the ending point coordinates of all the interpolation graphs into a G code file.
Specifically, the data of each size, position and the like of all the graphics, the starting point coordinates and the end point coordinates of the interpolation graphics are converted into corresponding G code files according to G code rules, and the G code files are output.
S4, analyzing the G code file, and obtaining the motion trail of the mechanical arm based on the analysis result.
The analysis result may be a point location obtained by analyzing the content of the G code file, and may be put into a point location generator.
The G code, also called RS-274 or G instruction, belongs to a numerical control programming language, is used for computer-aided manufacturing, and is a numerical control program, and operation instructions such as linear motion, arc motion, moving speed and the like are defined inside the numerical control program. The instruction set of the G code is open, transparent, e.g. G90 represents the use of absolute coordinate mode, G21 represents the use of metric millimeters as a unit, G1 represents linear motion, etc. The G code file can be analyzed according to the specific instructions, the obtained coordinate set and the motion mode are input to the controller in a mode specified by the motion algorithm in the mechanical arm, and then the track of the mechanical arm is intelligently planned. For example, the terminal glue gun tool attached to the mechanical arm is controlled to be on-off according to the change of the Z-axis direction coordinate of the mechanical arm.
Specifically, the interpolation straight line and the interpolation circular arc related coordinates in the G code file are all resolved into point positions and placed in a point position container, and the points in the point position container are converted into mechanical arm movement tracks according to specific actual requirements.
Therefore, the method for converting the DXF file into the mechanical arm movement track can convert the DXF file into the mechanical arm movement track without a plug-in unit, so that the time cost, the plug-in unit price and the maintenance cost caused by communication with a plug-in unit developer can be avoided, the research and development time can be reduced, and the research and development cost can be reduced.
In one embodiment of the invention, the different graphical data includes straight lines and circular arcs. The analyzed DXF file comprises a start point coordinate and an end point coordinate of a straight line, a start point coordinate, an end point coordinate, a circle center angle and a radius of an arc.
In this embodiment, step S2 may include the steps of:
and S21, respectively performing linear interpolation and circular arc interpolation according to the analyzed DXF file to obtain starting point coordinates and end point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line and starting point coordinates and end point coordinates of each interpolation circular arc in the multi-section interpolation circular arc corresponding to the circular arc.
It should be noted that, for the straight line and the circular arc in the file, since the parsed DXF file does not directly provide all points, but provides a starting point and an end point, in order to complete the track of the mechanical arm, the rest points in the straight line or the circular arc need to be calculated through an interpolation algorithm. Here, the analysis precision parameter set in advance is needed to be manually set, and the parameter influences the point density and the smoothness of the converted straight line and circular arc, so that the endpoint distribution is uniform.
Specifically, performing linear interpolation according to relevant parameters of the straight line in the analyzed DXF file to obtain the starting point coordinate and the end point coordinate of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line. Performing arc interpolation according to the related parameters of the arc in the analyzed DXF file to obtain the starting point coordinates and the end point coordinates of each interpolation arc in the multiple sections of interpolation arcs corresponding to the arc.
And then executing step S3, namely converting the starting point coordinates and the end point coordinates of the straight line and the circular arc, the starting point coordinates and the end point coordinates of all the interpolation straight lines corresponding to the straight line, the starting point coordinates and the end point coordinates of all the interpolation circular arcs corresponding to the circular arc and the circle center coordinates of the circular arc into corresponding G code files according to G code rules, and outputting the G code files.
The G code file comprises starting point coordinates and end point coordinates of all interpolation straight lines corresponding to the straight lines, starting point coordinates and end point coordinates of all interpolation circular arcs corresponding to the circular arcs and circle center coordinates of the circular arcs.
In one embodiment of the present invention, step S22 may include: performing linear interpolation based on the starting point coordinates and the ending point coordinates of the straight line to obtain starting point coordinates and ending point coordinates of each interpolation straight line in the multi-section interpolation straight lines corresponding to the straight line; and performing arc interpolation based on the circle center angle, the radius, the starting point coordinates and the end point coordinates of the arc to obtain the starting point coordinates and the end point coordinates of each interpolation arc in the plurality of sections of interpolation arcs corresponding to the arc.
Further, performing the arc interpolation based on the circle center angle, the radius, the starting point coordinate and the end point coordinate of the arc to obtain the starting point coordinate and the end point coordinate of each section of interpolation arc in the multiple sections of interpolation arcs corresponding to the arc, which may include: calculating the total arc length of the arc according to the circle center angle and the radius of the arc; calculating the number of segments of the interpolation arc of the arc based on the total arc length of the arc; calculating the offset angle of each section of interpolation arc according to the circle center angle and the number of sections of the arc; and calculating the starting point coordinates and the end point coordinates of each section of interpolation arc according to the radius, the starting point coordinates and the end point coordinates of the arc and the offset angle of each section of interpolation arc.
Specifically, for the straight line interpolation, first, the total length of the straight line is calculated according to the start point coordinate and the end point coordinate, the resolution value is obtained, the total length of the straight line is divided by the resolution value to obtain interpolation step length (number of segments), the end points (start point and end point) are added so that the straight line is divided into a plurality of sections of interpolation straight lines, each section of interpolation straight line has the start point coordinate and the end point coordinate, and finally the straight line is processed. In the linear interpolation method, interpolation between two points of a linear start point and an end point is approximated along a point group of the linear. First, on the XY plane, assuming that a small segment is moved in the X-axis direction at the start point of the actual contour, the end point is found to be below the actual contour, the next segment is moved a small segment in the Y-axis direction, at this time, if the end point of the segment is still below the actual contour, the small segment is continued to be moved in the Y-axis direction until a small segment is moved in the X-axis direction after the end point of the contour is above the actual contour, and so on until the end point of the contour is reached. The actual contour is formed by splicing a section of broken lines, and although the actual contour is formed by splicing the broken lines, each section of interpolation straight line is within the accuracy allowable range and is very small, the generated track is still smooth, and the section of broken line can be regarded as a straight line section approximately, namely the straight line interpolation. Assuming that the axis needs to move on the XY plane from the start point (X0, Y0) to the end point (X1, Y1), the process of the straight line interpolation thereof is as shown in fig. 2.
For the circular interpolation, similar to the linear interpolation, interpolation digital information between two end points of the circular arc is calculated, an offset angle (an angle offset from the center of a circle) increased by each offset is calculated according to a resolution value, the circular arc is moved by one offset angle each time from a connecting line of the center of the circular arc and a starting point, point coordinates of a current end shaft on the circular arc are calculated until the end point is reached, and a circular arc curve is finally processed. Firstly, calculating the total arc length of the arc according to the circle center angle and the radius of the arc, obtaining a resolution value, dividing the total arc length by the resolution value to obtain interpolation step length (number of segments), dividing the circle center angle by the number of segments to obtain the offset angle of each segment of interpolation arc, at the moment, calculating the starting point coordinate and the end point coordinate of each segment of interpolation arc according to the radius, the starting point coordinate and the end point coordinate of the arc and the offset angle of each segment of interpolation arc by adopting a triangle theorem, and adding the end points (starting point and end point) to divide the arc into a plurality of segments of interpolation arcs, wherein each segment of interpolation arc has the starting point coordinate and the end point coordinate. As shown in fig. 3, the point C0 is a circular arc starting point, the point Cn is a circular arc ending point, the points C1, C2, C3, C4, C5, … … and Cn-1 (n is greater than 1) are obtained through circular arc interpolation, the circular arc is divided into a plurality of interpolation circular arcs through the starting points and the ending points, and the coordinates of each point can be calculated according to a circular equation and an included angle.
After the DXF file is parsed, the straight line interpolation and the arc interpolation are performed, steps S3 and S4 are performed, that is, the parsed DXF file (the start point coordinate and the end point coordinate of the straight line, the start point coordinate, the end point coordinate, the center angle and the radius of the arc), the start point coordinate and the end point coordinate of all the interpolation straight lines, and the start point coordinate and the end point coordinate of all the interpolation arcs are converted into the G code file. The G code file comprises starting point coordinates and end point coordinates of all interpolation straight lines corresponding to the straight lines, starting point coordinates and end point coordinates of all interpolation circular arcs corresponding to the circular arcs and circle center coordinates of the circular arcs.
In one embodiment of the present invention, the parsing the G code file in step S4 may include: analyzing the coordinates of the starting points and the ending points of all the interpolation straight lines, the coordinates of the starting points and the ending points of all the interpolation circular arcs and the circle center coordinates of the circular arcs in the G code file; and calculating the coordinates of any point between the starting point and the end point of each interpolation arc according to the G code file.
Any point may be a point where the arc is 1/2, 1/3, 1/4 arc length, etc. from its start point.
Specifically, when analyzing the coordinates of the start point and the end point of all the interpolation straight lines, the coordinates of the start point and the end point of all the interpolation arcs, and the coordinates of the center of the circle of the arc in the G code, the trajectory algorithm supported by the mechanical arm itself requires three points (including the start point and the end point) on each interpolation arc, so that the third point (the point other than the start point and the end point on the arc) on the interpolation arc needs to be calculated according to the known conditions. The coordinates of any point (such as a midpoint) between the start point and the end point of each interpolation arc can be calculated according to the related parameters of the arc in the G code file and then used for the subsequent program to mobilize, so that the obtained analysis results are the start point coordinates and the end point coordinates of all interpolation straight lines, the start point coordinates, the end point coordinates and the coordinates of any point of all interpolation arcs, and the center coordinates of the arc.
Further, calculating coordinates of any point between the start point and the end point of each interpolation arc according to the G code file may include: calculating the abscissa of any point between the starting point and the end point of each interpolation arc according to the abscissa of the starting point and the abscissa of the end point of each interpolation arc; and calculating the ordinate of any point between the starting point and the end point of the interpolation arc according to the center coordinates of the arc, the coordinates of the starting point of each section of interpolation arc and the abscissa of any point between the starting point and the end point of the interpolation arc.
Specifically, assuming that any point is a midpoint between the start point and the end point of the interpolation arc, and the coordinates thereof are (x 3, y 3), since it is known that the point (x 3, y 3) is necessarily between the start point and the end point of the interpolation arc in the same arc (assuming that the arc is a clockwise arc), the abscissa of the midpoint between the start point and the end point of the interpolation arc can be calculated by the following formula:
x3=(x1+x2)/2
where x3 represents the abscissa of the midpoint between the starting point and the ending point of the interpolation arc, x1 represents the abscissa of the starting point of the interpolation arc, and x2 represents the abscissa of the ending point of the interpolation arc.
For y3, the radius of the arc is calculated first, and then y3 is calculated according to the radius, the center coordinates and the abscissa of the midpoint. The ordinate of the midpoint between the starting point and the ending point of the interpolation arc is calculated by the following formula:
(x3-b) 2 =r 2 +(x3-a) 2
wherein r represents the radius of the circular arc, x1 and y1 represent the abscissa and ordinate of the starting point of the interpolation circular arc respectively, a and b represent the abscissa and ordinate of the circle center of the circular arc respectively, and x3 and y3 represent the abscissa and ordinate of the midpoint between the starting point and the end point of the interpolation circular arc respectively.
Two y3 values can be calculated by the above formula, and are respectively adapted to the circular arcs shown in fig. 4 and 5 (the circular arcs in fig. 4 and 5 are clockwise), and can be specifically selected according to the situation.
After the coordinates of each point of the G code file are obtained, the G code file is parsed, and the following is an example of a parsing process for the circular arc G code in a specific G code file:
first, an arc instruction, a G2 (clockwise arc) instruction or a G3 (counterclockwise arc) instruction is explained, which are distinguished in that one direction is left to right and the other is right to left as viewed from the front of the occurrence rotation axis. The meaning of the arc instruction is to draw an arc. The displacement commands X, Y, Z for each axis are followed, while the three commands i, j, k are used to specify the offset relative to the starting point (no Z nor k in a two-dimensional planar scene). The value of the specified feed command f may be specified or may be derived from the f value of the previous instruction. Since G2 and G3 will be used together with G1, the f-number is not written as the f-number of the last code, and the f-number can be customized. And the degree of curvature of the arc is set by the center-formatted arc.
Assume that the existing G code file has the following three rows of circular arc G codes:
g0 X0Y 0 (indicating positioning to origin);
g1 X50Y 40 f100 (indicating a point from the origin at which the linear motion is performed to the coordinates (50, 40) at the feed speed 100);
g2 X20Y 10 i-30j0 f200 (shown as starting point (50, 40), ending point (20, 10), starting point (50, 40) as offset starting point, offset 30 on the negative half axis of X axis, not offset on Y axis, and draw arc with this point as center of circle.
The above code gives three known conditions for drawing an arc, the start point, the end point and the center of the circle, thereby drawing an interpolated arc, as shown in fig. 6.
After the coordinates of the middle point of the interpolation arc are obtained, the coordinates are put into a G code file, and then the G code file is analyzed to obtain the point position. So far, three arc points required by the mechanical arm algorithm are solved, and the mechanical arm track generator can be plugged with the points to generate the mechanical arm movement track.
In one embodiment of the present invention, the obtaining the motion trail of the mechanical arm based on the analysis result in step S4 may include: acquiring preset parameters and a mechanical arm track generation algorithm, wherein the preset parameters comprise a user coordinate system, mechanical arm tail end tool parameters and an amplification factor; and converting the analysis result into a motion track of the mechanical arm according to preset parameters and a mechanical arm track generation algorithm.
The preset parameters are parameters input by a user according to actual processing and operation requirements. The mechanical arm track generation algorithm refers to any algorithm capable of generating a mechanical arm motion track, and the algorithm can be built-in, internal or self algorithm of the mechanical arm.
Specifically, all the straight lines and circular arc related coordinates in the G code file are analyzed into points and put into a point container, the points in the point container are converted into the motion track of the mechanical arm according to a mechanical arm track generating algorithm according to preset parameters, such as a user coordinate system, mechanical arm end tool parameters and an amplification factor, which are preset on an interface by a user, and mechanical specific motion is controlled based on the motion track, for example, the level of a glue gun clamped by the mechanical arm end tool can be controlled at the point position of each Z-axis coordinate change (representing the position of the mechanical arm which is vertically or directly upwards relative to the user coordinate system), so that the switch of the glue gun is controlled, and glue spreading is completed.
In the related art, the plug-in itself program and the running logic are opaque, and the mechanical arm is difficult to process improvement on the original track file according to the actual processing requirement.
In the embodiment of the invention, the preset parameters can be input according to the actual processing requirements, the original track is improved and optimized by combining the preset parameters to obtain the final running track, and the track and the preset parameters can be optimized in real time according to the actual requirements, so that the running track is improved.
In one embodiment of the present invention, before step S1, the method may further include: acquiring an original track file of the mechanical arm, and judging whether the original track file is a G code file or not; if the original track file is a G code file, analyzing the G code file, and obtaining the motion track of the mechanical arm based on an analysis result; if the original track file is not a G code file, the original track file is saved, wherein the original track file comprises a DXF file.
Specifically, the original track file may be a custom file input by a user, firstly, whether the file is a G code file is judged, if yes, step S4 is executed, and then the motion track of the mechanical arm is directly read and analyzed; if not, storing the DXF file, executing the steps S1 to S4 to convert the DXF file into a G code file, and analyzing the G code file to obtain the running track of the mechanical arm.
The following demonstrates the operational flow with one specific programming example:
(1) The original track file is input and the DXF file is saved.
Opening a DXF (DXF) part to G code interface, clicking a related button after setting parameters to select a DXF file to be parsed, and displaying a parsed graph and highlighting an endpoint on the interface after confirmation;
(2) And converting into a G code file.
Clicking the relevant button, calling the internal algorithm to read the analyzed DXF file, and automatically generating the G code file according to the program logic, as shown in FIG. 7.
(3) The G code file is read.
Creating a motion instruction (such as a gluing instruction) on a programming interface to display a motion instruction configuration option, clicking a G code file generated by the related button selection (2), setting attributes such as a coordinate system according to actual scene production requirements, and finally saving a configuration result.
(4) And controlling the mechanical arm to move.
And saving the project and running the project, wherein the background can firstly call the G code file to convert the logic of the motion trail of the mechanical arm, then the generated mechanical arm trail is sent to the mechanical arm motion interface, and then the mechanical arm starts to move according to the input trail, so that the result can be seen.
In summary, the embodiment of the invention extracts the geometric information in the DXF file, analyzes and converts the geometric information to obtain the point location set, and performs trajectory planning and motion control according to the motion algorithm of the mechanical arm. The motion trail of the mechanical arm can be directly converted into the motion trail of the mechanical arm through internal analysis of the program without plug-in, so that the research and development time is shortened, and the research and development cost is reduced; the optimization of the processing requirements and the track planning algorithm can be loaded into the DXF sketch file processing result in real time, so that the motion track of the mechanical arm is improved; the dependence on plug-ins is reduced in the system, so that the system is more stable and efficient.
The invention also provides a device for converting the DXF file into the motion trail of the mechanical arm.
In the description of the present invention, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. The meaning of "a plurality of" is two or more, unless specifically defined otherwise.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms are not necessarily for the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and further implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
It is to be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable Gate Arrays (PGAs), field Programmable Gate Arrays (FPGAs), and the like.
Those of ordinary skill in the art will appreciate that all or a portion of the steps carried out in the method of the above-described embodiments may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and where the program, when executed, includes one or a combination of the steps of the method embodiments. In addition, each functional unit in the embodiments of the present invention may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.
Claims (10)
1. The method for converting the DXF file into the movement track of the mechanical arm is characterized by comprising the following steps of:
obtaining a DXF file and analyzing the DXF file, wherein the DXF file comprises different graphic data;
classifying and interpolating different graphic data according to the analyzed DXF file respectively to obtain a starting point coordinate and an end point coordinate of each section of interpolation graphic in the multi-section interpolation graphic corresponding to each graphic data;
converting the analyzed DXF file, the starting point coordinates and the ending point coordinates of all the interpolation graphs into G code files;
and analyzing the G code file, and obtaining the motion trail of the mechanical arm based on the analysis result.
2. The method of converting DXF file into a motion profile for a robotic arm of claim 1, wherein the different graphical data comprises a line and a circular arc,
classifying and interpolating different graphic data according to the analyzed DXF file to obtain a starting point coordinate and an end point coordinate of each section of interpolation graphic in the multi-section interpolation graphic corresponding to each graphic data, wherein the method comprises the following steps:
and respectively performing linear interpolation and circular interpolation according to the analyzed DXF file to obtain the starting point coordinates and the end point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line and the starting point coordinates and the end point coordinates of each interpolation circular arc in the multi-section interpolation circular arc corresponding to the circular arc.
3. The method for converting DXF file into motion trail of mechanical arm according to claim 2, wherein performing linear interpolation and arc interpolation according to the parsed DXF file respectively to obtain start point coordinates and end point coordinates of each interpolation line in the multi-segment interpolation lines corresponding to the straight line, and start point coordinates and end point coordinates of each interpolation arc in the multi-segment interpolation arcs corresponding to the arc, comprises:
performing linear interpolation based on the starting point coordinates and the ending point coordinates of the straight line to obtain the starting point coordinates and the ending point coordinates of each interpolation straight line in the multi-section interpolation straight line corresponding to the straight line;
and performing arc interpolation based on the circle center angle, the radius, the starting point coordinates and the end point coordinates of the arc to obtain the starting point coordinates and the end point coordinates of each section of interpolation arc in the plurality of sections of interpolation arcs corresponding to the arc.
4. The method of converting DXF files into motion trajectories for mechanical arms of claim 3, wherein performing an arc interpolation based on a center angle, a radius, a start point coordinate, and an end point coordinate of the arc to obtain the start point coordinate and the end point coordinate of each of a plurality of segments of interpolation arcs corresponding to the arc, comprises:
calculating the total arc length of the arc according to the circle center angle and the radius of the arc;
calculating the number of segments of the interpolation arc of the arc based on the total arc length of the arc;
calculating the offset angle of each interpolation arc according to the circle center angle of the arc and the number of segments;
and calculating the starting point coordinates and the end point coordinates of each section of interpolation arc according to the radius, the starting point coordinates and the end point coordinates of the arc and the offset angle of each section of interpolation arc.
5. The method of converting a DXF file into a motion profile for a robotic arm of claim 2, wherein the G-code file includes start point coordinates and end point coordinates of all interpolation lines corresponding to the lines, start point coordinates and end point coordinates of all interpolation arcs corresponding to the arcs, and center coordinates of the arcs, and wherein resolving the G-code file comprises:
analyzing the starting point coordinates and the end point coordinates of all the interpolation straight lines, the starting point coordinates and the end point coordinates of all the interpolation circular arcs and the circle center coordinates of the circular arcs in the G code file;
and calculating the coordinates of any point between the starting point and the end point of each interpolation arc according to the G code file.
6. The method of converting DXF file into a motion profile for a robotic arm of claim 5, wherein calculating coordinates for any point between the start and end points of each segment of the interpolated arc from the G-code file comprises:
calculating the abscissa of any point between the starting point and the end point of the interpolation arc according to the abscissa of the starting point and the abscissa of the end point of each section of the interpolation arc;
and calculating the ordinate of any point between the starting point and the end point of the interpolation arc according to the circle center coordinates of the arc, the coordinates of the starting point of each section of the interpolation arc and the abscissa of any point between the starting point and the end point of the interpolation arc.
7. The method of converting DXF file into a motion profile for a robotic arm of claim 6, wherein any point between the starting point and the ending point of the interpolated arc is a midpoint between the starting point and the ending point of the interpolated arc, and wherein the abscissa of the midpoint between the starting point and the ending point of the interpolated arc is calculated by the formula:
x3=(x1+x2)/2
wherein x3 represents the abscissa of the midpoint between the starting point and the ending point of the interpolation arc, x1 represents the abscissa of the starting point of the interpolation arc, and x2 represents the abscissa of the ending point of the interpolation arc.
8. The method of converting DXF file into a motion profile for a robotic arm of claim 7, wherein the ordinate of the midpoint between the starting and ending points of the interpolated arc is calculated by the formula:
(y3-b) 2 =r 2 +(x3-a) 2
wherein r represents the radius of the circular arc, x1 and y1 represent the abscissa and the ordinate of the starting point of the interpolation circular arc respectively, a and b represent the abscissa and the ordinate of the center of the circular arc respectively, and x3 and y3 represent the abscissa and the ordinate of the midpoint between the starting point and the end point of the interpolation circular arc respectively.
9. The method of converting DXF file of any of claims 1-8 into a motion profile for a robotic arm, wherein deriving the motion profile for the robotic arm based on the parsing result comprises:
acquiring preset parameters and a mechanical arm track generation algorithm, wherein the preset parameters comprise a user coordinate system, mechanical arm tail end tool parameters and an amplification factor;
and converting the analysis result into a motion track of the mechanical arm according to the preset parameters and the mechanical arm track generation algorithm.
10. The method of converting a DXF file into a robotic arm motion profile of any of claims 1-8, further comprising, prior to obtaining the DXF file:
acquiring an original track file of a mechanical arm, and judging whether the original track file is a G code file or not;
if the original track file is a G code file, analyzing the G code file, and obtaining the motion track of the mechanical arm based on an analysis result;
and if the original track file is not a G code file, saving the original track file, wherein the original track file comprises a DXF file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311852806.9A CN117754587A (en) | 2023-12-28 | 2023-12-28 | Method for converting DXF file into mechanical arm movement track |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311852806.9A CN117754587A (en) | 2023-12-28 | 2023-12-28 | Method for converting DXF file into mechanical arm movement track |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117754587A true CN117754587A (en) | 2024-03-26 |
Family
ID=90318194
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311852806.9A Pending CN117754587A (en) | 2023-12-28 | 2023-12-28 | Method for converting DXF file into mechanical arm movement track |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117754587A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102581849A (en) * | 2012-01-05 | 2012-07-18 | 东南大学 | Method for planning trajectories of industrial robot based on NC (numerical control) codes |
CN104875104A (en) * | 2015-05-14 | 2015-09-02 | 常州大思世成机电科技有限公司 | Wheel hub irregular curved surface polishing method based on CAD/CAM technologies |
CN110962368A (en) * | 2019-12-20 | 2020-04-07 | 镇江奥立特机械制造有限公司 | Seven fibre winding machines based on arm |
CN112180823A (en) * | 2020-09-28 | 2021-01-05 | 常州工学院 | PLC control method based on DXF file reading motion trail planning |
US20210154836A1 (en) * | 2019-11-22 | 2021-05-27 | Smc Corporation | Trajectory control device |
CN113305383A (en) * | 2021-05-31 | 2021-08-27 | 南京航空航天大学 | Method and device for analyzing wire cut electrical discharge machining (EDFA) graph based on DXF graph file |
CN113733085A (en) * | 2021-08-30 | 2021-12-03 | 三一建筑机器人(西安)研究院有限公司 | Industrial robot off-line programming method and device |
CN114453729A (en) * | 2022-01-12 | 2022-05-10 | 哈尔滨理工大学 | Laser cooperation device for multi-axis turning and milling composite machine tool and control method |
CN116175662A (en) * | 2022-12-24 | 2023-05-30 | 三峡大学 | Automatic honeycomb panel cutting method based on flat ultrasonic knife programming processing |
-
2023
- 2023-12-28 CN CN202311852806.9A patent/CN117754587A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102581849A (en) * | 2012-01-05 | 2012-07-18 | 东南大学 | Method for planning trajectories of industrial robot based on NC (numerical control) codes |
CN104875104A (en) * | 2015-05-14 | 2015-09-02 | 常州大思世成机电科技有限公司 | Wheel hub irregular curved surface polishing method based on CAD/CAM technologies |
US20210154836A1 (en) * | 2019-11-22 | 2021-05-27 | Smc Corporation | Trajectory control device |
CN110962368A (en) * | 2019-12-20 | 2020-04-07 | 镇江奥立特机械制造有限公司 | Seven fibre winding machines based on arm |
CN112180823A (en) * | 2020-09-28 | 2021-01-05 | 常州工学院 | PLC control method based on DXF file reading motion trail planning |
CN113305383A (en) * | 2021-05-31 | 2021-08-27 | 南京航空航天大学 | Method and device for analyzing wire cut electrical discharge machining (EDFA) graph based on DXF graph file |
CN113733085A (en) * | 2021-08-30 | 2021-12-03 | 三一建筑机器人(西安)研究院有限公司 | Industrial robot off-line programming method and device |
CN114453729A (en) * | 2022-01-12 | 2022-05-10 | 哈尔滨理工大学 | Laser cooperation device for multi-axis turning and milling composite machine tool and control method |
CN116175662A (en) * | 2022-12-24 | 2023-05-30 | 三峡大学 | Automatic honeycomb panel cutting method based on flat ultrasonic knife programming processing |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5805322B2 (en) | Computer program product and method for generating and simulating an object model | |
US20070159487A1 (en) | Processing image data | |
US6597368B1 (en) | Morphing image processing system using polygon reduction processing | |
CN104793560A (en) | Method and system for generating a trajectory | |
CN103649856A (en) | Method for simulating machining of objects by motion of tool and system and computer program product therefor | |
JP2004127099A (en) | Cad system and cad program | |
CN112906106A (en) | Method for establishing parameterized TBM shield tunnel model | |
US7062353B2 (en) | Method and system for reconstructing a surface | |
CN105867310A (en) | Numerical control processing method and numerical control processing system for realizing T spline model based on OCC | |
CN112132928B (en) | Vector diagram processing method, vector diagram processing device, electronic equipment and computer readable medium | |
CN117754587A (en) | Method for converting DXF file into mechanical arm movement track | |
EP3924792A1 (en) | Method and apparatus for managing robot program | |
US20120306851A1 (en) | Mesh sequence file format | |
JP4653732B2 (en) | System and method for curve shape preservation in the editing process | |
JP4622987B2 (en) | Tool reference plane data creation device and creation method | |
KR100404905B1 (en) | Caculation method for variable radius offset curves and a recording medium providing program therein | |
US11615590B2 (en) | Methods and systems for generating surfaces from polygonal data | |
CN110796729B (en) | Grid division method based on binary tree | |
JPH0950311A (en) | Numerical controller | |
CN118365838A (en) | Virtual simulation cutting method, device, computer equipment and readable storage medium | |
JP2001067391A (en) | Three-dimenisonal form processing method and recording medium recording program for executing the processing method | |
CN115761198A (en) | Data model lightweight method, device, equipment and storage medium | |
JPWO2004104869A1 (en) | Surface shape creation system, surface shape creation method and program recording medium | |
CN117930833A (en) | Evaluation optimization method for robot track | |
CN117689834A (en) | Three-dimensional CAD model direct editing method and system for maintaining columnar body characteristics |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |