Workpiece coordinate system establishment method, device and equipment and storage medium
By correcting and optimizing the coordinate system constructed by the principal component analysis method in the workpiece coordinate system establishment method, the problem of inaccurate coordinate system is solved, and the accuracy of the workpiece spraying direction and coating uniformity are improved.
Patent Information
- Application Number
- CN202411554921.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
AI Technical Summary
In the existing workpiece coordinate system establishment methods, the x-axis and y-axis directions of the coordinate system constructed by the principal component analysis method may be inaccurate, resulting in incorrect spraying directions and affecting the coating uniformity and performance of the workpiece surface.
By obtaining the three-dimensional point cloud data of the artifact, the eigenvalue decomposition is used to use principal component analysis to generate the initial eigenvector, and direction correction and optimization are performed. The eigenvector is adjusted using the Nelder-Mead optimization algorithm to ensure the accuracy of the coordinate system.
The precise construction of the workpiece coordinate system is achieved, the correctness of the spraying direction is ensured, and the coating uniformity and product performance of the workpiece surface are improved.
Smart Images

Figure CN119444858A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automatic spraying technology, and in particular to a method, device, equipment and storage medium for establishing a workpiece coordinate system. Background Art
[0002] Automatic spraying of workpieces is a process method in which the paint is evenly sprayed on the surface of the workpiece by automated equipment. In the automatic spraying task, a three-dimensional camera is usually used to shoot the workpiece to obtain a three-dimensional point cloud, then a workpiece coordinate system is established to determine the spraying direction, and finally point cloud slicing and other algorithms are used to obtain the spraying trajectory of the workpiece. In order to comply with the spraying process, the spraying trajectory usually selects a grating path. The directionality of the grating path is highly dependent on the accuracy of the workpiece coordinate system. Deviations in the establishment of the coordinate system will lead to errors in the spraying direction. The wrong spraying direction may cause adverse effects such as uneven coating thickness, color difference, uneven gloss, and poor coating adhesion in some areas of the workpiece surface. These problems will affect the appearance quality and performance of the product, and may lead to reduced corrosion resistance and durability, which in turn affects the overall use effect and life of the product.
[0003] At present, the method for establishing the workpiece coordinate system is usually achieved through the principal component analysis method; however, the directions of the x-axis and y-axis of the coordinate system constructed by the principal component analysis method may be inaccurate. Figure 1 , which leads to inaccurate establishment of the workpiece coordinate system, affects the spraying direction of the equipment, and further affects the appearance and performance of the product. Summary of the invention
[0004] In order to help solve the problem that the directions of the x-axis and y-axis of the coordinate system constructed by the principal component analysis method may be inaccurate, thereby causing inaccurate establishment of the workpiece coordinate system, affecting the spraying direction of the equipment, and further affecting the appearance and performance of the product, the present application provides a workpiece coordinate system establishment method, device, equipment and storage medium.
[0005] In a first aspect, the present application provides a method for establishing a workpiece coordinate system, which adopts the following technical solution: the method comprises:
[0006] Acquire three-dimensional point cloud data of the target workpiece and obtain workpiece point cloud data;
[0007] Using principal component analysis to perform eigenvalue decomposition on the workpiece point cloud data, and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors;
[0008] Determine an initial eigenvector corresponding to the smallest initial eigenvalue as a first direction, perform positive and negative direction correction on the first direction according to a preset rule, and correct the remaining two directions according to the corrected first direction and the right-hand rule to generate corrected eigenvectors corresponding to the three corrected directions;
[0009] The corrected feature vector is optimized by using the Nelder-Mead optimization algorithm to generate an optimized feature vector;
[0010] The three directions corresponding to the optimized feature vector are set as the optimal workpiece coordinate system.
[0011] In a specific implementation method, acquiring the three-dimensional point cloud data of the target workpiece and obtaining the workpiece point cloud data includes:
[0012] Acquire global point cloud data, wherein the global point cloud data includes workpiece point cloud data of the target workpiece and environment point cloud data of an environment where the target workpiece is located;
[0013] The global point cloud data is filtered to generate the workpiece point cloud data.
[0014] In a specific implementation scheme, the principal component analysis method is used to perform eigenvalue decomposition on the workpiece point cloud data, and the initial eigenvectors in three directions of the target workpiece and the initial eigenvalues corresponding to the initial eigenvectors are generated, including:
[0015] Calculating the centroid of the workpiece point cloud data, and decentralizing the workpiece point cloud data to generate a workpiece decentralized data set;
[0016] Calculating a covariance matrix of the artifact decentralized dataset;
[0017] Perform eigenvalue decomposition on the covariance matrix, and generate initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors.
[0018] In a specific implementation scheme, the method for calculating the centroid of the workpiece point cloud data includes:
[0019]
[0020] Wherein, k represents the number of points in the workpiece point cloud data, p l represents the three-dimensional coordinates of the i-th point, Represents the centroid of the workpiece point cloud data;
[0021] Decentralized processing methods include:
[0022]
[0023] Among them, p i ′ represents the decentralized three-dimensional coordinates of the i-th point, and P′ represents the decentralized dataset of the workpiece;
[0024] The calculation method of the covariance matrix of the artifact decentralized dataset includes:
[0025]
[0026] cov(x,y)=E{[xE(x)][yE(y)]}
[0027] Wherein, x, y, z represent the coordinates of the decentralized dataset of the artifacts, C represents the covariance matrix, and cov() represents the covariance calculation.
[0028] In a specific implementation scheme, the use of the Nelder-Mead optimization algorithm to optimize the corrected feature vector and generate the optimized feature vector includes:
[0029] Setting the coordinate system formed by the correction feature vector as the initial workpiece coordinate system;
[0030] Fixing a first direction in the initial workpiece coordinate system, rotating the remaining two directions around the first direction, and generating a rotation angle;
[0031] Constructing a target optimization function according to the rotation angle and the bounding box area of the workpiece point cloud data in the initial workpiece coordinate system;
[0032] The objective optimization function is calculated using the Nelder-Mead optimization algorithm;
[0033] When the bounding box area of the workpiece point cloud data in the initial workpiece coordinate system is the smallest, the rotation angle is the optimal rotation angle;
[0034] Based on the initial workpiece coordinate system, the optimized feature vector is calculated and generated according to the optimal rotation angle.
[0035] In a specific implementation scheme, after setting the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system, the method further includes:
[0036] Generate a transformation matrix according to the optimized feature vector, and convert the workpiece point cloud data into coordinates in the optimal workpiece coordinate system according to the transformation matrix;
[0037] The calculation method of the transformation matrix includes:
[0038]
[0039] Among them, V T represents the rotation matrix, represents the translation vector, represents the transformation matrix;
[0040] The calculation method of the rotation matrix includes:
[0041] V T =[v1″,v2″,v3″] T
[0042] Among them, v1″, v2″, and v3″ represent the optimized feature vectors in three directions;
[0043] The calculation method of the translation vector includes:
[0044]
[0045] in, Represents the centroid of the workpiece point cloud data.
[0046] In a specific implementation scheme, the calculation method of the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system includes:
[0047]
[0048]
[0049] Among them, p i represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data, Indicates p l The homogeneous form of represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data after transformation, P W Represents the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system.
[0050] In a second aspect, the present application provides a workpiece coordinate system establishment device, which adopts the following technical solution: the device comprises:
[0051] A data acquisition module is used to acquire three-dimensional point cloud data of a target workpiece and obtain workpiece point cloud data;
[0052] A feature decomposition module, used to perform eigenvalue decomposition on the workpiece point cloud data by using a principal component analysis method, and generate initial feature vectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial feature vectors;
[0053] A direction correction module, used to determine the initial eigenvector corresponding to the smallest initial eigenvalue as the first direction, perform positive and negative direction correction on the first direction according to a preset rule, and correct the remaining two directions according to the corrected first direction and the right-hand rule, to generate correction eigenvectors corresponding to the three corrected directions;
[0054] A direction optimization module, used for optimizing the corrected feature vector using a Nelder-Mead optimization algorithm and generating an optimized feature vector;
[0055] The coordinate system establishment module is used to set the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system.
[0056] In a third aspect, the present application provides a computer device, which adopts the following technical solution: it includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and execute any of the above-mentioned methods for establishing a workpiece coordinate system.
[0057] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: a computer program that can be loaded by a processor and execute any of the above-mentioned workpiece coordinate system establishment methods is stored.
[0058] In summary, this application has the following beneficial technical effects:
[0059] The traditional method of establishing the workpiece coordinate system uses the principal component analysis method. However, the coordinate system established by the principal component analysis method will have problems such as inaccurate direction and the three-dimensional direction not satisfying the right-hand rule. By correcting the direction and performing posture analysis and optimization on the coordinate system constructed by the principal component analysis method, the coordinate system of the workpiece can be accurately constructed and the correct spraying direction can be determined, which can help standardize the robot's spraying process. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a schematic diagram for explaining the workpiece coordinate system established by the principal component analysis method;
[0061] Figure 2 is a flow chart of a method for establishing a workpiece coordinate system in an embodiment of the present application;
[0062] Figure 3 is a schematic diagram of a coordinate system established by a method for establishing a workpiece coordinate system in an embodiment of the present application;
[0063] Figure 4 is a schematic diagram of a workpiece coordinate system establishment device in an embodiment of the present application;
[0064] Figure 5 It is a schematic diagram used to embody a computer device in an embodiment of the present application.
[0065] Figure numerals: 401, data acquisition module; 402, feature decomposition module; 403, direction correction module; 404, direction optimization module; 405, coordinate system establishment module. DETAILED DESCRIPTION
[0066] The following combination Figure 1-Figure 5This application is described in further detail.
[0067] The embodiment of the present application discloses a method for establishing a workpiece coordinate system. The method is applied to a workpiece coordinate system establishment system. The method can accurately establish a workpiece coordinate system in an automatic spraying process, thereby determining the correct spraying direction and standardizing the spraying process of the robot.
[0068] Automatic spraying of workpieces is a process method in which the paint is evenly sprayed on the surface of the workpiece by automated equipment. In the automatic spraying task, it is usually necessary to first obtain the accurate spraying trajectory of the workpiece. In order to comply with the spraying process, the spraying trajectory usually selects a grating path. The directionality of the grating path is highly dependent on the accuracy of the workpiece coordinate system. Deviations in the establishment of the coordinate system will lead to errors in the spraying direction. The wrong spraying direction may cause adverse effects such as uneven coating thickness, color difference, uneven gloss, and poor coating adhesion in some areas of the workpiece surface. These problems will affect the appearance quality and performance of the product, may lead to reduced corrosion resistance and durability, and thus affect the overall use effect and life of the product.
[0069] At present, the method for establishing the workpiece coordinate system is usually achieved through the principal component analysis method; however, the directions of the x-axis and y-axis of the coordinate system constructed by the principal component analysis method may be inaccurate. Figure 1 , which results in inaccurate establishment of the workpiece coordinate system, affects the spraying direction of the equipment, and further affects the appearance and performance of the product. In order to help improve the accuracy of the workpiece coordinate system, the present application provides a method for establishing a workpiece coordinate system.
[0070] Reference Figure 2 , the method comprises the following steps:
[0071] S10, acquiring three-dimensional point cloud data of the target workpiece, and obtaining workpiece point cloud data.
[0072] Specifically, the three-dimensional point cloud data of the target workpiece can be obtained with the help of a three-dimensional camera. The method of obtaining the workpiece point cloud data can specifically include, first, the global point cloud data can be photographed by a three-dimensional camera, and the photographed global point cloud data includes the workpiece point cloud data of the target workpiece and the environmental point cloud data of the environment where the target workpiece is located; then, the global point cloud data is filtered and processed to generate the workpiece point cloud data. Among them, the filtering processing method can include downsampling, filtering, smoothing, segmentation, clustering and other algorithms to extract the workpiece point cloud data from the global point cloud data, filter out the redundant point cloud data, and obtain the complete workpiece point cloud data. In addition, the user can also shoot the three-dimensional point cloud data of the workpiece in advance and process the photographed data. The system can directly obtain the processed workpiece point cloud data for the subsequent establishment of the workpiece coordinate system.
[0073] S20, using principal component analysis to perform eigenvalue decomposition on the workpiece point cloud data, and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors.
[0074] Specifically, the workpiece point cloud data is analyzed and calculated according to the principal component analysis method, and the eigenvalue decomposition is performed. After the eigenvalue decomposition, the initial eigenvectors v1, v2, and v3 in the three directions of the target workpiece are obtained, and the initial eigenvalues λ1, λ2, and λ3 corresponding to the initial eigenvectors are obtained. Among them, the initial eigenvectors v1, v2, and v2 have directions, and the directions pointed by the initial eigenvectors v1, v2, and v3 constitute the x-axis, y-axis, and z-axis of the coordinate system obtained by the principal component analysis method.
[0075] S30, determining that the initial eigenvector corresponding to the smallest initial eigenvalue is the first direction, performing positive and negative direction correction on the first direction according to a preset rule, and correcting the remaining two directions according to the corrected first direction and the right-hand rule, to generate corrected eigenvectors corresponding to the three corrected directions.
[0076] Specifically, the initial eigenvalues λ1, λ2, and λ3 obtained by the principal component analysis method generally have eigenvalues of λ1>λ2>λ3. The initial eigenvector corresponding to the smallest initial eigenvalue is determined as the first direction, that is, the direction corresponding to the initial eigenvector v3 corresponding to the initial eigenvalue λ3 is set as the first direction. Considering that the eigenvectors obtained by eigenvalue decomposition do not distinguish between positive and negative directions, if the initial eigenvectors v1, v2, and v3 obtained by eigenvalue decomposition in the principal component analysis are directly used as the coordinate system of the workpiece, the z-axis may be reversed and the right-hand rule may not be satisfied. Therefore, the first direction is corrected in the positive and negative directions according to the preset rules. The preset rules can be understood as that the z-axis of the camera coordinate system is opposite to the z-axis of the workpiece coordinate system. By correcting the initial eigenvector v3 in the positive and negative directions, the corrected first direction is obtained, that is, the direction corresponding to the corrected v3. Afterwards, the remaining two directions are corrected according to the corrected first direction and the right-hand rule, that is, the directions corresponding to v1 and v2 are corrected; specifically, in order to make the workpiece coordinate system satisfy the right-hand rule, the cross product result of v3 and v1 is used as the corrected v2. At this time, the initial eigenvectors v1, v2, and v3 are all corrected, and the corrected v1, v2, and v3 are used as the initial workpiece coordinate system of the target workpiece.
[0077] S40, using the Nelder-Mead optimization algorithm to optimize the corrected feature vector and generate an optimized feature vector.
[0078] Specifically, considering that for workpieces with high rotational symmetry, eigenvalue decomposition may not be able to accurately distinguish the three directions of the workpiece, resulting in inaccurate orientations of the x and y axes of the workpiece coordinate system obtained by the principal component analysis combined with the correction method. Therefore, it is necessary to adjust the directions of the x and y axes through an optimization algorithm. Specifically, the x and y axes are rotated around the z axis, and the Nelder-Mead optimization algorithm is used to optimize the rotation angle to obtain the optimized eigenvector, which can also be understood as obtaining the three accurate directions of the optimized coordinate system.
[0079] Among them, the Nelder-Mead algorithm, also known as the simplex method (Nelder-Mead simplex algorithm) or the downhill simplex method, is a numerical optimization method suitable for multi-dimensional unconstrained problems and can solve a variety of complex optimization problems.
[0080] S50, setting the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system.
[0081] Specifically, the three directions corresponding to the optimized feature vectors obtained by the Nelder-Mead optimization algorithm constitute the optimal workpiece coordinate system. Figure 3 , is the workpiece coordinate system constructed by the present application scheme, compared with Figure 1 The coordinate system constructed by the principal component analysis method has a more accurate orientation and coordinate system, which is more helpful in determining the spraying trajectory of the workpiece in automatic spraying.
[0082] In the present application, the traditional method of establishing the workpiece coordinate system is established using the principal component analysis method. However, the coordinate system established by the principal component analysis method may have problems such as inaccurate direction and the three-dimensional direction not satisfying the right-hand rule. By performing direction correction, posture analysis and optimization on the coordinate system constructed by the principal component analysis method, the coordinate system of the workpiece can be accurately constructed and the correct spraying direction can be determined, which can help standardize the robot's spraying process.
[0083] In one embodiment, the steps of performing eigenvalue decomposition on the workpiece point cloud data using the principal component analysis method and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors may be specifically performed as follows:
[0084] First, calculate the centroid of the workpiece point cloud data. The calculation method of the centroid can be expressed as:
[0085]
[0086] Among them, k represents the number of points in the workpiece point cloud data, p i represents the three-dimensional coordinates of the i-th point, Represents the centroid of the workpiece point cloud data.
[0087] Afterwards, the workpiece point cloud data is decentralized to generate a decentralized data set of the workpiece. The decentralized processing method can be expressed as:
[0088]
[0089] Among them, p i ′ represents the decentralized three-dimensional coordinate of the i-th point, and P′ represents the decentralized dataset of the workpiece.
[0090] After that, the covariance matrix of the artifact decentralized dataset is calculated. The calculation method of the covariance matrix can be expressed as:
[0091]
[0092] cov(x,y)=E{[xE(x)][yE(y)]}
[0093] Among them, x, y, z represent the coordinates of the decentralized dataset of artifacts, C represents the covariance matrix, and cov() represents the covariance calculation.
[0094] Finally, the covariance matrix is subjected to eigenvalue decomposition, and the initial eigenvectors of the target workpiece in three directions and the initial eigenvalues corresponding to the initial eigenvectors are generated. The eigenvalue decomposition method may specifically include directly obtaining the eigenvalues λ1, λ2, and λ3 by solving det(A-λI)=0. Generally, λ1>λ2>λ3; and then substituting the eigenvalues into (A-λI)v=0 to obtain the corresponding eigenvectors v1, v2, and v3, where v1, v2, and v2∈R 3×1 Since the eigenvalue decomposition obtains a set of orthogonal bases, the three principal component directions can be directly used as the three axes of the workpiece coordinate system, v1 as the x-axis, v2 as the y-axis, and v3 as the z-axis.
[0095] In the present application scheme, the original coordinate system is constructed by principal component analysis. Since the three principal component directions obtained by principal component analysis are a set of orthogonal bases and the three principal component directions are perpendicular to each other, they can be used as the original coordinate system to facilitate subsequent correction and optimization on the basis of the original coordinate system to obtain the optimal workpiece coordinate system, so as to determine the trajectory of automatic spraying, thereby improving the accuracy of automatic spraying.
[0096] In one embodiment, the steps of optimizing the corrected feature vector using the Nelder-Mead optimization algorithm and generating the optimized feature vector may be specifically performed as follows:
[0097] First, the coordinate system formed by the corrected feature vector is set as the initial workpiece coordinate system. After that, the first direction in the initial workpiece coordinate system is fixed, the other two directions are rotated around the first direction, and the rotation angle is generated. Specifically, the first direction is the direction indicated by v3, that is, the direction of the z-axis. The z-axis is fixed, and the other two directions are rotated around the z-axis, that is, the x and y axes are rotated around the z-axis by a certain angle, and the angle generated by the rotation is the rotation angle; the unit vectors of the rotated x and y axes can be calculated using the Rodriguez formula, and the calculation formula can be expressed as:
[0098] v1′=cos(α)v1+(1-cos(α))(v3·v1)v3+sin(α)(v3×v1)
[0099] v2′=cos(α)v2+(1-cos(α))(v3·v2)v3+sin(α)(v3×v2)
[0100] Wherein, (·) represents vector dot product, (×) represents vector cross product, v1′ represents the unit vector after the x-axis is rotated by an angle α, which can also be understood as the eigenvector obtained by rotating v1 by an angle α after correction, and v2′ represents the unit vector after the y-axis is rotated by an angle α, which can also be understood as the eigenvector obtained by rotating v2 by an angle α after correction.
[0101] Afterwards, the target optimization function is constructed according to the rotation angle and the bounding box area of the workpiece point cloud data in the initial workpiece coordinate system; specifically, the workpiece decentralized data set is transformed into the rotated workpiece coordinate system, and the range of the workpiece decentralized data set in the x-axis direction [x min , x max ], and the range in the y-axis direction [y min ,y max ], according to the range of the x-axis and y-axis directions, the bounding box area S of the workpiece point cloud data in the x and y directions in the current coordinate system can be calculated. The calculation method of the bounding box area can be expressed as:
[0102] S=(x max -x min )*(y max -y min )
[0103] When the area of the bounding box in the x and y directions is the smallest, the bounding box in this direction must be the minimum oriented bounding box (obb). Therefore, the bounding box area is used as the objective function to be optimized, and the rotation angles of the x and y axes are used as the parameters to be optimized. The Nelder-Mead optimization algorithm is used to calculate the objective optimization function. The Nelder-Mead optimization algorithm is used to solve the optimal rotation angle when the bounding box area is the smallest, and the optimized workpiece coordinate system can be obtained. Finally, based on the initial workpiece coordinate system, the optimized feature vector is calculated and generated according to the optimal rotation angle. The optimized feature vector can be recorded as v1″, v2″, v3″, where v1″, v2″, v3″∈R 3×1 .
[0104] In the present application, considering that for workpieces with high rotational symmetry, eigenvalue decomposition may not be able to accurately distinguish the three directions of the workpiece, resulting in inaccurate x and y axis orientations of the workpiece coordinate system obtained by the principal component analysis method combined with the correction method. Therefore, it is necessary to adjust the directions of the x and y axes through an optimization algorithm, thereby adjusting and optimizing the workpiece coordinate system to obtain a more accurate workpiece coordinate system.
[0105] In one embodiment, considering that after the workpiece coordinate system is established, it is difficult to obtain the accurate spraying trajectory of the workpiece without converting the original point cloud data, therefore, after setting the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system, the following steps can also be performed:
[0106] A transformation matrix is generated according to the optimized feature vector, and the workpiece point cloud data is converted into coordinates in the optimal workpiece coordinate system according to the transformation matrix.
[0107] The transformation matrix is calculated by:
[0108]
[0109] Among them, V T represents the rotation matrix, represents the translation vector, Represents a transformation matrix.
[0110] The calculation method of the rotation matrix includes:
[0111] V T =[v1″,v2″,v3″] T
[0112] Among them, v1″, v2″, and v3″ represent the optimized feature vectors in three directions.
[0113] The translation vector is calculated by:
[0114]
[0115] in, Represents the centroid of the workpiece point cloud data.
[0116] The calculation methods of the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system include:
[0117]
[0118] Among them, p i Represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data, Indicates p i The homogeneous form of represents the transformed three-dimensional coordinates of the i-th point in the workpiece point cloud data, P W Represents the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system, Keep only the first three elements of the homogeneous expression.
[0119] In the present application scheme, after the accurate workpiece coordinate system is established, it is necessary to convert the workpiece point cloud data in the original camera coordinate system to the optimal coordinate system to realize the automatic spraying trajectory. The optimized feature vector is used as the rotation matrix, and the center of mass is used as the translation vector to obtain the transformation matrix between the camera coordinate system and the workpiece coordinate system, so as to obtain accurate workpiece coordinate data, so as to facilitate the subsequent accurate automatic spraying of the workpiece, improve the spraying quality as well as the appearance and performance of the product.
[0120] Figure 2 FIG. 1 is a flow chart of a method for establishing a workpiece coordinate system in one embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows; unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps may be executed in other orders; and Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0121] Based on the above method, an embodiment of the present application also discloses a device for establishing a workpiece coordinate system.
[0122] Reference Figure 4 , the device includes the following modules:
[0123] The data acquisition module 401 is used to acquire the three-dimensional point cloud data of the target workpiece and obtain the workpiece point cloud data;
[0124] The feature decomposition module 402 is used to perform feature value decomposition on the workpiece point cloud data by using the principal component analysis method, and generate initial feature vectors in three directions of the target workpiece and initial feature values corresponding to the initial feature vectors;
[0125] A direction correction module 403 is used to determine the initial eigenvector corresponding to the smallest initial eigenvalue as the first direction, perform positive and negative direction correction on the first direction according to a preset rule, and correct the remaining two directions according to the corrected first direction and the right-hand rule to generate corrected eigenvectors corresponding to the three corrected directions;
[0126] A direction optimization module 404 is used to optimize the corrected feature vector using a Nelder-Mead optimization algorithm and generate an optimized feature vector;
[0127] The coordinate system establishing module 405 is used to set the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system.
[0128] In one embodiment, the data acquisition module 401 is specifically used to acquire global point cloud data, which includes workpiece point cloud data of the target workpiece and environmental point cloud data of the environment where the target workpiece is located; filter the global point cloud data and generate workpiece point cloud data.
[0129] In one embodiment, the feature decomposition module 402 is specifically used to calculate the centroid of the workpiece point cloud data, and to decentralize the workpiece point cloud data to generate a workpiece decentralized data set; calculate the covariance matrix of the workpiece decentralized data set; perform eigenvalue decomposition on the covariance matrix, and generate initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors.
[0130] In one embodiment, in the feature decomposition module 402, the centroid of the workpiece point cloud data is calculated by:
[0131]
[0132] Among them, k represents the number of points in the workpiece point cloud data, p i represents the three-dimensional coordinates of the i-th point, Represents the centroid of the workpiece point cloud data;
[0133] Decentralized processing methods include:
[0134]
[0135] Among them, p i′ represents the decentralized three-dimensional coordinate of the i-th point, and P′ represents the decentralized dataset of the workpiece;
[0136] The covariance matrix of the artifact decentralized dataset is calculated as follows:
[0137]
[0138] cov(x,y)=E{[xE(x)][yE(y)]}
[0139] Among them, x, y, z represent the coordinates of the decentralized dataset of artifacts, C represents the covariance matrix, and cov() represents the covariance calculation.
[0140] In one embodiment, the direction optimization module 404 is specifically used to set the coordinate system formed by the correction feature vector as the initial workpiece coordinate system; fix the first direction in the initial workpiece coordinate system, rotate the other two directions around the first direction, and generate a rotation angle; construct a target optimization function according to the rotation angle and the area of the bounding box of the workpiece point cloud data in the initial workpiece coordinate system; use the Nelder-Mead optimization algorithm to calculate the target optimization function; when the area of the bounding box of the workpiece point cloud data in the initial workpiece coordinate system is the smallest, the rotation angle is the optimal rotation angle; based on the initial workpiece coordinate system, calculate and generate an optimized feature vector according to the optimal rotation angle.
[0141] In one embodiment, the coordinate system establishment module 405 is further used to generate a transformation matrix according to the optimized feature vector, and convert the workpiece point cloud data into coordinates in the optimal workpiece coordinate system according to the transformation matrix; the calculation method of the transformation matrix includes:
[0142]
[0143] Among them, V T represents the rotation matrix, represents the translation vector, represents the transformation matrix;
[0144] The calculation method of the rotation matrix includes:
[0145] V T =[v1″,v2″,v3″] T
[0146] Among them, v1″, v2″, and v3″ represent the optimized feature vectors in three directions;
[0147] The translation vector is calculated by:
[0148]
[0149] in, Represents the centroid of the workpiece point cloud data.
[0150] In one embodiment, in the coordinate system establishment module 405, the calculation method of the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system includes:
[0151]
[0152] Among them, p i Represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data, Indicates p i The homogeneous form of represents the transformed three-dimensional coordinates of the i-th point in the workpiece point cloud data, P W Represents the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system.
[0153] The workpiece coordinate system establishment device provided in the embodiment of the present application can be applied to the workpiece coordinate system establishment method provided in the above embodiment. For relevant details, refer to the above method embodiment. The implementation principle and technical effect are similar and will not be repeated here.
[0154] It should be noted that: when the workpiece coordinate system establishment device provided in the embodiment of the present application establishes a workpiece coordinate system, only the division of the above-mentioned functional modules / functional units is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules / functional units as needed, that is, the internal structure of the workpiece coordinate system establishment device is divided into different functional modules / functional units to complete all or part of the functions described above. In addition, the implementation method of the workpiece coordinate system establishment method provided in the above method embodiment and the implementation method of the workpiece coordinate system establishment device provided in this embodiment belong to the same concept. The specific implementation process of the workpiece coordinate system establishment device provided in this embodiment is detailed in the above method embodiment, and will not be repeated here.
[0155] The embodiment of the present application also discloses a computer device.
[0156] Specifically, if Figure 5As shown, the computer device can be a computer device such as a desktop computer, a laptop computer, a PDA, and a cloud server. The computer device may include, but is not limited to, a processor and a memory. The processor and the memory may be connected via a bus or otherwise. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, graphics processors (GPU), embedded neural network processors (NPU) or other dedicated deep learning coprocessors, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned various chips.
[0157] As a non-transient computer-readable storage medium, the memory can be used to store non-transient software programs, non-transient computer executable programs and modules, such as program instructions / modules corresponding to the methods in the above-mentioned embodiments of the present application. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, that is, the method in the above-mentioned method implementation is realized. The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0158] The embodiment of the present application also discloses a computer-readable storage medium.
[0159] Specifically, a computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in the above-mentioned method implementation is implemented. Those skilled in the art will understand that the implementation of all or part of the process in the above-mentioned implementation method of the present application can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program, when executed, may include the process of the implementation of the above-mentioned methods. Among them, the storage medium may be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memory.
[0160] This specific embodiment is merely an explanation of the present invention and is not a limitation of the present invention. After reading this specification, those skilled in the art may make non-creative modifications to the present embodiment as needed. However, as long as they are within the scope of the claims of the present invention, they are protected by the patent law.
Claims
1. A method for establishing a workpiece coordinate system, characterized in that: The method comprises: Acquire three-dimensional point cloud data of the target workpiece and obtain workpiece point cloud data; Performing eigenvalue decomposition on the workpiece point cloud data using a principal component analysis method, and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors; Determine an initial eigenvector corresponding to the smallest initial eigenvalue as a first direction, perform positive and negative direction correction on the first direction according to a preset rule, and correct the remaining two directions according to the corrected first direction and the right-hand rule to generate corrected eigenvectors corresponding to the three corrected directions; The corrected feature vector is optimized by using a Nelder-Mead optimization algorithm to generate an optimized feature vector; The three directions corresponding to the optimized feature vector are set as the optimal workpiece coordinate system.
2. The method according to claim 1, characterized in that: The step of acquiring the three-dimensional point cloud data of the target workpiece and obtaining the workpiece point cloud data comprises: Acquire global point cloud data, wherein the global point cloud data includes workpiece point cloud data of the target workpiece and environment point cloud data of the environment where the target workpiece is located; The global point cloud data is filtered to generate the workpiece point cloud data.
3. The method according to claim 1, characterized in that: The method of performing eigenvalue decomposition on the workpiece point cloud data by using the principal component analysis method and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors includes: Calculating the centroid of the workpiece point cloud data, and decentralizing the workpiece point cloud data to generate a workpiece decentralized data set; Calculating a covariance matrix of the artifact decentralized dataset; Performing eigenvalue decomposition on the covariance matrix, and generating initial eigenvectors in three directions of the target workpiece and initial eigenvalues corresponding to the initial eigenvectors.
4. The method according to claim 3, characterized in that: The method for calculating the centroid of the workpiece point cloud data includes: Wherein, k represents the number of points in the workpiece point cloud data, p i represents the three-dimensional coordinates of the i-th point, Represents the centroid of the workpiece point cloud data; Decentralized processing methods include: Among them, p i ′ represents the decentralized three-dimensional coordinates of the i-th point, and P′ represents the decentralized dataset of the artifact; The calculation method of the covariance matrix of the artifact decentralized dataset includes: cov(x,y)=E{[xE(x)][yE(y)]} Wherein, x, y, z represent the coordinates of the decentralized dataset of the artifacts, C represents the covariance matrix, and cov() represents the covariance calculation.
5. The method according to claim 1, characterized in that: The step of optimizing the corrected feature vector using the Nelder-Mead optimization algorithm and generating the optimized feature vector comprises: Setting the coordinate system formed by the correction feature vector as the initial workpiece coordinate system; Fixing a first direction in the initial workpiece coordinate system, rotating the remaining two directions around the first direction, and generating a rotation angle; Constructing a target optimization function according to the rotation angle and the bounding box area of the workpiece point cloud data in the initial workpiece coordinate system; The objective optimization function is calculated using the Nelder-Mead optimization algorithm; When the bounding box area of the workpiece point cloud data in the initial workpiece coordinate system is the smallest, the rotation angle is the optimal rotation angle; Based on the initial workpiece coordinate system, the optimized feature vector is calculated and generated according to the optimal rotation angle.
6. The method according to claim 1, characterized in that: After setting the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system, the method further includes: Generate a transformation matrix according to the optimized feature vector, and convert the workpiece point cloud data into coordinates in the optimal workpiece coordinate system according to the transformation matrix; The calculation method of the transformation matrix includes: Among them, V T represents the rotation matrix, represents the translation vector, represents the transformation matrix; The calculation method of the rotation matrix includes: V T =[v1″,v2″,v3″] T Among them, v1″, v2″, and v3″ represent the optimized feature vectors in three directions; The calculation method of the translation vector includes: in, Represents the centroid of the workpiece point cloud data.
7. The method according to claim 6, characterized in that: The calculation method of the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system includes: Among them, p i represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data, Indicates p i The homogeneous form of represents the three-dimensional coordinates of the i-th point in the workpiece point cloud data after transformation, P W Represents the coordinates of the workpiece point cloud data in the optimal workpiece coordinate system.
8. A workpiece coordinate system establishment device, characterized in that: The device comprises: A data acquisition module (401) is used to acquire three-dimensional point cloud data of a target workpiece and obtain workpiece point cloud data; A feature decomposition module (402) is used to perform feature value decomposition on the workpiece point cloud data using a principal component analysis method, and generate initial feature vectors in three directions of the target workpiece and initial feature values corresponding to the initial feature vectors; A direction correction module (403) is used to determine the initial eigenvector corresponding to the smallest initial eigenvalue as the first direction, perform positive and negative direction correction on the first direction according to a preset rule, and correct the remaining two directions according to the corrected first direction and the right-hand rule to generate corrected eigenvectors corresponding to the three corrected directions; A direction optimization module (404), used to optimize the corrected feature vector using a Nelder-Mead optimization algorithm and generate an optimized feature vector; The coordinate system establishment module (405) is used to set the three directions corresponding to the optimized feature vector as the optimal workpiece coordinate system.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program which can be loaded by the processor and executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 7.