A curve fitting method, device, electronic equipment and storage medium
By employing non-uniform B-spline curves and considering the inconsistency in path point velocity and spacing, the fitting error problem of uniform B-spline curves with non-fixed path point spacing is solved, achieving a better path fitting effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2024-12-31
- Publication Date
- 2026-06-30
AI Technical Summary
Existing path fitting methods based on uniform B-spline curves have poor fitting results when the spacing between path points is not fixed, especially with large fitting errors near the endpoint.
By employing a non-uniform B-spline curve and considering the inconsistency in speed and spacing of path points, the control points and node vectors of the non-uniform B-spline curve are determined, and a matrix expression is used for fitting to ensure that the fitted curve passes through all path points.
This reduces the fitting error, improves the path fitting effect, and makes the fitted curve more in line with actual needs.
Smart Images

Figure CN122306062A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of path planning technology, and more specifically, to a curve fitting method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, robots are widely used in logistics warehousing, large shopping malls, and industrial parts handling. Robots achieve autonomous navigation by perceiving their surroundings, understanding map information, and making decisions. Path planning technology is the foundation of navigation technology, enabling robots to find an optimal path between their starting point and destination.
[0003] In practical robot applications, uniform B-spline curves are often used to fit paths to obtain smooth planned trajectories. However, the fitting effect based on uniform B-spline curves is poor, and it is difficult to handle the problem of non-fixed spacing between path points, resulting in large fitting errors near the endpoint. Therefore, improving the path fitting effect and reducing the fitting error has become an urgent technical problem to be solved. Summary of the Invention
[0004] This application provides a curve fitting method, apparatus, electronic device, and storage medium, which can improve the path fitting effect and reduce the fitting error.
[0005] Firstly, a curve fitting method is provided, comprising: determining each path point to be fitted and the velocity corresponding to a target path point among the path points; determining a first node vector corresponding to a non-uniform B-spline curve to be fitted based on the path points to be fitted; determining control points of the non-uniform B-spline curve based on the velocities corresponding to the path points to be fitted, the target path points, and the matrix expression corresponding to the non-uniform B-spline curve; wherein the matrix expression is used to describe the correspondence between the control points of the non-uniform B-spline curve, the velocities corresponding to the path points to be fitted, and the target path points, and the number of target path points is the degree of the non-uniform B-spline curve minus 1; determining each fitting point on the non-uniform B-spline curve based on the control points of the non-uniform B-spline curve and the first node vector; and determining the fitted non-uniform B-spline curve based on each fitting point.
[0006] In conjunction with the first aspect, in some possible implementations, determining the control points of the non-uniform B-spline curve based on the velocities corresponding to the path points to be fitted, the target path points, and the matrix expression corresponding to the non-uniform B-spline curve includes: determining the coefficient matrix in the matrix expression based on the first node vector; wherein the coefficient matrix includes the weight coefficients corresponding to the non-uniform B-spline curve; and substituting the path points to be fitted, the weight coefficients, and the velocities corresponding to the target path points into the matrix expression to calculate the control points of the non-uniform B-spline curve.
[0007] In conjunction with the first aspect, in some possible implementations, determining the coefficient matrix in the matrix expression based on the first node vector includes: calculating the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector; wherein the first weight coefficient is used to fit the path points; taking the first derivative of the non-uniform B-spline curve to obtain the velocity curve corresponding to the non-uniform B-spline curve; removing the first and last nodes from the first node vector to obtain the second node vector corresponding to the velocity curve; calculating the second weight coefficient of the control points of the non-uniform B-spline curve based on the second node vector; wherein the second weight coefficient is used to fit the velocity corresponding to the target path point; and determining the coefficient matrix in the matrix expression based on the first weight coefficient and the second weight coefficient.
[0008] In conjunction with the first aspect, in some possible implementations, the calculation of the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector includes: calculating the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector and a first formula; wherein the first formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the first node vector and the first weight coefficient; the calculation of the second weight coefficient of the control points of the non-uniform B-spline curve based on the second node vector includes: calculating the weight coefficient of the control points of the velocity curve based on the second node vector and a second formula; wherein the second formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the second node vector and the weight coefficient of the control points of the velocity curve; calculating the second weight coefficient based on the weight coefficient of the control points of the velocity curve, the nodes in the first node vector, and a third formula; wherein the third formula is used to describe the correspondence between the weight coefficient of the control points of the velocity curve, the nodes in the first node vector, the degree of the non-uniform B-spline curve, and the second weight coefficient.
[0009] In conjunction with the first aspect, in some possible implementations, the aforementioned non-uniform B-spline curve is a p-th order non-uniform B-spline curve, and the aforementioned matrix expression is constructed based on the following method: Constructing a first expression corresponding to the points on the aforementioned p-th order non-uniform B-spline curve; wherein the first expression describes the correspondence between the points on the aforementioned p-th order non-uniform B-spline curve, the first weight coefficient, and the control points of the aforementioned p-th order non-uniform B-spline curve; wherein the first weight coefficient is used to fit the aforementioned path points; Constructing a second expression corresponding to the points on the p-1 order non-uniform B-spline curve corresponding to the aforementioned p-th order non-uniform B-spline curve; wherein the second expression describes the correspondence between the points on the aforementioned p-1 order non-uniform B-spline curve, the second weight coefficient, and the control points of the aforementioned p-th order non-uniform B-spline curve; wherein the second weight coefficient is used to fit the velocity corresponding to the aforementioned target path point; Constructing the aforementioned matrix expression based on the aforementioned first expression and the aforementioned second expression.
[0010] In conjunction with the first aspect, in some possible implementations, the construction of the second expression corresponding to the points on the (p-1)th order non-uniform B-spline curve corresponding to the p-th order non-uniform B-spline curve includes: constructing a third expression corresponding to the points on the (p-1)th order non-uniform B-spline curve; wherein the third expression describes the correspondence between the points on the (p-1)th order non-uniform B-spline curve, the weight coefficients of the control points of the (p-1)th order non-uniform B-spline curve, and the control points of the (p-1)th order non-uniform B-spline curve; constructing a fourth expression between the control points of the (p-1)th order non-uniform B-spline curve and the control points of the p-th order non-uniform B-spline curve; and constructing the second expression based on the third expression and the fourth expression.
[0011] In conjunction with the first aspect, in some possible implementations, the degree of the aforementioned non-uniform B-spline curve is 3, and the velocities corresponding to the aforementioned target path points include: the starting velocity corresponding to the starting path point and the ending velocity corresponding to the ending path point.
[0012] In conjunction with the first aspect, in some possible implementations, the above matrix expression is as follows:
[0013]
[0014] Among them, V1, V2, V3, ..., V h-1 Let h represent the path points mentioned above, and let v represent the number of path points to be fitted. s This represents the preset starting velocity, v. d This represents the preset endpoint velocity, p0, p1, p2, p3...p h-1 p h p h+1These represent the control points of a non-uniform B-spline curve.
[0015] a 3,3 a 3,2 a 3,1 These represent the first weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve when fitting the path point V0;
[0016] a 4,3 a 4,2 a 4,1 These represent the first weighting coefficients of the control points p1, p2, and p3 of the 3rd-order non-uniform B-spline curve when fitting the path point V1;
[0017] a 5,3 a 5,2 a 5,1 These represent the first weighting coefficients of the control points p2, p3, and p4 of the 3rd degree non-uniform B-spline curve when fitting the path point V2.
[0018] a 6,3 a 6,2 a 6,1 These represent the first weighting coefficients of the control points p3, p4, and p5 of the cubic non-uniform B-spline curve when fitting the path point V3;
[0019] a h+2,3 a h+2,2 a h+2,1 They represent: the fitted path point V h-1 Control points p of a cubic non-uniform B-spline curve h-1 p h p h+1 The first weighting coefficient;
[0020] b 2,2 b 2,1 b 2,0 They represent: the initial velocity v of the fitted point. s The second weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve;
[0021] b h+1,2 b h+1,1 b h+1,0 They represent: the final velocity v of the fitted curve. d Control points p of a cubic non-uniform B-spline curve h-1 p h p h+1 The second weighting coefficient.
[0022] Secondly, a curve fitting device is provided, comprising: a path point determination module for determining each path point to be fitted and the velocity corresponding to a target path point among the path points; a first node vector determination module for determining a first node vector corresponding to the non-uniform B-spline curve to be fitted based on the path points to be fitted; a control point determination module for determining control points of the non-uniform B-spline curve based on the velocities corresponding to the path points to be fitted, the target path points, and the matrix expression corresponding to the non-uniform B-spline curve; wherein the matrix expression describes the correspondence between the control points of the non-uniform B-spline curve, the path points to be fitted, and the velocities corresponding to the target path points, and the number of target path points is: the degree of the non-uniform B-spline curve minus 1; and a fitting module for determining each fitting point on the non-uniform B-spline curve based on the control points and the first node vector, and determining the fitted non-uniform B-spline curve based on each fitting point.
[0023] Thirdly, an electronic device is provided, comprising: a memory for storing executable program code; and a processor for calling and running the executable program code from the memory, causing the electronic device to perform the method of the first aspect or any possible implementation thereof.
[0024] Fourthly, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0025] Fifthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation thereof.
[0026] The curve fitting method, apparatus, electronic device, and storage medium provided in this application have the following beneficial effects: If the number of path points to be fitted is denoted as h, and the degree of the non-uniform B-spline curve is p, then the number of control points of the non-uniform B-spline curve is h+p-1, that is, the number of unknowns to be determined is h+p-1. In this embodiment, when determining the control points, in addition to considering each path point to be fitted, i.e., the h path points, the p-1 parameters corresponding to the target path points are also taken into account. This allows h+p-1 equations to be obtained based on the matrix expression, thus ensuring that the number of unknowns to be solved is the same as the number of equations used to solve the unknowns. The h+p-1 equations are just enough to solve for the h+p-1 control points, making the final control points unique and ensuring that the fitted non-uniform B-spline curve will definitely pass through each path point to be fitted, thereby helping to reduce fitting errors. Attached Figure Description
[0027] Figure 1 This is a schematic diagram of a DeBoor algorithm flow provided in an embodiment of this application;
[0028] Figure 2 This is a schematic diagram illustrating the fitting effect of fitting a path using a uniform B-spline curve, as provided in an embodiment of this application.
[0029] Figure 3 This is a schematic flowchart of a curve fitting method provided in an embodiment of this application;
[0030] Figure 4 This is a schematic diagram of the fitting effect of using a non-uniform B-spline curve to fit a path, provided in an embodiment of this application.
[0031] Figure 5 This is a schematic diagram of the structure of a curve fitting device provided in an embodiment of this application.
[0032] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0033] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0034] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0035] In practical robot applications, uniform B-spline curves are often used to fit the path to obtain a smooth planned trajectory. For ease of understanding, the definition of a p-th degree B-spline curve is first introduced below:
[0036]
[0037] Among them, P i Let u be a control point, and u be a node, whose set U = {u0, u1, ..., u2} m Let} be the node vector, and let U be a monotonically non-decreasing sequence, u0 = a, u m =b. N i,p (u) is the o-th p-th B-spline basis function defined on node u, which can be solved recursively:
[0038]
[0039] Once the node vector U and control points P of the B-spline curve are determined, the value of any node u can be calculated using formulas (1.1) and (1.2) above. i The corresponding B-spline curve fitting point C(u) i In practical applications, the DeBoor algorithm, which is faster and more stable, is typically used to solve the problem. The DeBoor algorithm leverages the multi-node property of B-spline curves, rapidly solving for any node u by continuously inserting nodes. i The corresponding fitting point C(u) i If node u i After p consecutive insertions into the B-spline, the newly generated control points are located on the B-spline curve where u intersects the line. i The corresponding fitting points. For a p-th degree B-spline curve with no repeated nodes, for any u... i :u i ∈[u k ,u k+1 ), can be based on such Figure 1 The DeBoor algorithm flowchart shown calculates u i The coordinates C(u) of the corresponding fitting point i ) = p i,p .
[0040] The following is about Figure 1 The DeBoor algorithm flow is described below:
[0041] Input: Parameters (u), number of iterations (p), node vector (U), control point (P)
[0042] Output: Point C(u) on the B-spline curve.
[0043] The main flow of the DeBoor algorithm is as follows:
[0044] 1. Location node range: [u k ,u k+1 )←locateK not(u,U), which determines the node interval where the input parameter (u) is located in the node vector (U): [u k ,u k+1 ).
[0045] 2. Main loop:
[0046] For any number from r = 1 to p, perform the following steps:
[0047] • For any number from i = k - p + r to k, perform the following steps:
[0048] • Calculate the weighting coefficient a i,r :
[0049]
[0050] Update control point p i,r :
[0051] p i,r =(1-a i,r )p i-1,r-1 +a i,r p i,r-1
[0052] Among them, a i,r p represents the control point p of the i-th (r-1)th B-spline. i,r-1 The weighting coefficient, p i,r Let represent the control point of the i-th r-th B-spline.
[0053] 3. End the loop and output the result:
[0054] When i = k and r = p, the final p will be obtained. k,p Point C(u) is located on the B-spline curve.
[0055] This application, through research, reveals that when fitting a path using a uniform B-spline curve based on the aforementioned DeBoor algorithm, nodes in the node vector U are sampled at a fixed resolution as timestamps to obtain a smooth B-spline trajectory. However, in practical robot applications, the fitting effect is poor when using a uniform B-spline curve to fit the path. The inventors have discovered the following reasons for the poor fitting effect:
[0056] When the number of path points to be fitted is h, for a p-order B-spline curve, its control point P i The relationship between the number of nodes n and the number of nodes m in the node vector U should satisfy: n = h + p - 1, m = h + 2p. The basis functions are not fully defined for the first p and last p nodes of the node vector U; therefore, the effective node interval is [u...]. p+1 ,u h+p-1 When fitting a path using a uniform B-spline curve, the uniform parameter method is chosen for node u. i The choice of node vector U. For the uniform parameter method, the first p nodes of the node vector U are 0, and the last p nodes are 1, with the node interval [u...]. p+1 ,u h+p-1 The values of the nodes within the range change uniformly from 0 to 1. It can be understood that when p = 3, n = h + 2.
[0057] See Figure 2 , Figure 2 This is a schematic diagram illustrating the fitting effect of using a uniform B-spline curve to fit the path. For example... Figure 2 As shown, the starting and ending points are connected by a straight line composed of discrete points. The path downsampling algorithm downsamples the original path at a fixed resolution (e.g., a fixed resolution of 0.2m). Since the length of the original path may not be an integer multiple of 0.2m, the Euclidean distance between the last path point and the second-to-last path point is 0.1m. Figure 2 The experimental results show that the fitted uniform B-spline curve has a large fitting error near the endpoint. This is mainly because the uniform B-spline curve renders the nodal interval [u p+1 ,u h+p-1 Setting the B-spline to be uniform does not adequately address the issue of uneven spacing between path points, resulting in poor fitting performance. Therefore, uniform B-spline curves struggle to handle situations where the spacing between path points is not fixed, leading to suboptimal fitting results.
[0058] Based on this, in order to improve the path fitting effect and reduce the fitting error, this application provides a curve fitting method. Unlike the traditional path fitting method based on uniform B-spline curves, this application takes into account factors such as the speed corresponding to the target path point, the starting speed, the ending speed, and the inconsistency of the spacing between path points, and proposes a path fitting method based on non-uniform B-spline curves. This method can ensure a better path fitting effect and make the obtained path easier for users to understand and accept.
[0059] The curve fitting method in this embodiment is applied to an electronic device, which performs the curve fitting method. This electronic device can be implemented as a host computer communicating with the robot, and can be various types of devices, such as mobile terminals, tablet computers, laptops, desktop computers, or servers. The server can be a single server or a group of servers. The server group can be centralized or distributed. In some embodiments, the server can be local or remote relative to the user terminal. Furthermore, the server can also be implemented through a cloud platform, such as a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, cross-cloud, multi-cloud, or any combination thereof. In some embodiments, the server can be implemented on an electronic device having one or more components. Additionally, the electronic device can be an embedded device integrated with the robot body. Of course, the electronic device can also be other forms of electronic devices, which will not be detailed in this embodiment.
[0060] The application scenario of this application embodiment can be: robot path planning scenario. After obtaining the path points to be fitted through the path planning algorithm, the curve fitting method in this application embodiment can be used to fit a non-uniform B-spline curve, and the fitted non-uniform B-spline curve can be used as the path curve for robot planning.
[0061] In conjunction with the relevant descriptions in the above embodiments, to make this solution easier to understand, the following will be combined with... Figure 3 The flowchart shown illustrates in detail the curve fitting method provided in this embodiment. For example... Figure 3 As shown, the method includes:
[0062] Step 301: Determine the path points to be fitted and the speed corresponding to the target path point in each path point.
[0063] Step 302: Based on the path points to be fitted, determine the first node vector corresponding to the non-uniform B-spline curve to be fitted.
[0064] Step 303: Determine the control points of the non-uniform B-spline curve based on the velocities corresponding to each path point to be fitted, the target path point, and the matrix expression corresponding to the non-uniform B-spline curve; wherein, the matrix expression is used to describe the correspondence between the control points of the non-uniform B-spline curve, each path point to be fitted, and the velocities corresponding to the target path point.
[0065] Step 304: Based on the control points and the first node vector of the non-uniform B-spline curve, determine each fitting point on the non-uniform B-spline curve, and based on each fitting point, determine the fitted non-uniform B-spline curve.
[0066] exist Figure 3 In the illustrated embodiment, if the number of path points to be fitted is denoted as h, and the degree of the non-uniform B-spline curve is p, then the number of control points for the non-uniform B-spline curve is h+p-1. In other words, the number of unknowns to be determined is h+p-1. In this embodiment, when determining the control points, in addition to considering the h path points to be fitted, the p-1 parameters corresponding to the target path points are also taken into account. This allows for the generation of h+p-1 equations based on matrix expressions, ensuring that the number of unknowns to be solved is the same as the number of equations used to solve for the unknowns. The h+p-1 equations are precisely used to solve for the h+p-1 control points, resulting in a unique solution for the final control points. Furthermore, it ensures that the fitted non-uniform B-spline curve will definitely pass through each of the path points to be fitted, thereby helping to reduce fitting errors.
[0067] The following is about Figure 3 The specific implementation methods of each step in the illustrated embodiment are explained below:
[0068] In step 301, the electronic device can obtain the path points to be fitted according to the path planning algorithm. These path points can be: path points planned for the robot, including key points covering the path, such as the start point, end point, and inflection points, and each path point has its own position coordinates. In this embodiment, the path points to be fitted V = {V0, V1, V2...V...} h-2 V h-1 The number of path points to be fitted is denoted as h.
[0069] The path planning algorithm can be selected according to actual needs, such as: Rapidly-exploring Random Tree (RRT), Probabilistic Roadmap (PRM), Gradient Descent, Particle Swarm Optimization (PSO), Simultaneous Localization and Mapping (SLAM), etc. However, this application embodiment does not specifically limit the selected path planning algorithm.
[0070] For example, the spacing between the path points to be fitted can be set to be small, which is beneficial for solving the control points later, ensuring that the control points have a unique solution. For instance, a path planning algorithm can be used to set the spacing between the path points to be fitted to be less than a preset difference value.
[0071] The number of target path points in each path point is the order of the non-uniform B-spline curve minus 1. That is, for a p-order non-uniform B-spline curve, the number of target path points is p-1. The speed corresponding to a target path point can be the desired speed set for that target path point, such as the desired speed at which the robot travels on the target path point. The number of target path points is the number of speeds corresponding to each target path point. For ease of understanding, a specific example is given below:
[0072] When p=3, the non-uniform B-spline curve is a cubic non-uniform B-spline curve, and the number of target path points can be p-1=2. Considering that the starting velocity and the ending velocity have more practical physical meaning and are easier to set, when it is necessary to select 2 target path points, the starting path point and the ending path point can be selected. Thus, the velocities corresponding to the target path points can include: the starting velocity corresponding to the starting path point and the ending velocity corresponding to the ending path point.
[0073] When p=2, the non-uniform B-spline curve is a second-order non-uniform B-spline curve. The number of target path points can be p-1=1. The target path points can be either the starting path point or the ending path point. Therefore, the speed corresponding to the target path point can include either the starting speed corresponding to the starting path point or the ending speed corresponding to the ending path point.
[0074] The preset starting speed can be understood as the expected speed corresponding to the starting path point (the first path point) among the path points to be fitted, such as the expected speed of the robot at the starting path point. The preset ending speed can be understood as the expected speed corresponding to the ending path point (the last path point) among the path points to be fitted, such as the expected speed of the robot at the ending path point. The specific magnitudes of the preset starting speed and the preset ending speed can be set according to actual needs, and this application embodiment does not impose specific limitations on them.
[0075] When p=4, the non-uniform B-spline curve is a 4th-order non-uniform B-spline curve, and the number of target path points can be p-1=3. That is, the target path points can be selected from three path points, such as the starting path point, the ending path point, and a path point between the starting and ending path points. Optionally, the three path points can include: the starting path point V0, the ending path point V... h-1 And the second path point V1. Therefore, the velocities corresponding to the target path point include: the starting velocity corresponding to V0, V... h-1 The corresponding endpoint velocity and the velocity corresponding to V1.
[0076] When p=6, the non-uniform B-spline curve is a sixth-order non-uniform B-spline curve, and the number of target path points can be p-1=5. That is, the target path points can be selected from 5 path points, such as the starting path point, the ending path point, and the 3 path points between the starting and ending path points. Optionally, the 5 path points can include: the starting path point V0, the ending path point V... h-1 The second path point V1, the second-to-last path point V h-2 And the third path point V2. Therefore, the velocities corresponding to the target path point include: the starting velocity corresponding to V0, V... h-1 The corresponding final velocity, the velocity corresponding to V1, V h-2 The corresponding speed and the speed corresponding to V2.
[0077] In step 302, the first node vector corresponding to the non-uniform B-spline curve to be fitted is determined based on the position coordinates of each path point to be fitted. The selection of the first node vector has a significant impact on the shape of the non-uniform B-spline curve. The degree of this non-uniform B-spline curve is p, so it can also be called a p-order non-uniform B-spline curve. The value of p can be set according to actual needs, such as 3, 4, 5, etc., but this embodiment does not specifically limit it.
[0078] It should be noted that, in this embodiment of the application, for ease of description, the nodal vector of the non-uniform B-spline curve is referred to as the first nodal vector, and the nodal vector of the velocity curve corresponding to the non-uniform B-spline curve is referred to as the second nodal vector. The first nodal vector is denoted as nodal vector U1, and the second nodal vector is denoted as nodal vector U2.
[0079] In one possible implementation, based on the path points to be fitted, the non-uniform parameter method is used to determine the node vector U1 = {u0, u1, ..., u...} corresponding to the non-uniform B-spline curve to be fitted. m}. In conjunction with the above, when the number of path points to be fitted is h, for a cubic non-uniform B-spline curve, p = 3, its control points P i The relationship between the number of nodes *n* and the number of nodes *m* in node vector U1 should satisfy: *n* = *h* + 2, *m* = *h* + 2*p. The basis functions are not fully defined for the first *p* nodes and the last *p* nodes of node vector U1; therefore, the effective node interval is [u...]. p+1 u h+2 The first p nodes of node vector U1 are 0, and the last p nodes are 1. The valid node interval is [u p+1 u h+2 The values of the nodes within the range are determined by the distances between the corresponding points on the path to be fitted. For example, each node u within the valid node range... i , i∈[p+1, h+2], u i =u i-1 +dis, dis = (V i-p-1 -V i-p ) / V dis Among them, V dis V is the path length of the path to be fitted. i-p-1 and V i-p These are two adjacent path points.
[0080] In step 303, since the matrix expression is used to describe the correspondence between the control points of the p-th order non-uniform B-spline curve, the path points to be fitted, and the velocities corresponding to the target path points, the position coordinates of the path points to be fitted and the velocities corresponding to the target path points can be substituted into the matrix expression to calculate the position coordinates of the n control points of the non-uniform B-spline curve, so as to determine the control points of the non-uniform B-spline curve.
[0081] For example, for a cubic non-uniform B-spline curve, when the number of path points to be fitted is h, the obtained h+2 control points P = {p0, p1, p2...p...} h+1}, that is, the number of control points of the non-uniform B-spline curve is h+2. The position coordinates of each path point to be fitted, the preset starting velocity, and the ending velocity can be substituted into the above matrix expression to calculate the position coordinates of h+2 control points of the cubic non-uniform B-spline curve, so as to determine the control points of the non-uniform B-spline curve.
[0082] In one possible implementation, the control points of the non-uniform B-spline curve are determined based on the velocities corresponding to each path point to be fitted, the target path point, and the matrix expression corresponding to the non-uniform B-spline curve, including the following S11 to S12:
[0083] S11: Determine the coefficient matrix in the matrix expression based on the first node vector; where the coefficient matrix includes the weight coefficients corresponding to the non-uniform B-spline curve.
[0084] S12: Substitute the path points to be fitted, the weight coefficients, and the velocities corresponding to the target path points into the matrix expression to calculate the control points of the non-uniform B-spline curve.
[0085] Specifically, the matrix expression can be a linear expression similar to AX = D, where A is the coefficient matrix, X is the matrix composed of the control points to be solved, and D is the matrix composed of the velocities corresponding to each path point to be fitted and the target path point. In specific implementations, if the coefficient matrix A and matrix D in the above matrix expression are known, X can be calculated. The coefficient matrix A includes weight coefficients, and matrix D includes the velocities corresponding to each path point to be fitted and the preset target path point. Since each path point to be fitted has its own position coordinates, the position coordinates of each path point to be fitted, the weight coefficients, and the velocities corresponding to the preset target path point can be substituted into the matrix expression to calculate the h+p-1 control points P = {p0, p1, p2... p...} of the non-uniform B-spline curve. h+1}
[0086] For example, when p=3, matrix D includes the path points to be fitted, as well as the preset starting and ending velocities. Then, the position coordinates, weight coefficients, starting velocities, and ending velocities of the h path points to be fitted can be substituted into the matrix expression to calculate the h+2 control points P={p0,p1,p2...p} of the cubic non-uniform B-spline curve. h+1}
[0087] In one possible implementation, S11 is implemented as follows: S111 to S115:
[0088] S111: Calculate the first weighting coefficient of the control points of the non-uniform B-spline curve based on the first node vector.
[0089] In specific implementation, it can be done through methods such as Figure 1 The DeBoor algorithm flowchart shown calculates the first weight coefficients of the control points of the non-uniform B-spline curve. These first weight coefficients are used to fit each path point and include the weight coefficients used to fit each path point.
[0090] In one possible implementation, the above-mentioned calculation of the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector includes: calculating the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector and the first formula; wherein, the first formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the first node vector and the first weight coefficient.
[0091] For example, the first formula above can be expressed as follows:
[0092]
[0093] Among them, u i ∈[u k ,u k+1 ), r∈[1,p], i∈[k-p+i,k], p is the degree of the non-uniform B-spline curve, u i u k u i+p-r+1 For different nodes within the first node vector U1, a i,r This represents the first weighting coefficient, specifically referring to the control point p of the i-th (r-1)th order B-spline of the non-uniform B-spline curve. i,r-1 The weighting coefficients are given. The control point of the i-th r-1 order B-spline refers to the i-th point in the sequence of control points on an r-1 order B-spline curve. Using the first formula above, the first weighting coefficients of each control point of the non-uniform B-spline curve can be calculated.
[0094] S112: Take the first derivative of the non-uniform B-spline curve to obtain the velocity curve corresponding to the non-uniform B-spline curve.
[0095] The degree of the velocity curve is one less than that of the non-uniform B-spline curve. If the non-uniform B-spline curve is of degree p, then the velocity curve corresponding to the p-degree non-uniform B-spline curve is of degree p-1. For example, when p = 3, taking the first derivative of the 3rd degree non-uniform B-spline curve yields a 2nd degree non-uniform B-spline curve, which is the velocity curve corresponding to the 3rd degree non-uniform B-spline curve.
[0096] S113: Remove the first and last nodes from the first node vector to obtain the second node vector corresponding to the velocity curve.
[0097] Specifically, based on the description above, the first node vector U1 = {u0, u1, ..., u m If we remove the first node u0 and the last node u from the first node vector U1, then... m The second node vector U2 corresponding to the velocity curve is obtained.
[0098] {u1,...,u m-1}
[0099] S114: Calculate the second weighting coefficient of the control points of the non-uniform B-spline curve based on the second node vector.
[0100] The second weighting coefficient is used to fit the velocity corresponding to the target path point. When p=3, the second weighting coefficient includes: a weighting coefficient for fitting the starting velocity and a weighting coefficient for fitting the ending velocity.
[0101] In one possible implementation, the above-mentioned S114 may include: calculating the weight coefficients of the control points of the velocity curve based on the second node vector and the second formula; wherein the second formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the second node vector and the weight coefficients of the control points of the velocity curve; calculating the second weight coefficients of the control points of the non-uniform B-spline curve based on the weight coefficients of the control points of the velocity curve, the nodes in the first node vector, and the third formula; wherein the third formula is used to describe the correspondence between the weight coefficients of the control points of the velocity curve, the nodes in the first node vector, the degree of the non-uniform B-spline curve, and the second weight coefficients.
[0102] For example, the second formula above can be expressed as follows:
[0103]
[0104] Among them, u' i ∈[y' k ,u' k+1 ), r∈[1,p′], i∈[kp′+r,k], p′ is the degree of the velocity curve, p′=p-1, u' i 、u' k 、u' i+p′-r+1 For different nodes within the second node vector U2, α i′,r The weighting coefficients represent the control points of the velocity curve, specifically the weighting coefficients of the control points of the i-th (r-1)th order B-spline of the velocity curve. The control point of the i-th (r-1)th order B-spline is the i-th point in the sequence of control points on an (r-1)th order B-spline curve. The weighting coefficients of each control point of the velocity curve can be calculated using the second formula described above.
[0105] For example, when the non-uniform B-spline curve is a cubic non-uniform B-spline curve, the third formula above can be expressed as follows:
[0106]
[0107] For a cubic non-uniform B-spline curve, p = 3, α′ k-1,1 p′ is the control point of the (k-1)th linear B-spline of the velocity curve. k-1,1 The weighting coefficient, u k-1+p u k-1 u k u k+p All of them are nodes within the first node vector U1.
[0108] S115: Determine the coefficient matrix in the matrix expression based on the first weighting coefficient and the second weighting coefficient.
[0109] The coefficient matrix can be a positive definite matrix with (h+p-1) rows and (h+p-1) columns. The coefficient matrix includes unknown coefficients to be determined. The first weight coefficient and the second weight coefficient are the values of the unknown coefficients in the coefficient matrix. Therefore, the coefficient matrix in the matrix expression can be determined based on the first weight coefficient and the second weight coefficient.
[0110] In one possible implementation, the non-uniform B-spline curve is a p-th degree non-uniform B-spline curve, and the above matrix expression is constructed in the following ways: S21 to S23:
[0111] S21: Construct the first expression corresponding to the points on the p-th order non-uniform B-spline curve; wherein, the first expression is used to describe the correspondence between the points on the p-th order non-uniform B-spline curve, the first weight coefficient, and the control points of the p-th order non-uniform B-spline curve. The first weight coefficient is used to fit each path point.
[0112] Specifically, based on the DeBoor algorithm described above, we can construct the first expression corresponding to the points on a p-th degree non-uniform B-spline curve.
[0113] For example, for a p-th order non-uniform B-spline curve, as can be seen from the DeBoor algorithm flow described above, when node u = u k At that time, the point p on the corresponding p-th degree non-uniform B-spline curve k,p It can be represented as:
[0114] p k,p =a k,p p k-p +a k,p-1 p k-p+1 +a k,p-2 p k-p+2 +...+a k,1 pk-1
[0115] Among them, a k,p p is the control point of a p-th order non-uniform B-spline curve. k-p The first weighting coefficient, a k,p-1 p is the control point of a p-th order non-uniform B-spline curve. k-p+1 The first weighting coefficient, a k,p-2 p is the control point of a p-th order non-uniform B-spline curve. k-p+2 The first weighting coefficient, a k,1 p is the control point of a p-th order non-uniform B-spline curve. k-1 The first weighting coefficient.
[0116] It is understandable that p k,p Specifically, it represents the position coordinates of points on a p-th degree non-uniform B-spline curve, which are essentially also the position coordinates of points in the path V to be fitted. k,p =V k-p When a p-th order non-uniform B-spline curve is a cubic non-uniform B-spline curve, p k,3 =V k-3 For example, when k=3, p 3,3 =V0,p 4,3 =V1.
[0117] To facilitate understanding, the following explanation uses the first expression corresponding to points on a cubic non-uniform B-spline curve as an example:
[0118] For a cubic non-uniform B-spline curve, as can be seen from the DeBoor algorithm described above, when node u = u k At that time, the point p on the corresponding cubic non-uniform B-spline curve k,3 It can be expressed as the following formula (1.3):
[0119] p k,3 =(1-α) k,3 )p k-1,2 +α k,3 p k,2 (1.3)
[0120] Where, α k,3 p represents the control point of a cubic non-uniform B-spline curve. k,2 The weighting coefficient, (1-α) k,3 ) represents the control point p of a cubic non-uniform B-spline curve. k-1,2 The weighting coefficient. p in formula (1.3) k,2 and p k-1,2 It can also be expressed as the following formula (1.4):
[0121]
[0122] Where, α k-1,2 p represents the control point of a quadratic non-uniform B-spline curve. k-1,1 The weighting coefficient, (1-α) k-1,2 ) represents the control point p of a quadratic non-uniform B-spline curve. k-2,1 The weighting coefficient α. k,2 p represents the control point of a quadratic non-uniform B-spline curve. k,1 The weighting coefficient, (1-α) k,2 ) represents the control point p of a quadratic non-uniform B-spline curve. k-1,1 The weighting coefficients.
[0123] p in formula (1.4) k-2,1 p k-1,1 p k,1 It can also be expressed as the following formula (1.5):
[0124]
[0125] Where, α k-2,1 p represents the control point of a first-order non-uniform B-spline curve. k-2 The weighting coefficients, (1-α) k-2,1 ) represents the control point p of a first-order non-uniform B-spline curve. k-3 The weighting coefficient α. k-1,1 p represents the control point of a first-order non-uniform B-spline curve. k-1 The weighting coefficient, (1-α) k-1,1 ) represents the control point p of a first-order non-uniform B-spline curve. k-2 The weighting coefficient α. k,1 p represents the control point of a first-order non-uniform B-spline curve. k The weighting coefficient, (1-α) k,1 ) represents the control point p of a first-order non-uniform B-spline curve. k-1 The weighting coefficients.
[0126] Further simplification of formulas (1.3) to (1.5) yields the following formula (1.6):
[0127] p k,3 =a k,3 p k-3 +a k,2 p k-2 +a k,1 p k-1 (1.6)
[0128] More generally, for any p (p = 2, 3, 4, ..., n) degree B-spline curve, as can be seen from the DeBoor algorithm flow, when node u = u k At that time, the point p on the corresponding B-spline curvek,p It can be represented as:
[0129] p k,p =a k,p p k-p +a k,p-1 p k-p+1 +a k,p-2 p k-p+2 +...+a k,1 p k-1
[0130] Wherein, point p on the B-spline curve k,p The corresponding path point V to be fitted k-p .
[0131] Formula (1.6) is the first expression corresponding to the points on the constructed cubic non-uniform B-spline curve. k,3 =(1-α) k-1,2 )(1-α k-2,1 ), a k,2 =(1-α) k-1,2 )α k-2,1 +α k-1,2 (1-α k-1,1 ), a k,1 =α k-1,2 α k-1,1 When the number of path points to be fitted is h, for a cubic non-uniform B-spline curve, the number of control points P is h+2. From the node interval [u3, u...] of the first node vector U1... h+2 Take u in sequence from ] k Let k∈[3, h+2], and substitute it into formula (1.6) to obtain h equations. At this point, there are still 2 design degrees of freedom, so the starting velocity and the ending velocity can be introduced as constraints, thus obtaining h+2 equations.
[0132] S22: Construct a second expression corresponding to the points on the (p-1)th order non-uniform B-spline curve corresponding to the p-th order non-uniform B-spline curve; wherein, the second expression is used to describe the correspondence between the points on the (p-1)th order non-uniform B-spline curve, the second weighting coefficient, and the control points of the p-th order non-uniform B-spline curve. The second weighting coefficient is used to fit the velocity corresponding to the target path points.
[0133] Specifically, based on the DeBoor algorithm described above, a second expression can be constructed corresponding to the points on a p-1 degree non-uniform B-spline curve.
[0134] For example, for a cubic non-uniform B-spline curve, its corresponding velocity curve is a quadratic non-uniform B-spline curve. For a quadratic non-uniform B-spline curve (velocity curve), as shown in the DeBoor algorithm flow above, when the node u′=u′ of the quadratic non-uniform B-spline curve…k At that time, the point p′ on the corresponding quadratic B-spline curve k,2 It can be represented as:
[0135] p′ k,2 =(1-α′) k-1,1 )p′ k-2 +α′ k-1,1 p′ k-1
[0136] Among them, (1-α′ k-1,1 p′ is the control point of a quadratic non-uniform B-spline curve. k-2 The weighting coefficient, α′ k-1,1 p′ is the control point of a quadratic non-uniform B-spline curve. k-1 The weighting coefficients.
[0137] It is understandable that p′ k,2 Specifically, v represents the velocity of a point on a quadratic non-uniform B-spline curve; therefore, v s =p′ 2,2 v d =p′ h+1,1 .
[0138] For example, the above-mentioned S22 can be implemented as follows: S221 to S223:
[0139] S221: Construct a third expression corresponding to the points on the p-1 degree non-uniform B-spline curve; wherein, the third expression is used to describe the correspondence between the points on the p-1 degree non-uniform B-spline curve, the weight coefficients of the control points of the p-1 degree non-uniform B-spline curve, and the control points of the p-1 degree non-uniform B-spline curve.
[0140] The third expression can be constructed based on the DeBoor algorithm described above. For example, when the p-1th order non-uniform B-spline curve (i.e., the velocity curve) is a 2nd order non-uniform B-spline curve, the third expression can be represented as follows:
[0141] p′ k,2 =(1-α′) k-1,1 )p′ k-2 +α′ k-1,1 p′ k-1
[0142] Where, p′ k,2 It can represent the velocity corresponding to a point on a quadratic non-uniform B-spline curve, α′ k-1,1 p′ is the control point on a quadratic non-uniform B-spline curve. k-1 The weighting coefficients, (1-α′ k-1,1 p′ is the control point on a quadratic non-uniform B-spline curve. k-2 The weighting coefficients.
[0143] S222: The fourth expression for constructing the control points of the p-1 degree non-uniform B-spline curve and the control points of the p degree non-uniform B-spline curve.
[0144] The fourth expression can be represented as follows:
[0145]
[0146] p′ k p represents the control points of a p-1 degree non-uniform B-spline curve. k+1 and p k All represent the control points of a p-th order non-uniform B-spline curve, u k+p+1 and u k+1 All of them represent nodes in the first node vector U1.
[0147] S223: Construct the second expression based on the third and fourth expressions.
[0148] Specifically, the second expression can be constructed by combining the third and fourth expressions, for example, by substituting the fourth expression into the third expression.
[0149] To facilitate understanding, the following explanation uses the second expression corresponding to points on a quadratic non-uniform B-spline curve corresponding to a cubic non-uniform B-spline curve as an example:
[0150] For a cubic non-uniform B-spline curve, its corresponding velocity curve is a quadratic non-uniform B-spline curve. For a quadratic non-uniform B-spline curve, its node vector U2 is the set after removing the first and last nodes from U1. Similarly, from formulas (1.4) and (1.5), it can be seen that when the node u′ of the quadratic non-uniform B-spline curve is u′=u′ k At that time, the point p′ on the corresponding quadratic non-uniform B-spline curve (p′=2) k,2 It can be represented as:
[0151] p′ k,2 =(1-α′) k-1,1 )p′ k-2 +α′ k-1,1 p′ k-1 (1.7)
[0152] in, p′ k-2 and p′ k-1 All are control points of a quadratic non-uniform B-spline curve.
[0153] The relationship between the control points of a quadratic non-uniform B-spline curve and the control points of a cubic non-uniform B-spline curve can be expressed as:
[0154]
[0155] By combining equations (1.7) and (1.8), the relationship between velocity and the control points of the cubic non-uniform B-spline curve can be expressed as:
[0156] p′ k,2 =b k,2 p k-2 +b k,1 p k-1 +b k,0 p k (1.9)
[0157] in, Formula (1.9) is the second expression corresponding to the points on the constructed quadratic non-uniform B-spline curve.
[0158] S23: Construct a matrix expression based on the first and second expressions.
[0159] The matrix expression can be a linear expression like AX = D, where A is the coefficient matrix, X is the matrix composed of the control points to be solved, and D is the matrix composed of the path points to be fitted, the preset starting speed, and the ending speed.
[0160] For example, the degree of the non-uniform B-spline curve is 3, and the velocities corresponding to the target path points include: the starting velocity corresponding to the starting path point and the ending velocity corresponding to the ending path point. Therefore, based on the above formulas (1.6) and (1.9), the matrix expression shown in formula (1.10) can be constructed. That is, for a 3rd degree non-uniform B-spline curve, its control points P = {p0, p1, p2... p...} h+1 The path points V = {V0, V1, V2, V3, ..., V} to be fitted h-1} and initial velocity v s Final velocity v d The relationship between them can be expressed in matrix form as shown in the following formula (1.10):
[0161]
[0162] Based on the above matrix expression, we can see that:
[0163]
[0164] Among them, V0, V1, V2, V3, ..., V h-1 Let h represent the path points mentioned above, and let v represent the number of path points to be fitted. s This represents the preset starting velocity, v. dThis represents the preset endpoint velocity, p0, p1, p2, p3...p h-1 p h p h+1 These represent the control points of a non-uniform B-spline curve.
[0165] a 3,3 a 3,2 a 3,1 These represent the first weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve at the fitted path point V0. Specifically, a 3,3 Let a be the first weighting coefficient for control point p0. 3,2 Let a be the first weighting coefficient for control point p1. 3,1 The first weighting coefficient is for control point p2.
[0166] a 4,3 a 4,2 a 4,1 These represent the first weighting coefficients of the control points p1, p2, and p3 of the cubic non-uniform B-spline curve at the fitted path point V1. Specifically, a 4,3 Let a be the first weighting coefficient for control point p1. 4,2 Let a be the first weighting coefficient for control point p2. 4,1 The first weighting coefficient is for control point p3.
[0167] a 5,3 a 5,2 a 5,1 These represent the first weighting coefficients of the control points p2, p3, and p4 of the 3rd degree non-uniform B-spline curve when fitting the path point V2.
[0168] a 6,3 a 6,2 a 6,1 These represent the first weighting coefficients of the control points p3, p4, and p5 of the 3rd-order non-uniform B-spline curve when fitting the path point V3.
[0169] As can be understood, in the coefficient matrix A above, the path points from V4 to V are omitted. h-1 The first weight coefficient of the control points. Correspondingly, in the matrix X above, control points p4 to p5 are omitted. h-2 The path points V4 to V are omitted in the matrix D above. h-2 .
[0170] a h+2,3 a h+2,2 a h+2,1 They represent: the fitted path point V h-1 Control points p of a cubic non-uniform B-spline curve h-1 p h ph+1 The first weighting coefficient.
[0171] b 2,2 b 2,1 b 2,0 They represent: the initial velocity v of the fitted point. s The second weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve.
[0172] b h+1,2 b h+1,1 b h+1,0 They represent: the final velocity v of the fitted curve. d Control points p of a cubic non-uniform B-spline curve h-1 p h p h+1 The second weighting coefficient.
[0173] The above formula (1.10) can be converted into h+2 equations, each of which is used to solve for one control point, thus finally obtaining h+2 control points.
[0174] It should be noted that the above embodiments mainly take the construction of the matrix expression corresponding to the 3rd order non-uniform B-spline curve as an example for explanation. In the specific implementation, the same idea can be used to extend to higher or lower order non-uniform B-spline curves to obtain the matrix expression corresponding to the higher or lower order non-uniform B-spline curve. To avoid repetition, it will not be elaborated here.
[0175] In step 304, taking a cubic non-uniform B-spline curve as an example, the control points P = {p0, p1, p2... p...} of the cubic non-uniform B-spline curve are obtained. h+1 After that, for any node u in the first node vector U1, according to Figure 1 The DeBoor algorithm flowchart shown can obtain the corresponding point of any node u on the non-uniform B-spline curve, which is the fitting point C(u). Connecting the fitting points yields the fitted non-uniform B-spline curve, which can be used as the path curve for robot planning.
[0176] See Figure 4 , Figure 4 This is a schematic diagram illustrating the fitting effect of using a non-uniform B-spline curve to fit the path. Compared to Figure 2 , Figure 4 The fitted non-uniform B-spline curve shows virtually no fitting error near the endpoint. This demonstrates that the non-uniform B-spline curve performs better when the spacing between path points is inconsistent. Using the non-uniform B-spline curve improves the fitting effect for discrete path points and its adaptability to non-uniform paths.
[0177] Figure 5 This is a schematic diagram of the structure of a curve fitting device provided in an embodiment of this application.
[0178] For example, such as Figure 5 As shown, the curve fitting device 500 includes:
[0179] The path point determination module 501 is used to determine each path point to be fitted and the speed corresponding to the target path point in each path point.
[0180] The first node vector determination module 502 is used to determine the first node vector corresponding to the non-uniform B-spline curve to be fitted based on the path points to be fitted mentioned above.
[0181] The control point determination module 503 determines the control points of the non-uniform B-spline curve based on the velocities corresponding to the path points to be fitted and the target path points, as well as the matrix expression corresponding to the non-uniform B-spline curve. The matrix expression is used to describe the correspondence between the control points of the non-uniform B-spline curve, the velocities corresponding to the path points to be fitted and the target path points.
[0182] The fitting module 504 is used to determine each fitting point on the non-uniform B-spline curve based on the control points of the non-uniform B-spline curve and the first node vector, and to determine the fitted non-uniform B-spline curve based on each of the fitting points.
[0183] In one possible implementation, the control point determination module 503 includes: a coefficient matrix determination unit, used to determine the coefficient matrix in the matrix expression based on the first node vector; wherein the coefficient matrix includes each weight coefficient corresponding to the non-uniform B-spline curve; and a calculation unit, used to input each path point to be fitted, each weight coefficient, and the velocity corresponding to the target path point into the matrix expression to calculate the control points of the non-uniform B-spline curve.
[0184] In one possible implementation, the coefficient matrix determination unit is specifically used for: calculating the first weight coefficient of the control points of the non-uniform B-spline curve based on the first node vector; wherein the first weight coefficient is used to fit the path points; performing a first derivative on the non-uniform B-spline curve to obtain the velocity curve corresponding to the non-uniform B-spline curve; removing the first and last nodes from the first node vector to obtain the second node vector corresponding to the velocity curve; calculating the second weight coefficient of the control points of the non-uniform B-spline curve based on the second node vector; wherein the second weight coefficient is used to fit the velocity corresponding to the target path point; and determining the coefficient matrix in the matrix expression based on the first weight coefficient and the second weight coefficient.
[0185] In one possible implementation, the coefficient matrix determination unit is specifically used to: calculate the first weight coefficient of the control points of the non-uniform B-spline curve according to the first node vector and the first formula; wherein the first formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the first node vector and the first weight coefficient; calculate the weight coefficient of the control points of the velocity curve according to the second node vector and the second formula; wherein the second formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the second node vector and the weight coefficient of the control points of the velocity curve; calculate the second weight coefficient according to the weight coefficient of the control points of the velocity curve, the nodes in the first node vector, and the third formula; wherein the third formula is used to describe the correspondence between the weight coefficient of the control points of the velocity curve, the nodes in the first node vector, the degree of the non-uniform B-spline curve, and the second weight coefficient.
[0186] In one possible implementation, the aforementioned non-uniform B-spline curve is a p-th order non-uniform B-spline curve. The curve fitting device further includes a matrix expression construction module, used to construct a first expression corresponding to the points on the p-th order non-uniform B-spline curve; wherein the first expression describes the correspondence between the points on the p-th order non-uniform B-spline curve, the first weight coefficient, and the control points of the p-th order non-uniform B-spline curve; wherein the first weight coefficient is used to fit the path points; a second expression is constructed corresponding to the points on the (p-1)-th order non-uniform B-spline curve corresponding to the p-th order non-uniform B-spline curve; wherein the second expression describes the correspondence between the points on the (p-1)-th order non-uniform B-spline curve, the second weight coefficient, and the control points of the p-th order non-uniform B-spline curve; wherein the second weight coefficient is used to fit the velocity corresponding to the target path point; and the matrix expression is constructed based on the first expression and the second expression.
[0187] In one possible implementation, the matrix expression construction module is specifically used to construct a third expression corresponding to the points on the aforementioned p-1 degree non-uniform B-spline curve; wherein the aforementioned third expression is used to describe the correspondence between the points on the aforementioned p-1 degree non-uniform B-spline curve, the weight coefficients of the control points of the aforementioned p-1 degree non-uniform B-spline curve, and the control points of the aforementioned p-1 degree non-uniform B-spline curve; a fourth expression is constructed between the control points of the aforementioned p-1 degree non-uniform B-spline curve and the control points of the aforementioned p- degree non-uniform B-spline curve; and the aforementioned second expression is constructed based on the aforementioned third expression and the aforementioned fourth expression.
[0188] In one possible implementation, the non-uniform B-spline curve has a degree of 3, and the velocities corresponding to the target path points include: the starting velocity corresponding to the starting path point and the ending velocity corresponding to the ending path point.
[0189] In one possible implementation, the matrix expression is as follows:
[0190]
[0191] Among them, V0, V1, V2, V3, ..., V h-1 Let h represent the path points mentioned above, and let v represent the number of path points to be fitted. s This represents the preset starting velocity, v. d This represents the preset endpoint velocity, p0, p1, p2, p3...p h-1 p h p h+1 These represent the control points of a non-uniform B-spline curve.
[0192] a 3,3 a 3,2 a 3,1 These represent the first weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve at the fitted path point V0.
[0193] a 4,3 a 4,2 a 4,1 These represent the first weighting coefficients of the control points p1, p2, and p3 of the 3rd degree non-uniform B-spline curve when fitting the path point V1.
[0194] a 5,3 a 5,2 a 5,1 These represent the first weighting coefficients of the control points p2, p3, and p4 of the 3rd degree non-uniform B-spline curve when fitting the path point V2.
[0195] a 6,3 a 6,2 a 6,1 These represent the first weighting coefficients of the control points p3, p4, and p5 of the 3rd-order non-uniform B-spline curve when fitting the path point V3.
[0196] The first weight coefficients of the control points used to fit the path from path point V4 to path point Vh-1 are omitted in the coefficient matrix above.
[0197] a h+2,3 a h+2,2 a h+2,1 They represent: the fitted path point V h-1 Control points p of a cubic non-uniform B-spline curve h-1 ph p h+1 The first weighting coefficient.
[0198] b 2,2 b 2,1 b 2,0 They represent: the initial velocity v of the fitted point. s The second weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve.
[0199] b h+1,2 b h+1,1 b h+1,0 They represent: the final velocity v of the fitted curve. d Control points p of a cubic non-uniform B-spline curve h+1 p h p h+1 The second weighting coefficient.
[0200] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0201] For example, such as Figure 6 As shown, the electronic device 600 includes a memory 601 and a processor 602. The memory 601 stores executable program code 6011, and the processor 602 is used to call and execute the executable program code 6011 to perform a curve fitting method.
[0202] Furthermore, embodiments of this application also protect an apparatus that may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to perform a curve fitting method provided in embodiments of this application.
[0203] This embodiment can divide the device into functional modules based on the above method example. For example, each module can correspond to a separate function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0204] When each functional module is divided according to its corresponding function, the device may further include: a path point determination module, a first node vector determination module, a control point determination module, a fitting module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0205] It should be understood that the apparatus provided in this embodiment is used to perform the curve fitting method described above, and therefore can achieve the same effect as the above implementation method.
[0206] When using integrated units, the device may include a processing module and a storage module. When applied to an electronic device, the processing module can be used to control and manage the operation of the electronic device. The storage module can be used to support the execution of relevant program code by the electronic device.
[0207] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits shown in conjunction with the disclosure of this application. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.
[0208] In addition, the device provided in the embodiments of this application may specifically be a chip, component or module. The chip may include a connected processor and a memory. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can execute a curve fitting method provided in the above embodiments.
[0209] This embodiment also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the above-described related method steps to implement a curve fitting method provided in the above embodiment.
[0210] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement a curve fitting method provided in the above embodiment.
[0211] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0212] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0213] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0214] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A curve fitting method, characterized in that, The method includes: Determine the path points to be fitted and the velocity corresponding to the target path point among the path points; Based on each path point to be fitted, determine the first node vector corresponding to the non-uniform B-spline curve to be fitted; Based on the path points to be fitted, the velocities corresponding to the target path points, and the matrix expression corresponding to the non-uniform B-spline curve, the control points of the non-uniform B-spline curve are determined; wherein, the matrix expression is used to describe the correspondence between the control points of the non-uniform B-spline curve, the path points to be fitted, and the velocities corresponding to the target path points, and the number of target path points is: the degree of the non-uniform B-spline curve minus 1. Based on the control points of the non-uniform B-spline curve and the first node vector, each fitting point on the non-uniform B-spline curve is determined, and based on each fitting point, the fitted non-uniform B-spline curve is determined.
2. The method according to claim 1, characterized in that, The step of determining the control points of the non-uniform B-spline curve based on the path points to be fitted, the velocities corresponding to the target path points, and the matrix expression corresponding to the non-uniform B-spline curve includes: Based on the first node vector, the coefficient matrix in the matrix expression is determined; wherein, the coefficient matrix includes the weight coefficients corresponding to the non-uniform B-spline curve; By substituting the path points to be fitted, the weight coefficients, and the velocities corresponding to the target path points into the matrix expression, the control points of the non-uniform B-spline curve are calculated.
3. The method according to claim 2, characterized in that, The step of determining the coefficient matrix in the matrix expression based on the first node vector includes: Based on the first node vector, calculate the first weighting coefficient of the control points of the non-uniform B-spline curve; wherein, the first weighting coefficient is used to fit each path point; By taking the first derivative of the non-uniform B-spline curve, the velocity curve corresponding to the non-uniform B-spline curve is obtained. Remove the first and last nodes from the first node vector to obtain the second node vector corresponding to the velocity curve; Based on the second node vector, calculate the second weighting coefficient of the control points of the non-uniform B-spline curve; wherein, the second weighting coefficient is used to fit the velocity corresponding to the target path point; The coefficient matrix in the matrix expression is determined based on the first weighting coefficient and the second weighting coefficient.
4. The method according to claim 3, characterized in that, The step of calculating the first weighting coefficient of the control points of the non-uniform B-spline curve based on the first node vector includes: Based on the first node vector and the first formula, the first weight coefficient of the control points of the non-uniform B-spline curve is calculated; wherein, the first formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the first node vector and the first weight coefficient; The step of calculating the second weighting coefficient of the control points of the non-uniform B-spline curve based on the second node vector includes: The weight coefficients of the control points of the velocity curve are calculated based on the second node vector and the second formula; wherein, the second formula is determined based on the de Boer algorithm and is used to describe the correspondence between the nodes in the second node vector and the weight coefficients of the control points of the velocity curve. The second weighting coefficient is calculated based on the weighting coefficients of the control points of the velocity curve, the nodes in the first node vector, and the third formula; wherein, the third formula is used to describe the correspondence between the weighting coefficients of the control points of the velocity curve, the nodes in the first node vector, the degree of the non-uniform B-spline curve, and the second weighting coefficient.
5. The method according to claim 1, characterized in that, The non-uniform B-spline curve is a p-th degree non-uniform B-spline curve, and the matrix expression is constructed based on the following method: Construct a first expression corresponding to the points on the p-th order non-uniform B-spline curve; wherein, the first expression is used to describe the correspondence between the points on the p-th order non-uniform B-spline curve, the first weight coefficient, and the control points of the p-th order non-uniform B-spline curve; wherein, the first weight coefficient is used to fit each path point. Construct a second expression corresponding to the points on the (p-1)th order non-uniform B-spline curve corresponding to the p-th order non-uniform B-spline curve; wherein, the second expression is used to describe the correspondence between the points on the (p-1)th order non-uniform B-spline curve, the second weight coefficient, and the control points of the p-th order non-uniform B-spline curve; wherein, the second weight coefficient is used to fit the velocity corresponding to the target path point. The matrix expression is constructed based on the first expression and the second expression.
6. The method according to claim 5, characterized in that, The second expression for constructing the points on the (p-1)th order non-uniform B-spline curve corresponding to the p-th order non-uniform B-spline curve includes: Construct a third expression corresponding to the points on the p-1 degree non-uniform B-spline curve; wherein, the third expression is used to describe the correspondence between the points on the p-1 degree non-uniform B-spline curve, the weight coefficients of the control points of the p-1 degree non-uniform B-spline curve, and the control points of the p-1 degree non-uniform B-spline curve. Construct a fourth expression between the control points of the p-1 degree non-uniform B-spline curve and the control points of the p degree non-uniform B-spline curve; The second expression is constructed based on the third and fourth expressions.
7. The method according to any one of claims 1 to 6, characterized in that, The degree of the non-uniform B-spline curve is 3, and the velocity corresponding to the target path point includes: the starting velocity corresponding to the starting path point and the ending velocity corresponding to the ending path point.
8. The method according to claim 7, characterized in that, The matrix expression is as follows: Among them, V0, V1, V2, V3, ..., V h-1 Let h represent the path points to be fitted, and v represent the number of path points to be fitted. s The starting velocity, v d The endpoint velocities are represented by p0, p1, p2, p3...p h-1 p h p h+1 These represent the control points of a cubic non-uniform B-spline curve. a 3,3 a 3,2 a 3,1 These represent the first weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve when fitting the path point V0; a 4,3 a 4,2 a 4,1 These represent the first weighting coefficients of the control points p1, p2, and p3 of the 3rd-order non-uniform B-spline curve when fitting the path point V1; a 5,3 a 5,2 a 5,1 These represent the first weighting coefficients of the control points p2, p3, and p4 of the cubic non-uniform B-spline curve when fitting the path point V2; a 6,3 a 6,2 a 6,1 These represent the first weighting coefficients of the control points p3, p4, and p5 of the cubic non-uniform B-spline curve when fitting the path point V3; a h+2,3 a h+2,2 a h+2,1 They represent: the fitted path point V h-1 Control points p of a cubic non-uniform B-spline curve h-1 p h p h+1 The first weighting coefficient; b 2,2 b 2,1 b 2,0 They represent: the initial velocity v of the fitted point. s The second weighting coefficients of the control points p0, p1, and p2 of the cubic non-uniform B-spline curve; p h+1,2 b h+1,1 b h+1,0 They represent: the final velocity v of the fitted curve. d Control points p of a cubic non-uniform B-spline curve h-1 p h b h+1 The second weighting coefficient.
9. A curve fitting device, characterized in that, include: The path point determination module is used to determine each path point to be fitted and the speed corresponding to the target path point among the path points. The first node vector determination module is used to determine the first node vector corresponding to the non-uniform B-spline curve to be fitted based on each path point to be fitted. The control point determination module determines the control points of the non-uniform B-spline curve based on the path points to be fitted, the velocities corresponding to the target path points, and the matrix expression corresponding to the non-uniform B-spline curve. The matrix expression describes the correspondence between the control points of the non-uniform B-spline curve, the path points to be fitted, and the velocities corresponding to the target path points. The number of target path points is equal to the degree of the non-uniform B-spline curve minus one. The fitting module is used to determine each fitting point on the non-uniform B-spline curve based on the control points of the non-uniform B-spline curve and the first node vector, and to determine the fitted non-uniform B-spline curve based on each fitting point.
10. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, implements the method as described in any one of claims 1 to 8.