A method and device for globally smoothing a discrete trajectory
By obtaining the discrete curvature values of discrete trajectories and iteratively updating the control vertices, global path smoothing is performed using B-spline fitting curves. This solves the problems of tool path discontinuity and feed oscillation in CNC machining, achieving efficient path smoothing and error control.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TSINGHUA UNIVERSITY
- Filing Date
- 2024-12-31
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies lack a global smoothing method that can effectively reduce the number of control vertices and the amount of data processing, while ensuring fitting efficiency and effectively controlling errors, leading to discontinuities in tool paths and feed oscillations in CNC machining.
By obtaining the discrete curvature values of the discrete trajectory, the initial control vertices are determined, and the control vertices are iteratively updated based on the error objective function. Global path smoothing is performed using B-spline fitting of the curve, including judging the fitting error and inserting new control vertices to meet the error requirements.
It significantly improves the smoothness of the path, reduces speed and acceleration fluctuations, and improves the quality and efficiency of CNC machining.
Smart Images

Figure CN119828598B_ABST
Abstract
Description
Technical Field
[0001] This application relates to, but is not limited to, the field of numerical control technology, and in particular to a method and apparatus for global path smoothing of discrete trajectories. Background Technology
[0002] CNC machining is widely used in the production of free-form surface parts in aerospace, precision medical equipment, and the automotive industry. Typically, CNC machining generates toolpaths using a large number of G01 code segments composed of discrete data points and line segments. However, due to the discontinuities in the tangential direction and curvature of these paths, the machine tool needs to frequently accelerate and decelerate during machining, leading to feed oscillations, which in turn affect machining quality and reduce efficiency.
[0003] Studies have shown that smoothing the path of discrete trajectories is an effective method to solve the above problems.
[0004] High-order continuous spline parametric curves have been widely used in toolpath smoothing, mainly in two ways: one is as a corner transition curve for local smoothing, which is currently the mainstream method; the other is to use spline curves to approximate or interpolate the overall discrete trajectory for global smoothing. However, both methods have limitations: local smoothing, due to the small size of the discrete line segments, often results in large curvature extremes of the transition curve, which can cause machine tool speed fluctuations and weaken the smoothing effect. Moreover, each transition curve segment requires independent control vertices, so when the number of discrete line segments is large, the number of control vertices also increases, leading to high computational complexity and data processing volume. While global smoothing can ensure the continuity and smoothness of the toolpath, the fitting accuracy of global smoothing is directly related to the number and distribution of control vertices. Too many control vertices increase the computational load, while too few may lead to uncontrollable fitting errors, resulting in difficulties in controlling fitting errors.
[0005] In summary, existing technologies lack a global smoothing method that can effectively reduce the number of control vertices and the amount of data processing, while ensuring fitting efficiency and effectively controlling errors. Summary of the Invention
[0006] This application provides a method and apparatus for global path smoothing of discrete trajectories, which can effectively reduce the number of control vertices, reduce the amount of data processing, and effectively control the error while ensuring fitting efficiency.
[0007] This application provides a method for global path smoothing of discrete trajectories, including:
[0008] The discrete curvature values are obtained from the discrete data points in the discrete trajectory to be processed, and the initial control vertices of the discrete trajectory to be processed are determined based on the calculated discrete curvature values.
[0009] Based on the error objective function, the control vertices are iteratively updated starting from the initial control vertices to obtain the optimized fitting curve;
[0010] Determine whether the optimized fitting curve meets the fitting error requirement. If it does, output the discrete trajectory to be processed after global path smoothing and end the process. If it does not meet the error requirement, proceed to the next step.
[0011] Based on the parts that do not meet the fitting error requirements, a step is added to select new control vertices from discrete data points and update the node parameters, returning to the step of judging whether the optimized fitting curve meets the fitting error requirements.
[0012] In one exemplary instance, determining the initial control vertex of the discrete trajectory to be processed includes:
[0013] Calculate the discrete derivative values of the discrete data points in the discrete trajectory to be processed;
[0014] Calculate the discrete curvature value of the discrete data points in the discrete trajectory to be processed based on the calculated discrete derivative value;
[0015] The initial control vertex is selected from the discrete data points based on the calculated discrete curvature values.
[0016] In one exemplary instance, calculating the discrete derivative values of discrete data points in the discrete trajectory to be processed includes:
[0017] Calculate the cumulative chord length corresponding to the discrete data points in the discrete trajectory to be processed;
[0018] The discrete data points in the discrete trajectory to be processed are reconstructed using the cumulative chord length;
[0019] For each reconstructed discrete data point, a first discrete derivative value is obtained by weighting its neighboring points, and a second discrete derivative value is obtained by weighting its neighboring points based on the first discrete derivative value.
[0020] In one exemplary instance, the step of selecting initial control vertices from discrete data points based on calculated discrete curvature values includes:
[0021] Calculate the local curvature difference value for each discrete data point based on the discrete curvature value;
[0022] Traverse all discrete data points and determine the discrete data points that satisfy the extreme value condition as the initial control vertices.
[0023] In one exemplary instance, the extremum condition is: the local difference of curvature is a local maximum value and is greater than 0.
[0024] In one exemplary instance, the iterative update of the control vertices from the initial control vertex to obtain the optimized fitted curve includes:
[0025] Using the initial control vertex P i 0 Calculate the initial fitting curve using the node vector U corresponding to the defined fitting curve;
[0026] The error objective function is constructed, and the initial fitting curve is optimized by iteratively updating the control vertex to obtain the optimized fitting curve.
[0027] In one exemplary instance, the fitted curve is a B-spline fitted curve; the objective function of the error is an objective function that minimizes the approximation error.
[0028] In one exemplary instance, determining whether the optimized fitted curve meets the fitting error requirement includes:
[0029] The straight-line distance between each discrete data point and the optimized fitting curve is calculated as the fitting error. When all straight-line distances are less than the set fitting error threshold, the fitting error requirement is considered to be met.
[0030] In one exemplary instance, the step of adding a new control vertex from discrete data points and updating node parameters includes:
[0031] Each node interval where the fitting error exceeds the fitting error threshold is defined as an insertable interval, which contains at least two discrete data points;
[0032] Calculate the fitting error of the insertable interval and insert new nodes and corresponding control vertices into the insertable interval when the fitting error is greater than the fitting error threshold;
[0033] After the node insertion is completed, the newly inserted node corresponds to a new control vertex, and all nodes and the control vertex set are updated.
[0034] In one exemplary instance, the updated node parameters include:
[0035] Choose initial values for the node parameters, and use Newton's iteration method to calculate the node parameters until the stopping iteration condition is met, thus obtaining the updated node parameters.
[0036] In one exemplary instance, the step of calculating the node parameters using Newton's iteration method until the stopping iteration condition is met, and obtaining the updated node parameters, includes:
[0037] The fitted curve is subdivided to obtain the corresponding node intervals. The left and right endpoints of the node parameter with the minimum distance when all node intervals are traversed are selected as the guess intervals. Then, the guess intervals are traversed to obtain the initial values of the node parameters.
[0038] This application also provides a computer-readable storage medium storing computer-executable instructions for performing the method for global path smoothing of discrete trajectories as described in any of the preceding embodiments.
[0039] This application provides another computer device, including a memory and a processor, wherein the memory stores the following instructions executable by the processor: steps for performing the method for global path smoothing of discrete trajectories as described in any of the preceding claims.
[0040] This application also provides an apparatus for global path smoothing of discrete trajectories, comprising: a determination module, an optimization module, a judgment module, and a processing module; wherein,
[0041] The determination module is used to obtain discrete curvature values based on discrete data points in the discrete trajectory to be processed, and to determine the initial control vertices of the discrete trajectory to be processed based on the calculated discrete curvature values.
[0042] The optimization module is used to iteratively update the control vertices from the initial control vertices based on the error objective function to obtain the optimized fitting curve.
[0043] The judgment module is used to determine whether the optimized fitting curve meets the fitting error requirements. When the error requirements are met, the discrete trajectory to be processed after global path smoothing is output and the process ends. When the error requirements are not met, the process module is entered.
[0044] The processing module is used to add new control vertices from discrete data points and update node parameters for parts that do not meet the fitting error requirements, and then return to the optimization module to continue optimization.
[0045] The method and apparatus for global path smoothing of discrete trajectories provided in this application use fitted curves to globally smooth discrete line segments, which not only significantly improves the smoothing effect of the path, but also effectively reduces speed and acceleration fluctuations, thereby improving processing quality and efficiency.
[0046] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description
[0047] The accompanying drawings are used to provide a further understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0048] Figure 1 This is a flowchart illustrating the method for global path smoothing of discrete trajectories in an embodiment of this application.
[0049] Figure 2 This is a schematic diagram of the distribution of the initial control vertices selected by given discrete data points in an embodiment of this application;
[0050] Figure 3 This is a schematic diagram of the initial value search in the node parameter update in the embodiments of this application;
[0051] Figure 4 This is a schematic diagram showing whether node parameters are updated or not in the embodiments of this application;
[0052] Figure 5 This is a schematic diagram of the discrete trajectory smoothing results given in the embodiments of this application;
[0053] Figure 6 This is a schematic diagram of the fitting error after smoothing in an embodiment of this application;
[0054] Figure 7 This is a schematic diagram of the structure of the apparatus for global path smoothing of discrete trajectories in the embodiments of this application. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be arbitrarily combined with each other.
[0056] To facilitate understanding of this application, a more complete description will be provided below with reference to the accompanying drawings, which illustrate embodiments of the present application. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that the disclosure of this application will be thorough and complete.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0058] It is understood that the terms "first" and "second" used in this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0059] It is understood that the term "connection" in the following embodiments should be understood as "electrical connection," "communication connection," etc., if the connected circuits, modules, units, etc., have electrical signal or data transmission with each other.
[0060] When used herein, the singular forms of “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “comprising / including” or “having,” etc., specify the presence of the stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0061] Figure 1 This is a flowchart illustrating the method for global path smoothing of discrete trajectories in an embodiment of this application, as shown below. Figure 1 As shown, it may include:
[0062] Step 100: Obtain the discrete curvature value based on the discrete data points in the discrete trajectory to be processed, and determine the initial control vertex of the discrete trajectory to be processed based on the calculated discrete curvature value.
[0063] In one exemplary instance, the discrete trajectory to be processed can be, but is not limited to, the discrete trajectory of the tool tip in CNC machining.
[0064] In one exemplary instance, step 100 may include:
[0065] Calculate the discrete derivative values of discrete data points in the discrete trajectory to be processed;
[0066] Calculate the discrete curvature value of the discrete data points in the discrete trajectory to be processed based on the calculated discrete derivative value;
[0067] Initial control vertices are selected from discrete data points based on the calculated discrete curvature values.
[0068] In one exemplary instance, calculating the discrete derivative of discrete data points in the discrete trajectory to be processed may include:
[0069] Calculate the cumulative chord length corresponding to the discrete data points in the discrete trajectory to be processed;
[0070] Reconstruct discrete data points in the discrete trajectory to be processed using the cumulative chord length;
[0071] For each reconstructed discrete data point, a first discrete derivative value is obtained by weighting its neighboring points, and a second discrete derivative value is obtained by weighting its neighboring points based on the first discrete derivative value.
[0072] In one embodiment, for discrete data points D in a two-dimensional plane or three-dimensional space i =(x i ,y i ,z i (0 << i << n), where n represents the number of discrete data points minus one; initialize the starting point cumulative chord length parameter s0 = 0, and calculate its corresponding cumulative chord length parameter s i As shown in formula (1):
[0073]
[0074] In formula (1), |D k+1 -D k | represents the Euclidean distance between adjacent points; i represents the index of a trajectory point; n represents the upper bound of the index, which is the endpoint of the trajectory.
[0075] The discrete data points in the discrete trajectory to be processed are reconstructed using the cumulative chord length, that is, the discrete curve segment is represented by the chord length parameter as shown in formula (2):
[0076] D i (s i )={(x(s i ),y(s i ),z(s i ))},s i ∈{s0,s1,…,s n} (2)
[0077] Formula (2) uses the cumulative chord length parameter to reconstruct the discrete points into a function form.
[0078] In one embodiment, for each reconstructed discrete data point, the first discrete derivative, i.e., the first-order derivative, is obtained by weighted calculation using its neighboring points: D i ' (s i )={(x ' (s i ),y ' (s i ),z ' (s iThe calculation is shown in formula (3):
[0079]
[0080] Where m is the number of neighboring points.
[0081] In one embodiment, the second discrete derivative, i.e., the second-order derivative, is obtained by weighted calculation using its neighboring points based on the first discrete derivative value: D″ i (s i )={(x″(s i ),y"(s i ),z"(s i The calculation is shown in formula (4):
[0082]
[0083] In one exemplary instance, calculating the discrete curvature value of discrete data points in the discrete trajectory to be processed based on the calculated discrete derivative value may include:
[0084] Discretize the curvature of the continuous curve to obtain discrete curvature values, where the discrete data points in the discrete trajectory to be processed are the sampling points of the continuous curve.
[0085] In one embodiment, for a continuous function f(t) = (x(t), y(t), z(t)) (t0≤t≤t1) in three-dimensional space, the curvature κ(t) of the continuous curve is as shown in formula (5):
[0086]
[0087] In formula (5), f′(t) is the first derivative, representing the tangent vector of the curve; f″(t) is the second derivative, representing the acceleration vector of the curve; |f′(t)×f″(t)| is the modulus of the cross product of the first and second derivatives, representing the curvature of the curve; |f′(t)| 3 The first derivative is the cube of the magnitude of the first derivative, and the curvature is normalized to eliminate the scaling effect.
[0088] In one embodiment, the curvature of the discretized continuous curve is obtained by substituting the estimated discrete derivative value into formula (5) to obtain the discrete curvature value of the discrete data points in the discrete trajectory to be processed, as shown in formula (6):
[0089]
[0090] In formula (6), D′(s) and D″(s) represent the first discrete derivative value, i.e., the first-order derivative, and the second discrete derivative value, i.e., the second-order derivative, respectively; s represents the cumulative chord length parameter of the discrete data points.
[0091] In one exemplary instance, selecting initial control vertices from discrete data points based on calculated discrete curvature values may include:
[0092] Calculate the local difference of curvature for each discrete data point based on the discrete curvature values;
[0093] Traverse all discrete data points and determine the discrete data points that satisfy the extremum condition as the initial control vertices. In one embodiment, the extremum condition is: the local difference of curvature is a local maximum value and is greater than 0.
[0094] In one embodiment, the local curvature difference ξ of the discrete curvature values can be calculated according to formula (7). j :
[0095]
[0096] In formula (7), κ j σ represents the discrete curvature value of the j-th discrete data point; σ is a positive integer defining the neighborhood, representing the size of the neighborhood, determining the calculation range of the local curvature difference value, and affecting the sparsity of the selected control vertices; n is the number of discrete points. This represents the sum of the discrete curvature values of the first σ points before the j-th point. ξ represents the sum of discrete curvature values at points σ after point j, and the local curvature difference value. j This represents the difference between the discrete curvature value at point j and the average discrete curvature value of the neighborhood, reflecting whether the discrete curvature value at that point is significantly higher or lower than the local average.
[0097] In one embodiment, when the local curvature difference ξ corresponding to a certain discrete data point is satisfied... j The curvature local difference value is greater than the curvature local difference value corresponding to the previous discrete data point, and also greater than the curvature local difference value corresponding to the next discrete data point. Meanwhile, the curvature local difference value ξ corresponding to the current discrete data point... j When the value is greater than 0, the local difference value ξ of the curvature is... j The corresponding discrete data points are selected as the initial control vertices, as shown in formula (8):
[0098]
[0099] In formula (8), ξ i Let ξ be the local difference value of curvature corresponding to the i-th discrete data point. i-1 Let ξ be the local difference value of curvature corresponding to the (i-1)th discrete data point. i+1 It represents the local curvature difference value corresponding to the (i+1)th discrete data point.
[0100] Figure 2This is a schematic diagram of the distribution of initial control vertices selected from given discrete data points in an embodiment of this application. Taking the selection of 1000 discrete data points from the butterfly curve as initial points as an example, the algorithm shown in step 100 is applied to select the initial control vertices, such as... Figure 2 As shown in the butterfly curve on the left, when σ = 1, there are initially 137 control vertices (as indicated by the small black dots on the butterfly curve); Figure 2 As shown in the butterfly curve on the right, there are 84 initial control vertices when σ = 5 (as indicated by the small black dots on the butterfly curve).
[0101] In one embodiment, this application uses discrete derivative values to accurately calculate discrete curvature values, and selects the curvature extrema corresponding to the local difference curvature values that meet the conditions as the initial control vertices, thereby effectively compressing the amount of data while ensuring fitting accuracy.
[0102] Step 101: Based on the error objective function, iteratively update the control vertices starting from the initial control vertices to obtain the optimized fitting curve.
[0103] In one exemplary instance, step 101 may include:
[0104] Using the initial control vertex P i 0 Calculate the initial fitted curve using the node vector U corresponding to the defined fitted curve;
[0105] An error objective function is constructed, and the initial fitted curve is optimized by iteratively updating the control vertices to obtain the optimized fitted curve.
[0106] In one embodiment, the fitted curve includes, but is not limited to, a B-spline fitted curve.
[0107] In one embodiment, the error objective function may include, but is not limited to, an objective function that minimizes the approximation error, that is, an iterative update of the control vertex is guided by an asymptotic least squares iterative approximation method.
[0108] In an exemplary instance, taking the B-spline fitting curve as an example, the B-spline curve is first defined as shown in formula (9):
[0109]
[0110] In formula (9), P i Indicates the control vertex; B i,k (u) represents the B-spline basis function; U = [u0, u1, ..., u] nThe symbol ] represents the node vector. The node vector is a core concept in B-spline curves, used to define the effective range of the B-spline basis functions and control the positions where the curve shape changes. The node vector is an ordered numerical sequence used to divide parameter intervals and determine the continuity and smoothness between curve segments.
[0111] In one exemplary instance, the generation of node vectors may include: using discrete data points D i Calculate the parameter value ψ i According to the parameter value ψ i Generate node vectors.
[0112] In one embodiment, the parameter value ψ can be calculated according to formula (10). i :
[0113]
[0114] In formula (10), The parameter values corresponding to the endpoints are Ψ0 = 0 and Ψn = 1.
[0115] In one embodiment, the node vector can be generated according to formula (11):
[0116]
[0117] In formula (11), k is the order of the B-spline function and m is the number of control vertices.
[0118] In one embodiment, the basis functions can be calculated using the De Boor recursive relation, as shown in formula (12):
[0119]
[0120] In formula (12), B i,0 (u) is a zero-order basis function; B i,k (u) is a higher-order basis function; As a special case, in B-spline basis functions, It is a numerical processing convention to avoid errors in the calculation process.
[0121] In one exemplary instance, the initial control vertex P can be used via formula (13). i 0 The node vector U = [u0, u1, ..., u] corresponding to the defined fitted curve n Calculate the initial fitted curve:
[0122]
[0123] In formula (13), Bi (u)>0.
[0124] In an exemplary instance, taking the error objective function as the approximation error minimization objective function as an example, the matrix equation of the approximation error minimization objective function can be constructed using formula (14):
[0125] E(P)=(ZP-D) T (ZP-D) (14)
[0126] In formula (14), D = [D0, D1, ... D n ] T Z represents discrete data points; Z is a basis function matrix with elements Z. j,i =B i,k (u j Specifically, as shown in formula (15):
[0127]
[0128] In formula (15), k represents the matrix equation at the kth iteration.
[0129] In an exemplary example, taking the error objective function as the approximation of the minimum error objective function, the optimized fitting curve can be obtained by iteratively updating the control vertex to obtain the optimized fitting curve through formula (16):
[0130]
[0131] In formula (16), It is the distance between the j-th discrete data point and the point on the curve calculated by the corresponding node parameter at the k-th iteration, which is also the error between the current fitted curve and the discrete data point. It updates the distance the control vertex moves; is the position of the controlling vertex in the (k+1)th iteration; μ is a constant that affects the convergence speed of the iteration. Where λ max , λ min These are matrices ZZ T The maximum and minimum eigenvalues.
[0132] Thus, the B-spline curve of the (k+1)th iteration is shown in formula (17):
[0133]
[0134] Formula (17) is used to update the fitted curve based on the optimized control vertex to obtain the optimized fitted curve.
[0135] The initial and terminal points remain unchanged during the update iteration process, as shown in equation (18):
[0136]
[0137] In formula (18), This indicates that the first control vertex is the first discrete data point; This indicates that the final control vertex is the final discrete data point.
[0138] In one embodiment, the present application uses an incremental iterative approximation least squares method to fit discrete data points, which effectively avoids the numerical instability problem in large matrix operations of the traditional least squares method.
[0139] Step 102: Determine whether the optimized fitting curve meets the fitting error requirements. If the error requirements are met, output the discrete trajectory to be processed after global path smoothing and end this process. If the error requirements are not met, proceed to step 103.
[0140] In one exemplary instance, determining whether the optimized fitted curve meets the fitting error requirement may include:
[0141] The straight-line distance between each discrete data point and the optimized fitting curve is calculated as the fitting error. When all straight-line distances are less than the set fitting error threshold, the fitting error requirement is considered to be met.
[0142] In one embodiment, the fitting error can be calculated according to formula (19):
[0143] ε i =||D i -A(u i )||,i=0,1,…,n (19)
[0144] In formula (19), ε i Let be the error of the i-th discrete data point, if max(ε) i )≤ε o , ε o The set fitting error threshold is used. At this point, the objective function converges, which is considered to satisfy the fitting error requirement. The fitting curve with the minimum fitting error is obtained, and the final fitting curve A(u) is output, with node parameters u. i Represents discrete data point D i The process ends at the projection point on the fitted curve A(u).
[0145] Step 103: Based on the parts that do not meet the fitting error requirements, add new control vertices selected from the discrete data points and update the node parameters, then return to step 102.
[0146] In one exemplary instance, adding a new control vertex selected from discrete data points may include: adding a new control vertex among control vertices whose fitting error is greater than a fitting error threshold, inserting a new node. In one embodiment, it may include:
[0147] First, define the insertable interval: the interval in which each fitting error exceeds the fitting error threshold, i.e., the node interval, is: This interval contains at least two discrete data points.
[0148] Then, the fitting error of the interpolable interval is calculated, as shown in Equation (20):
[0149]
[0150] When the fitting error exceeds the fitting error threshold, new nodes and corresponding control vertices are inserted into the insertable interval. If the discrete data points within the insertable interval include only two points, such as D... j D j+1 Therefore, inserting a new node at the midpoint of the insertable interval is: If the number of discrete data points within the insertable interval exceeds two, such as D j D j+1 …D j+a The corresponding node parameter value is u, u j+1 …u j+a Therefore, the newly inserted node is: And it satisfies:
[0151]
[0152]
[0153] Finally, after the node insertion is completed, the newly inserted node will correspond to the new control vertex, updating all nodes and the control vertex set.
[0154] In one exemplary instance, the updated node parameters in step 103 may include:
[0155] First, select an initial value u0 for the node parameter, and use Newton's iteration method to calculate the node parameter until the stopping iteration condition is met, thus obtaining the updated node parameter.
[0156] In this embodiment of the application, the node parameter u i Represents discrete data point D i At the projection point location on the fitted curve A(u), the goal of updating the node parameters is to find the most suitable u. i Make discrete data points D i The projection onto curve A(u) results in the smallest error. The projection conditions satisfied by the projection process are shown in formula (21):
[0157] r(u)=9D-A(u))·A′(u)=0 (21)
[0158] In formula (21), D represents discrete data points, A(u) is the curve value of the fitted curve at parameter u, u is the nodal parameter value of the projection, and A′(u) is the first derivative of the fitted curve, representing the tangent vector of the fitted curve. The goal of updating the nodal parameters is to solve for the value of u so that the projection error r(u) is zero. In this embodiment, the nonlinear equation can be solved by Newton's iteration method.
[0159] In one exemplary instance, selecting an initial value u0 for the node parameters and using Newton's iteration method to calculate the node parameters until the stopping condition is met to obtain the updated node parameters can include:
[0160] The fitted curve is subdivided to obtain the corresponding node intervals. The left and right endpoints of the node parameter with the minimum distance when all node intervals are traversed are selected as the guess intervals. Then, the guess intervals are traversed to obtain the initial value u0 of the node parameter.
[0161] In one embodiment, the selection of the initial value u0 of the node parameter is very important for the convergence and efficiency of the iteration. A reasonable initial interval can be found by subdividing the curve and using the principle of minimum distance. Then, the initial interval can be further subdivided to find the point with the minimum distance as the initial value u0 of the node parameter.
[0162] In one embodiment, further subdividing the initial interval to find the point with the smallest distance as the initial value u0 of the node parameter may include:
[0163] First, calculate the search step size: from u ξ When searching to the right: From u ξ When searching to the left:
[0164] Next, taking the rightward search as an example, at each subdivision point, the projection error r(u) is calculated. k ):u k =u ξ +i·Δ right u, u k+1 =u ξ +(i+1)·Δ right u, determine if r(u) k )·r(u k+1 If r(u) ≤ 0, then k )·r(u k+1 If )≤0, then the initial values of the node parameters are... If r(u) k )·r(uk+1 If )>0, then the search is further refined, and a new step size is calculated. Continue searching, i.e., repeat the calculation of u. k =u k +i·Δu u k+1 =u k +(i+1)·Δu and determine r(u) k )·r(u k+1 )≤0 until Δu≤ε, where ε is a pre-set convergence error threshold;
[0165] If in the current interval [u ξ ,u ξ+1 [Does not exist u] k That is, r(u) cannot be satisfied. k )·r(u k+1 If the condition is ≤0, then try in the interval [u] on the left. ξ-1 ,u ξ The above search is performed within the range until the convergence error threshold is met.
[0166] During the search for the initial node parameter u0, after searching to the right or left, multiple candidate u0s may be found, i.e., a set of candidate points. In one embodiment, these candidate points can be evaluated, and the candidate point with the smallest distance error can be selected as the final initial node parameter u0. The distance d(u0) corresponding to each candidate point is |D|. i -A(u0)|, the candidate point corresponding to the minimum value is used as the final initial node parameter u0.
[0167] In one embodiment, this application proposes a node parameter update method that improves fitting efficiency by iteratively updating the curve based on the fitting error to obtain a smooth path that meets the fitting accuracy requirements.
[0168] In one embodiment, taking the discrete trajectory to be processed as the discrete trajectory of the tool tip in CNC machining as an example, the embodiments of this application use a cubic B-spline curve to fit the discrete tool tip trajectory, thereby obtaining a smooth tool trajectory, compressing the amount of data, and strictly controlling the accuracy of the fitted curve.
[0169] Figure 3 This is a schematic diagram of the initial value search in the node parameter update in this application embodiment, such as... Figure 3 As shown, this demonstrates the use of multiple nodes (such as u0, u0…u ...…u…u……u……u……u……u……u……u……u…… n The process of initial value search is performed. Vertex D represents the node that needs to be optimized, involving calculating distances d0 and d1. min ,d n+k+1 We need to determine the optimal initial node values, that is, find the candidate point with the smallest distance error as the final initial node parameter u0.
[0170] Figure 4 This is a schematic diagram showing whether node parameters are updated or not in the embodiments of this application. Figure 4 The left and right plots respectively show the trajectory fitting before and after the node parameter update, as shown in the figure. Figure 4 As shown, the trajectory without updated node parameters has a large error with the discrete points; while the updated node parameters optimize the fitting curve, making it smoother and closer to the discrete points.
[0171] After obtaining accurate initial values for the node parameters, continue with Newton's iteration method, using u i Let represent the parameter value obtained by the i-th Newton iteration method. The Newton iteration is shown in formula (22):
[0172]
[0173] In formula (22), u i The parameter value for the current node; r(u i ) is the projection error function, defined as: r(u i )=[A(u i )-D i ]·A′(u i );r′(u i Let r′(u) be the first derivative of the projection error function. It is defined as: r′(u) i )=[A(u i )-D i ]·A″(u i )+A′(u i )·A′(u i ).
[0174] Thus, starting from the initial value u0, calculate r(u i ) and r′(u i ), update u according to Newton's iterative formula (22) i+1 .
[0175] The convergence criterion can include any of the following conditions; that is, Newton's iteration terminates when any of the following conditions are met:
[0176] Distance error condition: |A(u i )-D i |≤η1, used for convergence determination of whether points coincide.
[0177] Cosine error condition: Used for convergence determination of whether the cosine value is zero.
[0178] Parameter change condition: |(u i+1 -u i )A′(u i )|≤η1.
[0179] In the above formula, η1 is used to measure whether the Euclidean distance is zero, and η2 is used to measure whether the cosine value is zero. In one embodiment, if either the distance error condition or the cosine error condition fails to converge, then a new u is calculated. i+1 In one embodiment, if the parameter changes little after multiple Newton iterations, the parameter change condition is checked again. If one of the following conditions is met—distance error condition, cosine error condition, or parameter change condition—the iteration stops.
[0180] Figure 5 This is a schematic diagram of the discrete trajectory smoothing processing result given in the embodiments of this application. Figure 5 In this context, linear path points represent discrete trajectories, and B-spline curves represent smoothed (i.e., polished) paths. For example... Figure 5 As shown, the smoothing results indicate that the optimized path is smoother and can better connect the original discrete trajectory points. Figure 6 This is a schematic diagram of the fitting error after smoothing in an embodiment of this application. Figure 6 In the diagram, the horizontal axis represents the cumulative arc length (unit: mm), and the vertical axis represents the error value (unit: mm). Taking a set error threshold of 0.02 mm as an example... Figure 6 As shown, the curve illustrates the fitting error at each point after smoothing, indicating that the error value is small and within the acceptable range.
[0181] The method for global path smoothing of discrete trajectories provided in this application uses a fitted curve to globally smooth discrete line segments, which not only significantly improves the smoothing effect of the path, but also effectively reduces speed and acceleration fluctuations, thereby improving processing quality and efficiency.
[0182] This application also provides a computer-readable storage medium storing computer-executable instructions for performing the method for global path smoothing of discrete trajectories as described in any of the preceding claims.
[0183] This application further provides a computer device, including a memory and a processor, wherein the memory stores the following instructions executable by the processor: steps for performing the method for global path smoothing of discrete trajectories as described in any of the preceding claims.
[0184] Figure 7 This is a schematic diagram of the structural composition of the apparatus for global path smoothing of discrete trajectories in an embodiment of this application, as shown below. Figure 7 As shown, it may include: a determination module, an optimization module, a judgment module, and a processing module; wherein,
[0185] The determination module is used to obtain discrete curvature values based on discrete data points in the discrete trajectory to be processed, and to determine the initial control vertices of the discrete trajectory to be processed based on the calculated discrete curvature values.
[0186] The optimization module is used to iteratively update the control vertices from the initial control vertices based on the error objective function to obtain the optimized fitting curve.
[0187] The judgment module is used to determine whether the optimized fitting curve meets the fitting error requirements. When the error requirements are met, the discrete trajectory to be processed after global path smoothing is output and the process ends. When the error requirements are not met, the process module is entered.
[0188] The processing module is used to add new control vertices from discrete data points and update node parameters for parts that do not meet the fitting error requirements, and then return to the optimization module to continue optimization.
[0189] The apparatus for global path smoothing of discrete trajectories provided in this application uses a fitted curve to globally smooth discrete line segments, which not only significantly improves the smoothing effect of the path, but also effectively reduces speed and acceleration fluctuations, thereby improving processing quality and efficiency.
[0190] Although the embodiments disclosed in this application are as described above, the content described is merely for the purpose of understanding this application and is not intended to limit this application. Any person skilled in the art to which this application pertains may make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in this application; however, the scope of patent protection of this application shall still be determined by the scope defined in the appended claims.
Claims
1. A method for global path smoothing of discrete trajectories, characterized in that, include: The discrete curvature values are obtained from the discrete data points in the discrete trajectory to be processed, and the initial control vertices of the discrete trajectory to be processed are determined based on the calculated discrete curvature values. A B-spline fitting curve is constructed using the node vectors corresponding to the initial control vertices and the defined fitting curve. The control vertices are then iteratively updated starting from the initial control vertices based on the error objective function that minimizes the approximation error to obtain the optimized fitting curve. Calculate the straight-line distance between each discrete data point and the optimized fitting curve as the fitting error. When all straight-line distances are less than the set fitting error threshold, output the discrete trajectory to be processed after global path smoothing and end this process; otherwise, proceed to the next step. Each node interval where the fitting error exceeds the fitting error threshold is defined as an insertable interval, which contains at least two discrete data points; new nodes are inserted into the insertable interval and corresponding new control vertices are selected from the discrete data points, and all node and control vertex sets are updated after the insertion is completed; The fitted curve is subdivided to obtain the corresponding node intervals. The left and right endpoints of the node parameter with the minimum distance when all node intervals are traversed are selected as the guess intervals. Then, the guess intervals are traversed to obtain the initial values of the node parameters. The node parameters are updated using Newton's iteration method until the stopping iteration condition is met. The process returns to the step of judging whether the optimized fitted curve meets the fitting error requirements.
2. The method according to claim 1, wherein, The determination of the initial control vertex of the discrete trajectory to be processed includes: Calculate the discrete derivative values of the discrete data points in the discrete trajectory to be processed; Calculate the discrete curvature value of the discrete data points in the discrete trajectory to be processed based on the calculated discrete derivative value; The initial control vertex is selected from the discrete data points based on the calculated discrete curvature values.
3. The method according to claim 2, wherein, The calculation of the discrete derivative values of discrete data points in the discrete trajectory to be processed includes: Calculate the cumulative chord length corresponding to the discrete data points in the discrete trajectory to be processed; The discrete data points in the discrete trajectory to be processed are reconstructed using the cumulative chord length; For each reconstructed discrete data point, a first discrete derivative value is obtained by weighting its neighboring points, and a second discrete derivative value is obtained by weighting its neighboring points based on the first discrete derivative value.
4. The method according to claim 2, wherein, The step of selecting initial control vertices from discrete data points based on the calculated discrete curvature values includes: Calculate the local curvature difference value for each discrete data point based on the discrete curvature value; Traverse all discrete data points and determine the discrete data points that satisfy the extreme value condition as the initial control vertices; The extreme value condition is: the local difference of curvature is a local maximum value and is greater than 0.
5. An apparatus for global path smoothing of discrete trajectories, comprising a memory and a processor, wherein, The memory stores the following instructions executable by the processor: steps for performing the method of global path smoothing of discrete trajectories as described in any one of claims 1-4.