Method of converting DXF file into robot arm motion trajectory
By parsing and interpolation of DXF files, it is directly converted into G code files to obtain the motion trajectory of the robotic arm, which solves the problems of long R&D cycle and high cost caused by plug-in dependence in the existing technology, and achieves a fast and economical motion trajectory generate.
Patent Information
- Application Number
- CN202311852806.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2043-12-28
AI Technical Summary
In the prior art, methods of converting DXF files into robotic arm motion trajectories need to rely on plug-ins, resulting in long R&D cycles and high costs, and difficult to debug and maintain.
By obtaining DXF files for parsing, sorting and interpolation, converting them into G-code files, and obtaining the movement trajectory of the robotic arm based on the G-code files, communication and maintenance costs with plug-in developers are avoided.
The DXF file can be converted into a robotic arm motion trajectory without plug-ins, reducing R&D time and cost and simplifying the debugging process.
Smart Images

Figure CN117754587B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of robot arm motion trajectories, and in particular to a method for converting a DXF file into a robot arm motion trajectory. Background Art
[0002] DXF files are CAD data file formats used for CAD data exchange between AutoCAD and other software. At present, the method of converting DXF files into robot arm motion trajectories is: CAD software manufacturers and third-party manufacturers provide some plug-in extensions that can import DXF files into robot arm control software.
[0003] However, the extension method through plug-ins has the following disadvantages:
[0004] (1) When using the motion trajectory generated by the plug-in to perform related tests on the robot arm, problems are difficult to debug and require communication with the plug-in developer, which prolongs the R&D cycle;
[0005] (2) The price of the plug-in itself and the subsequent maintenance costs are too high, which increases the R&D costs. Summary of the invention
[0006] In order to solve the problems of long R&D cycle and high cost in related technologies, the present invention proposes the following technical solutions.
[0007] The first aspect of the present invention proposes a method for converting a DXF file into a motion trajectory of a robot arm, comprising: obtaining a DXF file and parsing the DXF file, wherein the DXF file includes different graphic data; classifying and interpolating the different graphic data according to the parsed DXF file to obtain the starting point coordinates and the end point coordinates of each interpolation graphic in a plurality of interpolation graphics corresponding to each of the graphic data; converting the parsed DXF file and the starting point coordinates and the end point coordinates of all the interpolation graphics into a G code file; parsing the G code file, and obtaining the motion trajectory of the robot arm based on the parsing result.
[0008] In addition, the method for converting a DXF file into a robot arm motion trajectory according to the above embodiment of the present invention may also have the following additional technical features.
[0009] According to one embodiment of the present invention, different graphic data include straight lines and circular arcs, and the different graphic data are classified and interpolated according to the parsed DXF file to obtain the starting point coordinates and end point coordinates of each interpolated graphic in the multi-segment interpolated graphics corresponding to each of the graphic data, including: performing straight line interpolation and circular arc interpolation according to the parsed DXF file to obtain the starting point coordinates and end point coordinates of each interpolated straight line in the multi-segment interpolated straight lines corresponding to the straight lines, and the starting point coordinates and end point coordinates of each interpolated circular arc in the multi-segment interpolated circular arcs corresponding to the circular arc.
[0010] According to one embodiment of the present invention, linear interpolation and circular arc interpolation are respectively performed according to the parsed DXF file to obtain the starting point coordinates and end point coordinates of each interpolation line in the multi-segment interpolation lines corresponding to the straight line, and the starting point coordinates and end point coordinates of each interpolation arc in the multi-segment interpolation circular arcs corresponding to the circular arc, including: performing linear interpolation based on the starting point coordinates and end point coordinates of the straight line to obtain the starting point coordinates and end point coordinates of each interpolation line in the multi-segment interpolation lines corresponding to the straight line; performing circular arc interpolation based on the center angle, radius, starting point coordinates and end point coordinates of the circular arc to obtain the starting point coordinates and end point coordinates of each interpolation circular arc in the multi-segment interpolation circular arcs corresponding to the circular arc.
[0011] According to one embodiment of the present invention, arc interpolation is performed based on the center angle, radius, start point coordinates and end point coordinates of the arc to obtain the start point coordinates and end point coordinates of each interpolated arc in multiple interpolated arcs corresponding to the arc, including: calculating the total arc length of the arc based on the center angle and radius of the arc; calculating the number of interpolated arc segments of the arc based on the total arc length of the arc; calculating the offset angle of each interpolated arc segment based on the center angle of the arc and the number of segments; calculating the start point coordinates and end point coordinates of each interpolated arc segment based on the radius, start point coordinates, end point coordinates of the arc and the offset angle of each interpolated arc segment.
[0012] According to one embodiment of the present invention, the G code file includes the start point coordinates and end point coordinates of all interpolated straight lines corresponding to the straight lines, the start point coordinates and end point coordinates of all interpolated arcs corresponding to the arcs, and the center coordinates of the arcs.
[0013] The G code file is parsed, including: parsing the starting point coordinates and end point coordinates of all interpolated straight lines, the starting point coordinates and end point coordinates of all interpolated arcs, and the center coordinates of the arcs in the G code file; and calculating the coordinates of any point between the starting point and the end point of each interpolated arc according to the G code file.
[0014] According to one embodiment of the present invention, the coordinates of any point between the starting point and the end point of each interpolated arc are calculated according to the G code file, including: calculating the horizontal coordinate of any point between the starting point and the end point of each interpolated arc according to the horizontal coordinate of the starting point and the horizontal coordinate of the end point of the interpolated arc; calculating the vertical coordinate of any point between the starting point and the end point of the interpolated arc according to the coordinates of the center of the arc, the coordinates of the starting point of each interpolated arc and the horizontal coordinate of any point between the starting point and the end point of the interpolated arc.
[0015] According to one embodiment of the present invention, any point between the starting point and the end point of the interpolation arc is the midpoint between the starting point and the end point of the interpolation arc, and the horizontal coordinate of the midpoint between the starting point and the end point of the interpolation arc is calculated by the following formula:
[0016] x3=(x1+x2) / 2
[0017] Among them, x3 represents the horizontal coordinate of the midpoint between the starting point and the end point of the interpolation arc, x1 represents the horizontal coordinate of the starting point of the interpolation arc, and x2 represents the horizontal coordinate of the end point of the interpolation arc.
[0018] According to one embodiment of the present invention, the ordinate of the midpoint between the start point and the end point of the interpolation arc is calculated by the following formula:
[0019]
[0020] (y3-b) 2 =r 2 +(x3-a) 2
[0021] Among them, r represents the radius of the arc, x1 and y1 represent the horizontal coordinate and vertical coordinate of the starting point of the interpolated arc, a and b represent the horizontal coordinate and vertical coordinate of the center of the arc, and x3 and y3 represent the horizontal coordinate and vertical coordinate of the midpoint between the starting point and the end point of the interpolated arc.
[0022] According to one embodiment of the present invention, the motion trajectory of the robot arm is obtained based on the analysis results, including: obtaining preset parameters and a robot arm trajectory generation algorithm, wherein the preset parameters include a user coordinate system, robot arm end tool parameters and a magnification factor; according to the preset parameters and the robot arm trajectory generation algorithm, the analysis results are converted into the motion trajectory of the robot arm.
[0023] According to one embodiment of the present invention, before obtaining the DXF file, it also includes: obtaining the original trajectory file of the robot arm, and determining whether the original trajectory file is a G code file; if the original trajectory file is a G code file, parsing the G code file, and obtaining the motion trajectory of the robot arm based on the parsing result; if the original trajectory file is not a G code file, saving the original trajectory file, wherein the original trajectory file includes a DXF file.
[0024] The technical solution of the embodiment of the present invention first parses the DXF file, classifies and interpolates different graphic data according to the parsed DXF file, so as to obtain the starting point coordinates and end point coordinates of each interpolation graphic in the multi-segment interpolation graphics corresponding to each graphic data, and then converts the parsed DXF file and the starting point coordinates and end point coordinates of all interpolation graphics into a G code file, and finally parses the G code file, and obtains the motion trajectory of the robot based on the parsing result. Thus, the DXF file can be converted into the motion trajectory of the robot without a plug-in, which can avoid the time cost of communicating with the plug-in developer, as well as the plug-in price and maintenance costs, thereby reducing the R&D time and reducing the R&D cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 The present invention is a flowchart of a method for converting a DXF file into a robot arm motion trajectory according to an embodiment of the present invention.
[0026] Figure 2 A schematic diagram of linear interpolation according to an example of the present invention.
[0027] Figure 3 A schematic diagram of circular interpolation according to an example of the present invention.
[0028] Figure 4 The figure is a schematic diagram of a clockwise arc according to an example of the present invention.
[0029] Figure 5 FIG. 4 is a schematic diagram of a clockwise arc according to another example of the present invention.
[0030] Figure 6 The figure is a schematic diagram of parsing arc G code according to an example of the present invention.
[0031] Figure 7 The figure is a schematic diagram of an arc G code of a specific example of the present invention. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] Figure 1 The present invention is a flowchart of a method for converting a DXF file into a robot arm motion trajectory according to an embodiment of the present invention.
[0034] like Figure 1 As shown, the method for converting the DXF file into the robot arm motion trajectory includes the following steps S1 to S4.
[0035] S1, obtaining a DXF file and parsing the DXF file, wherein the DXF file includes different graphic data.
[0036] It is understandable that a DXF file (also referred to as a DXF sketch) includes a variety of graphics and their data, such as graphics such as straight lines and arcs, and other information such as descriptive fields.
[0037] The parsed DXF file includes the size, position and other data of each graphic data, such as the starting point coordinates and the end point coordinates.
[0038] Specifically, first obtain a DXF file containing different graphic data such as straight lines and arcs. The content of the file is geometric figures and their parameters, which can be parsed by any feasible method to obtain the starting point coordinates and end point coordinates of the straight line, and the starting point coordinates, end point coordinates, center coordinates, center angle and radius of the arc. The parsing method can be the open source C++ parsing library dxflib, CAM software (such as MASTER-CAM), etc.
[0039] In order to facilitate the parsing of DXF files, you can use the open source C++ parsing library dxflib. By using the functions and classes provided by the dxflib library, you can read the content of the DXF file, parse its structure, and extract the required graphic data, such as points, lines, circles, polygons, etc. This library defines the metadata of the graphics. For example, the metadata of a straight line is defined as a DLLineData structure, which stores the coordinates of the start and end points of the line, and the metadata of a circle is defined as a DLCircleData structure, which stores the coordinates of the center of the circle and the radius.
[0040] In terms of code implementation, the library's related functions are used to parse DXF files, build modules for reading and writing files, and classify and process them according to different primitive data. Taking the polyline primitive as an example, two methods, addPolyline and addsertex, are used to add a polyline, where addPolyline is used to save the polyline and addVertex is used to save the vertices of the polyline. The primitives in the file stream are saved through the corresponding primitive objects. When all the primitives in the file stream are read, all BLOCK primitives are saved in BLOCKs, as well as the POLYLINE, CIRCLE (arc, etc.) and other primitives contained in the BLOCK primitives. Finally, a custom class is used to save the corresponding graphic data and draw it on the user interface.
[0041] S2. Classify and interpolate different graphic data according to the parsed DXF file to obtain the starting point coordinates and the ending point coordinates of each interpolation graphic segment in the multi-segment interpolation graphics corresponding to each graphic data.
[0042] It should be noted that for the graphics in the file, since the parsed DXF file does not directly provide all the points, but provides the starting point and the end point, in order to complete the robot arm trajectory, it is necessary to use the interpolation algorithm to calculate the remaining points in the graphics. Here, the parsing accuracy parameter needs to be set manually in advance. This parameter affects the point density and smoothness of the converted graphics to achieve uniform distribution of endpoints.
[0043] Specifically, classification and interpolation are performed according to the graphics-related parameters in the parsed DXF file to obtain the starting point coordinates and the ending point coordinates of each interpolation graphic segment in the multi-segment interpolation graphics corresponding to each graphic segment.
[0044] S3, converting the parsed DXF file and the start point coordinates and end point coordinates of all interpolated graphics into a G code file.
[0045] Specifically, the data of all sizes, positions, etc. of all graphics, the starting point coordinates and the end point coordinates of the interpolated graphics are converted into corresponding G code files according to G code rules, and the G code files are output.
[0046] S4. Analyze the G code file and obtain the motion trajectory of the robot arm based on the analysis result.
[0047] The parsing result may refer to the points obtained after parsing the content of the G-code file, which may be put into the point generator.
[0048] G code, also known as RS-274 or G instruction, is a CNC programming language used for computer-aided manufacturing. It is a CNC program that defines linear motion, arc motion, moving speed and other operating instructions. The G code instruction set is open and transparent. For example, G90 represents the use of absolute coordinate mode, G21 represents the use of metric millimeters as units, and G1 represents linear motion. G code files can be parsed according to these specific instructions, and the obtained coordinate set and movement mode can be input to the controller in the manner specified by the internal motion algorithm of the robot arm, thereby intelligently planning the trajectory of the robot arm. For example, for the end glue gun tool attached to the robot arm, its switch is controlled according to the change of the coordinates of the robot arm in the Z-axis direction.
[0049] Specifically, all the interpolation line and interpolation arc related coordinates in the G code file are parsed into points and put into a point container, and the points in the point container are converted into robot arm motion trajectories according to specific actual needs.
[0050] Therefore, the method for converting a DXF file into a robot arm motion trajectory in an embodiment of the present invention can convert a DXF file into a robot arm motion trajectory without a plug-in, thereby avoiding the time cost of communicating with the plug-in developer as well as the plug-in price and maintenance costs, thereby reducing R&D time and reducing R&D costs.
[0051] In one embodiment of the present invention, the different graphic data include straight lines and circular arcs. The parsed DXF file includes the starting point coordinates and end point coordinates of the straight lines, the starting point coordinates, end point coordinates, center coordinates, center angle and radius of the circular arcs.
[0052] In this embodiment, step S2 may include the following steps:
[0053] S21, performing linear interpolation and circular interpolation according to the parsed DXF file, respectively, to obtain the starting point coordinates and end point coordinates of each interpolation straight line in the multi-segment interpolation straight line corresponding to the straight line, and the starting point coordinates and end point coordinates of each interpolation circular arc in the multi-segment interpolation circular arc corresponding to the circular arc.
[0054] It should be noted that for the lines and arcs in the file, since the parsed DXF file does not directly provide all the points, but only the starting point and the end point, in order to complete the robot arm trajectory, it is necessary to use the interpolation algorithm to calculate the remaining points in the line or arc. Here, the parsing accuracy parameter needs to be set manually in advance. This parameter affects the point density and smoothness of the converted line and arc to achieve uniform distribution of the endpoints.
[0055] Specifically, linear interpolation is performed according to the line-related parameters in the parsed DXF file to obtain the starting coordinates and end coordinates of each interpolated line in the multi-segment interpolated line corresponding to the line. Circular arc interpolation is performed according to the arc-related parameters in the parsed DXF file to obtain the starting coordinates and end coordinates of each interpolated arc in the multi-segment interpolated arc corresponding to the arc.
[0056] Then execute step S3, that is, convert the starting point coordinates, end point coordinates of the straight line and arc, the starting point coordinates, end point coordinates of all interpolated straight lines corresponding to the straight line, the starting point coordinates, end point coordinates of all interpolated arcs corresponding to the arc, and the center coordinates of the arc into corresponding G code files according to G code rules, and output the G code files.
[0057] The G code file includes the start point coordinates and end point coordinates of all interpolated straight lines corresponding to the straight lines, the start point coordinates, end point coordinates of all interpolated arcs corresponding to the arcs, and the center point coordinates of the arcs.
[0058] 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 the starting point coordinates and the ending point coordinates of each interpolated straight line in the multi-segment interpolated straight line corresponding to the straight line; performing arc interpolation based on the center angle, radius, starting point coordinates and the ending point coordinates of the arc to obtain the starting point coordinates and the ending point coordinates of each interpolated arc in the multi-segment interpolated arc corresponding to the arc.
[0059] Further, arc interpolation is performed based on the center angle, radius, starting point coordinates and end point coordinates of the arc to obtain the starting point coordinates and end point coordinates of each interpolated arc in the multiple interpolated arcs corresponding to the arc, which may include: calculating the total arc length of the arc based on the center angle and radius of the arc; calculating the number of interpolated arc segments of the arc based on the total arc length of the arc; calculating the offset angle of each interpolated arc segment based on the center angle and number of segments of the arc; calculating the starting point coordinates and end point coordinates of the interpolated arc segment based on the radius, starting point coordinates, end point coordinates of the arc and the offset angle of each interpolated arc segment.
[0060] Specifically, for linear interpolation, first calculate the total length of the line based on its starting point coordinates and end point coordinates, obtain the resolution value, divide the total length of the line by the resolution value to get the interpolation step (number of segments), add endpoints (starting point and end point) to divide the line into multiple interpolation lines, each interpolation line has a starting point coordinate and an end point coordinate, and finally process the line. In the linear interpolation method, the interpolation between the starting point and the end point of the line is approximated along the point group of the line. First, on the XY plane, assume that at the starting point of the actual contour, walk a short distance along the X-axis direction, and find that the end point is below the actual contour, then the next line segment walks a short distance along the Y-axis direction. At this time, if the end point of the line segment is still below the actual contour, continue to walk a short distance along the Y-axis direction until it is above the actual contour, and then walk a short distance in the X-axis direction, and so on, until the end point of the contour is reached. In this way, the actual contour is composed of segments of broken lines. Although it is a broken line, each interpolated straight line is within the accuracy range and is very small. The generated trajectory is still smooth. Then this segment of the broken line can be approximated as a straight line segment. This is linear interpolation. Assuming that the axis needs to move from the starting point (X0, Y0) to the end point (X1, Y1) on the XY plane, the process of linear interpolation is as follows: Figure 2 shown.
[0061] For arc interpolation, similar to linear interpolation, the interpolation digital information between the two end points of the arc is calculated, and the offset angle (angle of offset from the center of the circle) added for each offset is calculated with the resolution value. Starting from the line connecting the center of the arc and the starting point, an offset angle is moved each time, and the coordinates of the point on the arc of the current end axis are calculated until the end point is reached, and finally the arc curve is processed. First, the total arc length of the arc is calculated according to its center angle and radius, and the resolution value is obtained. The total arc length is divided by the resolution value to obtain the interpolation step length (number of segments), and the center angle is divided by the number of segments to obtain the offset angle of each interpolated arc. At this time, the trigonometric theorem can be used, and the starting point coordinates and end point coordinates of the interpolated arc can be calculated according to the radius of the arc, the starting point coordinates, the end point coordinates, and the offset angle of each interpolated arc. Then, endpoints (starting point and end point) are added to divide the arc into multiple interpolated arcs, and each interpolated arc has a starting point coordinate and an end point coordinate. If Figure 3 As shown, point C0 is the starting point of the arc, point Cn is the end point of the arc, and points C1, C2, C3, C4, C5, ..., Cn-1 (n is greater than 1) are obtained through arc interpolation. The arc is divided into multiple interpolated arcs through these starting points and end points. The coordinates of each point can be calculated based on the circle equation and the included angle.
[0062] After parsing the DXF file and performing linear interpolation and circular interpolation, steps S3 and S4 are executed to convert the parsed DXF file (starting point coordinates and end point coordinates of a straight line, starting point coordinates and end point coordinates of an arc, center point coordinates, center point angle and radius), starting point coordinates and end point coordinates of all interpolated straight lines, and starting point coordinates and end point coordinates of all interpolated circular arcs into a G code file. The G code file includes the starting point coordinates and end point coordinates of all interpolated straight lines corresponding to the straight line, the starting point coordinates and end point coordinates of all interpolated circular arcs corresponding to the circular arc, and the center point coordinates of the circular arc.
[0063] In one embodiment of the present invention, parsing the G code file in step S4 may include: parsing the starting point coordinates and end point coordinates of all interpolated straight lines, the starting point coordinates and end point coordinates of all interpolated arcs, and the center point coordinates of the arcs in the G code file; and calculating the coordinates of any point between the starting point and the end point of each interpolated arc according to the G code file.
[0064] Among them, any point can be a point at which the arc is 1 / 2, 1 / 3, 1 / 4 of the arc length from its starting point.
[0065] Specifically, when parsing the starting point coordinates and end point coordinates of all interpolated straight lines, the starting point coordinates and end point coordinates of all interpolated arcs, and the center point coordinates of the arcs in the G code, the trajectory algorithm supported by the robot itself requires three points (including the starting point and end point) on each interpolated arc, so it is necessary to calculate the third point on the interpolated arc (a point other than the starting point and end point on the arc) based on known conditions. Therefore, the coordinates of any point (such as the midpoint) between the starting point and the end point of each interpolated arc can be calculated based on the relevant parameters of the arc in the G code file, and then used for subsequent program calls, so the parsing results obtained are the starting point coordinates and end point coordinates of all interpolated straight lines, the starting point coordinates, end point coordinates and coordinates of any point of all interpolated arcs, and the center point coordinates of the arc.
[0066] Furthermore, calculating the coordinates of any point between the starting point and the end point of each interpolated arc according to the G code file may include: calculating the horizontal coordinate of any point between the starting point and the end point of each interpolated arc according to the horizontal coordinate of the starting point and the horizontal coordinate of the end point of the interpolated arc; calculating the vertical coordinate of any point between the starting point and the end point of the interpolated arc according to the coordinates of the center of the arc, the coordinates of the starting point of each interpolated arc, and the horizontal coordinate of any point between the starting point and the end point of the interpolated arc.
[0067] Specifically, assume that any point is the midpoint between the start point and the end point of the interpolation arc, and its coordinates are (x3, y3). Because in the same arc (assuming that the arc is a clockwise arc), it can be known that the point (x3, y3) must be between the start point and the end point of the interpolation arc, so the horizontal coordinate of the midpoint between the start point and the end point of the interpolation arc can be calculated by the following formula:
[0068] x3=(x1+x2) / 2
[0069] Among them, x3 represents the horizontal coordinate of the midpoint between the start point and the end point of the interpolation arc, x1 represents the horizontal coordinate of the start point of the interpolation arc, and x2 represents the horizontal coordinate of the end point of the interpolation arc.
[0070] For y3, first calculate the radius of the arc, and then calculate y3 based on the radius, the coordinates of the center of the circle, and the horizontal coordinate of the midpoint. The vertical coordinate of the midpoint between the start and end points of the interpolated arc is calculated using the following formula:
[0071]
[0072] (x3-b) 2 =r 2 +(x3-a) 2
[0073] Among them, r represents the radius of the arc, x1 and y1 represent the horizontal and vertical coordinates of the starting point of the interpolated arc, a and b represent the horizontal and vertical coordinates of the center of the arc, and x3 and y3 represent the horizontal and vertical coordinates of the midpoint between the starting point and the end point of the interpolated arc.
[0074] The above formula can be used to calculate two y3 values, which are suitable for Figure 4 and Figure 5 The arc shown ( Figure 4 and Figure 5 The arcs are all clockwise), and the specific ones can be selected according to the situation.
[0075] After obtaining the coordinates of each point in the G code file, the G code file is parsed. The following is an example of the parsing process of the arc G code in a specific G code file:
[0076] First, let me explain the arc command, G2 (clockwise arc) command or G3 (counterclockwise arc) command. The difference is that when viewed from the front of the rotating axis, the direction is from left to right and from right to left. The meaning of the arc command is to draw an arc. It is followed by the displacement commands X, Y, and Z of each axis, and the three commands i, j, and k are used to specify the offset relative to the starting point (there is no Z or k in the two-dimensional plane scene). The value of the feed command f can be specified or it can come from the f value of the previous command. Because G2 and G3 are generally used with G1, its f value is not written. In fact, it uses the f value of the previous code. Of course, you can also customize the f value. The curvature of the arc is set by the center format arc.
[0077] Assume that the existing G code file has the following three lines of arc G code:
[0078] G0 X0 Y0 (indicates positioning to the origin);
[0079] G1 X50 Y40 f100 (indicates linear motion from the origin at a feed rate of 100 to the coordinate point (50,40));
[0080] G2 X20 Y10 i-30j0 f200 (means to use (50,40) as the starting point, (20,10) as the end point, the starting point (50,40) as the offset starting point, offset 30 on the negative half axis of the X axis, no offset on the Y axis, and draw an arc with this point as the center. The feed rate is adjusted to 200.
[0081] The above code gives three known conditions for drawing an arc, the starting point, the end point, and the center of the circle, so as to draw an interpolated arc. Figure 6 shown.
[0082] After obtaining the coordinates of the midpoint of the interpolated arc, put them into the G code file, and then parse the G code file to get the point position. At this point, the three arc points required by the robot algorithm have been obtained, and the points can be inserted into the robot trajectory generator to generate the robot motion trajectory.
[0083] In one embodiment of the present invention, obtaining the motion trajectory of the robot arm based on the analysis results in step S4 may include: obtaining preset parameters and a robot arm trajectory generation algorithm, wherein the preset parameters include a user coordinate system, robot arm end tool parameters and a magnification factor; and converting the analysis results into the motion trajectory of the robot arm according to the preset parameters and the robot arm trajectory generation algorithm.
[0084] The preset parameters are parameters input by the user according to the actual processing and operation requirements. The robot trajectory generation algorithm refers to any algorithm that can generate the robot motion trajectory, which can be a robot built-in, internal or native algorithm.
[0085] Specifically, all the straight line and arc-related coordinates in the G-code file are parsed into points and placed in a point container. According to the preset parameters set by the user in advance on the interface, such as the user coordinate system, the robot end tool parameters and the magnification factor, the points in the point container are converted into the motion trajectory of the robot arm according to the robot arm trajectory generation algorithm. The mechanical motion is controlled based on the running trajectory. For example, at each point where the Z-axis coordinate changes (representing whether the robot arm is directly up or down relative to the user coordinate system), the level of the glue gun clamped by the robot end tool can be controlled, and then the switch of the glue gun can be controlled to complete the gluing.
[0086] In the related art, the program and operation logic of the plug-in itself are opaque, and it is difficult for the robot arm to improve the process of the original trajectory file according to actual processing requirements.
[0087] In the embodiment of the present invention, preset parameters can be input according to actual processing requirements, and the original trajectory can be improved and optimized in combination with the preset parameters to obtain the final operation trajectory. The trajectory and preset parameters can be optimized in real time according to actual requirements, thereby improving the operation trajectory.
[0088] In one embodiment of the present invention, before step S1, it may also include: obtaining the original trajectory file of the robot arm, and determining whether the original trajectory file is a G code file; if the original trajectory file is a G code file, parsing the G code file, and obtaining the motion trajectory of the robot arm based on the parsing result; if the original trajectory file is not a G code file, saving the original trajectory file, wherein the original trajectory file includes a DXF file.
[0089] Specifically, the original trajectory file can be a custom file input by the user. First, determine whether the file is a G code file. If so, execute step S4 to directly read and parse the motion trajectory of the robot arm; if not, save its DXF file, and execute steps S1 to S4 to convert the DXF file into a G code file, and parse the G code file to obtain the movement trajectory of the robot arm.
[0090] The following is a specific programming example to demonstrate the operation process:
[0091] (1) Input the original trajectory file and save its DXF file.
[0092] Open the DXF to G-code interface, set the parameters and click the relevant button to select the DXF file to be parsed. After confirmation, the interface will display the parsed graphics and highlight the endpoints;
[0093] (2) Convert to G-code file.
[0094] Click the relevant button to call the internal algorithm to read the parsed DXF file and automatically generate the G code file according to the program logic, such as Figure 7 shown.
[0095] (3) Read the G-code file.
[0096] In the programming interface, create a motion instruction (such as a gluing instruction) to display the motion instruction configuration options, click the relevant button to select the G-code file generated by (2), and set the coordinate system and other properties according to the actual production requirements of the scene, and finally save the configuration results.
[0097] (4) Control the movement of the robotic arm.
[0098] Save the project and run it. The background will first call the G-code file to convert the logic of the robot's motion trajectory, and then send the generated robot trajectory to the robot's motion interface. After that, the robot will start to move according to the input trajectory, and you can see the result.
[0099] In summary, the embodiment of the present invention extracts geometric information from the DXF file, obtains a point set after parsing and converting it, and then performs trajectory planning and motion control according to the motion algorithm of the robot itself. No plug-in is required, and it can be directly converted into the motion trajectory of the robot after internal analysis of the program, which reduces R&D time and reduces R&D costs; the processing requirements and optimization of the trajectory planning algorithm can be loaded into the results of DXF sketch file processing in real time, improving the motion trajectory of the robot; the system reduces the dependence on plug-ins, making the system more stable and efficient.
[0100] Corresponding to the method for converting a DXF file into a robot arm motion trajectory in the above embodiment, the present invention further provides a device for converting a DXF file into a robot arm motion trajectory.
[0101] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. "Multiple" means two or more, unless otherwise clearly and specifically defined.
[0102] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0103] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0104] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0105] A person of ordinary skill in the art can understand that all or part of the steps carried by the method of the above-mentioned embodiment can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, and the program, when executed, includes one or a combination of the steps of the method embodiment. In addition, each functional unit in each embodiment of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0106] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for converting a DXF file into a robot arm motion trajectory, characterized in that: The following steps are involved: Obtaining a DXF file and parsing the DXF file, wherein the DXF file includes different graphic data; According to the parsed DXF file, different graphic data are classified and interpolated respectively to obtain the starting point coordinates and the ending point coordinates of each interpolation graphic segment in the multiple interpolation graphics segments corresponding to each of the graphic data; Convert the parsed DXF file, the starting point coordinates and the ending point coordinates of all the interpolated graphics into a G code file; The G code file is parsed, and the motion trajectory of the robot arm is obtained based on the parsing result. Different graphic data include straight lines and arcs, According to the parsed DXF file, different graphic data are classified and interpolated respectively to obtain the starting point coordinates and the ending point coordinates of each interpolation graphic segment in the multi-segment interpolation graphics corresponding to each of the graphic data, including: According to the parsed DXF file, linear interpolation and circular interpolation are performed respectively to obtain the starting point coordinates and end point coordinates of each interpolation straight line in the multi-segment interpolation straight line corresponding to the straight line, and the starting point coordinates and end point coordinates of each interpolation circular arc in the multi-segment interpolation circular arc corresponding to the circular arc. The G code file includes the starting point coordinates and the end point coordinates of all interpolated straight lines corresponding to the straight lines, the starting point coordinates and the end point coordinates of all interpolated arcs corresponding to the arcs, and the center coordinates of the arcs. Parsing the G code file includes: Analyze the starting point coordinates and end point coordinates of all interpolation lines, the starting point coordinates and end point coordinates of all interpolation arcs, and the center coordinates of the arcs in the G code file; Calculate the coordinates of any point between the starting point and the end point of each interpolation arc according to the G code file, Calculating the coordinates of any point between the starting point and the end point of each interpolation arc 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 end point of each interpolation arc; The vertical coordinate of any point between the starting point and the end point of the interpolation arc is calculated according to the coordinates of the center of the arc, the coordinates of the starting point of each interpolation arc and the horizontal coordinate of any point between the starting point and the end point of the interpolation arc.
2. The method for converting a DXF file into a robot arm motion trajectory according to claim 1, characterized in that: According to the parsed DXF file, linear interpolation and circular interpolation are respectively performed to obtain the starting point coordinates and the end point coordinates of each interpolation straight line in the multi-segment 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-segment 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 plurality of interpolation straight lines corresponding to the straight line; Circular arc interpolation is performed based on the center angle, radius, start point coordinates and end point coordinates of the circular arc to obtain the start point coordinates and end point coordinates of each interpolated circular arc in the multiple interpolated circular arcs corresponding to the circular arc.
3. The method for converting a DXF file into a robot arm motion trajectory according to claim 2, characterized in that: Performing arc interpolation based on the center angle, radius, start point coordinates and end point coordinates of the arc to obtain the start point coordinates and end point coordinates of each interpolation arc in the multiple interpolation arcs corresponding to the arc, including: Calculate the total arc length of the arc according to the center angle and radius of the arc; Calculate the number of segments of the interpolated arc of the arc based on the total arc length of the arc; Calculate the offset angle of each interpolated arc according to the center angle of the arc and the number of segments; The starting point coordinates and the ending point coordinates of each interpolation arc are calculated according to the radius of the arc, the starting point coordinates, the ending point coordinates and the offset angle of each interpolation arc.
4. The method for converting a DXF file into a robot arm motion trajectory according to claim 1, characterized in that: Any point between the starting point and the end point of the interpolation arc is the midpoint between the starting point and the end point of the interpolation arc. The horizontal coordinate of the midpoint between the starting point and the end point of the interpolation arc is calculated by the following formula: x3=(x1+x2) / 2 Among them, x3 represents the horizontal coordinate of the midpoint between the starting point and the end point of the interpolation arc, x1 represents the horizontal coordinate of the starting point of the interpolation arc, and x2 represents the horizontal coordinate of the end point of the interpolation arc.
5. The method for converting a DXF file into a robot arm motion trajectory according to claim 4, characterized in that: The ordinate of the midpoint between the start point and the end point of the interpolation arc is calculated by the following formula: (y3-b) 2 =r 2 +(x3-a) 2 Among them, r represents the radius of the arc, x1 and y1 represent the horizontal coordinate and vertical coordinate of the starting point of the interpolated arc, a and b represent the horizontal coordinate and vertical coordinate of the center of the arc, and x3 and y3 represent the horizontal coordinate and vertical coordinate of the midpoint between the starting point and the end point of the interpolated arc.
6. The method for converting a DXF file into a robot arm motion trajectory according to any one of claims 1 to 5, characterized in that: Based on the analysis results, the motion trajectory of the robot arm is obtained, including: Obtaining preset parameters and a robot arm trajectory generation algorithm, wherein the preset parameters include a user coordinate system, robot arm end tool parameters, and a magnification factor; According to the preset parameters and the robot arm trajectory generation algorithm, the analysis result is converted into the motion trajectory of the robot arm.
7. The method for converting a DXF file into a robot arm motion trajectory according to any one of claims 1 to 5, characterized in that: Before getting the DXF file, also include: Obtaining an original trajectory file of the robot arm, and determining whether the original trajectory file is a G-code file; If the original trajectory file is a G code file, the G code file is parsed, and the motion trajectory of the robot arm is obtained based on the parsing result; If the original trajectory file is not a G-code file, the original trajectory file is saved, wherein the original trajectory file includes a DXF file.
