Adaptive B-spline curve fitting method for weld seams based on 3D dense random point sets
Through the region growing method and adaptive B-spline curve fitting method, the efficiency and adaptability problems of weld path generation for 3D dense disordered point sets are solved, and smooth weld trajectory generation under assembly errors is achieved, which is suitable for robot welding.
Patent Information
- Application Number
- CN202510990599.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-18
AI Technical Summary
Existing automatic weld extraction methods lack a systematic means to sort scattered points when processing 3D dense disordered point sets, resulting in low efficiency and poor adaptability of weld path generation. In particular, it is difficult to generate smooth weld trajectories when assembly errors are large.
The region growing method is used to generate smooth spline curves from disordered discrete points. Through region segmentation, initial line fitting and sorting, region growing method B-spline curve fitting and mean sampling, adaptive fitting of 3D dense disordered point sets is achieved. KD tree and ball tree search are used to dynamically adjust the neighborhood range, and the point sequence is filtered by combining terminal tangent vector projection sorting.
It significantly improves the generation efficiency and adaptability of irregular weld trajectories, overcomes the dependence on CAD models, ensures the continuity and smoothness of the weld path, and is suitable for adaptive fitting of complex curved surface welds in robotic welding.
Smart Images

Figure CN120510220B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of robot automatic welding, and specifically provides a weld seam adaptive B-spline curve fitting method for 3D dense disordered point sets. Background Art
[0002] Automatic weld extraction, as an essential step in weld path programming, is one of the most important tasks in the robotic automatic welding process. Due to common positioning errors in assembly processes such as spot welding and threaded connections and in the clamping of welded parts, assembled welds usually have large individual differences. Therefore, unlike cut workpieces that can be precisely positioned and clamped, weld positioning during welding is a common problem. Compared to straight welds that only require locating the start and end points, arc welds formed by curved surfaces have larger and more difficult to predict path deviations due to assembly errors, making them a more difficult problem to handle. Quadratic surfaces are the most commonly used surfaces in welded parts, including typical surfaces such as ellipsoids, cylinders, paraboloids, cones, and hyperboloids.
[0003] Weld seam recognition methods are divided into two categories based on whether or not they involve surface segmentation. For weld seam extraction methods that don't involve surface segmentation, the basic idea is to traverse the point cloud using a specific feature extraction descriptor, classifying the points into two or more categories, typically including edge points or crease points that may lie on the weld trajectory. The descriptor can be selected as the angle of the normal vector projected onto the local tangent plane; eigenvectors of the covariance matrix of the points in the OBB (Oriented Bounding Box) or the curvature change can be used. For two-dimensional weld seams that can be represented on a plane, the weld seam is mostly obtained by pixel analysis of 2D images scanned by laser profilers. Some existing technologies exploit the pixel mapping relationship between 2D and 3D images to extract intersection lines from the 2D image, which are then mapped to a point cloud to obtain 3D scattered points. Some existing technologies perform semantic segmentation of V-butt joints by extracting pixels representing the weld centerline. Some existing technologies use neural networks to perform semantic segmentation and weld seam extraction on 2D images of narrow butt joints. These studies primarily estimate intersection curves based on boundary features in 2D or 3D images, which leads to greater uncertainty in the results. At the same time, without calculating the surface, it's impossible to simply calculate the welding gun's pose at a specific point along the weld path. A second approach involves identifying the surface and considering intersecting lines as possible welds. For straight welds formed by intersecting planes, a model-free approach can be used. Some existing technologies have proposed using RANSAC plane segmentation to identify multiple straight welds from arbitrarily placed planar welds. Compared to surface fitting, plane fitting doesn't require case-specific feature extraction, so fine-tuning the RANSAC algorithm is often used in these applications. In contrast, surface segmentation is typically model-based, requiring a 3D model (such as a CAD drawing) as a blueprint for surface recognition. In model-based applications, the model contains the necessary geometric information to determine whether a point within a specific region meets the criteria for being a point within a specific surface. Since the coordinates of the measured point cloud of the workpiece differ from those of the 3D model, a geometric relationship must be determined between the model and the point cloud. Point cloud registration is a common coordinate registration method that calculates the transformation from the discretized 3D model to the measured point cloud and further calculates the intersection lines. Some existing technologies use point cloud registration to obtain the poses of the workpiece and assembly point clouds, as well as the actual assembly point cloud. They then map the ideal weld in the model to the measured point cloud to extract scattered points representing the weld. Some existing technologies use a two-step ICP (Iterative Closest Point) registration method to register the measured pipe point cloud with the CAD model. The success of surface recognition through point cloud registration relies on the assumption that the assembly errors of the welded parts are sufficiently small, which is often not the case. Furthermore, point cloud registration is prone to local optima, especially for components with a certain degree of global symmetry.
[0004] After obtaining the surface, the weld can be obtained by calculating the intersection line. The ideal result is an analytical solution for the intersection line. Some existing techniques have studied weld extraction between two perpendicularly intersecting cylinders by geometrically modeling the cylinders and calculating an analytical solution for the intersection line. However, calculating an analytical solution becomes more difficult when the intersection is non-perpendicular. Furthermore, the problem becomes even more complex when different types of quadratic surfaces are involved. This conclusion can be confirmed in the open-source tool Sympy under loose testing: calculating the analytical solution to a quadratic equation with an intersection term (which can be approximated as a non-perpendicular intersection of quadratic surfaces) is very slow. Therefore, a common approach to obtaining the intersection curve is to approximate it by fitting a spline curve to the intersection points, which can be easily converted into a robot trajectory. However, due to random noise and occlusion in the point cloud, such as pre-assembled spot welds, this process is not as simple as it seems. The point density distribution on the surface intersection line is uneven, and there may even be large gaps, interrupting the continuous trajectory. Furthermore, existing techniques generally overlook a problem: the scattered points on the intersection obtained by the distance criterion from the surface are disordered and cannot be directly used for spline fitting. Some prior art techniques propose an MLS projection procedure to smooth the points, but do not perform spline fitting on the scattered points.
[0005] In summary, existing automatic weld extraction methods lack a systematic way to sort the scattered points of a weld, which is composed of disordered points. Given a known surface model of the weld, the discrete intersection points representing the weld characteristics obtained by using a distance threshold are disordered and cannot be directly used for spline curve fitting. Summary of the Invention
[0006] In view of this, the object of the present invention is to provide a weld seam adaptive B-spline curve fitting method for 3D dense disordered point sets, which uses a region growing method to generate a smooth spline curve from disordered discrete points.
[0007] In order to achieve the above object, the present invention provides the following technical solutions:
[0008] A weld seam adaptive B-spline curve fitting method for 3D dense disordered point sets includes the following steps:
[0009] Step 1: Obtain a 3D dense random point set: Obtain a 3D point cloud representing the complete geometric features of the weldment and fit an arbitrary quadratic surface from the 3D point cloud. When multiple quadratic surfaces are included, segment the point cloud into multiple regions using a region segmentation algorithm. Then, use a quadratic surface fitting algorithm to transfer the point clouds within each region to the quadratic surface, obtain the model parameters of each quadratic surface, and obtain a 3D dense random point set through quadratic surface intersection calculation.
[0010] Step 2: Initial line fitting and sorting: Select a starting point from the 3D dense random points, iteratively expand the neighborhood to perform line fitting, and calculate the root mean square error (RMSE). When the RMSE exceeds a preset threshold, terminate the iteration and sort the points in the neighborhood by projection value.
[0011] Step 3: Region growing method B-spline curve fitting and point set sorting: Based on the sorting results of step 2, a neighborhood is established at the end of the curve, and the end tangent vector projection sorting method is used to screen new points. The neighborhood range is dynamically adjusted through ball tree or KD tree search to determine the closedness of the curve. The new points are added to the control point set for B-spline fitting.
[0012] Step 4: Smooth B-spline curve fitting based on mean sampling: Perform mean sampling on the control point set obtained in step 3, use the ball tree to search for valid points in the neighborhood to obtain the mean point as the new control point, perform quadratic B-spline fitting, obtain a smooth B-spline fitting result, and extract the weld of the welded part.
[0013] Furthermore, in step 1, the region segmentation algorithm includes RANSAC, clustering and region growing method.
[0014] Furthermore, in step 2, the method steps for initial straight line fitting and sorting are:
[0015] 21) Preset the maximum root mean square error (RMSE) threshold for straight line fitting and the minimum number of initial neighborhood points K;
[0016] 22) Select any point from the point set and use the KD tree to search for its K nearest neighbors;
[0017] 23) Calculate the mean value and covariance matrix of the points in the neighborhood, perform eigenvalue decomposition on the covariance matrix, and take the eigenvector corresponding to the maximum eigenvalue as the direction vector of the line;
[0018] 24) Decentralize the coordinates of the points in the neighborhood by subtracting the average value, project the decentralized points onto the line direction vector, and obtain the projection value (one-dimensional projection coordinate value). Sort the points in the neighborhood according to the projection value.
[0019] 25) Multiply the projection value by the line direction vector to obtain the projection vector (i.e., the projection point of the decentralized point on the line); subtract the projection vector from the decentralized point to obtain the residual vector; modulus all residual vectors, calculate their square mean, and then take the square root to obtain the fitting error RMSE;
[0020] 26) Determine whether the current RMSE value exceeds the preset threshold: If so, end step 1 and output the ordered point set and line direction; if not, increase the K value and loop through step 22).
[0021] Furthermore, in step three, the method steps of region growing curve fitting are as follows:
[0022] 31) Preset the distance threshold between the beginning and the end of the curve and the ball tree search radius;
[0023] 32) Using the ordered point set output in step 1 as the initial control point set, fit the initial B-spline curve; using the end point of the current B-spline curve as the center, search for neighboring points using the ball tree search radius, and filter out points that already exist in the control point set and are marked as invalid;
[0024] If the neighborhood point set is empty after filtering, the KD tree is used to search for neighborhood points, and the K value increases until a new valid point is found or the termination condition is reached;
[0025] If a new valid point is found, calculate its distance to the end of the current curve; if the distance does not exceed the threshold of the distance between the beginning and the end, the curve is considered closed; otherwise, the curve is considered disconnected and the spline growth direction is reversed to the starting point of the curve. If it is disconnected again after reversal, it is determined that single curve fitting is impossible;
[0026] 33) Calculate the direction vector of the end point of the current B-spline curve;
[0027] 34) Projecting the points in the neighborhood onto the direction vector to obtain projection values; filtering out points whose projection values are smaller than the projection value of the end point and marking them as invalid points; sorting the remaining points in ascending order of projection values;
[0028] 35) Add the sorted neighborhood points to the control point set, re-fit the B-spline curve, and calculate the RMSE value of the fitting from the control points to the spline curve;
[0029] 35) Execute S32 repeatedly until all valid points in the disordered point set are traversed, and output the ordered control point set and the fitted B-spline curve.
[0030] Furthermore, the method for calculating the direction vector of the end point of the current B-spline curve is: taking the difference vector between the coordinates of the end point of the current B-spline curve and the penultimate control point as the direction vector.
[0031] Furthermore, in step 4, the method steps of smoothing B-spline curve fitting based on mean sampling are as follows:
[0032] 41) Preset the ball tree search radius for mean sampling;
[0033] 42) Starting from the first point of the ordered control point set output in step 3, use the ball tree search radius to search for neighboring points and filter out invalid points and points that have been averaged.
[0034] 43) Calculate the coordinate mean of the valid points in the neighborhood, use the mean point as the control point of the quadratic fitting, and mark the points in the neighborhood that have undergone the mean operation;
[0035] 44) Extract the next control point according to the point sequence obtained in step 3, and repeat step 42) until all control points are processed to obtain a sparse control point set;
[0036] 45) Using the sparse control point set to perform quadratic B-spline curve fitting, outputting a final smooth B-spline curve, and extracting the weld of the welded part.
[0037] Furthermore, a data structure that supports both KD tree and ball tree is used to implement neighborhood search, where KD tree is used for iterative search with dynamically expanded neighborhood range; ball tree is used for neighborhood search with fixed radius.
[0038] Furthermore, the B-spline curve adopts an open uniform B-spline (the curve passes through the first and last control points, and the tangent vector of the end point is collinear with the direction of the line connecting the last two points).
[0039] The beneficial effects of the present invention are:
[0040] The present invention is a weld seam adaptive B-spline curve fitting method for 3D dense random point sets. It addresses the problem of complex surface weld seam trajectory generation caused by assembly errors in robot welding, and breaks through the limitations of existing technologies through a three-stage adaptive fitting mechanism. First, the linear fitting error adaptive screening and projection sorting are used to effectively solve the disorder problem of discrete points of quadratic surface intersections, overcoming the strong dependence of traditional methods on CAD models; secondly, combined with the end tangent vector-guided region growing method, the robust conversion of random point sets to ordered control points is achieved through dynamic neighborhood search and projection value sorting, ensuring the path continuity of open / closed curves; finally, mean sampling quadratic fitting is used to optimize the distribution of control points while suppressing noise, generating a smooth B-spline trajectory that meets the requirements of welding gun movement. The present invention realizes the direct fitting of 3D dense random point sets under model-free conditions for the first time, significantly improving the generation efficiency and adaptability of irregular weld seam trajectories. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to make the purpose, technical solutions and beneficial effects of the present invention more clear, the present invention provides the following drawings for illustration:
[0042] Figure 1 This is a flow chart of the weld seam adaptive B-spline curve fitting method for 3D dense disordered point sets according to the present invention;
[0043] Figure 2 The figure is the actual test result; where: (0) is the 3D dense random point set output from step 1; (1) is the straight line fitting result output from step 2; (2)-(4) are the fitting results from step 3; (5) is the smooth B-spline curve obtained by fitting in step 4;
[0044] Figure 3 The point order is determined by the terminal tangent vector projection sorting method; the left figure is the terminal closest point sorting, and the right figure is the terminal tangent vector projection sorting;
[0045] Figure 4 Comparison between open uniform B-spline and non-open uniform B-spline;
[0046] Figure 5 is the B-spline curve fitting result; where: (a) the first fitting result; (b) the second fitting result;
[0047] Figure 6 is the process of fitting a B-spline curve from a set of random discrete points; where (a) to (g) are the first fitting process; (h) is the result of the second fitting process;
[0048] Figure 7 The B-spline curve fitting results of multiple quadratic surface intersections; where: (a) is the unprocessed discrete points of the surface intersections; (b) is the sampling points of the B-spline curve fitting results. DETAILED DESCRIPTION
[0049] The present invention will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention.
[0050] like Figure 1 As shown, the weld seam adaptive B-spline curve fitting method for 3D dense random point sets in this embodiment includes the following steps.
[0051] Step 1: Obtain a 3D dense random point set: Obtain a 3D point cloud that represents the complete geometric features of the weldment, and fit an arbitrary quadratic surface from the 3D point cloud. When multiple quadratic surfaces are included, the point cloud is divided into multiple regions using a region segmentation algorithm. The point clouds in each region are transferred to the quadratic surface using a quadratic surface fitting algorithm to obtain the model parameters of each quadratic surface. The 3D dense random point set is obtained through quadratic surface intersection calculation.
[0052] Specifically, this embodiment uses a 3D camera to capture a single-frame point cloud of the assembled welded part. However, due to field of view limitations, only local features of the welded part can be represented. To stitch together a complete point cloud from multiple frames of point cloud, it is necessary to integrate the coordinate systems of the 3D camera, welding robot, and turntable that fixes the workpiece with high precision to obtain a 3D point cloud that can represent the complete geometric features of the welded part.
[0053] This example establishes a general quadratic surface analytical model based on a 3D point cloud, based on a workpiece surface characterization method using a general quadratic surface fitting method. Specifically, by mathematically modeling the general quadratic surface fitting problem and optimizing the minimum algebraic residual, an analytical solution for the general quadratic surface is derived for a given point cloud, achieving an analytical representation of the workpiece surface in space.
[0054] This embodiment addresses the problem of workpiece identification in multi-workpiece welding and divides multi-workpiece point cloud recognition into two core tasks: "region segmentation" and "surface fitting." Specifically, region segmentation algorithms include RANSAC, clustering, and region growing. The quadratic surface fitting algorithm corresponds to a general quadratic surface fitting algorithm for three-dimensional point clouds. In this embodiment, a point cloud containing multiple quadratic surfaces is first segmented into multiple regions. The point clouds within each region are then passed to the quadratic surface algorithm to obtain the model parameters of each surface, thereby achieving automatic segmentation and recognition of multiple workpieces.
[0055] Step 2: Initial line fitting and sorting: Select any starting point from the 3D dense random points, iteratively expand the neighborhood to perform line fitting, and calculate the root mean square error (RMSE). When the RMSE exceeds the preset threshold, terminate the iteration and sort the points in the neighborhood by projection value.
[0056] The number of iterations in the line fitting process and the number of points included in the fitting result are adaptively adjusted based on the characteristics of the point set. Their purpose is to determine the initial ordered point set and region growth direction for the global B-spline fit. Given a given upper limit for the RMSE of the line fit, the more points included in the fitting result, the more robust the subsequent B-spline fit. Specifically, in this embodiment, the steps for the initial line fitting and sorting are as follows.
[0057] 21) Preset the maximum root mean square error (RMSE) threshold for straight line fitting and the minimum number of initial neighborhood points K (the minimum number of points for straight line fitting).
[0058] 22) Randomly select a point from the set of points and use a KD tree to search for its K nearest neighbors. The KD tree is chosen for the nearest neighbor search because it allows the neighborhood to be expanded by adjusting the number of points.
[0059] 23) For the points in the current neighborhood, calculate the mean value and covariance matrix of the points in the neighborhood, perform eigenvalue decomposition on the covariance matrix, and take the eigenvector corresponding to the maximum eigenvalue as the direction vector of the line.
[0060] 24) Decentralize the neighborhood by subtracting the average from the neighborhood's coordinates. This means subtracting the neighborhood's average from the current point to obtain a decentralized set of points. Project the decentralized points onto the line's direction vector using a vector dot product to obtain the projection value (one-dimensional projection coordinate value). Sort the neighborhood points by the projection value.
[0061] 25) Multiply the projection value by the line direction vector to obtain the projection vector (i.e., the projection point of the decentralized point on the line); subtract the projection vector from the decentralized point to obtain the residual vector; modulus all residual vectors, calculate their square mean, and then take the square root to obtain the fitting error RMSE.
[0062] 26) Determine whether the current RMSE value exceeds the preset threshold: If so, end step 1 and output the ordered point set and line direction; if not, increase the K value and loop through step 22).
[0063] After step 2 is completed, a series of points whose straight line fitting errors do not exceed the set value are obtained, and the order of these points is arranged along the fixed direction of the straight line.
[0064] Step 3: Region growing method B-spline curve fitting and point set sorting: Based on the sorting results of step 2, a neighborhood is established at the end of the curve, and the end tangent vector projection sorting method is used to screen new points; the neighborhood range is dynamically adjusted through ball tree or KD tree search to determine the closedness of the curve; the new points are added to the control point set for B-spline fitting.
[0065] Based on the results obtained in step 2, at the end of the currently fitted line (which becomes a B-spline curve from step 3), the region growing method is used to continuously increase the range of the point set used for B-spline fitting. During each B-spline fitting process, the tangent vector direction of the current spline curve end is used as the region growing direction, and the neighborhood of the spline curve end point is used as the scope for new points to be examined. The points in the neighborhood are sorted and filtered using the end tangent vector projection sorting method until all points are traversed.
[0066] The main purpose of this step is to sort the disordered point set under the premise of satisfying B-spline fitting; at the same time, it judges the closure of the spline curve and whether the disordered point set can be fitted into a single spline curve.
[0067] Specifically, in this embodiment, the method steps of region growing curve fitting are as follows.
[0068] 31) Preset the distance threshold between the start and end of the curve and the ball tree search radius. The distance threshold is used to determine whether the spline curve is closed. If it exceeds this value, it is considered an open curve; otherwise, it is considered a closed curve.
[0069] 32) Using the ordered point set output from step 1 as the initial control point set, fit an initial B-spline curve. Using the endpoint of the current B-spline curve (initially the line output from step 2) as the center, search for neighboring points using a ball tree search radius, filtering out points already in the control point set and those marked as invalid. Specifically, the nearest neighbor search method uses a ball tree because it allows the search radius to be set to limit the neighborhood size.
[0070] If the neighborhood point set is empty after filtering (removing existing points and invalid points) (meaning there are no new valid points within the current ball tree search range), the KD tree is used to search the neighborhood points, and the K value is increased by 1 until a new valid point is found or the termination condition is reached.
[0071] If a new valid point is found, its distance to the end of the current curve is calculated. If this distance does not exceed the threshold for the distance between the beginning and the end, the curve is considered closed. Otherwise, the curve is considered disconnected, and the spline growth direction is reversed to the curve starting point. If the curve is disconnected again after the reversal, it is determined that a single curve fit is not possible. In other words, in this embodiment, the curve growth direction reversal operation is only allowed to occur once globally. If, after the reversal, the curve is judged to be disconnected before all points are traversed, the current point set is considered unfittable using a single B-spline curve.
[0072] 33) Calculating the direction vector of the current B-spline curve end point. In this embodiment, the method for calculating the direction vector of the current B-spline curve end point is to take the difference vector between the coordinates of the current B-spline curve end point and the penultimate control point as the direction vector.
[0073] 34) Project the points in the neighborhood onto the direction vector to obtain projection values; filter out points whose projection values are smaller than the projection value of the endpoint and mark them as invalid points; sort the remaining points in ascending order by projection value. Specifically, this embodiment filters and sorts the points in the neighborhood based on the sorting results of the endpoint tangent vector projection. Points whose projection values are smaller than the projection value of the endpoint are points in the opposite direction of the curve growth direction and need to be marked as invalid points and removed from the current set of neighborhood points under investigation; the remaining points are sorted in ascending order by projection value.
[0074] 35) Add the sorted neighborhood points to the control point set, re-fit the B-spline curve, and calculate the RMSE value of the fitting from the control points to the spline curve.
[0075] 35) Execute S32 repeatedly until all valid points in the disordered point set are traversed, and output the ordered control point set and the fitted B-spline curve.
[0076] After step 3, a B-spline curve and a series of control points that meet the curve fitting requirements are obtained. The order of these points is arranged along the fixed direction of the spline curve. The points in the random point set that are not included in the fitting control points have been marked as invalid points and are no longer included in the scope of investigation.
[0077] Step 4: Smooth B-spline curve fitting based on mean sampling: Perform mean sampling on the control point set obtained in step 3, use the ball tree to search for valid points in the neighborhood to obtain the mean point as the new control point, perform quadratic B-spline fitting, obtain a smooth B-spline fitting result, and extract the weld of the welded part.
[0078] In order to avoid overfitting caused by too many control points, step 4 performs mean sampling and quadratic fitting on the point set according to the point order after the three sorting to obtain a smooth B-spline fitting result. Specifically, in this embodiment, the method steps of smooth B-spline curve fitting based on mean sampling are as follows.
[0079] 41) Preset the ball tree search radius for mean sampling. The size of this value determines the sparsity of the control points of the quadratic B-spline fitting.
[0080] 42) Starting from the first point of the ordered control point set output in step 3, use the ball tree search radius to search for neighboring points and filter out invalid points and points that have undergone mean operations.
[0081] 43) Calculate the coordinate mean of the valid points in the neighborhood, use the mean point as the control point of the quadratic fitting, and mark the points in the neighborhood that have undergone the mean operation.
[0082] 44) Extract the next control point according to the point sequence obtained in step 3 (skip invalid points and points that have been averaged), and repeat step 42) until all control points are processed to obtain a sparse control point set.
[0083] 45) Use the sparse control point set to perform quadratic B-spline curve fitting, output the final smooth B-spline curve, and extract the weld of the welded part.
[0084] In this embodiment, the B-spline curve adopts an open uniform B-spline, and the curve passes through the first and last control points.
[0085] In this embodiment, a data structure that supports both KD trees and ball trees is used to implement neighborhood search, enabling single-time construction and multiple reuse, achieving efficient computation. KD trees are used for iterative searches with dynamically expanding neighborhoods, while ball trees are used for neighborhood searches with a fixed radius.
[0086] The specific implementation method of the surface weld extraction of the weld adaptive B-spline curve fitting method for 3D dense random point sets in this embodiment is further described below.
[0087] Similar to the intersection line calculation of plane intersection, the intersection line of quadratic surfaces needs to satisfy two quadratic surface equations at the same time:
[0088]
[0089]
[0090] in: is the point coordinate (expressed as a four-dimensional vector ); and The matrix of two intersecting quadratic surfaces is a fourth-order parameter matrix.
[0091] However, when quadratic intersection terms exist in the surface model, the analytical solution to this equation is difficult to obtain. Considering that the ultimate goal is to calculate the robot welding path, and this application requires a numerical solution, we consider fitting the discrete points near the surface intersection line into a B-spline curve.
[0092] 1. Open uniform B-spline curve.
[0093] The B-spline curve is expressed as:
[0094]
[0095] in: is the control point, ; for Step ( times) basis functions.
[0096] In this embodiment, open uniform B-splines are used. Figure 4 A comparison of open uniform B-spline, general uniform B-spline, and open non-uniform B-spline curves is shown. Compared with the latter two, open uniform B-spline ensures that the B-spline curve passes through the first and last control points, that is:
[0097]
[0098] In addition, since the knot vectors are evenly distributed, the smoothness of the open uniform B-spline is relatively uniform everywhere.
[0099] Therefore, in order to fit the discrete points near the surface intersection line into a B-spline curve, it is necessary to solve the following spline function
[0100]
[0101] in: is the output B-spline curve; is a series of vectors defined on the nodes Order regularized B-spline function. Since we are considering the intersection of quadratic surfaces, we choose (The corresponding B-spline function degree is 2). is the distance function.
[0102] 2. Two-stage B-spline fitting to solve the curved weld.
[0103] Although spline curve fitting is a mature technology, the premise for successful fitting is that the control points are arranged in order. Figure 6As shown in (a), the discrete intersection points obtained by the distance threshold are disordered and cannot be directly used for spline curve fitting. When studying the problem of identifying the weld of a three-way pipe formed by two cylindrical surfaces, the prior art uses a plane projection method to project the control points along the cylinder axis into the plane, and converts the three-dimensional spline fitting problem into a two-dimensional spline fitting problem. Since the projection of the intersection line of the cylinder along the cylinder axis falls within a circle of known shape, the order of the points in the fitting process can be easily obtained by traversing the circumference arc. However, the weld identification problem studied in this embodiment is a weld generated by the intersection of arbitrary quadratic surfaces. The shape, position, whether it is closed, etc. of the weld are all unknown. Therefore, a new algorithm is needed to solve this problem.
[0104] (1) Determine the initial direction of the B-spline curve by straight line fitting.
[0105] To achieve adaptive B-spline fitting, it is necessary to first determine the initial direction of the B-spline fitting. The points in the neighborhood of any control point are fitted into a straight line and sorted according to the projection values of the relevant points in the direction of the line. Figure 6 (b) shows the results of the initial straight line fit.
[0106] (2) The region growing method guided by the terminal tangent vector is used to determine the point order of the spline curve.
[0107] After obtaining the initial direction and control point sequence of the B-spline curve, the region growing method guided by the terminal tangent vector is used to determine the order of the remaining control points, while filtering out invalid points that do not meet the B-spline fitting requirements. The tangent vector of the existing spline end point is used to sort and filter the points in its neighborhood, and the updated control points are fitted with B-spline to achieve region growing until all discrete points are traversed.
[0108] In order to verify the effectiveness of the terminal tangent vector projection sorting method in determining the point order, Figure 3 The nearest neighbor search method for the end (that is, the point closest to the current curve end control point is used as the next control point, such as Figure 3 As shown in the left figure) and the terminal tangent projection sorting method (as shown in Figure 3 It is not difficult to see that the end tangent vector projection sorting method can effectively avoid the spline curve path from making a sharp turn or even causing the curve to grow in the opposite direction. The basic idea of the end tangent vector projection sorting method is to use the tangent vector of the current B-spline curve end point Provide a reference for the growth direction of the curve; All points in the neighborhood are projected onto , sorting these points in ascending order of projection value. Points with projection values less than the projection value of the current curve end point are marked as invalid points. The following is the relevant mathematical explanation.
[0109] Consider the differentiation of the recursive form of a B-spline curve:
[0110]
[0111] We can get:
[0112]
[0113] Under the premise of open uniform, the right end of the spline has ,exist Department, Only the last term in the sum is non-zero. Therefore, the tangent vector at the end point of the curve is:
[0114] From the above formula, we can see that the direction of the tangent vector at the end point is completely determined by the line vector between the two end points of the curve. Since we only care about the direction of the tangent vector, we can directly set:
[0115]
[0116] Note that since the number of control points of the B-spline is growing, the index in the above formula Compared with the above formula The meanings are different. Represents the current fitting iteration number, Represents the current number of control points.
[0117] point About the current end point The projection value of is given by the following formula:
[0118]
[0119] Points with projection values less than 0, such as Figure 3 In the left picture and , because they are located behind the curve growth direction, they need to be discarded. The points with projection values not less than 0 are added to the control point sequence in the order of projection values from small to large, such as Figure 3 As shown in the picture on the right.
[0120] (3) Quadratic fitting smoothing spline
[0121] like Figure 5As shown in (a), after the region growing method is used, the discrete points are reordered and the spline curve path is repaired. However, due to the uneven density of points in the point cloud, the spline curve obtained at this time is not smooth. Therefore, a second spline curve fitting is required. During this process, the neighborhood around each control point is averaged according to the sorted point order, and the average result is used as the next control point, as shown in the figure below. Figure 5 (b) shown.
[0122] 3. Algorithm implementation of the main steps of two-stage B-spline fitting.
[0123]
[0124] Figure 7 (a) shows the unprocessed surface intersection discrete points, Figure 7 (b) shows the results of B-spline fitting using the region growing method.
[0125] The above embodiments are merely preferred embodiments for the purpose of fully illustrating the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are within the scope of protection of the present invention. The scope of protection of the present invention shall be subject to the claims.
Claims
1. A weld seam adaptive B-spline curve fitting method for 3D dense random point sets, characterized by: The following steps are involved: Step 1: Obtain a 3D dense random point set: Obtain a 3D point cloud representing the complete geometric features of the weldment and fit an arbitrary quadratic surface from the 3D point cloud. When multiple quadratic surfaces are included, segment the point cloud into multiple regions using a region segmentation algorithm. Then, use a quadratic surface fitting algorithm to transfer the point clouds within each region to the quadratic surface, obtain the model parameters of each quadratic surface, and obtain a 3D dense random point set through quadratic surface intersection calculation. Step 2: Initial line fitting and sorting: Select a starting point from the 3D dense random points, iteratively expand the neighborhood to perform line fitting, and calculate the root mean square error (RMSE). When the RMSE exceeds a preset threshold, terminate the iteration and sort the points in the neighborhood by projection value. The steps for initial straight line fitting and sorting are: 21) Preset the maximum root mean square error (RMSE) threshold for straight line fitting and the minimum number of initial neighborhood points K; 22) Select any point from the point set and use the KD tree to search for its K nearest neighbors; 23) Calculate the mean value and covariance matrix of the points in the neighborhood, perform eigenvalue decomposition on the covariance matrix, and take the eigenvector corresponding to the maximum eigenvalue as the direction vector of the line; 24) Decentralize the coordinates of the points in the neighborhood by subtracting the average value, project the decentralized points onto the straight line direction vector, obtain the projection value, and sort the points in the neighborhood according to the projection value; 25) Multiply the projection value by the line direction vector to obtain the projection vector; subtract the projection vector from the decentralized point to obtain the residual vector; modulus all residual vectors, calculate their square mean and then take the square root to obtain the fitting error RMSE; 26) Determine whether the current RMSE value exceeds the preset threshold: If so, end step 1 and output the ordered point set and line direction; if not, increase the K value and loop through step 22); Step 3: Region growing method B-spline curve fitting and point set sorting: Based on the sorting results of step 2, a neighborhood is established at the end of the curve, and the end tangent vector projection sorting method is used to screen new points. The neighborhood range is dynamically adjusted through ball tree or KD tree search to determine the closedness of the curve. The new points are added to the control point set for B-spline fitting. Step 4: Smooth B-spline curve fitting based on mean sampling: Perform mean sampling on the control point set obtained in step 3, use the ball tree to search for valid points in the neighborhood to obtain the mean point as the new control point, perform quadratic B-spline fitting, obtain a smooth B-spline fitting result, and extract the weld of the welded part.
2. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: In the step 1, the region segmentation algorithm includes RANSAC, clustering and region growing method.
3. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: In step 3, the method steps of region growing curve fitting are as follows: 31) Preset the distance threshold between the beginning and the end of the curve and the ball tree search radius; 32) Using the ordered point set output in step 1 as the initial control point set, fit the initial B-spline curve; using the end point of the current B-spline curve as the center, search for neighboring points using the ball tree search radius, and filter out points that already exist in the control point set and are marked as invalid; If the neighborhood point set is empty after filtering, the KD tree is used to search for neighborhood points, and the K value increases until a new valid point is found or the termination condition is reached; If a new valid point is found, calculate its distance to the end of the current curve; if the distance does not exceed the threshold of the distance between the beginning and the end, the curve is considered closed; otherwise, the curve is considered disconnected and the spline growth direction is reversed to the starting point of the curve. If it is disconnected again after reversal, it is determined that single curve fitting is impossible; 33) Calculate the direction vector of the end point of the current B-spline curve; 34) Projecting the points in the neighborhood onto the direction vector to obtain projection values; filtering out points whose projection values are smaller than the projection value of the end point and marking them as invalid points; sorting the remaining points in ascending order of projection values; 35) Add the sorted neighborhood points to the control point set, re-fit the B-spline curve, and calculate the RMSE value of the fitting from the control points to the spline curve; 35) Execute S32 repeatedly until all valid points in the disordered point set are traversed, and output the ordered control point set and the fitted B-spline curve.
4. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: The method for calculating the direction vector of the end point of the current B-spline curve is: taking the difference vector between the coordinates of the end point of the current B-spline curve and the penultimate control point as the direction vector.
5. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: In step 4, the method steps for smoothing B-spline curve fitting based on mean sampling are as follows: 41) Preset the ball tree search radius for mean sampling; 42) Starting from the first point of the ordered control point set output in step 3, use the ball tree search radius to search for neighboring points and filter out invalid points and points that have been averaged. 43) Calculate the coordinate mean of the valid points in the neighborhood, use the mean point as the control point of the quadratic fitting, and mark the points in the neighborhood that have undergone the mean operation; 44) Extract the next control point according to the point sequence obtained in step 3, and repeat step 42) until all control points are processed to obtain a sparse control point set; 45) Using the sparse control point set to perform quadratic B-spline curve fitting, outputting a final smooth B-spline curve, and extracting the weld of the welded part.
6. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: The neighborhood search is implemented using a data structure that supports both KD tree and ball tree, where KD tree is used for iterative search with dynamically expanded neighborhood range, and ball tree is used for neighborhood search with a fixed radius.
7. The weld seam adaptive B-spline curve fitting method for 3D dense random point sets according to claim 1, characterized in that: The B-spline curve adopts an open uniform B-spline.