Cutter path fairing method based on B spline curve
By fitting the original tool path into a B-spline curve and performing Fourier low-pass filtering and Rayleigh-Ritz optimization, the problem of curvature sudden change in the B-spline curve smoothing method is solved, and high-precision and efficient curve smoothing is achieved, suitable for CNC processing and industrial design.
Patent Information
- Application Number
- CN202510596526.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-12
AI Technical Summary
In existing CNC machining and industrial design, the smoothing method of B-spline curves is difficult to balance local feature retention and global smoothing, resulting in sudden curvature changes, machine tool vibration, tool wear and problems with product accuracy and appearance, and cannot meet the real-time response and multi-objective optimization needs of intelligent manufacturing and personalized customization.
The original tool path is fitted into a B-spline curve, Fourier low-pass filtering is used to process the curvature vector, and the second-order differential equation with boundary constraints is constructed. The Rayleigh-Ritz method is used to discrete and transform it into the least squares optimization problem. The light-concise curve is solved to meet the curvature continuity and position constraints.
It has achieved optimization of curvature rate change, improved CNC machining accuracy and efficiency, reduced tool wear, and is suitable for high-precision curve smoothing under complex constraints, and is suitable for many fields such as industrial product appearance design and vehicle path smoothing.
Smart Images

Figure CN120469343A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of numerical control machining, and in particular to a tool path smoothing method based on a B-spline curve. Background Art
[0002] In the field of modern manufacturing and design, curve smoothing technology is a core technology in scenarios such as CNC machining and industrial design. As the requirements for product precision, performance, and aesthetics increase, the limitations of traditional technologies are becoming increasingly apparent. In CNC machining, if there are sudden changes in curvature or inflection points in the tool path, it will cause machine vibration and increased tool wear, seriously affecting machining accuracy and efficiency. In precision machining, even uneven paths may cause surface defects on the mold, affecting product accuracy and appearance. In industrial design, curve smoothness is directly related to product function and aesthetics. For example, the aerodynamic performance of aerospace components and the drag coefficient and safety of automobile bodies all rely on smooth curves for optimization.
[0003] From a mathematical perspective, the core of curve smoothing is optimizing the curvature distribution, which requires continuous and gently varying curvature. However, parametric methods such as B-spline curves struggle to balance local feature preservation with global smoothing when adjusting control points, leading to over-smoothing or under-smoothing. Among existing smoothing methods, global optimization methods are computationally complex and prone to losing original features, local adjustment methods risk falling into local optima, and curvature filtering methods are parameter-sensitive and cumbersome to debug, making them difficult to meet practical needs.
[0004] In recent years, intelligent manufacturing and personalized customization have put forward higher requirements for the real-time response, multi-objective optimization and adaptive parameter selection of smoothing technology, and existing methods cannot effectively cope with it. Summary of the Invention
[0005] This specification provides a tool path smoothing method based on B-spline curves to overcome at least one technical problem existing in the related art.
[0006] The embodiment of the specification provides a tool path smoothing method based on a B-spline curve, comprising:
[0007] S1, import the original tool path in NC machining and the maximum allowable deviation value δ of smoothing max , fitting the original tool path into a B-spline curve
[0008] Among them, the symbol N i,k-1 (t) represents the vector defined at the node The k-order B-spline basis function on is used to describe the geometry of the tool path; the symbol d i Represents a control point, which indicates the key control position of the tool path in CNC machining;
[0009] Calculate the original curvature vector κ(t)n(t) of the B-spline curve and perform a curvature κ(t) with a cutoff frequency of ω c Fourier low-pass filtering is performed to obtain the smoothed target curvature vector Wherein, the symbol t represents the curve parameter;
[0010] S2, arc length parameter Reparameterize the B-spline curve and construct a boundary value problem of the second-order differential equation with Dirichlet boundary conditions:
[0011]
[0012] Among them, P(s) represents the curve after arc length parameterization, Symbol c(t k-1 ) represents the starting coordinates of the original tool path, symbol c(t n+1 ) represents the end point coordinates of the original tool path; the symbol L represents the total arc length of the curve, P′(0)=t0,P′(L)=t L , symbol t0 and symbol t L Respectively represent the tangent direction vectors of the curve at the starting point and the end point of the original tool path;
[0013] S3. Discretize the second-order differential equation based on the Rayleigh-Ritz method, construct the stiffness matrix A and the right-hand side term b, and generate the linear equation system Ap=b; wherein the elements of the stiffness matrix A are:
[0014]
[0015] The elements of the right-hand term b are:
[0016]
[0017] S4: Convert the solution of the linear equations into a constrained least squares optimization problem:
[0018]
[0019] subject to||d i -p i ||≤δ max ,i=1,...,n-1
[0020] d i =p i ,i=0,n
[0021] Among them, the symbol d i Indicates the original curve control vertex, p iIndicates the control vertex of the curve after smoothing;
[0022] S5, solve the least squares optimization problem, and output the solution that satisfies the endpoint position constraint (c(t k-1 ),c(t n+1 )) and the tangential constraint (t0,t L ) and the control vertex deviation does not exceed δ max Smoothing tool path curve.
[0023] In some optional embodiments, the node vector T of the original B-spline curve is retained during the discretization process of step S3, and the basis function N is converted to i,k-1 (t) is converted into basis functions in the arc length parameter domain To ensure the consistency of geometric reconstruction results.
[0024] In some optional implementations, in step S5 , the constrained least squares optimization problem is solved using methods including Lagrange multiplier method, QR decomposition method, and interior point method.
[0025] The beneficial effects of the embodiments of this specification are as follows:
[0026] The technical solution of this application effectively filters out high-frequency noise components by representing the original tool path as a B-spline curve and performing Fourier low-pass filtering on its curvature vector, laying the foundation for subsequent precise control of the curve shape; on this basis, a second-order differential equation model with boundary constraints is established, and the improved Rayleigh-Ritz numerical solution is used to solve it, which can fully utilize the boundary conditions to accurately control the direction of the curve; the linear system solution in the traditional Rayleigh-Ritz method is converted into a least squares optimization problem with constraints, and the deviation tolerance constraint is introduced to strictly limit the maximum allowable deviation between the smoothed curve and the original curve while ensuring the quality of the curve smoothing. The smoothing result obtained by this technical solution has significant optimization effects on indicators such as strain energy and curvature change rate, which not only improves the accuracy and efficiency of CNC machining and reduces tool wear, but is also applicable to many fields such as industrial product appearance design and vehicle path smoothing, achieving high-precision curve smoothing under complex constraints, and has good versatility and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of this specification or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0028] Figure 1A brief flow chart of a tool path smoothing method based on B-spline curves provided in an embodiment of this specification;
[0029] Figure 2 A schematic diagram of performing the smoothing of the curvature vector in step S1 is shown;
[0030] Figure 3 An example of applying the present invention to smoothing a B-spline curve is shown in FIG. From left to right, the original curve and the curves with different maximum allowable deviation values δ are shown. max The output result;
[0031] Figure 4 An example of applying the present invention to smooth a B-spline curve and a comparison of smoothing metric data are shown in FIG. 1 , where the original curve and the output results with different cutoff frequencies are shown from left to right. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0033] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of this specification and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to the process, method, product, or apparatus.
[0034] The present invention discloses a tool path smoothing method based on B-spline curves. The method is based on B-spline curves and takes into account boundary and starting point constraints. First, the original tool path is represented as a B-spline curve, and then the original curvature vector of the B-spline curve is subjected to Fourier low-pass filtering to effectively filter out high-frequency noise components in the curvature, thereby obtaining a smooth target curvature vector distribution. On this basis, a second-order differential equation model with boundary constraints is established, and an improved Rayleigh-Ritz numerical solution is adopted to solve it, and finally a target curve that meets the smoothing requirements is obtained. In order to accurately control the geometric deviation between the smoothed path and the original path, the present invention converts the linear system solution in the traditional Rayleigh-Ritz method into a least squares optimization problem with constraints. By introducing deviation tolerance constraints, the optimization model strictly limits the maximum allowable deviation between the smoothed curve and the original curve while ensuring the smoothing quality of the curve. The smoothing results obtained by this method have significant optimization effects on indicators such as strain energy and curvature change rate. It is not only suitable for CNC machining tool path optimization, but can also be applied to industrial product appearance design, vehicle path smoothing and other fields with high precision and strong practicality.
[0035] The technical solution of this application is described in detail below with reference to the accompanying drawings. Figure 1 A simplified flowchart of a tool path smoothing method based on a B-spline curve provided in an embodiment of this specification includes the following steps:
[0036] Step S1: Import the original tool path and the maximum allowable deviation value δ in NC machining max , fitting the original tool path into a B-spline curve
[0037] Among them, the symbol N i,k-1 (t) represents the vector defined at the node The k-order B-spline basis function on is used to describe the geometry of the tool path; the symbol d i Represents a control point, which indicates the key control position of the tool path in CNC machining;
[0038] Calculate the original curvature vector κ(t)n(t) of the B-spline curve and perform a curvature κ(t) with a cutoff frequency of ω c Fourier low-pass filtering is performed to obtain the smoothed target curvature vector Here, the symbol t represents the curve parameter.
[0039] In this step, the original tool path refers to the tool motion trajectory pre-planned based on product design requirements and machining techniques in processes involving tool motion, such as CNC machining. It serves as the initial state of tool path smoothing. In actual production, the original tool path is typically generated using computer-aided design (CAD) and computer-aided manufacturing (CAM) software. For example, based on a 3D model of the part to be machined, CAM software calculates the tool's motion trajectory in the machining space according to the specified machining parameters (such as tool type, cutting depth, feed rate, etc.) and machining strategy (such as down-cut or up-cut milling). This trajectory is represented as a series of discrete points, each containing the tool's position in space, typically represented by 3D coordinates (x, y, z). These discrete points are arranged sequentially according to the machining order, accurately depicting the tool's path during machining. When machining a complex mechanical part, the original tool path may consist of hundreds or even thousands of such discrete points, detailing the tool's motion from the starting position through the various parts of the part until the machining is complete.
[0040] In the technical solution of this application, the original tool path is the basis and object of tool path smoothing. The purpose of smoothing is to optimize the original tool path. Through specific algorithms and mathematical models, such as the method based on B-spline curves in the technical solution of this application, the original tool path is fitted into a B-spline curve, its original curvature vector is subjected to Fourier low-pass filtering, and a second-order differential equation model with boundary constraints is constructed and solved, thereby eliminating or reducing the problems existing in the original tool path, making the tool path smoother and more continuous, and meeting the requirements of actual processing and design. In the design of industrial product appearance, after the original tool path is smoothed, the product's appearance curve can be made more beautiful and in line with the principles of engineering mechanics; in CNC processing, the smoothed tool path can improve processing efficiency and product quality and reduce processing costs.
[0041] Symbol d i Indicates control points. In CNC machining scenarios, these points represent the key control positions of the tool path. Control points are key parameters in the construction of B-spline curves. i,k-1 (t) multiply and sum (i.e. ∑ i N i,k-1 (t)d i ), the specific shape of the B-spline curve can be determined. Symbol N i,k-1 (t) represents the vector defined at the node The k-order B-spline basis function on the B-spline curve is the core element of the B-spline curve. By combining different values of i (index of basis function) and t (parameter) with control points, complex and diverse curve shapes can be constructed. j(j=0,1,...,n+k) determines the domain and characteristics of the basis function. For example, the distribution of nodes affects the support interval of the basis function, which in turn affects the local controllability of the curve. The k-order (degree) determines the smoothness of the basis function and the basic shape of the curve. A higher order can make the curve smoother, but it will also increase the computational complexity and the difficulty of shape adjustment. In this step, it is used to describe the geometry of the tool path. i,k-1 The combination of (t) can accurately fit or construct the curve shape of the tool.
[0042] In this step, κ(t) (curvature) is a scalar that describes the degree of curvature of the curve at parameter t. Mathematically, for a parametric curve r(t), the curvature Here, the symbol r′(t) is the first-order derivative, r″(t) is the second-order derivative, and × represents the vector cross product. The larger the value of κ(t), the more sharply the curve is curved at that point. For example, on a circle, the curvature is constant and equal to the inverse of the circle's radius; on a straight line, the curvature is 0, indicating that the line is not curved. The symbol n(t) represents the unit normal vector, which is the tangent vector perpendicular to the curve at parameter t. The unit vector κ(t)n(t) is a unit vector pointing toward the concave side of a curve and is used to determine the direction of the curve's curvature. Combining the curvature κ(t) (which reflects the degree of curvature) with the unit normal vector n(t) (which reflects the direction of curvature) completely describes the curvature of the curve at parameter t. For example, for a plane curve, the curvature vector always points toward the concave side of the curve, and its modulus is equal to the curvature κ(t).
[0043] Maximum allowable deviation of smoothing δ max It is used to limit the maximum allowable difference between the smoothed curve and the original curve. When smoothing the tool path, this parameter can balance the smoothing effect and the degree of retention of the original path features. In the field of CNC machining, if the deviation between the smoothed tool path and the original path is too large, the processed product will not meet the design specifications. For example, in the processing of precision parts, dimensional accuracy is difficult to guarantee, which reduces product quality. If the deviation is too small, the purpose of smoothing may not be fully achieved, and the noise and roughness factors in the original path cannot be effectively eliminated. By setting a reasonable maximum allowable deviation value for smoothing, the key features of the original path can be maintained to the greatest extent while ensuring the smoothing effect, thereby ensuring the accuracy of machining or design. Maximum allowable deviation value for smoothing δ maxThe specific value of can be determined by comprehensively considering multiple factors such as processing accuracy requirements, product performance requirements, computing resources and time costs. For example, from the perspective of processing accuracy requirements, in processing scenarios with extremely high precision requirements, such as the manufacturing of aerospace parts, slight deviations may lead to serious consequences and affect the performance and safety of the aircraft. When processing aircraft engine blades, the shape accuracy of the blades is directly related to the efficiency and reliability of the engine. In this case, δ max The value should be set to a very small value, usually in the millimeter or even micron level, to ensure that the smoothed tool path is highly consistent with the original path and meet the high-precision processing requirements. For the processing of some ordinary mechanical parts, the accuracy requirements are relatively low, and δ max The value can be increased appropriately. When processing ordinary nuts and bolts, the shape deviation is allowed within a certain range. max The value can be set in a relatively loose numerical range while meeting the basic functions of the product, which can not only ensure the processing efficiency but also achieve a certain degree of smoothing effect.
[0044] In the above original tool path and the maximum allowable deviation value of smoothing δ max Based on the concept of This is because B-spline curves have many excellent properties that make them an ideal choice for fitting the original tool path. They are locally controllable, meaning that adjusting a control point only affects the local shape of the curve without having a global impact on the entire curve. This allows for more precise adjustments to the curve during the subsequent smoothing process. In addition, B-spline curves are flexible and can represent various complex curve shapes by adjusting control points and node vectors, effectively approximating the original tool path.
[0045] The specific fitting process is described below. The purpose of fitting is to find a set of suitable control points d i and node vector The generated B-spline curve is made as close as possible to the original tool path. A specific fitting method can be the least squares method. The basic idea of the least squares method is to determine the optimal control points and node vectors by minimizing the sum of the squares of the distances from the discrete points on the original tool path to the B-spline curve. Assume that there are m discrete points p on the original tool path. i (i=1,2,...,m), the expression of B-spline curve is where N i,k-1 (t) is the k-order B-spline basis function defined on the node vector T. The least squares method is to find the minimum value of the following objective function:
[0046]
[0047] By solving this optimization problem, we can get a set of optimal control points d i and node vector T, thereby completing the fitting of the original tool path to the B-spline curve.
[0048] Based on the above sub-steps, this step then calculates the original curvature vector κ(t)n(t) of the B-spline curve obtained by the above fitting, and performs a curvature correction with a cutoff frequency of ω on the original curvature vector κ(t)n(t). c Fourier low-pass filtering is performed to obtain the smoothed target curvature vector This step is explained in detail below.
[0049] The following is a brief introduction to the concept of curvature. Curvature is an important geometric quantity that describes the degree of curvature of a curve. For a B-spline curve, its curvature κ(t) can be calculated by the first-order derivative c′(t) and the second-order derivative c″(t) of the curve. The formula is:
[0050]
[0051] The symbol × represents the cross product operation of the vector, and the symbol ||·|| represents the modulus of the vector.
[0052] The original curvature vector is composed of the curvature value κ(t) of each point on the curve and the corresponding unit normal vector n(t), that is, κ(t)n(t). The unit normal vector n(t) can be obtained by projecting the second-order derivative c″(t) of the curve onto a plane perpendicular to the first-order derivative c′(t) and normalizing it. In actual calculations, a series of discrete parameter points t are usually selected in the parameter domain of the B-spline curve. i , calculate the curvature value and unit normal vector at each parameter point, and thus obtain a set of discrete original curvature vector data.
[0053] This step then performs a cutoff frequency ω on the original curvature vector κ(t)n(t) c Fourier low-pass filtering is a filtering method based on Fourier transform. Its basic principle is to convert the original curvature vector κ(t)n(t) from the time domain (parameter domain) to the frequency domain by setting a cutoff frequency ω c , filter out the high-frequency components above this frequency, retain only the low-frequency components, and then convert the processed frequency domain signal back to the time domain through inverse Fourier transform to obtain the smoothed curvature vector.
[0054] The following describes the process of Fourier low-pass filtering. In the specific operation, the original curvature vector κ(t)n(t) is first subjected to discrete Fourier transform DFT to convert it into a frequency domain signal. Then, according to the pre-set cutoff frequency ω c, the frequency domain signal with a frequency higher than ω c Finally, the processed frequency domain signal is subjected to inverse discrete Fourier transform IDFT to obtain the smoothed curvature vector The cutoff frequency ω in this step c The choice of is critical, it directly affects the filtering effect. If ω c If the value is set too high, high-frequency noise may not be effectively filtered out. c If it is set too low, the curve may be smoothed too much and some useful curvature information may be lost. c When choosing the specific value of , it is necessary to comprehensively consider factors such as the characteristics of the original tool path, the expected effect after smoothing, and computing resources. For example, in terms of the expected effect after smoothing, the expected effect of the smoothed curve determines the approximate range of the cutoff frequency. If the smoothed curve is expected to be highly smooth with almost no obvious curvature changes, such as when designing products such as aircraft airfoils that have extremely high requirements for surface smoothness, a lower cutoff frequency should be used. A lower cutoff frequency can suppress high-frequency components to a greater extent, making the curvature of the curve change more smoothly, meeting the strict aerodynamic requirements for airfoil surface smoothness. If you want to retain some detailed features of the original curve as much as possible while smoothing the curve, for example, in the design of industrial product appearance, there are some subtle changes in the product surface. In order to prevent these details from being lost due to excessive smoothing, you need to increase the cutoff frequency appropriately. At this time, the cutoff frequency can be set to a value that can balance the smoothing effect and detail retention, such as around 0.1Hz, which can achieve a certain degree of smoothing while retaining the key details of the original curve.
[0055] Through the above steps, the import, fitting, construction of the original tool path, and Fourier low-pass filtering are completed, which can lay the foundation for subsequent steps such as building a second-order differential equation model with boundary constraints.
[0056] Step S2: Using arc length parameter Reparameterize the B-spline curve and construct a boundary value problem of the second-order differential equation with Dirichlet boundary conditions:
[0057]
[0058] Among them, P(s) represents the curve after arc length parameterization, Symbol c(t k-1 ) represents the starting coordinates of the original tool path, symbol c(t n+1 ) represents the end point coordinates of the original tool path; the symbol L represents the total arc length of the curve, P′(0)=t0,P′(L)=t L , symbol t0 and symbol tL Respectively represent the tangent direction vectors of the curve at the starting point and end point of the original tool path.
[0059] In this step, the arc length parameter Reparameterize the B-spline curve, where ||c'(τ)|| represents the tangent vector modulus of the curve c(τ) at parameter τ, and the integral operation accumulates from t k-1 This parameterization method makes the new parameter t directly correspond to the geometric arc length of the curve, which can eliminate the possible unevenness of the original parameterization and provide a more reasonable parameter basis for subsequent analysis and processing based on geometric characteristics (such as curvature calculation and curve smoothing).
[0060] The constructed second-order differential equation with Dirichlet boundary conditions establishes the intrinsic connection between the second-order derivative of the curve and the curvature vector. By solving this equation, the curvature characteristics of the curve P(s) can be made to meet the curvature requirements after smoothing, achieving a smoothing effect. Boundary condition P(0)=c(t k-1 ) and P(L)=c(t n+1 ) Ensure that the smoothed curve P(s) is exactly the same as the original tool path at the endpoint, maintaining the basic direction and positioning of the path. It represents the total arc length of the curve from the starting point to the end point, clarifies the value range of the parameter s, and also provides a geometric scale basis for solving the equation. Tangential constraints P′(0)=t0 and P′(L)=t L It can ensure that the tangent direction of the smoothed curve at the endpoint is consistent with the original path, ensure the continuity and smooth transition of the curve at the endpoint, avoid sudden changes in direction, and make the smoothed path more in line with actual application requirements as a whole (such as smooth cutting in and out of the tool in CNC machining).
[0061] Step S3: Discretize the second-order differential equation based on the Rayleigh-Ritz method, construct the stiffness matrix A and the right-hand side term b, and generate the linear equation system Ap=b; wherein the elements of the stiffness matrix A are:
[0062]
[0063] The elements of the right-hand term b are:
[0064]
[0065] This step discretizes the second-order differential equation based on the Rayleigh-Ritz method, aiming to transform the continuous differential equation into a solvable system of linear algebraic equations. The specific explanation is as follows:
[0066] The Rayleigh-Ritz method is a numerical analysis technique used to discretize continuous differential equation problems. By selecting appropriate basis functions (here, spline basis functions), the problem of solving differential equations is transformed into the problem of solving a system of linear algebraic equations, which facilitates computer numerical calculations.
[0067] Element a of the stiffness matrix A i,j The calculation formula is In this formula, the first step is to integrate the parameter s, and the integrand is the product of the derivatives of the basis functions. Here is a spline basis function associated with parameter s. The second step uses the derivative of the arc length parameter s(t) s′(t) = ||c′(t)|| (c(t) is the original curve, c′(t) is its tangent vector) and converts the integral over s into the integral over t by replacing the variables ds = s′(t)dt = ||c′(t)||dt. The third step clarifies the equivalence between s′(t) and ||c′(t)|| and obtains the final integral form. The stiffness matrix elements reflect the "stiffness" relationship between the basis functions. Their calculation is based on the derivative of the basis function and the inverse of the modulus of the curve's tangent vector, reflecting the influence of the curve's geometric characteristics on discretization.
[0068] The elements of the right-hand term b are:
[0069]
[0070] The first step is to integrate s. The integrand is the product of the smoothed target curvature vector r(s) and the spline basis function. The second step is to convert the integral into the integral over t by replacing the variable ds = || c′(t) || dt. In the third step, substitute ( is the curvature after smoothing, is the corresponding unit normal vector).
[0071] After constructing the stiffness matrix A and the right-hand term b through the above steps, a linear equation system Ap = b is formed. Solving this system of equations yields the discretized parameter vector p, which in turn determines the smoothed curve. This discretization method transforms the complex differential equation into a linear algebraic operation, facilitating efficient solution using computer numerical algorithms (such as Gaussian elimination and iterative methods), providing a feasible numerical computational approach for achieving curve smoothing.
[0072] Step S4: Convert the solution of the linear equations into a constrained least squares optimization problem:
[0073]
[0074] subject to||d i -p i ||≤δmax ,i=1,...,n-1
[0075] d i =p i ,i=0,n
[0076] Among them, the symbol d i Indicates the original curve control vertex, p i Indicates the control vertex of the curve after smoothing.
[0077] During toolpath smoothing, simply smoothing the curve without considering deviations from the original path can cause the smoothed path to deviate from the original design intent and fail to meet practical application requirements. For example, in CNC machining, excessive deviations can cause the machined part to not meet design specifications. Therefore, this step aims to smooth the curve while limiting the smoothing deviation to an acceptable range by defining a constrained optimization problem.
[0078] In the previous step, the Rayleigh-Ritz method was used to discretize the linear equation system Ap=b, where A is the stiffness matrix, p is the unknown vector to be solved, and b is the right-hand side vector. In this step S4, the problem of solving this linear equation system is transformed into an optimization problem with constraints.
[0079] The objective function is defined as:
[0080]
[0081] The objective function here takes the form of half the squared 2-norm of a vector. Mathematically speaking, minimizing this objective function means making Ap as close as possible to b. This means adjusting p to achieve a relatively optimal solution to the linear equations, thereby indirectly optimizing the shape of the smoothing curve. In actual toolpath smoothing scenarios, this optimization method helps obtain a more reasonable smoothing curve while satisfying subsequent constraints.
[0082] At the same time, set constraints to control the smoothing deviation:
[0083]
[0084] Among them, d i represents the control points of the original B-spline curve, p i represents the control points of the smoothed B-spline curve, δ max The maximum allowable deviation of the smoothing is set in advance. The first constraint condition || d i -p i ||≤δ max, i=1,...,n-1 restricts the intermediate control points to ensure that the distance between the intermediate control points of the smoothed curve and the corresponding control points of the original curve does not exceed the maximum allowable deviation δ max This ensures that the smoothed curve maintains similarity in shape to the original curve in the middle of the curve, preventing excessive deformation of the curve shape during the smoothing process. For example, when machining complex molds, uncontrolled deviations at the intermediate control points can cause key details of the mold to change after smoothing, affecting the mold's precision and the quality of the final product.
[0085] The second constraint d i =p i , i = 0, n explicitly specifies that the starting and ending control points of the curve before and after smoothing must be identical. In practical applications, starting and ending points often have special significance. For example, in CNC machining, the tool's starting and ending positions are determined based on the machining process and part design and cannot be arbitrarily changed. This constraint ensures that the starting and ending positions of the smoothed curve are identical to those of the original curve, ensuring that the smoothing process does not alter the critical control points of the path.
[0086] Step S5: Solve the least squares optimization problem and output the solution that satisfies the endpoint position constraint (c(t k-1 ),c(t n+1 )) and the tangential constraint (t0,t L ) and the control vertex deviation does not exceed δ max Smoothing tool path curve.
[0087] This step solves the least-squares optimization problem, ultimately outputting a smoothed toolpath curve that is the optimal solution while satisfying all the aforementioned constraints. This ensures both the smoothness of the curve (smoothing out characteristics like curvature through least-squares optimization) and consistency with the original path in position, orientation, and key features. This smoothed path effectively reduces tool wear and improves machining accuracy and surface quality in CNC machining.
[0088] In an optional embodiment, the node vector T of the original B-spline curve is retained during the discretization process of step S3, and the basis function N is converted to i,k-1 (t) is converted into basis functions in the arc length parameter domain To ensure the consistency of geometric reconstruction results.
[0089] Node Vector It is the core element of the B-spline curve, which defines the B-spline basis function N i,k-1The support interval of (t) and the segmented nature of the curve directly determine the local geometric behavior of the curve (such as the number of curve segments and the domain of each segment). Preserving T during the discretization process in step S3 ensures structural consistency between the smoothing process and the original curve. This allows subsequent basis function-based operations (such as the construction of the stiffness matrix A and the right-hand term b) to inherit the topology and local properties of the original curve, avoiding structural disturbances or geometric distortion caused by changes in the node vectors.
[0090] Based on the above technical solutions, this application also provides some more specific technical solutions, which are explained below.
[0091] In an optional embodiment, the constrained least squares optimization problem is solved in step S5, and the methods used may include Lagrange multiplier method, QR decomposition method, and interior point method.
[0092] The following is a brief description of this method. First, the Lagrange multiplier method is used. This method transforms the constrained optimization problem into an unconstrained optimization problem by introducing Lagrange multipliers. Specifically, for the above constrained optimization problem, the Lagrange function is constructed. The symbol λ i Denotes the Lagrange multiplier. The partial derivatives of the Lagrange function with respect to p and λ are then taken and set to zero, resulting in a set of equations. Solving this system of equations yields the solution to the optimization problem. The advantage of the Lagrange multiplier method is its comprehensive theory and applicability to a wide range of constraints. However, in practical calculations, the introduction of too many Lagrange multipliers can increase computational complexity.
[0093] Let's talk about the QR decomposition method. QR decomposition is to decompose the matrix A into the product of an orthogonal matrix Q and an upper triangular matrix R, that is, A = QR. Using QR decomposition, the original linear equation system Ap = b can be transformed into Rp = Q T b, and then solve for p by back substitution. In constrained optimization problems, the QR decomposition method can be combined with other methods to solve the linear system. Its advantages include good numerical stability and certain advantages for large-scale matrix calculations.
[0094] The interior point method is a method that searches for the optimal solution within the constrained region. It starts from an initial point that satisfies the constraints and gradually approaches the optimal solution through continuous iteration. In each iteration, the interior point method updates the iteration point by solving an obstacle problem related to the original problem. The interior point method is effective in dealing with inequality constraints, can effectively avoid complex calculations on the boundary, and has a fast convergence speed. In this constrained optimization problem, the interior point method can directly deal with ||d i -p i ‖≤δ maxSuch inequality constraints are solved by iteratively adjusting the value of p so that both the objective function and the constraints are satisfied.
[0095] The following is an actual example to illustrate the content of the smooth curvature vector in step S1. In the tool path smoothing method based on B-spline curve and considering boundary and starting point constraints involved in the technical solution of this application, step S1 performs Fourier low-pass filtering on the curvature vector of the B-spline curve fitted to the original tool path, which is a key pre-step to achieve curve smoothing. Figure 2 This intuitively presents the effect of this processing process. Figure 2 In the figure, the black dotted line represents the original curvature value, which reflects the initial curvature state of the original tool path. In actual application scenarios such as CNC machining, the curvature of the original tool path may fluctuate and have high-frequency noise due to various factors. These fluctuations and noise will cause the tool path to be non-smooth, thereby affecting the machining quality or product performance. For example, in CNC machining, a sudden change in the original curvature will make the tool movement unstable, causing machine vibration and increased tool wear, which will ultimately affect the surface quality of the workpiece. The remaining lines represent the smoothed curvature values obtained by applying different parameters. The parameters here mainly refer to the cutoff frequency of the Fourier low-pass filter. The principle of Fourier low-pass filtering is to filter out signal components above the frequency by setting the cutoff frequency, and only retain low-frequency components. When processing the curvature vector of the B-spline curve, the cutoff frequency plays a key regulatory role. When the cutoff frequency is low, more high-frequency noise components are filtered out, and the resulting smoothed curvature vector changes more slowly, corresponding to Figure 2 The lines are smoother and the fluctuations are smaller. This means that the tool path after filtering can ensure better continuity and stability in subsequent processing or design applications, and effectively avoid the adverse effects caused by sudden changes in curvature. For example, in the design of industrial product appearance, gentle changes in curvature can make the product surface smoother, meeting aesthetic and engineering requirements. On the contrary, if the cutoff frequency is set higher, although more original curvature features can be retained, the filtering effect of high-frequency noise is relatively weak, and the smoothed curvature vector may still fluctuate to a certain extent. Figure 2 This is reflected in the relatively low smoothness of the lines. Figure 2 By comparing different lines in the figure, we can clearly see the optimization effect of Fourier low-pass filtering on the original curvature under different parameter settings when processing the curvature vector. This can provide an intuitive basis for selecting appropriate filtering parameters. In actual operation, technicians can refer to the following factors according to the processing accuracy requirements, product characteristics, etc. Figure 2 The filtering effects under different parameters are shown, and the optimal cutoff frequency is selected to obtain a smooth curvature vector that meets specific requirements, laying the foundation for subsequent steps such as building a second-order differential equation model with boundary constraints and solving the smoothing curve.
[0096] Figure 3 An example of applying the present invention to smoothing a B-spline curve is shown in FIG. From left to right, the original curve and the curves with different maximum allowable deviation values δ are shown. max The output result is: Figure 4 The comparison of the smoothing effect of Fourier low-pass filtering on the original curvature vector of the B-spline curve at different cutoff frequencies is shown in the figure. The Δω in the figure is a relative expression of the cutoff frequency. c =ω min +Δω(ω max -ω min ), where ω max and ω min are the maximum and minimum frequencies before filtering, respectively.
[0097] The following is a detailed explanation of it. In the previous article, it is mentioned that the original curvature vector κ(t)n(t) is processed by Fourier low-pass filtering with different cutoff frequencies to obtain the smoothed target curvature vector
[0098] Figure 4 In the figure, gray corresponds to the original curve, while the remaining colored curves (e.g., green, purple, and blue) correspond to the smoothed results at different cutoff frequencies. The cutoff frequency determines the frequency components retained during filtering: a lower cutoff frequency removes more high-frequency components, making the curve smoother, but with the potential loss of detail; a higher cutoff frequency retains relatively more high-frequency components, allowing the smoothed curve to maintain a certain degree of smoothness while retaining more of the original curve's features.
[0099] from Figure 4 It can be seen from the measurement data in the figure that as the cutoff frequency changes, the smoothness and morphological details of the curve show differences. This intuitively reflects that the technical solution of this application can be achieved by adjusting the cutoff frequency ω. c The principle of controlling the smoothing effect is to process the frequency components in the original curvature vector in a targeted manner through Fourier low-pass filtering, thereby achieving precise control of the smoothness of the curve and meeting the requirements of curve smoothness and feature retention in different application scenarios. For example, in precision machining scenarios with extremely high smoothness requirements, a lower ω c To filter out high-frequency noise to the greatest extent possible and ensure the smoothness of the tool path; in design scenarios where more original shape features need to be retained, the ω c , achieving a balance between smoothing and feature preservation. Figure 3 and Figure 4 Through visualization and data comparison, the specific impact of this technical operation on the curve shape is demonstrated, which is an intuitive presentation of the filtering and smoothing principle in the technical solution of this application.
[0100] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of an embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present invention.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A tool path smoothing method based on B-spline curve, characterized in that: The following steps are involved: S1, import the original tool path in NC machining and the maximum allowable deviation value δ of smoothing max , fitting the original tool path into a B-spline curve Among them, the symbol N i,k-1 (t) represents the vector defined at the node The k-order B-spline basis function on is used to describe the geometry of the tool path; the symbol d i Represents a control point, which indicates the key control position of the tool path in CNC machining; Calculate the original curvature vector κ(t)n(t) of the B-spline curve and perform a curvature κ(t) with a cutoff frequency of ω c Fourier low-pass filtering is performed to obtain the smoothed target curvature vector Wherein, the symbol t represents the curve parameter; S2, arc length parameter Reparameterize the B-spline curve and construct a boundary value problem of the second-order differential equation with Dirichlet boundary conditions: Among them, P(s) represents the curve after arc length parameterization, Symbol c(t k-1 ) represents the starting coordinates of the original tool path, symbol c(t n+1 ) represents the end point coordinates of the original tool path; the symbol L represents the total arc length of the curve, P′(0)=t0,P′(L)=t L , symbol t0 and symbol t L Respectively represent the tangent direction vectors of the curve at the starting point and the end point of the original tool path; S3. Discretize the second-order differential equation based on the Rayleigh-Ritz method, construct the stiffness matrix A and the right-hand side term b, and generate the linear equation system Ap=b; wherein the elements of the stiffness matrix A are: The elements of the right-hand term b are: Step S4: Convert the solution of the linear equations into a constrained least squares optimization problem: subject to||d i -p i ||≤δ max ,i=1,...,n-1 d i =p i ,i=0,n Among them, the symbol d i Indicates the original curve control vertex, p i Indicates the control vertex of the curve after smoothing; S5, solve the least squares optimization problem, and output the solution that satisfies the endpoint position constraint (c(t k-1 ),c(t n+1 )) and the tangential constraint (t0,t L ) and the control vertex deviation does not exceed δ max Smoothing tool path curve.
2. The tool path smoothing method based on B-spline curve according to claim 1, characterized in that: In the discretization process of step S3, the node vector T of the original B-spline curve is retained, and the basis function N is transformed into i,k-1 (t) is converted into basis functions in the arc length parameter domain To ensure the consistency of geometric reconstruction results.
3. The tool path smoothing method based on B-spline curve according to claim 1, characterized in that: In step S5, the constrained least squares optimization problem is solved using methods including Lagrange multiplier method, QR decomposition method, and interior point method.