Method and device for fitting a spatial circle trajectory, and computer-readable storage medium
By performing plane fitting and centroid calculation in three-dimensional space, and combining the target plane and spherical space, the target circular trajectory is determined, which solves the problem of low efficiency in the existing technology and achieves high accuracy and fast fitting.
Patent Information
- Application Number
- CN202310588533.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-19
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-05-19
AI Technical Summary
Existing technologies are inefficient in fitting spatial circular trajectories and cannot meet real-time requirements, especially in robotic arm applications.
By acquiring multiple data points in three-dimensional space, performing plane fitting and calculating the centroid, the center and radius of the target circle are determined. Combining the target plane and spherical space, the trajectory of the target circle is determined.
The accuracy and speed of spatial circle fitting are improved, the algorithm process is simplified, and it is suitable for robotic arm applications with high real-time requirements.
Smart Images

Figure CN116740136B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of trajectory fitting, and in particular to a spatial circular trajectory fitting method, a fitting device, and a computer-readable storage medium. Background Art
[0002] When sensors collect data points, it is inevitable that errors are introduced. The discrete data points collected are distributed very irregularly in space, making it difficult to obtain a complete and continuous trajectory shape. In order to obtain the closest trajectory based on the data points generated by the sensors, a fitting method is needed.
[0003] Many existing methods rely on solving optimization problems for fitting. However, the optimization problem solving process is complex, slow, and inefficient. However, for a robotic arm with strong real-time requirements, efficiency is extremely important. Summary of the Invention
[0004] The present application provides a spatial circle trajectory fitting method, a fitting device, and a computer-readable storage medium, which can improve the fitting accuracy of the spatial circle.
[0005] A first aspect of an embodiment of the present application provides a method for fitting a spatial circular trajectory, the method comprising: acquiring multiple collected data points in a three-dimensional space; performing plane fitting based on the multiple collected data points to obtain a target plane; calculating the center of mass of the multiple collected data points; determining the center of a target circle based on the center of mass; determining the radius of the target circle based on the distance from the center of the target circle to the multiple collected data points; determining the target sphere space with the center of the target circle as the sphere center and the radius of the target circle as the radius of the target sphere; and determining the target circular trajectory based on the target plane and the target sphere space.
[0006] The step of performing plane fitting based on the multiple collected data points to obtain a target plane includes: performing plane fitting based on the multiple collected data points and using a least squares method to obtain the target plane.
[0007] Among them, the step of calculating the centroid of the multiple collected data points includes: screening out multiple target data points from the multiple collected data points, wherein the distance between any two adjacent target data points is within a preset range; calculating the centroid of the multiple target data points, and determining the centroid of the multiple target data points as the centroid of the multiple collected data points.
[0008] Among them, the step of filtering out multiple target data points from the multiple collected data points includes: searching for an initial data point among the multiple collected data points; searching for the collected data points adjacent to the initial data point among the collected data points that have not been searched; judging whether the distance between the found collected data point and the initial data point is greater than a preset distance; if the judgment result is greater than, retaining the found collected data point, and using the found collected data point as the initial data point, and then returning to execute the step of searching for the collected data points adjacent to the initial data point among the collected data points that have not been searched; otherwise, deleting the found collected data point, and then returning to execute the step of searching for the collected data points adjacent to the initial data point among the collected data points that have not been searched; after traversing each of the collected data points, each of the retained collected data points is used as the target data point.
[0009] The step of calculating the centroid of the plurality of collected data points includes: respectively calculating the average values of the plurality of collected data points on the X component, the Y component, and the Z component; and respectively determining the average values on the X component, the Y component, and the Z component as the X component, the Y component, and the Z component of the centroid.
[0010] The step of determining the center of the target circle based on the center of mass includes: vertically projecting the center of mass onto the target plane to obtain a projection point; and determining the projection point as the center of the target circle.
[0011] The step of determining the radius of the target circle based on the distance from the center of the target circle to the multiple collected data points includes: calculating the average distance from the center of the target circle to the multiple collected data points; and obtaining the radius of the target circle based on the average distance.
[0012] The step of determining the target circle trajectory based on the target plane and the target ball space includes: determining the area where the target plane and the target ball space overlap as the area where the target circle is located, thereby determining the target circle trajectory.
[0013] A second aspect of an embodiment of the present application provides a fitting device, which includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit respectively. Program data is stored in the memory. The processor implements the steps in the above method by executing the program data in the memory.
[0014] A third aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed by a processor to implement the steps in the above method.
[0015] The beneficial effect is: this application takes into account that multiple collected data points on a circle in three-dimensional space are on the target plane on the one hand and on the target sphere space on the other hand. Therefore, the target plane is determined first, and then the target sphere is determined. Finally, the target circle trajectory is determined based on the target plane and the target sphere, which can improve the fitting accuracy, and the entire algorithm is simple, which can improve the fitting speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive work, among which:
[0017] Figure 1 This is a flow chart of an embodiment of a method for fitting a spatial circular trajectory of the present application;
[0018] Figure 2 yes Figure 1 Flow chart of step S130;
[0019] Figure 3 It is a structural diagram of multiple data collection points;
[0020] Figure 4 It is a structural schematic diagram of an embodiment of the fitting device of the present application;
[0021] Figure 5 It is a structural schematic diagram of another embodiment of the fitting device of the present application;
[0022] Figure 6 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0024] It should be noted that the terms "first" and "second" in this application are only used for descriptive purposes and should not be understood as indicating or suggesting relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0025] See Figure 1 , Figure 1 : is a flow chart of an embodiment of a method for fitting a spatial circular trajectory of the present application, the method comprising:
[0026] S110: Acquire multiple collected data points in a three-dimensional space.
[0027] Specifically, the collected data points are located in a three-dimensional space, and their coordinates include a component in the X direction, a component in the Y direction, and a component in the Z direction. The purpose of this application is to determine a target circle in which multiple collected data points are located. The multiple collected data points may be data points collected by a sensor provided on a robotic arm.
[0028] S120: Performing plane fitting based on the multiple collected data points to obtain a target plane.
[0029] Specifically, all circles in the three-dimensional space must be on the same plane, so plane fitting is performed based on multiple collected data points to obtain the target plane where the multiple collected data points are located.
[0030] The target plane can be obtained by plane fitting using the least squares method. Specifically, the least squares method is a relatively mature algorithm with a simple process and high fitting accuracy, which can ensure the accuracy of the final fit. The specific process of plane fitting using the least squares method is prior art and will not be described in detail here.
[0031] In other embodiments, the target plane may be obtained by using fitting methods such as quadratic polynomial fitting, LOG fitting, and semi-logarithmic fitting. In summary, the present application does not impose any specific restrictions on the method used for plane fitting.
[0032] S130: Calculate the centroid of the plurality of collected data points.
[0033] In one application scenario, the average values of the X, Y, and Z components of multiple collected data points can be calculated respectively, and then the average values of the X, Y, and Z components can be determined as the X, Y, and Z components of the centroid. Specifically, if the coordinates of the collected data points are marked as (x i ,y i , z i ), then calculate x i The average value is used as the X component of the centroid and y is calculated. i The average value is used as the Y component of the centroid and z is calculated. i The average value is used as the Z component of the centroid.
[0034] Among them, considering that when multiple collected data points are partially dense and partially sparse, if the centroid of multiple collected data points is calculated, the obtained centroid will be biased towards the direction of the dense point. Therefore, in order to avoid this defect, in another application scenario, when calculating the centroid of multiple collected data points, the multiple collected data points will be filtered first, and then the centroid will be calculated based on the filtered multiple collected data points. See Figure 2 , at this time step S130 specifically includes:
[0035] S1301: Filter out a plurality of target data points from a plurality of collected data points, wherein the distance between any two adjacent target data points is within a preset range.
[0036] S1302: Calculate the centroids of the multiple target data points, and determine the centroids of the multiple target data points as the centroids of the multiple collected data points.
[0037] Specifically, a plurality of uniform target data points are screened out from the plurality of collected data points, and then the centroids of the plurality of target data points are calculated, and the centroids are used as the centroids of the plurality of collected data points.
[0038] Among them, the preset range can be pre-set by the designer and is not limited in this application.
[0039] The process of calculating the centroid of the plurality of target data points may be: respectively calculating the average values of the plurality of target data points on the X component, the Y component, and the Z component, and then respectively determining the average values on the X component, the Y component, and the Z component as the X component, the Y component, and the Z component of the centroid.
[0040] It should be noted that, in other implementations, the multiple collected data points may not be screened, that is, the centroid may be directly calculated using the multiple collected data points.
[0041] When multiple target data points are selected from multiple collected data points, subsequent steps can be performed based on the selected target data points. However, for ease of explanation, the following description assumes that the multiple collected data points are not selected.
[0042] In one application scenario, the process of screening multiple collected data points in step S1301 includes:
[0043] Step a: Find the initial data point among multiple collected data points.
[0044] Step b: Search for collected data points adjacent to the initial data point among the collected data points that have not been searched.
[0045] Specifically, for each collected data point that has not been found, the straight-line distance between it and the initial data point is calculated, and in the final calculation result, the collected data point corresponding to the minimum distance is found. The collected data point is the collected data point adjacent to the initial data point.
[0046] If a collected data point is determined to be adjacent to the initial data point, the collected data point can be marked. During the search for collected data points, if a collected data point does not carry a mark, it is determined that the collected data point has not been searched. Step c: Whether the distance between the found collected data point and the initial data point is greater than a preset distance.
[0047] If the judgment result is greater than, execute step d; otherwise, execute step e.
[0048] Step d: retain the found collected data points and use them as initial data points.
[0049] After step d, return to step b.
[0050] Step e: Delete the found collected data.
[0051] After step e, return to step b.
[0052] Step f: After traversing each collected data point, each retained collected data point is used as a target data point.
[0053] In order to facilitate the understanding of the above scheme, Figure 3 The following example illustrates this:
[0054] In this example, there are 8 collected data points, which are represented by labels 1, 2, 3, 4, 5, 6, 7, and 8 respectively.
[0055] First, assume that data point 1 is taken as the initial data point, and the data points adjacent to data point 1 are two collected data points, data point 2 and data point 8. At this time, assume that data point 2 is taken as the data point adjacent to data point 1, and calculate the distance between data point 1 and data point 2.
[0056] If the distance between data point 1 and data point 2 is greater than the preset distance, data point 2 is retained and used as the initial data point, and the above steps are repeated. When data point 2 is used as the initial data point, data points adjacent to data point 2 are searched among the unfinished collected data points. Therefore, in this case, only data point 3 is used as the collected data point adjacent to data point 2.
[0057] If the distance between data point 1 and data point 2 is not greater than the preset distance, delete data point 2 and continue to search for collected data points adjacent to data point 1 among the remaining collected data points. At this time, the collected data points adjacent to data point 1 are data point 3 and data point 8. At this time, assuming that data point 3 is regarded as the data point adjacent to data point 1, calculate the distance between data point 1 and data point 3 and repeat the above steps.
[0058] Repeat the above steps until all collected data points are traversed, and the remaining collected data points are the target data points.
[0059] In other application scenarios, multiple collected data points can also be filtered in other ways. For example, any two collected data points can be selected from multiple collected data points to determine whether the distance between the two collected data points is greater than a preset distance. If so, the two points are retained; if the distance between the two points is less than the preset distance, one is randomly deleted, and the next round of judgment is performed until the distance between every two data points in the remaining data points is greater than the preset distance. These remaining data points are the target data points.
[0060] S140: Determine the center of the target circle according to the center of mass.
[0061] In one application scenario, the center of mass is directly determined as the center of the target circle.
[0062] In another application scenario, considering that the center of the target circle must also lie on the target plane, the centroid is first projected vertically onto the target plane to obtain a projection point, which is then determined as the center of the target circle. The process of determining the projection point is prior art and is not described in detail in this application.
[0063] S150: Determine the radius of the target circle according to the distance from the center of the target circle to the multiple collected data points.
[0064] In one application scenario, the average distance from the center of the target circle to multiple collected data points is calculated, and then the radius of the target circle is obtained based on the average distance. In this case, the average distance can be directly used as the radius of the target circle.
[0065] In other application scenarios, the distances from the center of the target circle to multiple collected data points can be calculated separately, and then the median of the distances can be determined as the radius of the target circle, or the value that appears most frequently in the distances can be determined as the radius of the target circle.
[0066] S160: Determine the target ball space by taking the center of the target circle as the center of the sphere and the radius of the target circle as the radius of the target sphere.
[0067] Specifically, multiple collected data points are located on a target ball in a three-dimensional space while being located in a target circle. The center of the target ball space coincides with the center of the target circle, and the radius of the target ball space is equal to the radius of the target circle. Therefore, the target ball space can be determined with the center of the target circle as the center and the radius of the target circle as the radius of the target ball.
[0068] S170: Determine the target circular trajectory according to the target plane and the target ball space.
[0069] Specifically, the area where the target plane and the target ball space overlap is determined as the area where the target circle is located, thereby determining the target circle trajectory.
[0070] From the above content, it can be seen that the present application takes into account that multiple collected data points on a circle in three-dimensional space are on the target plane on the one hand and on the target sphere space on the other hand. Therefore, the target plane is determined first, and then the target sphere is determined. Finally, the target circle trajectory is determined based on the target plane and the target sphere. This can improve the accuracy of fitting, and the entire algorithm is simple, which can improve the speed of fitting.
[0071] See Figure 4 , Figure 4 2 is a schematic diagram of the structure of an embodiment of a fitting device of the present application. The fitting device 200 includes a processor 210, a memory 220, and a communication circuit 230. The processor 210 is coupled to the memory 220 and the communication circuit 230, respectively. The memory 220 stores program data. The processor 210 executes the program data in the memory 220 to implement the steps of any of the above-mentioned embodiments. The detailed steps can be found in the above-mentioned embodiments and will not be repeated here.
[0072] The fitting device 200 can be any device with algorithm processing capabilities, such as a computer or a mobile phone, and is not limited here.
[0073] See Figure 5 , Figure 53 is a schematic diagram of another embodiment of the fitting device of the present invention. The fitting device 300 includes an acquisition module 310, a fitting module 320, a centroid module 330, a circle center module 340, a radius module 350, a first determination module 360, and a second determination module 370, which are connected in sequence.
[0074] The acquisition module 310 is used to acquire multiple collected data points in a three-dimensional space.
[0075] The fitting module 320 is used to perform plane fitting based on multiple collected data points to obtain a target plane.
[0076] The centroid module 330 is used to calculate the centroid of multiple collected data points.
[0077] The circle center module 340 is used to determine the center of the target circle according to the center of mass.
[0078] The radius module 350 is used to determine the radius of the target circle according to the distance from the center of the target circle to multiple collected data points.
[0079] The first determination module 360 is used to determine the target ball space with the center of the target circle as the center of the ball and the radius of the target circle as the radius of the target ball.
[0080] The second determination module 370 is used to determine the target circular trajectory according to the target plane and the target sphere space.
[0081] The fitting device 300 executes the method steps in any of the above embodiments when working. The detailed method steps can be found in the above related content and will not be repeated here.
[0082] The fitting device 300 may be any device with algorithm processing capability, such as a computer or a mobile phone, and is not limited here.
[0083] See Figure 6 , Figure 6 The computer-readable storage medium 400 stores a computer program 410, which can be executed by a processor to implement the steps of any of the above methods.
[0084] Among them, the computer-readable storage medium 400 can specifically be a device that can store the computer program 410, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it can also be a server that stores the computer program 410. The server can send the stored computer program 410 to other devices for execution, or it can also run the stored computer program 410 itself.
[0085] The above description is merely an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for fitting a spatial circular trajectory, characterized in that: The method comprises: Acquire a plurality of collected data points in a three-dimensional space, wherein the plurality of collected data points are data points collected by a sensor provided on a robotic arm; Performing plane fitting based on the multiple collected data points to obtain a target plane; Calculating the centroid of the plurality of collected data points; Determining the center of the target circle based on the centroid; Determining the radius of the target circle according to the distance from the center of the target circle to the multiple collected data points; Taking the center of the target circle as the center of the sphere and the radius of the target circle as the radius of the target sphere, the target sphere space is determined; Determining the target circular trajectory according to the target plane and the target ball space; The step of calculating the centroid of the plurality of collected data points includes: Filtering a plurality of target data points from the plurality of collected data points, wherein the distance between any two adjacent target data points is within a preset range; Calculating the centroids of the plurality of target data points, and determining the centroids of the plurality of target data points as the centroids of the plurality of collected data points; The step of determining the center of the target circle according to the centroid includes: Projecting the centroid vertically onto the target plane to obtain a projection point; Determine the projection point as the center of the target circle; The step of determining the radius of the target circle according to the distance from the center of the target circle to the plurality of collected data points comprises: Calculating the average distance from the center of the target circle to the plurality of collected data points; Obtaining the radius of the target circle according to the average distance; The step of determining the target circular trajectory according to the target plane and the target ball space includes: The area where the target plane and the target ball space overlap is determined as the area where the target circle is located, thereby determining the target circle trajectory.
2. The method according to claim 1, characterized in that The step of performing plane fitting based on the multiple collected data points to obtain a target plane includes: The target plane is obtained by performing plane fitting based on the multiple collected data points and using the least square method.
3. The method according to claim 1, characterized in that The step of selecting a plurality of target data points from the plurality of collected data points comprises: Searching for an initial data point among the plurality of collected data points; Searching for the collected data points adjacent to the initial data point among the collected data points that have not been searched; Determine whether the distance between the found collected data point and the initial data point is greater than a preset distance; If the result of the judgment is greater than, the found collected data point is retained and used as the initial data point, and then the process returns to the step of searching for the collected data point adjacent to the initial data point among the collected data points that have not been searched. Otherwise, the found collected data point is deleted, and then the process returns to the step of searching for the collected data point adjacent to the initial data point among the collected data points that have not been searched; After traversing each of the collected data points, each of the retained collected data points is used as the target data point.
4. The method according to claim 1, wherein The step of calculating the centroid of the plurality of collected data points comprises: Calculating the average values of the plurality of collected data points on the X component, the Y component, and the Z component respectively; The average values of the X component, Y component, and Z component are respectively determined as the X component, Y component, and Z component of the centroid.
5. A fitting device, characterized in that: The fitting device includes a processor, a memory and a communication circuit, the processor is coupled to the memory and the communication circuit respectively, the memory stores program data, and the processor implements the steps in the method according to any one of claims 1 to 4 by executing the program data in the memory.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program can be executed by a processor to implement the steps in the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Track searching method, device and equipment for arc welding seam and storage medium
CN114663350A
Method and device for welding circular track by robot
CN115937162A