A numerical control machining trajectory smoothing optimization and interpolation method and device
The CNC machining trajectory is optimized by using the cubic B-spline smoothing method and the 4th-order explicit Adams method, which solves the problem of lateral speed consistency, improves the efficiency and accuracy of CNC machining, and realizes efficient interpolation calculation.
Patent Information
- Application Number
- CN202411854992.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-12-16
AI Technical Summary
The existing CNC machining trajectory smoothing method fails to effectively consider the lateral velocity consistency, resulting in a decrease in the quality of the machined surface. In addition, it is difficult to balance the efficiency and accuracy of the interpolation calculation. The Taylor expansion method and the Newton iteration method are cumbersome and inefficient.
The cubic B-spline smoothing method is used to generate the transition curve, combined with forward and reverse speed extreme value scanning and 7-segment S-shaped speed planning, and the 4th-order explicit Adams method is used for interpolation calculation to ensure lateral speed consistency and high interpolation efficiency and accuracy.
While ensuring the quality of CNC machining, the machining efficiency and interpolation calculation efficiency are improved, and smooth movement of the tool trajectory and high-precision interpolation are achieved.
Smart Images

Figure CN119689987B_ABST
Abstract
Description
Technical Field
[0001] This article relates to the field of intelligent manufacturing technology, and in particular to a method and device for CNC machining trajectory smoothing optimization and interpolation. Background Art
[0002] At present, in the field of CNC machining, in order to make the machine tool run smoothly during machining, the straight line tool path is smoothed to generate a transition curve with continuous tangent and curvature at the straight line connection point. However, the existing method does not consider the lateral consistency of the machining speed, resulting in a decrease in the surface quality of the machining; in addition, in order to pursue a faster feed rate to achieve higher machining efficiency, speed planning and calculation of interpolation points are required after obtaining the transition curve. However, the correspondence between the curve parameters and the arc length is the difficulty of high-speed interpolation. There is usually no analytical expression between the two, and numerical methods need to be used for calculation. This type of calculation is not suitable for the high-speed interpolation. The calculation is quite cumbersome. Currently, Taylor expansion method and Newton iteration method are mainly used for interpolation calculation. Among them, if Taylor expansion method is only expanded to low order, the accuracy is low, and there are small errors in each interpolation cycle, which will eventually lead to very obvious cumulative errors. The calculation of high-order derivatives is relatively cumbersome and the calculation efficiency is low; Newton iteration method requires iteration, the calculation speed is slow and unstable, and it takes a lot of time; therefore, the current CNC machining trajectory smoothing and interpolation methods lack consideration of lateral velocity consistency, and in the interpolation calculation method, the calculation efficiency and calculation accuracy cannot be taken into account at the same time, which needs to be improved urgently. Summary of the Invention
[0003] The embodiment of the present application provides a method and device for CNC machining trajectory smoothing optimization and interpolation. The speed planning takes into account the consistency of the lateral speed. The interpolation method is efficient and accurate, which improves the efficiency of CNC machining while ensuring the quality of CNC machining.
[0004] On the one hand, an embodiment of the present application provides a method for smoothing optimization and interpolation of a CNC machining trajectory, comprising:
[0005] Based on the multiple original tool position points pre-set by the CNC machine tool, N points to be smoothed are obtained, and the following operations are performed at each point to be smoothed: Based on the cubic B-spline smoothing method, a transition curve C is generated at the point to be smoothed under the first set of constraints. n (τ), where n = 1, 2, ... N, and τ is the curve parameter;
[0006] Under the second set of constraints, each transition curve C is obtained. n (τ) at the point B where the curvature is maximum n The upper speed limit v en ;
[0007] The plurality of original tool positions are located on the N transition curves C nThe original tool position points outside (τ) are set as straight tool paths, and all straight tool paths and N transition curves C n (τ) is spliced into a tool hybrid trajectory, and the tool hybrid trajectory is scanned by the forward and reverse speed extreme value method and the 7-segment S-type speed planning method at the N speed upper limits v en Perform velocity planning under the constraint of , and obtain a velocity curve with continuous acceleration;
[0008] According to the speed curve, the tool mixed trajectory is calculated from the starting point to the end point in a forward interpolation manner, and each transition curve C is calculated in turn. n (τ) Perform the following forward interpolation operation: in each interpolation cycle, calculate the curve parameter value dτ of the current interpolation cycle according to the arc length dl of the current interpolation cycle, solve dτ using the fourth-order explicit Adams method in the modified prediction-correction mode, add the curve parameter value τ of the previous interpolation cycle to dτ to obtain the curve parameter value τ of the current interpolation cycle; interpolate to the current transition curve C n (τ) At the end point, the cumulative error of the tool hybrid trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated;
[0009] For each of the transition curves C n (τ) Perform the following operations: Substitute the curve parameter value τ corresponding to each interpolation period into C n (τ) Get the interpolation point.
[0010] On the other hand, an embodiment of the present application further provides a CNC machining trajectory smoothing optimization and interpolation device, comprising a memory and a processor;
[0011] The memory is used to store the CNC machining trajectory smoothing optimization and interpolation program;
[0012] The processor is used to read the CNC machining trajectory smoothing optimization and interpolation program and perform the CNC machining trajectory smoothing optimization and interpolation method as described in the above embodiment.
[0013] Compared with the related art, the embodiment of the present application provides a method and device for CNC machining trajectory smoothing optimization and interpolation. For scenarios where CNC machine tools have dynamic specific constraints, transition curves can be generated between straight tool paths, and speed planning and real-time interpolation of the transition curves can be performed. The speed planning takes into account the consistency of the lateral speed, and the 4th-order explicit Adams method is used for interpolation calculation. The interpolation method is highly efficient and accurate, and can meet the needs of real-time interpolation of CNC machining. While ensuring the quality of CNC machining, the efficiency of CNC machining is improved.
[0014] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. Other advantages of the present application can be realized and obtained by the solutions described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0016] Figure 1 This is a flow chart of a CNC machining trajectory smoothing optimization and interpolation method according to an embodiment of the present application;
[0017] Figure 2 This is a schematic diagram of generating a transition curve at the point Q to be smoothed according to an embodiment of the present application;
[0018] Figure 3 This is a speed curve diagram of an embodiment of the present application;
[0019] Figure 4 This is a transition curve and a partially enlarged schematic diagram generated based on the butterfly-shaped knife point in a specific example of this application;
[0020] Figure 5 This is a schematic diagram of interpolation points and a partial enlargement after smoothing and interpolation based on the butterfly-shaped tool position points in a specific example of this application;
[0021] Figure 6 Schematic diagram of a CNC machining trajectory smoothing optimization and interpolation device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] This application describes multiple embodiments, but this description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in this application. Although many possible feature combinations are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.
[0023] The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features, and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive solution. Any features or elements of any embodiment may also be combined with features or elements from other inventive solutions to form another unique inventive solution. Therefore, it should be understood that any feature shown and / or discussed in this application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the appended claims and their equivalents, the embodiments are not subject to other limitations. In addition, various modifications and changes may be made within the scope of protection of the appended claims.
[0024] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps in the specific order described. As will be understood by those skilled in the art, other orders of steps are also possible. Therefore, the specific order of the steps set forth in the specification should not be interpreted as a limitation to the claims. In addition, the claims for the method and / or process should not be limited to performing their steps in the order written, and those skilled in the art can readily understand that these orders can be changed and still remain within the spirit and scope of the embodiments of the present application.
[0025] The embodiment of the present application provides a method for optimizing and interpolating a CNC machining trajectory, including steps S100-S500. Figure 1 As shown:
[0026] S100: Based on a plurality of original tool position points pre-set by the CNC machine tool, N points to be smoothed are obtained, and the following operations are performed at each point to be smoothed: Based on the cubic B-spline smoothing method, a transition curve C is generated at the point to be smoothed under the first set of constraints. n (τ), where n = 1, 2, ... N, and τ is the curve parameter;
[0027] S200: Obtain each transition curve C under the second set of constraints n (τ) at the point B where the curvature is maximum n The upper speed limit v en ;
[0028] S300: The plurality of original tool positions are located on the N transition curves C n The original tool position points outside (τ) are set as straight tool paths, and all straight tool paths and N transition curves C n (τ) is spliced into a tool hybrid trajectory, and the tool hybrid trajectory is scanned by the forward and reverse speed extreme value method and the 7-segment S-type speed planning method at the N speed upper limits ven Perform velocity planning under the constraint of , and obtain a velocity curve with continuous acceleration;
[0029] S400: Perform forward interpolation calculation from the starting point to the end point on the tool mixed trajectory according to the speed curve, and perform forward interpolation calculation on each transition curve C in turn. n (τ) Perform the following forward interpolation operation: in each interpolation cycle, calculate the curve parameter value dτ of the current interpolation cycle according to the arc length dl of the current interpolation cycle, solve dτ using the fourth-order explicit Adams method in the modified prediction-correction mode, add the curve parameter value τ of the previous interpolation cycle to dτ to obtain the curve parameter value τ of the current interpolation cycle; interpolate to the current transition curve C n (τ) At the end point, the cumulative error of the tool hybrid trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated;
[0030] S500: For each transition curve C n (τ) Perform the following operations: Substitute the curve parameter value τ corresponding to each interpolation period into C n (τ) Get the interpolation point.
[0031] In this embodiment, in the current field of numerical control machining, the original tool location point generated by the CAM software is usually a linear path composed of multiple straight lines. The linear path has discontinuous tangent vectors and curvature at the connection points of adjacent straight lines, which will cause machine tool vibration and reduce machining efficiency and quality. When executing step S100, the connection points of adjacent straight lines in the original tool location point can be used as points to be smoothed, and a transition curve C is generated for each point to be smoothed. n (τ).
[0032] In this embodiment, when executing step S200, at the point B with the maximum curvature n The processing speed should be kept low to ensure the processing accuracy, avoid tool wear, avoid tool and workpiece vibration, improve processing quality, and obtain the maximum curvature point B. n The upper speed limit v en , can be used for B n The speed at the position is set to the maximum value, that is, to ensure that B n The velocity at is less than or equal to v en .
[0033] In this embodiment, by executing steps S300-S500, the tool mixed trajectory is interpolated to generate interpolation points corresponding to each interpolation cycle. The tool mixed trajectory and all interpolation points are integrated to obtain the tool trajectory diagram of the CNC machine tool, which can be used for workpiece processing of the CNC machine tool.
[0034] The CNC machining trajectory smoothing optimization and interpolation method of this embodiment is aimed at scenarios where CNC machine tools have dynamic specific constraints. It can generate transition curves between straight tool paths and perform speed planning and real-time interpolation on the transition curves. The speed planning takes into account the consistency of lateral speed and uses the fourth-order explicit Adams method for interpolation calculation. The interpolation method is highly efficient and accurate, which can meet the needs of real-time interpolation in CNC machining. While ensuring the quality of CNC machining, it improves the efficiency of CNC machining.
[0035] In an exemplary embodiment, in step S100, "based on the cubic B-spline smoothing method, generating a transition curve C at the point to be smoothed under the first set of constraints" n (τ)" may include steps S110-S120:
[0036] S110: Based on the first set of constraints, control points P0, P1, P2, P3, and P4 are obtained on the two end lines l1 and l2 of the point to be smoothed Q, where P0 and P1 pass through the line l1, P3 and P4 pass through the line l2, l1 and l2 intersect at P2, and the point to be smoothed Q coincides with P2, as shown in FIG. Figure 2 As shown;
[0037] S120: Generate a transition curve based on the control points P0, P1, P2, P3, and P4 under the first set of constraints using a cubic B-spline smoothing method and a knot vector U = [0, 0, 0, 0.5, 1, 1, 1, 1].
[0038] In this embodiment, τ∈[0,1], a=0,1,2,3,4, N a,3 (τ) is the cubic B-spline basis function, which satisfies the recurrence relationship: u i and u i+1 are two adjacent internal nodes in the node vector U = [0, 0, 0, 0.5, 1, 1, 1, 1].
[0039] In this embodiment, steps S110-S120 can be performed for each point Q to be smoothed, by obtaining control points P0, P1, P2, P3, P4, and generating a transition curve C based on the control points P0, P1, P2, P3, P4 and the node vector U. n (τ), that is, for N points to be smoothed, N transition curves C can be obtained by executing steps S110-S120. n (τ); The node vector U is a non-decreasing vector. Under the node vector U and the first set of constraints, it affects the transition curve C together with the control points P0, P1, P2, P3, and P4. n(τ) continuity, smoothness and shape; for each point Q to be smoothed, it can be used as a control point and recorded as control point P2.
[0040] In an exemplary embodiment, the first set of constraints may include condition 1, condition 2, and condition 3:
[0041] Condition 1: The transition curve C n The design parameters d1 and d2 of (τ) satisfy d2=2d1 to ensure that the transition curve C n (τ) maintaining curvature continuity with the adjacent straight line tool path, wherein |P0P1|=|P3P4|=d1, |P1P2|=|P2P3|=d2;
[0042] Condition 2: The design parameter d2 satisfies To ensure that the transition curve C n The error between (τ) and the control points P0, P1, P2, P3, and P4 is no greater than a preset error threshold ∈, where β is the angle between l1 and l2;
[0043] Condition 3: Ensure the transition curve C n (τ) at the point B where the curvature is maximum n The curvature at Closest to local curvature in, The local curvature is estimated by weighted least squares method based on P2 and its adjacent tool positions.
[0044] In this embodiment, the smoothing point Q coincides with P2, and the condition 1 ensures that the transition curve C n (τ) is continuous with the curvature of the adjacent straight line tool path, which ensures the continuity of the machine tool movement. The design of d2=2d1 can ensure that the transition curve C n The second-order derivative of the starting point and the end point of (τ) is 0. Under the constraint of condition 1, the transition curve C n (τ) Only d2 is left as the design parameter for design. At the same time, the design of |P0P1|=|P3P4|=d1, |P1P2|=|P2P3|=d2 ensures the transition curve C n (τ) symmetry; Conditions 2 and 3 give the constraints of the design parameter d2 to select a suitable d2, thereby determining the control points P0, P1, P3, and P4.
[0045] In this embodiment, in the condition 2, the transition curve C n The error between (τ) and the control points P0, P1, P2, P3, and P4 can be expressed by the transition curve C n The maximum distance e between (τ) and P0, P1, P2, P3, and P4 is expressed as follows: Figure 2 As shown, Then there is
[0046]
[0047] In this embodiment, in condition 3, the local curvature is estimated by the point to be smoothed Q and its adjacent tool position points. The arc least square method can be used to fit the local trajectory near the smoothing point Q, and in the fitting process, the corresponding weights are assigned to each adjacent tool position point and P2 to achieve the local curvature. The purpose of setting condition 3 is to ensure that the transition curve C n The curvature of (τ) is close to the local curvature estimated by the original tool position point, which improves the surface quality of machine tool processing. Because the trajectories of adjacent tool paths have high similarity, the local curvature is also similar, so the transition curve C generated at the corresponding position of the adjacent tool paths is n The curvature of (τ) is also similar. In the subsequent speed planning, when the tool is processed according to the transition curve, its speed is mainly determined by the curvature of the transition curve, which helps to indirectly ensure the lateral consistency of the tool speed. The lateral speed consistency means that the feed speed of the tool at the corresponding points of adjacent trajectories is as equal as possible. For the transition curve C n (τ), the curvature κ(τ) at any point is calculated as: Since the transition curve C n The symmetry of (τ) is that its curvature is at its maximum point B. n Located at τ = 0.5, substituting τ = 0.5 and d2 into the calculation formula of k(k), we can get the point B with maximum curvature. n The curvature at That is, the transition curve C n The maximum curvature k of (τ) max Determined solely by d2, the expectation Then the expected value of d2 is The formula in condition 2 can be combined Select the most appropriate value as d2.
[0048] In this embodiment, the first set of constraints provides constraints for the selection of control points P0, P1, P3, and P4. The combination of conditions 1, 2, and 3 ensures that the transition curve C n (τ) The continuity of the adjacent straight line tool path in the tangential direction, the transition curve C n (τ) due to its symmetry and computational simplicity, the N transition curves C generated n After (τ) is connected with the straight tool path, a curvature-continuous tool hybrid trajectory is formed, that is, the G2 continuity of the tool trajectory is achieved.
[0049] In an exemplary embodiment, step S200 may include step S210:
[0050] S210: For each transition curve C n (τ), obtain the maximum curvature point B according to the following formula n The upper speed limit v at en :
[0051]
[0052] In this embodiment, T s represents the interpolation period, k max Represents the transition curve C n (τ) in B n The curvature of the transition curve C n The second set of constraints corresponding to (τ) includes: the set value F of the speed command for the feed speed, the maximum interpolation bow height error δ max , maximum acceleration of the machine tool A max , maximum jerk of the machine tool J max .
[0053] In this embodiment, the transition curve C n The greater the curvature of (τ), the greater the acceleration, jerk, and bow height errors. Therefore, it is necessary to calculate the curvature maximum point B. n The speed limit is set at B n The radius of curvature at can be expressed as B n The motion at B is approximately a circular motion with a radius of ρ. n The upper speed limit v en To meet v en The calculation formula is, that is, in B n At this point, the tool speed should be less than or equal to v en Maintaining a low processing speed at the point of maximum curvature can ensure processing accuracy, avoid tool wear, avoid vibration of the tool and workpiece, and improve processing quality.
[0054] In an exemplary embodiment, in step S300, the method of scanning the tool hybrid trajectory using the forward and reverse speed extreme value and the 7-segment S-type speed planning method is used to select the N speed upper limits v en Under the constraint of , velocity planning is performed to obtain a velocity curve with continuous acceleration, which may include: based on the maximum curvature point B of each two adjacent n The speed curve is obtained by the speed curve segment between each two adjacent maximum curvature points B. n The speed curve segment between can be obtained based on steps S310-S340:
[0055] S310: The two adjacent maximum curvature points Bn Denoted as B i and B i+1 , and get the i To B i+1 The arc length L i , B i The v en Denoted as v ei , B i+1 The v en Denoted as v ei+1 ;
[0056] S320: Use F as slave B i To B i+1 The initial maximum expected velocity value v fi , from the speed v ei Start, use the 7-stage S-shaped speed planning method to accelerate to v fi , at speed v fi Uniform speed running time t i , and then use the 7-segment S-type speed planning method to decelerate to v ei+1 , generate an initial velocity curve segment, wherein the initial velocity curve segment satisfies the constraint condition: the maximum acceleration of the machine tool A max , the maximum jerk of the machine tool J max ;
[0057] S330: Perform the forward and reverse speed extreme value scan according to the initial speed curve segment to obtain the value of v ei Accelerate to v fi The acceleration distance, given by v fi Slow down to v ei+1 The deceleration distance and the uniform motion distance v fi t i , obtaining an initial arc length L according to the sum of the acceleration distance, the deceleration distance and the uniform motion distance;
[0058] S340: Compare the initial arc length L with the L i , if L > L i , solve the problem of satisfying L≤L i From B i To B i+1 The maximum expected speed v fi , and according to the maximum expected speed value v fi Obtained from B i To B i+1 The speed curve segment; if L≤L i , then the initial velocity curve segment is taken as the i To B i+1 The speed curve segment.
[0059] In this embodiment, by executing step S340, it is ensured that i To B i+1 The arc length L i , enough by v ei Accelerate to v fi , and then by v fi Slow down to v ei+1 .
[0060] In this embodiment, the N transition curves C generated n After (τ) is connected with the straight tool path, a mixed tool trajectory with continuous curvature is formed, that is, the G2 continuity of the tool trajectory is achieved. However, to achieve the smoothness of the actual tool movement, it is also necessary to plan a speed curve with continuous acceleration. By executing step S300, a speed curve with continuous acceleration and bounded acceleration can be obtained.
[0061] In this embodiment, when executing step S300, the tool mixed trajectory can be divided into N maximum curvature points B n As the dividing point, the tool mixed trajectory is divided into N+1 lines, among which the first line is from the starting point S of the tool mixed trajectory to the maximum curvature point B1, including the straight tool path starting from the starting point S and the first half of the transition curve C1(τ); the second line is from the maximum curvature point B1 to the maximum curvature point B2, including the second half of the transition curve C1(τ), the straight tool path and the first half of the transition curve C2(τ); the third line is from the maximum curvature point B2 to the maximum curvature point B3, including the second half of the transition curve C2(τ), the straight tool path and the first half of the transition curve C3(τ); the fourth to Nth lines are not repeated one by one; the N+1th line is the maximum curvature point B N To the end point E of the tool blend trajectory, including the transition curve C N The second half of (τ) and the straight line tool path extending to the end point E.
[0062] In this embodiment, between any two adjacent maximum curvature points B i and B i+1 The speed planning can be performed according to steps S310-S340. For the first line and the N+1 line, a method similar to steps S310-S340 can be used. For the first line, when executing step S320, the speed of the starting point S of the mixed trajectory can be set to v fi , in the straight line path with v fi At a constant speed, in the first half of the transition curve C1(τ), the speed v fi Gradually decelerate to v e1 For the N+1th line, when executing step S320, the speed of the end point E of the mixed trajectory can be set to v fi , on the transition curve C NThe second half of (τ), from the speed v eN Gradually increase the speed to v fi and at a speed v fi Run at a constant speed to the end point E of the mixed trajectory.
[0063] In this embodiment, the speed curve segments corresponding to the N+1 lines are connected to obtain the speed curve from the starting point S to the end point E of the tool mixed trajectory, as shown in FIG. Figure 3 shown.
[0064] In an exemplary embodiment, in step S310, "obtaining i To B i+1 The arc length L i ”, which may include steps S311-S313:
[0065] S311: From B i To B i+1 The arc length L i Denoted as the first curve, the second curve and the straight line path connecting the first curve and the second curve, wherein the first curve is B i To B i The transition curve C n (τ) is the end point, the second curve is B i+1 The transition curve C n (τ) from the starting point to B i+1 ;
[0066] S312: Use the first curve or the second curve as a curve to be calculated, and divide the curve to be calculated into M integral intervals of different lengths [τ a ,τ b ], and the three-node Gauss-Legendre integration method with adaptive step size is used to calculate each of the integral intervals [τ a ,τ b ]The corresponding arc length l z , the M arc lengths l z The sum is taken as the arc length of the curve to be calculated;
[0067] S313: The sum of the arc length of the first curve, the arc length of the second curve, and the length of the straight line tool path is used as the length from B i To B i+1 The arc length L i ;
[0068] In this embodiment, according to the formula Calculate the arc length l z , The arc length integrand g(τ) is given by the integration interval [τ a ,τ b] is mapped to the interval [-1,1] and the integral function is transformed. The arc length integrand is C x C n (τ) The component of the x-axis in the Cartesian coordinate system, C y C n (τ) The component of the y-axis in the Cartesian coordinate system, C z C n (τ) The component of the z-axis in the Cartesian coordinate system.
[0069] In this embodiment, for each integral interval [τ a ,τ b ]Calculate the corresponding arc length l z When the integral interval of the curve parameter τ is [τ a ,τ b ] to [-1,1], and map g(τ) to the integral function The value range of x is [-1,1], and the point x=-√0.6, x=0, Substitute the integral function The weights are According to the formula Calculate the integral interval [τ a ,τ b ]The corresponding arc length l z .
[0070] In this embodiment, when executing step S312, since the shape of the portion with larger curvature in the curve changes dramatically, when dividing the first curve or the second curve into integral intervals, the length of the integral interval τ in the portion with smaller curvature, that is, the portion closer to the straight line tool path, is b -τ a larger, and in the part with greater curvature, that is, the distance B i and B i+1 The length of the integration interval for the closer part is τ b -τ a Small, thus laying the foundation for the three-node Gauss-Legendre integration method with adaptive step size, which can ensure that the calculated i To B i+1 The arc length L i More accurate, reducing calculation errors; when dividing the integral interval, if an integral interval [τ a ,τ b] crosses an internal node in the node vector U, which will greatly reduce the accuracy of calculating the arc length, and the length of the integration interval applicable to different internal nodes is also different. We can first use the internal nodes of the node vector as the dividing points, and then further divide the integration interval between adjacent internal nodes according to the accuracy requirements, thereby improving the accuracy of calculating the arc length.
[0071] In this embodiment, the transition curve C obtained by cubic B-spline smoothing n (τ) has no analytical expression, the transition curve C n The arc length of (τ) can be calculated by numerical integration. In traditional calculation methods, the Simpson method is usually used for integration and iteration. In the nth iteration, the interval is divided into 2 equal parts. n The quadrature is calculated for each segment until the error between two iterations is less than the set tolerance. In order to achieve a certain accuracy, a large number of calculations must be performed, which is quite time-consuming. However, when executing step S312, this embodiment adopts the three-node Gauss-Legendre integration method with adaptive step size, which can achieve 5th-order algebraic accuracy and has more superior performance in terms of calculation accuracy. To achieve the same accuracy, only fewer integration intervals need to be divided, thereby reducing the amount of calculation and improving the efficiency of calculating arc length.
[0072] In this embodiment, by executing step S300, the tool mixed trajectory from the starting point S to the end point E and the speed curve with continuous acceleration are obtained, and then step S400 is executed to perform forward interpolation calculation on the tool mixed trajectory from the starting point S to the end point E using the speed curve, and the transition curve C1(τ) is converted to the transition curve C N (τ) performs forward interpolation calculation in sequence, and divides each transition curve into multiple interpolation cycles.
[0073] In an exemplary embodiment, step S400 of "calculating, in each interpolation cycle, a curve parameter value dτ for the current interpolation cycle according to the arc length dl for the current interpolation cycle, and solving dτ using a fourth-order explicit Adams method in a modified prediction-correction mode" may include: executing step S410 in each interpolation cycle:
[0074] S410: According to the formula Calculate the curve parameter value dτ for the current interpolation cycle. Convert the problem of solving dτ into an initial value problem of an ordinary differential equation and use the fourth-order explicit Adams method in the modified prediction-correction mode to solve it. The calculation expression is:
[0075]
[0076] In this embodiment, Δl iis the arc length of the i-th step, and the value of the curve parameter τ obtained by solving is τ i , then dτ=τ i+4 -τ i+3 , and is the intermediate result of the calculation.
[0077] In this embodiment, the fourth-order explicit Adams method is a numerical method for solving ordinary differential equations. The initial value can be obtained using a single-step method with the same compatible order, such as the single-step explicit RK4 (fourth-order Runge-Kutta) to obtain the initial value. To avoid solving implicit equations, the approximate value given by the explicit multi-step method is used. Computed The function value of the current interpolation period is replaced, and the estimated value and the correction value are corrected using the main term of the local truncation error of the Adams method to further improve the accuracy.
[0078] In this embodiment, compared with the traditional interpolation method based on Taylor expansion, the local truncation error of the fourth-order explicit Adams method can reach O(Δl 5 ), with higher accuracy; the fourth-order explicit Adams method using the modified prediction-correction mode avoids the implicit equation solving problem of the implicit multi-step method, and has a faster calculation speed than the fourth-order implicit Adams method; as a multi-step method, the fourth-order explicit Adams method only needs to calculate the value of f twice for each step forward on average, while the single-step explicit RK4 needs to calculate f four times for each step forward, which reduces the amount of calculation. Compared with the single-step explicit RK4, the fourth-order explicit Adams method is also more efficient; compared with the Newton iteration method for calculating the parameter τ, the fourth-order explicit Adams method does not require iteration, avoiding the problem of uncertain calculation time during the iteration process, which may consume a lot of time in some positions; therefore, the fourth-order explicit Adams method using the modified prediction-correction mode has both accuracy and efficiency, and is suitable for real-time interpolation of cubic B-spline curves.
[0079] In this embodiment, since the forward interpolation operation is performed on each transition curve, for each transition curve C n (τ), after being divided into multiple interpolation cycles, the curve parameter τ at the starting point of the first interpolation cycle is 0, the curve parameter τ at the end point of the first interpolation cycle is dτ calculated in the first interpolation cycle, the curve parameter τ at the end point of the second interpolation cycle is the sum of the curve parameter τ at the end point of the first interpolation cycle and dτ calculated in the second interpolation cycle, and the curve parameters τ of other interpolation cycles are not repeated one by one.
[0080] In an exemplary embodiment, the step S400 of "interpolating to the current transition curve C n(τ) When the end point is reached, the cumulative error of the tool mixed trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated. The steps S420-S430 may be included:
[0081] S420: Interpolate to the current transition curve C n (τ) When the end point is reached, the corresponding total arc length l is calculated according to the current interpolation cycle curve parameter value τ. real , and the total distance l corresponding to the current time t in the speed curve expect , according to formula l err =l real -l expect Obtain the cumulative error l err ;
[0082] S430: According to the formula Adjust the current transition curve C n (τ) The uniform speed running time t between the next transition curve i t i ', obtain the compensated speed curve, and perform the forward interpolation operation of the next transition curve according to the compensated speed curve.
[0083] In this embodiment, since interpolation on the straight line tool path does not produce cumulative errors, it is only necessary to interpolate on the transition curve C n (τ) is used to compensate for the error caused by interpolation, wherein the total distance l corresponding to the current time t in the speed curve expect is the expected value of arc length; when τ>1, it means that the transition curve C has been interpolated. n (τ) is the end point, at which point the corresponding total arc length l is calculated based on the current interpolation cycle curve parameter value τ. real , l real is the true value of the arc length, then for the transition curve C n (τ), the cumulative error is l err =l real -l expect ; l real The same three-node Gauss-Legendre integration method as in step S312 can be used to obtain l expect The velocity curve can be obtained by integrating; since the error of the 4th order explicit Adams method in step S410 is very small in each interpolation cycle, and calculating the error once in each interpolation cycle will cause the arc length calculation to be too large and the calculation efficiency is very low, the transition curve C of this embodiment can be used. n The end point of (τ) is used to compensate for the cumulative error, l realIt is approximately the sum of the arc lengths of the last interpolation cycle and all previous interpolation cycles, and the arc lengths of the previous interpolation cycles can be calculated before the last interpolation cycle. expect It can be accumulated from the dl of all interpolation cycles, so this compensation method has almost no computational overhead and will not reduce the overall interpolation speed.
[0084] In this embodiment, since the S-shaped speed curve is involved in the transition curve section, which is not conducive to compensation, step S430 can be executed to adjust the current transition curve C n (τ) and the uniform speed running section between the next transition curve.
[0085] In an exemplary embodiment, step S500 may include step S510:
[0086] S510: Perform the following operations for each curve parameter value τ: perform three recursive operations according to the De Boor recursive algorithm, and use the control point obtained by the third recursive operation as the interpolation point Q corresponding to τ. i .
[0087] In this embodiment, when executing step S510 for each curve parameter value τ, it is necessary to determine the node interval [u i ,u i+1 ], take out the node interval [u i ,u i+1 ] The four control points corresponding to the first recursive operation are used as the control points and are recorded as P i-3 、P i-2 、P i-1 、P i ; After the first recursive operation, three control points Q are obtained i-2,1 , Q i-1,1 , Q i,1 ; Then according to these three control points Q i-2,1 , Q i-1,1 , Q i,1 Perform the second recursive operation to obtain two control points Q i-1,2 , Q i,2 , and then according to these two control points Q i-1,2 , Q i,2 Perform the third recursive operation to obtain the final interpolation point Q i .
[0088] In order to illustrate the CNC machining trajectory smoothing optimization and interpolation method and its effect according to the embodiment of the present application, a specific example is described in detail below. The specific example includes steps S1-S14:
[0089] S1: Based on multiple original tool position points pre-set by the CNC machine tool, N points to be smoothed are obtained, and steps S2-S4 are performed at each of the points to be smoothed.
[0090] S2: Based on the first set of constraints, control points P0, P1, P2, P3, and P4 are obtained on the two end lines l1 and l2 of the point to be smoothed Q;
[0091] S3: Generate a transition curve based on the control points P0, P1, P2, P3, and P4 under the first set of constraints using the cubic B-spline smoothing method and the knot vector U = [0, 0, 0, 0.5, 1, 1, 1, 1]
[0092] S4: Obtain the transition curve C under the second set of constraints n (τ) at the point B where the curvature is maximum n The upper speed limit v en ;
[0093] S5: Set the N transition curves C n The original tool position points outside (τ) are set as straight tool paths, and all straight tool paths and N transition curves C n (τ) is spliced into tool hybrid trajectory;
[0094] S6: Use N points B with maximum curvature n Divide the tool mixed trajectory into N+1 segments, and in each segment B i and B i+1 Steps S7-S8 are performed between;
[0095] S7: Will be from B i To B i+1 The arc length L i Denoted as the first curve, the second curve and the straight line path connecting the first curve and the second curve, the first curve or the second curve is used as the curve to be calculated, and the curve to be calculated is divided into M integral intervals of different lengths [τ a ,τ b ], and the three-node Gauss-Legendre integration method with adaptive step size is used to calculate each of the integral intervals [τ a ,τ b ]The corresponding arc length l z , the M arc lengths l z The sum of the arc length of the first curve, the arc length of the second curve, and the length of the straight line tool path is taken as the arc length of the curve to be calculated. i To B i+1 The arc length L i ;
[0096] S8: Bi The v en Denoted as v ei , B i+1 The v en Denoted as v ei+1 , get from B i To B i+1 The speed curve segment is F as the speed curve from B i To B i+1 The initial maximum expected velocity value v fi ,, from the speed v ei Start, use the 7-stage S-shaped speed planning method to accelerate to v fi , at speed v fi Uniform speed running time t i , and then use the 7-segment S-type speed planning method to decelerate to v ei+1 , generate an initial velocity curve segment, perform the forward and reverse velocity extreme value scan according to the initial velocity curve segment, and obtain the velocity extreme value of v ei Accelerate to v fi The acceleration distance, given by v fi Slow down to v ei+1 The deceleration distance and the uniform motion distance v fi t i , obtain the initial arc length L according to the sum of the acceleration distance, the deceleration distance and the uniform motion distance; compare the initial arc length L with the L i , if L > L i , solve the problem of satisfying L≤L i From B i To B i+1 The maximum expected speed v fi , and according to the maximum expected speed value v fi Obtained from B i To B i+1 The speed curve segment; if L≤L i , then the initial velocity curve segment is taken as the i To B i+1 The speed curve segment;
[0097] S9: splicing the N+1 speed curve segments to obtain the speed curve from the start point to the end point of the tool hybrid trajectory;
[0098] S10: Perform forward interpolation calculation from the start point to the end point of the tool mixed trajectory according to the speed curve, and perform interpolation calculation on each transition curve C in turn. n (τ) Execute steps S11-S13 to implement forward interpolation operation;
[0099] S11: In each interpolation cycle, the curve parameter value dτ of the current interpolation cycle is calculated based on the arc length dl of the current interpolation cycle, dτ is solved using the fourth-order explicit Adams method in the modified prediction-correction mode, and the curve parameter value τ of the previous interpolation cycle is added to dτ to obtain the curve parameter value τ of the current interpolation cycle;
[0100] S12: interpolation to the current transition curve C n (τ) At the end point, the cumulative error of the tool hybrid trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated;
[0101] S13: Substitute the curve parameter value τ corresponding to each interpolation cycle into C n (τ) obtain interpolation points;
[0102] S14: Integrate the tool mixed trajectory and all interpolation points to obtain the tool trajectory diagram of the CNC machine tool.
[0103] Figure 4 A schematic diagram showing the generation of transition curves based on the original butterfly-shaped knife points is shown, with a zoomed-in display of the local transition curve in the upper right corner. Figure 5 A schematic diagram of the interpolation points generated after the CNC machining trajectory smoothing optimization and interpolation of the butterfly-shaped tool position point in the embodiment of the present application is shown, and the local interpolation points are magnified in the upper right corner; it can be seen that after smoothing and interpolation by the method of the embodiment of the present application, the machine tool tool moves along the transition curve path at the intersection of the straight lines, achieving trajectory continuity, and the speed can be adjusted at the maximum curvature of the transition curve, ensuring the smooth movement of the tool when processing the workpiece.
[0104] The embodiment of the present application also provides a CNC machining trajectory smoothing optimization and interpolation device, including a memory and a processor, such as Figure 6 As shown:
[0105] The memory is used to store the CNC machining trajectory smoothing optimization and interpolation program;
[0106] The processor is used to read the CNC machining trajectory smoothing optimization and interpolation program and perform the CNC machining trajectory smoothing optimization and interpolation method as described in the above embodiment.
[0107] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term "computer storage medium" includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media generally embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A method for smoothing optimization and interpolation of CNC machining trajectory, characterized in that: include: Based on the multiple original tool position points pre-set by the CNC machine tool, N points to be smoothed are obtained, and the following operations are performed at each point to be smoothed: Based on the cubic B-spline smoothing method, a transition curve C is generated at the point to be smoothed under the first set of constraints. n (τ), where n = 1, 2, ... N, and τ is the curve parameter; Under the second set of constraints, each transition curve C is obtained. n (τ) at the point B where the curvature is maximum n The upper speed limit v en ; The plurality of original tool positions are located on the N transition curves C n The original tool position points outside (τ) are set as straight tool paths, and all straight tool paths and N transition curves C n (τ) is spliced into a tool hybrid trajectory, and the tool hybrid trajectory is scanned by the forward and reverse speed extreme value method and the 7-segment S-type speed planning method at the N speed upper limits v en Perform velocity planning under the constraint of , and obtain a velocity curve with continuous acceleration; According to the speed curve, the tool mixed trajectory is calculated from the starting point to the end point in a forward interpolation manner, and each transition curve C is calculated in turn. n (τ) Perform the following forward interpolation operation: in each interpolation cycle, calculate the curve parameter value dτ of the current interpolation cycle according to the arc length dl of the current interpolation cycle, solve dτ using the fourth-order explicit Adams method in the modified prediction-correction mode, add the curve parameter value τ of the previous interpolation cycle to dτ to obtain the curve parameter value τ of the current interpolation cycle; interpolate to the current transition curve C n (τ) At the end point, the cumulative error of the tool hybrid trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated; For each of the transition curves C n (τ) Perform the following operations: Substitute the curve parameter value τ corresponding to each interpolation period into C n (τ) Get the interpolation point.
2. The CNC machining trajectory smoothing optimization and interpolation method according to claim 1, characterized in that: The cubic B-spline smoothing method generates a transition curve C at the point to be smoothed under the first set of constraints. n (τ), including: Based on the first set of constraints, control points P0, P1, P2, P3, and P4 are obtained on the straight lines l1 and l2 at both ends of the point Q to be smoothed, where P0 and P1 pass through the straight line l1, P3 and P4 pass through the straight line l2, l1 and l2 intersect at P2, and the point Q to be smoothed coincides with P2; According to the control points P0, P1, P2, P3, P4, a transition curve is generated based on the cubic B-spline smoothing method and the node vector U = [0, 0, 0, 0.5, 1, 1, 1, 1] under the first set of constraints. Among them, τ∈[0,1], a=0,1,2,3,4, N a,3 (τ) is the cubic B-spline basis function, which satisfies the recursive relationship: u i and u i+1 are two adjacent internal nodes in the node vector U = [0, 0, 0, 0.5, 1, 1, 1, 1].
3. The CNC machining trajectory smoothing optimization and interpolation method according to claim 2, characterized in that: The first set of constraints includes condition 1, condition 2, and condition 3: Condition 1: The transition curve C n The design parameters d1 and d2 of (τ) satisfy d2=2d1 to ensure that the transition curve C n (τ) maintaining curvature continuity with the adjacent straight line tool path, wherein |P0P1|=|P3P4|=d1, |P1P2|=|P2P3|=d2; Condition 2: The design parameter d2 satisfies To ensure that the transition curve C n The error between (τ) and the control points P0, P1, P2, P3, and P4 is no greater than a preset error threshold ∈, where β is the angle between l1 and l2; Condition 3: Ensure the transition curve C n (τ) at the point B where the curvature is maximum n The curvature at Closest to local curvature in, The local curvature is estimated by weighted least squares method based on P2 and its adjacent tool positions.
4. The CNC machining trajectory smoothing optimization and interpolation method according to claim 1, characterized in that: The step of obtaining each transition curve C under the second set of constraints n (τ) at the point B where the curvature is maximum n The upper speed limit v en ,include: For each of the transition curves C n (τ), obtain the maximum curvature point B according to the following formula n The upper speed limit v at en : Among them, T s represents the interpolation period, κ max Represents the transition curve C n (τ) in B n The curvature of the transition curve C n The second set of constraints corresponding to (τ) includes: the set value F of the speed command for the feed speed, the maximum interpolation bow height error δ max , maximum acceleration of the machine tool A max , maximum jerk of the machine tool J max .
5. The CNC machining trajectory smoothing optimization and interpolation method according to claim 4, characterized in that: The tool hybrid trajectory adopts the forward and reverse speed extreme value scanning method and the 7-segment S-type speed planning method to en Perform velocity planning under the constraints of , and obtain a velocity curve with continuous acceleration, including: Based on every two adjacent maximum curvature points B n The speed curve is obtained by the speed curve segment between each two adjacent maximum curvature points B. n The speed curve segments between are obtained based on the following steps: The two adjacent maximum curvature points B n Denoted as B i and B i+1 , and get the i To B i+1 The arc length L i , B i The v en Denoted as v ei , B i+1 The v en Denoted as v ei+1 ; Take F as the slave B i To B i+1 The initial maximum expected velocity value v fi , from the speed v ei Start, use the 7-stage S-shaped speed planning method to accelerate to v fi , at speed v fi Uniform speed running time t i , and then use the 7-segment S-type speed planning method to decelerate to v ei+1 , generate an initial velocity curve segment, wherein the initial velocity curve segment satisfies the constraint condition: the maximum acceleration of the machine tool A max , the maximum jerk of the machine tool J max ; According to the initial speed curve segment, the forward and reverse speed extreme value scanning is performed to obtain the value of v ei Accelerate to v fi The acceleration distance, given by v fi Slow down to v ei+1 The deceleration distance and the uniform motion distance v fi t i , obtaining an initial arc length L according to the sum of the acceleration distance, the deceleration distance and the uniform motion distance; Compare the initial arc length L and the L i , if L > L i , solve the problem of satisfying L≤L i From B i To B i+1 The maximum expected speed v fi , and according to the maximum expected speed value v fi Obtained from B i To B i+1 The speed curve segment; if L≤L i , then the initial velocity curve segment is taken as the i To B i+1 The speed curve segment.
6. The CNC machining trajectory smoothing optimization and interpolation method according to claim 5, characterized in that: The acquisition from B i To B i+1 The arc length L i , include: Will start from B i To B i+1 The arc length L i Denoted as the first curve, the second curve and the straight line path connecting the first curve and the second curve, wherein the first curve is B i To B i The transition curve C n (τ) is the end point, the second curve is B i+1 The transition curve C n (τ) from the starting point to B i+1 ; The first curve or the second curve is used as the curve to be calculated, and the curve to be calculated is divided into M integral intervals of different lengths [τ a ,τ b ], and the three-node Gauss-Legendre integration method with adaptive step size is used to calculate each of the integral intervals [τ a ,τ b ]The corresponding arc length l z , the M arc lengths l z The sum is taken as the arc length of the curve to be calculated; The sum of the arc length of the first curve, the arc length of the second curve, and the length of the straight line tool path is taken as the length from B i To B i+1 The arc length L i ; According to the formula Calculate the arc length l z , The arc length integrand g(τ) is given by the integration interval [τ a ,τ b ] is mapped to the interval [-1,1] and the integral function is transformed. The arc length integrand is C x C n (τ) The component of the x-axis in the Cartesian coordinate system, C y C n (τ) The component of the y-axis in the Cartesian coordinate system, C z C n (τ) The component of the z-axis in the Cartesian coordinate system.
7. The CNC machining trajectory smoothing optimization and interpolation method according to claim 1, characterized in that: In each interpolation cycle, the curve parameter value dτ of the current interpolation cycle is calculated according to the arc length dl of the current interpolation cycle, and dτ is solved using the fourth-order explicit Adams method in the modified prediction-correction mode, including: The following operations are performed in each interpolation cycle: According to the formula Calculate the curve parameter value dτ for the current interpolation cycle. Convert the problem of solving dτ into an initial value problem of an ordinary differential equation and use the fourth-order explicit Adams method in the modified prediction-correction mode to solve it. The calculation expression is: Where, Δl i is the arc length of the i-th step, and the value of the curve parameter τ obtained by solving is τ i , then dτ=τ i+4 -τ i+3 , and is the intermediate result of the calculation.
8. The CNC machining trajectory smoothing optimization and interpolation method according to claim 5, characterized in that: The interpolation to the current transition curve C n (τ) When the end point is reached, the cumulative error of the tool mixed trajectory is determined according to the current interpolation cycle curve parameter value τ and the speed curve is compensated, including: Interpolate to the current transition curve C n (τ) When the end point is reached, the corresponding total arc length l is calculated according to the current interpolation cycle curve parameter value τ. real , and the total distance l corresponding to the current time t in the speed curve expect , according to formula l err =l real -l expect Obtain the cumulative error l err ; According to the formula Adjust the current transition curve C n (τ) The uniform speed running time t between the next transition curve i t i ', obtain the compensated speed curve, and perform the forward interpolation operation of the next transition curve according to the compensated speed curve.
9. The CNC machining trajectory smoothing optimization and interpolation method according to claim 2, wherein: The curve parameter value τ corresponding to each interpolation cycle is brought into C n (τ) obtain interpolation points, including: For each curve parameter value τ, the following operations are performed: three recursive operations are performed according to the De Boor recursive algorithm, and the control point obtained by the third recursive operation is used as the interpolation point Q corresponding to τ. i .
10. A CNC machining trajectory smoothing optimization and interpolation device, comprising a memory and a processor, characterized in that: The memory is used to store the CNC machining trajectory smoothing optimization and interpolation program; The processor is used to read the CNC machining trajectory smoothing optimization and interpolation program and perform the CNC machining trajectory smoothing optimization and interpolation method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Real-time smooth transition interpolation method of small high-speed and high-accuracy numerical control machining line segment
CN103699056A
Small line segment tool path local fairing method based on B-spline fitting and piecewise interpolation
CN112327758A