A numerical control industrial processing method and device based on trajectory curve fitting
By dividing the trajectory in CNC industrial machining into sub-segments and fitting them, the problem of frequent tool pauses is solved, improving machining efficiency and equipment lifespan.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU XINT AUTOMATION TECH CO LTD
- Filing Date
- 2025-02-14
- Publication Date
- 2026-05-12
AI Technical Summary
In current CNC industrial machining, the frequent pauses of machining tools caused by custom processing of CNC files result in equipment vibration and slow processing speed.
By using a trajectory curve fitting method, the trajectory to be fitted is divided into multiple sub-segments, and then fitted to obtain the target fitted trajectory, thereby reducing the number of pauses during tool operation and improving machining efficiency.
This reduces the frequency of servo motor starts and stops, lowers equipment vibration, and improves processing efficiency and equipment lifespan.
Smart Images

Figure CN120010391B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CNC industrial machining technology, and in particular to a CNC industrial machining method and apparatus based on trajectory curve fitting. Background Technology
[0002] With the upgrading of industrial equipment automation, in order to adapt to the processing of various free shapes, more and more industrial products tend to use CNC machining methods to achieve contour processing. In the process of using CNC machining, the machining tool is mainly controlled by the CNC industrial controller to process the industrial product along a predetermined trajectory.
[0003] Currently, custom machining using CNC files has become standard practice in CNC industrial controller machining. Since CNC files are generally generated by design software in the relevant field, many design software programs, in order to ensure that some low-end CNC industrial controllers, which cannot execute circular arcs or splines, can successfully run these files, will break down the original circular arcs, polylines, splines, etc., into small, continuous, dense sub-segment trajectories. This results in a large number of short trajectory points in the CNC machining file. Therefore, when using the point-to-point original trajectory of the CNC machining file, the number of times the machining tool pauses will increase, leading to slower machining speeds. Furthermore, frequent trajectory changes during machining will cause frequent start-stop cycles of the servo motors, resulting in equipment vibration and affecting the overall lifespan of the equipment. Summary of the Invention
[0004] The purpose of this invention is to solve the problems in the prior art, and to propose a numerical control industrial machining method and apparatus based on trajectory curve fitting.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A CNC industrial machining method based on trajectory curve fitting.
[0007] Includes the following steps:
[0008] Based on the product type of the product to be processed, obtain the trajectory to be fitted and the processing mode, and obtain the first trajectory coordinates of the trajectory to be fitted;
[0009] Based on the processing mode and the first trajectory coordinates, the trajectory to be fitted is divided into multiple sub-segments; the multiple sub-segments are in a continuous state.
[0010] By fitting multiple sub-line segments, the target fitted trajectory is obtained;
[0011] Based on the second trajectory coordinates of the target fitted trajectory, the type of the target fitted trajectory is determined;
[0012] The product to be processed is CNC machined based on the type of the target fitted trajectory.
[0013] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein fitting multiple sub-line segments to obtain a target fitted trajectory includes:
[0014] The starting point coordinates of the first target sub-segment among the plurality of sub-segments are connected with the two endpoint coordinates of the second target sub-segment among the plurality of sub-segments to obtain the first included angle; the first target sub-segment is the first sub-segment among the plurality of sub-segments, and the second target sub-segment is any other sub-segment among the plurality of sub-segments except the first sub-segment;
[0015] The starting point coordinates of the first target sub-segment among the plurality of sub-segments are connected with the two endpoint coordinates of the third target sub-segment among the plurality of sub-segments to obtain the second included angle; the third target sub-segment is any other sub-segment among the plurality of sub-segments besides the first sub-segment and the second sub-segment, and the third target sub-segment is continuous with the second target sub-segment and located after the second target sub-segment;
[0016] The angle difference is obtained based on the first included angle and the second included angle;
[0017] The multiple sub-line segments are fitted based on the angle difference to obtain the target fitted trajectory.
[0018] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein fitting the plurality of sub-line segments based on the angle difference to obtain the target fitted trajectory includes:
[0019] If the angle difference is less than or equal to a preset threshold, then the first trend direction result between the current target sub-segment and the fourth target sub-segment, and the second trend direction result between the current target sub-segment and the fifth target sub-segment are determined; the current target sub-segment is any sub-segment other than the first sub-segment and the second sub-segment among the multiple sub-segments, the fourth target sub-segment is an adjacent sub-segment of the current target sub-segment, and the fifth target sub-segment is an alternating sub-segment of the current target sub-segment;
[0020] If the first trend direction result is consistent with the trend direction, and the second trend direction result is consistent with the trend direction, then the current target sub-segment, the fourth target sub-segment, and the fifth target sub-segment are connected until at least one of the first trend direction result and the second trend direction result is inconsistent with the trend direction, then the fitting is stopped, and the target fitting trajectory is obtained.
[0021] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein connecting the starting coordinates of the first target sub-segment among a plurality of sub-segments with the coordinates of the two endpoints of the second target sub-segment among a plurality of sub-segments to obtain a first included angle includes:
[0022] Based on the starting coordinate x0 of the first target sub-segment and the i-th sub-segment x in the second target sub-segment i and the (i+1)th sub-segment x in the second target sub-segment i+1 Determine the first included angle;
[0023] The formula for calculating the first included angle is as follows:
[0024]
[0025] Among them, a i Let b be the length between the endpoint of the i-th sub-segment in the second target sub-segment and the starting point coordinate x0 in the first target sub-segment. i+1 c represents the length between the end point of the (i+1)th sub-segment in the second target sub-segment and the starting point x0. i+1 It represents the length of the (i+1)th sub-segment in the second target sub-segment.
[0026] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein determining the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory includes:
[0027] Based on the first coordinate information, the second coordinate information, and the third coordinate information in the second trajectory coordinates, the slope change result of the target fitted trajectory is obtained; the first coordinate information, the second coordinate information, and the third coordinate information are the coordinate information of different trajectory coordinate positions in the second trajectory coordinates;
[0028] If the slope change result is a preset value, then the type of the target fitted trajectory is determined to be a straight line trajectory;
[0029] If the slope change result is not the preset value, then the type of the target fitted trajectory is determined to be a circular arc trajectory.
[0030] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein the machining mode includes a first machining mode, the first machining mode representing tool path planning along a contour line of the same height on the workpiece;
[0031] The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes:
[0032] If the processing mode is the first processing mode, then the equation line corresponding to the ordinate of the first target trajectory coordinate point in the first trajectory coordinate is determined as a contour line; the first target trajectory coordinate point is any trajectory coordinate point in the first trajectory coordinate.
[0033] Determine the vertical distance between each trajectory coordinate point in the first trajectory coordinate system and the contour line;
[0034] Based on the Euclidean distance and perpendicular distance between two adjacent trajectory coordinate points in the first trajectory coordinate system, the trajectory to be fitted is divided into multiple sub-segments.
[0035] According to the present invention, a CNC industrial machining method based on trajectory curve fitting is provided, wherein the machining mode includes a second machining mode, the second machining mode characterized by the tool path maintaining an equal distance from the part contour;
[0036] The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes:
[0037] If the processing mode is the second processing mode, then the first trajectory coordinate point in the first trajectory coordinate is used as the first reference trajectory coordinate point, and the second target trajectory coordinate point in the first trajectory coordinate is determined; a first sub-line segment is constructed based on the trajectory coordinate points between the first trajectory coordinate point and the second target trajectory coordinate point; the coordinate point distance between the second target trajectory coordinate point and the first trajectory coordinate point is equal to a preset spacing value;
[0038] Using the second target trajectory coordinate point as the second reference trajectory coordinate point, determine the third target trajectory coordinate point in the first trajectory coordinates; construct a second sub-line segment based on the trajectory coordinate points between the second target trajectory coordinate point and the third target trajectory coordinate point, until all trajectory coordinate points in the first trajectory coordinates are constructed as sub-line segments, thus obtaining the plurality of sub-line segments; the coordinate point distance between the third target trajectory coordinate point and the second target trajectory coordinate point is equal to a preset spacing value.
[0039] A CNC industrial machining device based on trajectory curve fitting, comprising:
[0040] The acquisition unit is used to acquire the trajectory to be fitted and the processing mode based on the product type of the product to be processed, and to acquire the first trajectory coordinates of the trajectory to be fitted.
[0041] The first processing unit is configured to divide the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments are in a continuous state.
[0042] The second processing unit is used to fit multiple sub-line segments to obtain a target fitted trajectory;
[0043] The third processing unit is used to determine the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory.
[0044] The output unit is used to perform CNC machining on the product to be processed based on the type of the target fitted trajectory.
[0045] The present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of a CNC industrial machining method based on trajectory curve fitting as described in any of the preceding claims.
[0046] The present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a CNC industrial machining method based on trajectory curve fitting as described in any of the preceding claims.
[0047] Compared with the prior art, the present invention has the following advantages:
[0048] This invention provides a CNC industrial machining method and apparatus based on trajectory curve fitting. First, the trajectory to be fitted is divided into multiple sub-segments based on a first trajectory coordinate system, changing the trajectory coordinates from points to sub-segments, thus initially improving overall machining efficiency. Then, multiple sub-segments are fitted to obtain a target fitted trajectory. This target fitted trajectory is a combination of multiple sub-segments, allowing the tool to travel a longer distance in a single pass, further improving overall machining efficiency. Finally, the product to be machined is CNC machined based on the type of the target fitted trajectory. During product machining, targeted processing is performed according to the type of the target fitted trajectory, resulting in better machining effects. In summary, this invention first changes the point-to-point machining method in the trajectory to a line-segment to line-segment machining method, and then further fits the line-segment to line-segment machining method, thereby minimizing the number of pauses during tool operation and improving overall machining efficiency. Simultaneously, it minimizes the frequent start-stop cycles of the servo motor, reducing vibration problems caused by frequent start-stop cycles and extending the equipment's lifespan. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0050] Figure 1 A schematic diagram of the CNC industrial machining method based on trajectory curve fitting provided in an embodiment of the present invention;
[0051] Figure 2 Trajectory illustration provided for embodiments of the present invention Figure 1 ;
[0052] Figure 3 Trajectory illustration provided for embodiments of the present invention Figure 2 ;
[0053] Figure 4 Trajectory illustration provided for embodiments of the present invention Figure 3 ;
[0054] Figure 5 Quadrant diagram of a Cartesian coordinate system provided in an embodiment of the present invention;
[0055] Figure 6 A schematic diagram of the structure of a CNC industrial machining device based on trajectory curve fitting provided in an embodiment of the present invention;
[0056] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0058] The following is combined Figure 1 - Figure 5 This invention describes a numerical control industrial machining method and apparatus based on trajectory curve fitting.
[0059] Figure 1 This is a schematic diagram of the CNC industrial machining method based on trajectory curve fitting provided in an embodiment of the present invention. Figure 1 As shown, the method includes:
[0060] Step 101: Obtain the trajectory to be fitted based on the product type of the product to be processed, and obtain the first trajectory coordinates of the trajectory to be fitted.
[0061] Specifically, the product type of the product to be processed includes its shape, product category, and purpose, all of which are pre-stored in the database. The CNC machining controller retrieves this information from the database. The product to be processed can be any of the following: mechanical parts and molds. Each product type corresponds to a CNC machining tool trajectory in the database. Therefore, after obtaining the product type, the CNC machining controller can determine all the trajectories of the product to be processed from the pre-stored database. All trajectories include the trajectory to be fitted and the trajectory that does not need to be fitted. Here, only the trajectory to be fitted is obtained, along with the trajectory coordinates of the corresponding trajectory points in the database, i.e., the first trajectory coordinates. Thus, after obtaining the trajectory to be fitted, the controller can quickly match the corresponding first trajectory coordinates and obtain the starting position of the trajectory to be fitted, as well as other information about the trajectory coordinates carried by the trajectory to be fitted.
[0062] Step 102: Divide the trajectory to be fitted into multiple sub-segments based on the processing mode and the coordinates of the first trajectory; the multiple sub-segments are in a continuous state.
[0063] Specifically, in the process of dividing the trajectory into multiple sub-segments, different methods of sub-segment division can be used according to different processing modes to adapt to different usage requirements. Meanwhile, after obtaining the specific position of the first trajectory coordinates in the planar coordinate system, since each trajectory to be fitted consists of several trajectory points, the length of the multiple sub-segments is limited within a certain range, thus allowing each individual sub-segment to be considered a straight line segment. By dividing the trajectory to be fitted into multiple sub-segments, the point-to-point operation in actual work is initially planned to be operated on a sub-segment-to-sub-segment basis, changing the actual trajectory operation method, initially improving overall work efficiency, and facilitating subsequent fitting processing between adjacent sub-segments.
[0064] Furthermore, the machining mode includes a first machining mode, which represents toolpath planning along contour lines of the same height on the workpiece. That is, the first machining mode is a constant-height machining mode. In the constant-height machining mode, the smoothness and consistency of the machined surface can be guaranteed, effectively reducing the stress and deformation generated during machining. For machining complex shapes, it can better control dimensional accuracy and surface roughness, thereby improving the quality of machining.
[0065] Wherein, if the processing mode is the first processing mode, the equation line corresponding to the ordinate of the first target trajectory coordinate point in the first trajectory coordinate is determined as a contour line; the first target trajectory coordinate point is any trajectory coordinate point in the first trajectory coordinate; the vertical distance between each trajectory coordinate point in the first trajectory coordinate and the contour line is determined; based on the Euclidean distance and vertical distance between two adjacent trajectory coordinate points in the first trajectory coordinate, the trajectory to be fitted is divided into multiple sub-segments. Here, the equation line corresponding to the ordinate of the first target trajectory coordinate point, in one embodiment, if the first target trajectory coordinate point P1(x p y p If ), then the corresponding equation line is y = y p .
[0066] The machining mode also includes a second machining mode, which indicates that the tool path maintains an equal distance from the part contour. This is the equidistant machining mode. In this mode, when machining simple, equidistant structures, the tool movement path is relatively simple, the machining process is smoother, and machining efficiency is improved, especially for mass production of equidistant structures. This allows for the division of multiple sub-segments within the equal-height machining mode.
[0067] If the processing mode is the second processing mode, the first trajectory coordinate point in the first trajectory coordinate is used as the first reference trajectory coordinate point, and the second target trajectory coordinate point in the first trajectory coordinate is determined; the first sub-segment is constructed based on the trajectory coordinate points between the first trajectory coordinate point and the second target trajectory coordinate point; the distance between the coordinate points of the second target trajectory coordinate point and the first trajectory coordinate point is equal to the preset spacing value; in addition, the preset spacing value is less than or equal to the length limit range value of the above-mentioned division of multiple sub-segments.
[0068] Using the second target trajectory coordinate point as the second reference trajectory coordinate point, the third target trajectory coordinate point in the first trajectory coordinate system is determined. A second sub-segment is constructed based on the trajectory coordinate points between the second and third target trajectory coordinate points, until all trajectory coordinate points in the first trajectory coordinate system are constructed as sub-segments, resulting in multiple sub-segments. The distance between the coordinate points of the third target trajectory coordinate point and the second target trajectory coordinate point is equal to a preset spacing value. This achieves the process of dividing multiple sub-segments under the equidistant processing mode.
[0069] Step 103: Fit multiple sub-segments to obtain the target fitted trajectory.
[0070] Specifically, the starting coordinates of the first target sub-segment among multiple sub-segments are connected with the coordinates of the two endpoints of the second target sub-segment among multiple sub-segments to obtain the first included angle. The first target sub-segment is the first sub-segment among multiple sub-segments, and the second target sub-segment is any other sub-segment among multiple sub-segments except the first sub-segment. In the actual calculation process, since the sub-segment fitting process is performed one by one from the starting point, the second target sub-segment starts sequentially from the second sub-segment.
[0071] Connect the starting point coordinates of the first target sub-segment among multiple sub-segments with the coordinates of the two endpoints of the third target sub-segment among multiple sub-segments to obtain the second included angle. The third target sub-segment is any other sub-segment among multiple sub-segments except for the first and second sub-segments. The third target sub-segment is continuous with the second target sub-segment and is located after the second target sub-segment. In the actual calculation process, since the sub-segment fitting process is performed one by one starting from the starting point, the third target sub-segment, while following the second target sub-segment continuously, starts sequentially from the third sub-segment.
[0072] Based on the first and second included angles, the angle difference is obtained. Multiple sub-segments are then fitted using this angle difference to obtain the target fitted trajectory. When calculating the angle difference, the degree of inflection of the third target sub-segment compared to the second target sub-segment can be determined.
[0073] Step 104: Determine the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory.
[0074] Specifically, after fitting multiple sub-segments into a continuous target trajectory, the second trajectory coordinates of the fitted target trajectory can be obtained based on the initial trajectory coordinates. Then, based on the first, second, and third coordinate information in the second trajectory coordinates, the slope change of the target trajectory is obtained. Based on the slope change, the type of the target trajectory is determined. The first, second, and third coordinate information are coordinates at different positions in the second trajectory coordinates, ensuring that the coordinates of the first, second, and third coordinate information are distinct. This allows for the calculation of slope changes using three points. Furthermore, the first coordinate information preferably represents the starting point, the second coordinate information preferably represents the midpoint of the target trajectory, and the third coordinate information preferably represents the ending point. The slope change at these three points is calculated using the starting point, midpoint, and ending point of the entire target trajectory. Therefore, the type of the fitted target trajectory can be determined based on the slope change. The types of target trajectories are divided into straight-line trajectories and circular arc trajectories.
[0075] Step 105: Perform CNC machining on the product to be processed based on the type of the target fitted trajectory.
[0076] Specifically, when performing CNC machining on the product to be processed, the industrial controller controls the machining tool to process the product based on the fitted straight line trajectory and the fitted circular arc trajectory, so that the machining tool continuously passes through the fitted straight line trajectory or circular arc trajectory to complete the line-to-line machining process of the product to be processed.
[0077] This invention relates to the fields of CNC machining, motion trajectory, and trajectory fitting, and proposes a CNC industrial machining method based on trajectory curve fitting. In this invention, the proposed CNC industrial machining method first divides the trajectory to be fitted into multiple sub-segments based on the first trajectory coordinates, changing the trajectory coordinates from points to sub-segments to initially improve overall machining efficiency. Then, the multiple sub-segments are fitted to obtain the target fitted trajectory, which is a combination of multiple sub-segments, allowing the tool to travel a longer distance in one pass during machining, further improving overall machining efficiency. Finally, CNC machining of the product to be processed is performed based on the type of the target fitted trajectory—whether it is a straight line or a circular arc—allowing for targeted processing and better machining results. This invention, in the machining process, first changes the point-to-point machining method in the trajectory to a line segment-to-line segment machining method, and then further fits the line segment-to-line segment machining method, thereby minimizing the number of pauses during tool operation and improving overall machining efficiency. Simultaneously, it minimizes the frequent start-stop cycles of the servo motor, reducing vibration problems caused by frequent start-stops and extending the equipment's lifespan.
[0078] In step 102, if the processing mode is the first processing mode, i.e., the contour processing mode, in one embodiment, the coordinate set of several points of the first trajectory coordinates is first set as P = {p1, p2, p3, ..., p...} n}, where each point p q The coordinates are (x q y q The y-value of a point in the coordinate set P of the first trajectory is selected as the elevation value h of the contour line. For example, if the 5th point p5(x5, y5) is selected, then the orientation of the contour line is y = h = y5. For any point p in the first trajectory coordinate set... q (x q y q ), calculate p q The perpendicular distance d to the contour line y = h q If y q If ≥h, then d q =y q -h; if y q<h, then d q = h - y q At the same time, for each pair of adjacent points p q (x q , y q ) and p q+1 (x q+1 , y q+1 ) in the first trajectory coordinates (where q = 1, 2,..., n - 1), the Euclidean distance d q,q+1 between two adjacent trajectory coordinate points is given by the formula: And a distance threshold D d is preset. Starting from the first point p1 in the coordinate set P of the first trajectory coordinates, the Euclidean distance d q,q+1 between adjacent points and the perpendicular distance d q , d q+1 from the point to the contour line are checked in turn. When d q,q+1 ≤D d ; and |d q - d q+1 |≤∈ (∈ represents a preset small error tolerance value for judging the "approximate contour height" situation where adjacent points are near the contour line), when both are satisfied, these two adjacent points d q and d q+1 are regarded as belonging to the same sub-segment. When not both are satisfied, the point d q is taken as the end point of the current sub-segment, and then a new sub-segment is reconstructed starting from the point d q+1 . The above judgment process is repeated until all trajectory points are traversed, and the trajectory to be fitted is divided into multiple sub-segments.
[0079] In step 102, if the processing mode is the second processing mode, that is, the equidistant processing mode, in one embodiment. First, the coordinate set of several points of the first trajectory coordinates is set as F = {f1, f 2, f 3, …, f n}, where f m = (x m , y m ) represents the mth point in the two-dimensional coordinates. A preset spacing value is L, and the allowable distance error is for processing the approximate matching of the calculated distance and the preset spacing value. Then the current reference point f cu = f1 is set, the current sub-segment set S = {S1}, and a sub-segment S1 it contains is initialized, and a sub-segment index is set to mark the serial number of the sub-segment currently being constructed or processed, where S1 = {f1};
[0080] From the coordinate set F of several points on the first trajectory, the current reference point f is selected. cu Start by iterating through each point f in the set F (i.e., the index is greater than the index of the current reference point in the set F). m (m>index(f) cu For each point f visited, m Calculate its relationship with the current reference point f. cu Distance between In this process, seeking satisfaction point f ta So that the calculated point f r With the current reference point f cu The absolute value of the difference between the distance between them and the preset spacing value L is less than or equal to the allowable distance error. This means that a target point that approximately matches the preset spacing value has been found.
[0081] Then, when the target point f that satisfies the above conditions is found... ta At this time, construct a new sub-segment: create a new set of sub-segments. And initialize it to include the current reference point f. cu ,Right now Record the current reference point f cu The index in store S is Right now The index is from the coordinate set F. Starting from point f, to target point f ta Add these points to the newly created sub-segment set in turn. In, that is, for To index (f) ta ),implement Update sub-segment index The value is incremented by 1, that is... Update current reference point f cu For the target point f that was just found ta This is used in the next cycle to continue searching for the next target point and constructing new sub-segments with a new reference point.
[0082] Repeat the above steps until index (f) is reached. cu The expression ) = n indicates that the entire point set F has been traversed, and the resulting sub-segment set S = {S1, S2, ..., Sn} is obtained. m That is, according to the preset spacing value L and the allowable distance error. The result after dividing the original trajectory coordinate point set.
[0083] In step 103, when calculating the first included angle, the coordinates of the starting point x0 of the first target sub-segment and the coordinates of the i-th sub-segment x in the second target sub-segment are used.i And the (i+1)th sub-segment x in the second target sub-segment i+1 The first included angle is determined to be
[0084] Among them, a i Let b represent the length from the end point of the i-th sub-segment in the second target sub-segment to the starting point x0 in the first target sub-segment. i+1 c represents the length from the end point of the (i+1)th sub-segment in the second target sub-segment to the starting point x0. i+1 This represents the length of the (i+1)th sub-segment within the second target sub-segment. Meanwhile, since the lengths of multiple sub-segments are determined after division, c... i+1 The length is always fixed.
[0085] On the other hand, in step 103, when calculating the included angle, the coordinates of the starting point x0 of the first target sub-segment and the j-th sub-segment x of the third target sub-segment are used. j And the (j+1)th sub-segment x in the third target sub-segment j+1 Then the second included angle is
[0086] Among them, a j Let b represent the length from the end point of the j-th sub-segment in the third target sub-segment to the starting point x0 in the first target sub-segment. j+1 c represents the length from the end point of the (j+1)th sub-segment in the third target sub-segment to the starting point x0. j+1 This represents the length of the (j+1)th sub-segment within the third target sub-segment. Similarly, c j+1 The length is also fixed, and since the third target sub-segment is connected to the second target sub-segment, the third target sub-segment is located after the second target sub-segment. Therefore, a j Length and b i+1 The lengths are the same, meaning that actually a j With b i+1 This refers to the length from the endpoint to the starting point of the same sub-segment, satisfying j = i + 1. This ensures that when calculating the angle between the first and second endpoints of two consecutive sub-segments and the starting point coordinate x0, the b value in the first calculation... i+1 The length can be stored for a second calculation, thus avoiding the number of calculations on the length value, reducing the occupation of controller resources, and improving overall calculation efficiency.
[0087] Specifically, the angle difference θ d =|∠x i+1 x0x i+2 -∠x i x0x i+1|; Note the angle difference θ here. d Take the absolute value to facilitate subsequent comparison with the preset threshold.
[0088] Furthermore, if the angle difference is less than or equal to a preset threshold, the first trend direction result between the current target sub-segment and the fourth target sub-segment, and the second trend direction result between the current target sub-segment and the fifth target sub-segment are determined. The current target sub-segment is any sub-segment other than the first and second sub-segments among the multiple sub-segments, the fourth target sub-segment is the adjacent sub-segment of the current target sub-segment, and the fifth target sub-segment is the alternating sub-segment of the current target sub-segment.
[0089] If both the first and second trend direction results show a consistent trend direction, then the current target sub-segment, the fourth target sub-segment, and the fifth target sub-segment are connected until at least one of the first and second trend direction results shows a inconsistent trend direction. At this point, fitting stops, and the target fitted trajectory is obtained. The consistency judgment primarily assesses changes in the trend direction of the sub-segments. Specifically, the trend direction of the current target sub-segment is compared with that of the fourth target sub-segment to determine the first trend direction result. Then, the trend direction of the current target sub-segment is compared with that of the fifth target sub-segment to determine the second trend direction result. Both the first and second trend direction results include changed and unchanged states. In other words, consistency changes only when either the first or second trend direction result shows a changed state. Simultaneously, the trajectory fitting step stops directly when the angle difference exceeds a preset threshold. The comparison of the angle difference with the preset threshold is a preliminary judgment in the fitting process of multiple sub-segments; only when the preliminary judgment requirement is met can subsequent further judgments be performed.
[0090] In contrast, the angle difference is determined to be less than or equal to a preset threshold. That is, comparing θ... d Is it greater than θ? min If θ d >θ min This indicates that the third target sub-segment has a larger turning point compared to the second target sub-segment. Therefore, fitting can be stopped at this point, and the previous sub-segments can be connected together to obtain the target fitting trajectory. If θ d ≤θ min If the third target sub-segment on the surface has a smaller angle of inflection compared to the second target sub-segment, then the fitting process for the next sub-segment can continue.
[0091] In one embodiment, a preset threshold θ is used. min =5°, Figures 2-4 This is an example diagram of the trajectory provided by the present invention. Figure 2Trajectory illustration provided in the embodiments of the present invention Figure 1 The trajectory to be fitted is divided into multiple sub-segments, where the trajectory on the left is... Figure 2 (1) shows a division into 9 sub-segments, and the trajectory on the right is... Figure 2 (2) Divide into 8 sub-segments. From the left trajectory, i.e. Figure 2 As can be seen from (1), the three consecutive segments [1-3] and [5-7] are perpendicular vectors. Therefore, judging from the trend, the angle between these three perpendicular vectors is 0, so they can be fitted into a continuous straight line trajectory. From the trajectory on the right... Figure 2 (2) It can be seen that their slopes are obviously changing. Therefore, it is necessary to determine whether multiple sub-segments in the right trajectory can be fitted into the target fitted trajectory.
[0092] Therefore, the right-hand trajectory is... Figure 2 (2) Projected onto a plane coordinate system, i.e. Figure 3 Trajectory illustration provided in the embodiments of the present invention Figure 2 Based on the position of the trajectory in the coordinate system, the length of each sub-segment can be calculated, as well as the distance from the starting point to the endpoint of each sub-segment. This results in a triangle formed by connecting the starting point 0 and the two endpoints of the current sub-segment. Each triangle has an included angle based on the starting point 0, i.e., ∠102, ∠203, ∠304, etc. The range of variation between adjacent included angles can then be used to determine the trend change between adjacent sub-segments. If the trend change is small, fitting can continue. If the trend change is large, there are two possibilities: continue fitting or stop fitting. This characteristic can be used to filter out sub-segments that produce abrupt changes leading to excessively large included angles, allowing for early termination of fitting to obtain a closer approximation.
[0093] Specifically, such as Figure 4 The trajectory example shown in the figure has 9 sub-segments to be fitted. The trend change between adjacent sub-segments is judged by the fluctuation range between adjacent included angles (i.e., the difference in angle between adjacent included angles is compared with the preset threshold). The fitting is terminated in advance when the position of sub-segment 5 is obtained. That is, at this time, ∠506-∠405> the preset threshold, which is 5°, so the sudden change generated at sub-segment 6 is filtered out.
[0094] However, it should be noted that in one embodiment, even if the angle difference between adjacent angles is less than a preset threshold, the following situations may still affect the fitting, such as the trend direction of the sub-line segment changing. In this case, it is necessary to further filter the noise of the sub-line segment to determine whether the trend direction of the sub-line segment has changed when the angle difference is less than the preset threshold.
[0095] Specifically, when calculating whether the trend directions are inconsistent, the original four quadrants and four central axes in the plane coordinate system will be numbered from 1 to 8 in a counterclockwise order to define the quadrant status of the sub-line segment. Figure 5 This is a quadrant diagram of a Cartesian coordinate system provided in an embodiment of the present invention. Therefore... Figure 2 Multiple sub-segments are all located in the first quadrant, and the trend direction of these sub-segments remains unchanged. The trend direction is represented as [1, 1, 1, 1, 1, 1, 1, 1], where 1 represents no change and 0 represents a change. In extreme cases (such as when the sub-segments are extremely short), the trend direction of multiple sub-segments may be represented as [1, 1, 1, 1, 1, 0, 1, 1], meaning the trend direction of the sixth sub-segment has changed. Because the sixth sub-segment is extremely short, it may... The noise caused by the numerical values is not the start of the change in direction of subsequent sub-segments. Therefore, it is necessary to filter out the noise caused by the numerical values. That is, it is necessary to consider whether the trend direction of the current target sub-segment is inconsistent with that of the fourth and fifth target sub-segments. The trend direction is represented as [1, 1, 1, 1, 1, 0, 0, 1]. At this time, the fitting will terminate at the sixth sub-segment, instead of immediately terminating the fitting when the trend direction changes. This will filter out the noise caused by the numerical values to a certain extent.
[0096] More specifically, the steps for calculating the change in trend direction between two adjacent sub-segments are as follows:
[0097] In one embodiment, the coordinates of the two endpoints of the first sub-segment are (x1, y1) and (x2, y2), and the coordinates of the two endpoints of the adjacent second sub-segment are (x2, y2) and (x3, y3). Then, in the x-axis direction, the change in the first sub-segment is Δx1 = x2 - x1, and the change in the second sub-segment is Δx2 = x3 - x2. When Δx1 * Δx2 > 0, it indicates that the second sub-segment continues in the x-axis direction. When Δx1 * Δx2 < 0, it indicates that the second sub-segment changes in the opposite direction in the x-axis direction.
[0098] Similarly, in the y-axis direction, the change in the first sub-segment is Δy1 = y2 - y1, and the change in the second sub-segment is Δy2 = y3 - y2. When Δy1 * Δy2 > 0, it indicates that the second sub-segment continues in the y-axis direction; when Δy1 * Δy2 < 0, it indicates that the second sub-segment changes in the opposite direction in the y-axis direction. Therefore, when neither the x-axis nor the y-axis direction changes, the trend direction is used to represent it. Thus, when the trend direction changes continuously, the fitting process terminates. When only the trend direction of one sub-segment changes, noise caused by the shortness of the sub-segment and resulting direction change is filtered out, improving the accuracy of the sub-segment fitting process. This improves the fitting efficiency and accuracy of the sub-segments.
[0099] On the other hand, when performing the sub-segment fitting process, it is also necessary to first determine whether the number of multiple sub-segments after the trajectory to be fitted is within the allowed number of fitting segments. If it is not satisfied, it is treated as a completed trajectory, and the total number of overall trajectory fitting is increased by 1.
[0100] In step 104, based on the slope change results, the type of the target fitted trajectory is determined, specifically as follows:
[0101] If the slope change is zero, the target fitted trajectory is a straight line trajectory.
[0102] If the slope change result is not equal to zero, then the type of the target fitted trajectory is a circular arc trajectory.
[0103] Specifically, in one embodiment, the first coordinate information A is (X1, Y1), the second coordinate information B is (X2, Y2), and the third coordinate information C is (X3, Y3). Then, the slope of line segment AB... The slope of line segment BC is The change in slope Among them, X2-X1≠0, X3-X2≠0, thus obtaining the result of the slope change.
[0104] After determining that the target fitted trajectory is a circular arc trajectory, the center and radius of the circular arc trajectory are determined based on the first coordinate information, the second coordinate information, and the third coordinate information.
[0105] Specifically, in one embodiment, when calculating the center and radius of the circular arc trajectory, the first coordinate information A is taken as (X1, Y1), the second coordinate information B as (X2, Y2), and the third coordinate information C as (X3, Y3), then the center coordinates are... Given the center coordinates 0(X0,Y0), and based on the principle that the distance from the center to any point on the circle is equal to the radius, select point A(X1,Y1) and use the distance formula between two points to calculate the radius. The target fitted trajectory is then uploaded to the database, the trajectory buffer data is corrected, and the trajectory to be processed is replaced with the target fitted trajectory.
[0106] Figure 6 This is a schematic diagram of the structure of a CNC industrial machining device based on trajectory curve fitting provided in an embodiment of the present invention, as shown below. Figure 6As shown, the device includes: an acquisition unit 10, used to acquire a trajectory to be fitted and a processing mode based on the product type of the product to be processed, and to acquire the first trajectory coordinates of the trajectory to be fitted; a first processing unit 20, used to divide the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments are continuous; a second processing unit 30, used to fit the multiple sub-segments to obtain a target fitted trajectory; a third processing unit 40, used to determine the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory; and an output unit 50, used to perform CNC machining on the product to be processed based on the type of the target fitted trajectory.
[0107] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute a look-ahead velocity planning method based on a continuous trajectory. This method includes: obtaining a trajectory to be fitted and a processing mode based on the product type of the product to be processed, and obtaining the first trajectory coordinates of the trajectory to be fitted; dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments are continuous; fitting the multiple sub-segments to obtain a target fitted trajectory; determining the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory; and performing CNC machining on the product to be processed based on the type of the target fitted trajectory.
[0108] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0109] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by the computer, the computer is able to execute a look-ahead velocity planning method based on a continuous trajectory provided by the above methods. The method includes: obtaining a trajectory to be fitted and a processing mode based on the product type of the product to be processed, and obtaining the first trajectory coordinates of the trajectory to be fitted; dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments are in a continuous state; fitting the multiple sub-segments to obtain a target fitted trajectory; determining the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory; and performing CNC machining on the product to be processed based on the type of the target fitted trajectory. In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the aforementioned look-ahead velocity planning method based on a continuous trajectory. The method includes: obtaining a trajectory to be fitted and a processing mode based on the product type of the product to be processed, and obtaining first trajectory coordinates of the trajectory to be fitted; dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments being continuous; fitting the multiple sub-segments to obtain a target fitted trajectory; determining the type of the target fitted trajectory based on second trajectory coordinates of the target fitted trajectory; and performing CNC machining on the product to be processed based on the type of the target fitted trajectory.
[0110] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A CNC industrial machining method based on trajectory curve fitting, characterized in that, Includes the following steps: Based on the product type of the product to be processed, obtain the trajectory to be fitted and the processing mode, and obtain the first trajectory coordinates of the trajectory to be fitted; Based on the processing mode and the first trajectory coordinates, the trajectory to be fitted is divided into multiple sub-segments; the multiple sub-segments are in a continuous state. By fitting multiple sub-line segments, the target fitted trajectory is obtained; Based on the second trajectory coordinates of the target fitted trajectory, the type of the target fitted trajectory is determined; The product to be processed is CNC machined based on the type of the target fitted trajectory. The machining mode includes a first machining mode, which represents tool path planning along a contour line of the same height on the workpiece. The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes: If the processing mode is the first processing mode, then the equation line corresponding to the ordinate of the first target trajectory coordinate point in the first trajectory coordinate is determined as a contour line; the first target trajectory coordinate point is any trajectory coordinate point in the first trajectory coordinate. Determine the vertical distance between each trajectory coordinate point in the first trajectory coordinate system and the contour line; Based on the Euclidean distance and perpendicular distance between two adjacent trajectory coordinate points in the first trajectory coordinate system, the trajectory to be fitted is divided into the multiple sub-segments; The machining mode includes a second machining mode, which indicates that the tool path and the part contour are kept at equal distances. The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes: If the processing mode is the second processing mode, then the first trajectory coordinate point in the first trajectory coordinate is used as the first reference trajectory coordinate point, and the second target trajectory coordinate point in the first trajectory coordinate is determined; a first sub-line segment is constructed based on the trajectory coordinate points between the first trajectory coordinate point and the second target trajectory coordinate point; the coordinate point distance between the second target trajectory coordinate point and the first trajectory coordinate point is equal to a preset spacing value; Using the second target trajectory coordinate point as the second reference trajectory coordinate point, determine the third target trajectory coordinate point in the first trajectory coordinates; construct a second sub-line segment based on the trajectory coordinate points between the second target trajectory coordinate point and the third target trajectory coordinate point, until all trajectory coordinate points in the first trajectory coordinates are constructed as sub-line segments, thus obtaining the plurality of sub-line segments; the coordinate point distance between the third target trajectory coordinate point and the second target trajectory coordinate point is equal to the preset spacing value.
2. The CNC industrial machining method based on trajectory curve fitting according to claim 1, characterized in that, The step of fitting multiple sub-line segments to obtain a target fitted trajectory includes: The starting point coordinates of the first target sub-segment among the plurality of sub-segments are connected with the two endpoint coordinates of the second target sub-segment among the plurality of sub-segments to obtain the first included angle; the first target sub-segment is the first sub-segment among the plurality of sub-segments, and the second target sub-segment is any other sub-segment among the plurality of sub-segments except the first sub-segment; The starting point coordinates of the first target sub-segment among the plurality of sub-segments are connected with the two endpoint coordinates of the third target sub-segment among the plurality of sub-segments to obtain the second included angle; the third target sub-segment is any other sub-segment among the plurality of sub-segments besides the first sub-segment and the second sub-segment, and the third target sub-segment is continuous with the second target sub-segment and located after the second target sub-segment; The angle difference is obtained based on the first included angle and the second included angle; The multiple sub-line segments are fitted based on the angle difference to obtain the target fitted trajectory.
3. The CNC industrial machining method based on trajectory curve fitting according to claim 2, characterized in that, The step of fitting the multiple sub-line segments based on the angle difference to obtain the target fitted trajectory includes: If the angle difference is less than or equal to a preset threshold, then the first trend direction result between the current target sub-segment and the fourth target sub-segment, and the second trend direction result between the current target sub-segment and the fifth target sub-segment are determined; the current target sub-segment is any sub-segment other than the first sub-segment and the second sub-segment among the multiple sub-segments, the fourth target sub-segment is an adjacent sub-segment of the current target sub-segment, and the fifth target sub-segment is an alternating sub-segment of the current target sub-segment; If the first trend direction result is consistent with the trend direction, and the second trend direction result is consistent with the trend direction, then the current target sub-segment, the fourth target sub-segment, and the fifth target sub-segment are connected until at least one of the first trend direction result and the second trend direction result is inconsistent with the trend direction, then the fitting is stopped, and the target fitting trajectory is obtained.
4. The CNC industrial machining method based on trajectory curve fitting according to claim 2, characterized in that, The step of connecting the starting coordinates of the first target sub-segment among the plurality of sub-segments with the coordinates of the two endpoints of the second target sub-segment among the plurality of sub-segments to obtain the first included angle includes: Based on the starting coordinates of the first target sub-segment The i-th sub-segment in the second target sub-segment and the (i+1)th sub-segment in the second target sub-segment Determine the first included angle; The formula for calculating the first included angle is as follows: ; in, Represented as the coordinates of the endpoint of the i-th sub-segment in the second target sub-segment and the starting point in the first target sub-segment. Length between This represents the endpoint and starting point of the (i+1)th sub-segment in the second target sub-segment. The length between, It represents the length of the (i+1)th sub-segment in the second target sub-segment.
5. The CNC industrial machining method based on trajectory curve fitting according to claim 1, characterized in that, Determining the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory includes: Based on the first coordinate information, the second coordinate information, and the third coordinate information in the second trajectory coordinates, the slope change result of the target fitted trajectory is obtained; the first coordinate information, the second coordinate information, and the third coordinate information are the coordinate information of different trajectory coordinate positions in the second trajectory coordinates; If the slope change result is a preset value, then the type of the target fitted trajectory is determined to be a straight line trajectory; If the slope change result is not the preset value, then the type of the target fitted trajectory is determined to be a circular arc trajectory.
6. A CNC industrial machining device based on trajectory curve fitting, characterized in that, include: The acquisition unit is used to acquire the trajectory to be fitted and the processing mode based on the product type of the product to be processed, and to acquire the first trajectory coordinates of the trajectory to be fitted. The first processing unit is configured to divide the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates; the multiple sub-segments are in a continuous state. The second processing unit is used to fit multiple sub-line segments to obtain a target fitted trajectory; The third processing unit is used to determine the type of the target fitted trajectory based on the second trajectory coordinates of the target fitted trajectory; The output unit is used to perform CNC machining on the product to be processed based on the type of the target fitted trajectory; The machining mode includes a first machining mode, which represents tool path planning along a contour line of the same height on the workpiece. The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes: If the processing mode is the first processing mode, then the equation line corresponding to the ordinate of the first target trajectory coordinate point in the first trajectory coordinate is determined as a contour line; the first target trajectory coordinate point is any trajectory coordinate point in the first trajectory coordinate. Determine the vertical distance between each trajectory coordinate point in the first trajectory coordinate system and the contour line; Based on the Euclidean distance and perpendicular distance between two adjacent trajectory coordinate points in the first trajectory coordinate system, the trajectory to be fitted is divided into the multiple sub-segments; The machining mode includes a second machining mode, which indicates that the tool path and the part contour are kept at equal distances. The step of dividing the trajectory to be fitted into multiple sub-segments based on the processing mode and the first trajectory coordinates includes: If the processing mode is the second processing mode, then the first trajectory coordinate point in the first trajectory coordinate is used as the first reference trajectory coordinate point, and the second target trajectory coordinate point in the first trajectory coordinate is determined; a first sub-line segment is constructed based on the trajectory coordinate points between the first trajectory coordinate point and the second target trajectory coordinate point; the coordinate point distance between the second target trajectory coordinate point and the first trajectory coordinate point is equal to a preset spacing value; Using the second target trajectory coordinate point as the second reference trajectory coordinate point, determine the third target trajectory coordinate point in the first trajectory coordinates; construct a second sub-line segment based on the trajectory coordinate points between the second target trajectory coordinate point and the third target trajectory coordinate point, until all trajectory coordinate points in the first trajectory coordinates are constructed as sub-line segments, thus obtaining the plurality of sub-line segments; the coordinate point distance between the third target trajectory coordinate point and the second target trajectory coordinate point is equal to the preset spacing value.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the CNC industrial machining method based on trajectory curve fitting as described in any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of a CNC industrial machining method based on trajectory curve fitting as described in any one of claims 1 to 5.