A method for collision detection and avoidance of a numerical control machining tool and a workpiece
By using workpiece model offsetting and ray cluster simplification methods, collisions between tapered milling cutters and workpieces are efficiently detected and avoided, solving the problem of collision detection for tapered milling cutters in the machining of complex curved surface parts, and achieving stability and safety in the machining process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2026-01-30
- Publication Date
- 2026-06-12
AI Technical Summary
Existing methods for detecting tool-workpiece collisions, especially those for tapered milling cutters, are not effectively applicable to the machining of complex curved surface parts such as integral bladed disks, resulting in limitations in machining quality and efficiency.
By offsetting the workpiece model along the normal vector and simplifying the tool model into a ray cluster, collisions are determined by the intersection of the rays and the offset model, and the tool is adjusted to a safe direction near the initial tool placement direction, thus achieving collision detection and avoidance.
It efficiently determines whether the tapered milling cutter collides with the workpiece and adjusts the cutter axis direction based on the principle of minimum cutter axis change, ensuring the stability and safety of the machining process. It is suitable for machining complex curved surface parts.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer-aided manufacturing (CAM) technology, specifically relating to a method for detecting and avoiding collisions between CNC machining tools and workpieces. Background Technology
[0002] With the surge in demand for complex curved surface parts (such as integral bladed disks and deep cavity molds) from industries like aerospace and automotive mold making, complex machining methods such as five-axis linkage are widely used in CNC machining and robotic cutting. This leads to more complex tool movements and a significantly increased risk of interference between the tool and workpiece. Therefore, collision detection and avoidance between the tool and workpiece are crucial for ensuring workpiece quality and the safety of equipment and personnel during machining. Collisions during machining can not only cause precision tool breakage and workpiece scrap, but also damage critical components such as the spindle of high-end CNC machine tools, resulting in huge economic losses and requiring downtime for maintenance, severely impacting production schedules.
[0003] Current toolpath planning software primarily employs two methods to avoid tool-workpiece collisions: solving the feasible tool placement domain at each machining position during the toolpath planning stage, and performing feasibility checks and adjustments on the already planned path. Both methods are essentially based on collision detection between the tool and the workpiece.
[0004] For integral bladed disk-type parts, which typically feature complex curved surfaces, narrow machining channels, and complex collision detection spaces, a large tool body length is required. Therefore, tapered end mills, which have greater rigidity than cylindrical ball end mills, are usually chosen for machining. However, the larger tool body of tapered end mills and the complex machining environment of the bladed disk pose greater challenges to collision detection between the tool and the workpiece, making ordinary collision detection methods unsuitable for such scenarios. Existing literature contains limited discussion on collision detection methods between the tool and the workpiece, especially for tapered ball end mills, which to some extent restricts the machining quality and efficiency of integral bladed disk-type parts. Summary of the Invention
[0005] To address the collision avoidance problem in machining path planning, this invention provides a method for detecting and adjusting whether a collision occurs between the tool and the workpiece model. This method first offsets the workpiece model outwards by a certain distance along its normal vector and simplifies the tool model into a cluster of rays. Then, based on solving for the intersection points of the rays and the workpiece, collision detection is achieved between the offset tool and workpiece model, and the tool placement direction causing the collision is adjusted to a safe direction. This method can assist in solving the feasible region of tool placement and determining the feasibility of tool axis vector planning results.
[0006] A method for detecting and avoiding collisions between CNC machining tools and workpieces includes the following steps:
[0007] (1) Offset each triangular facet in the triangular mesh model of the workpiece to be inspected outward along its own normal vector to obtain the offset model;
[0008] (2) Take any untraversed contact point as the current contact point, and construct a ray cluster consisting of multiple rays with a common endpoint, based on its initial tool placement direction and the center point of the ball head of the tool as the endpoint;
[0009] (3) Calculate the number of intersections between each ray in the ray cluster and the offset model, and determine whether the tool and the workpiece will collide:
[0010] When all the intersections between the rays in the ray cluster and the offset model are 0, it means that the tool and the workpiece will not collide.
[0011] If any ray in the ray cluster intersects the offset model at a point greater than or equal to 1, it is determined that the tool and the workpiece will collide, and the process proceeds to step (4).
[0012] (4) Solve for candidate placement directions that will not collide near the initial tool placement direction, and adjust the tool to the optimal candidate placement direction to complete the adjustment of the tool placement direction at the current cutting point;
[0013] (5) Repeat steps (2) to (4) until all contact points on the processing path have been traversed.
[0014] In step (1) above:
[0015] Preferably, the offset distance is equal to the radius of the ball end of the ball-end tool.
[0016] More specifically, the workpiece model read is in the form of a discrete triangular mesh. The normal vector of each mesh element is calculated based on the VTK library, and the triangular mesh offset is implemented.
[0017] The specific process of step (1) is as follows:
[0018] (1-1) Read the STL model file of the workpiece. The STL model reading function vtkSTLReader in the VTK library converts the model file into vtkPolyData format, denoted as mesh;
[0019] (1-2) Use vtkTriangleFilter to extract all triangles mesh_triangules in the mesh, and calculate the normal vector normals corresponding to each triangle based on vtkPolyDataNormals function;
[0020] (1-3) Based on the vtkWarpVector function, the triangular mesh element is offset outward along the calculated normal vector normals. .
[0021] In step (2) above:
[0022] The cutting tool in this invention is a tapered ball end mill or can be approximately a tapered ball end mill.
[0023] Preferably, the plane containing any tool axis is intersected with the non-ball end portion of the tool to obtain two intersecting generatrices on the tool surface. Within this plane, one of the intersecting generatrices is translated so that its lower endpoint coincides with the center point of the ball end of the tool, and the other endpoint extends to infinity to obtain a ray originating from the center point of the ball end of the tool and parallel to the generatrices on the tool surface. This ray is then rotated around the straight line containing the tool axis with its endpoint as a reference to obtain the ray cluster.
[0024] In any plane containing the tool axis, ignoring the cutting edge shape, the non-spherical part of the tool is intersected by the plane to obtain two profiles. For a tapered tool, the two profiles are line segments, which are the generatrices of the geometry of revolution of the non-spherical part of the tool; for a non-tapered tool, the two profiles are not line segments. Therefore, the tool is approximated as a minimal cone, and any point on the tool surface lies inside or on the approximate cone. Using the approximate cone instead of the tool, the plane intersects to obtain two generatrices.
[0025] As a further preferred method, the specific process of rotating the ray around the line containing the tool axis with its endpoint as a reference to obtain the ray cluster is as follows:
[0026] (2-1) Establish a three-dimensional coordinate system with the center point of the ball end of the tool as the origin and the tool axis direction as the Z-axis direction. Let the unit vectors representing the X-axis, Y-axis and Z-axis directions be respectively... and ;
[0027] (2-2) Let the angle between the ray and the line containing the cutter axis be y. This angle is only related to the taper angle of one side of the tool; let the angle between the projection of the ray onto the XOY plane of the coordinate system and the X-axis direction be denoted as . , and set the angle in [0 , 360 By taking values at equal intervals within a range, a set of rotation angle values is obtained. }, where i∈[1,m].
[0028] (2-3) According to the angle With rotation angle ,calculate The corresponding number unit direction vector of a ray Iterate through all rotation angle values in sequence to obtain a result from... A ray cluster is a group of rays that share the origin as their common endpoint.
[0029] In step (3) above:
[0030] As a preferred method, the steps for calculating the number of intersections between a ray and the bias model are as follows:
[0031] Given a line segment length setting that is much larger than the tool length. According to the ray endpoint With unit direction vector Find the endpoint on the ray. The distance is point From point and points Define a line segment and use the VTK library to calculate the number of intersections between the line segment and the bias model.
[0032] Furthermore, the specific steps for calculating the number of intersections between a ray and the bias model are as follows:
[0033] (3-1) Give a line segment length setting that is much larger than the tool length. According to the ray endpoint With unit direction vector Calculate a point on the ray. , From point and points Determine a length of Seg, replace the ray with a line segment. Used to determine the number of intersections;
[0034] (3-2) Based on the vtkCellLocator class in the VTK library, a cell locator m_meshLocator for the workpiece's offset triangular mesh (offset model) is established. With the help of the IntersectWithLine function of the locator, the triangular mesh cells that intersect with the line segment Seg in the offset model are quickly located, and the number of intersection points between the offset model and the line segment Seg is obtained.
[0035] Preferably, when determining whether a ray cluster collides with the offset model, if the number of intersection points between a ray and the offset model is greater than or equal to 1, the calculation of other uncalculated rays is terminated. This is because when the number of intersection points between a ray and the offset model is greater than or equal to 1, it can be determined that the corresponding tool placement direction will cause a collision between the tool and the workpiece, and the intersection calculation of the remaining rays with the offset model does not need to be performed.
[0036] In step (4) above:
[0037] Preferably, the initial tool placement direction is used as a reference, and the swing angle is set within a certain range. Swing the tool slightly to obtain a set of placement directions to be detected near the initial tool placement direction; according to steps (2) to (3), determine whether each placement direction to be detected will cause the tool to collide with the workpiece, retain the placement directions to be detected that will not cause collision and store them in the candidate set as candidate placement directions, and select the optimal candidate placement direction in the candidate set to replace the initial tool placement direction based on the principle of minimum change.
[0038] Specifically, the operation process of step (4) is as follows:
[0039] (4-1) Establish a three-dimensional coordinate system with the center point of the ball end of the tool as the origin and the tool axis direction as the Z-axis direction. Let the unit vectors representing the X-axis, Y-axis and Z-axis directions be respectively... and ;
[0040] (4-2) Set the swing angle range [ By taking values at equal intervals, a set of swing angle values is obtained. }, where k represents the number of swing angles; for the rotation angle range [0 , 360 By taking values at equal intervals, a set of rotation angle values is obtained. }, where l represents the number of rotation angles;
[0041] (4-3) Based on the swing angle With rotation angle Calculate the tool axis vector corresponding to the tool placement direction. Calculate sequentially to obtain There are three placement directions to be detected; where i∈[1,k], j∈[1,l];
[0042] (4-4) Following the method of steps (2) to (3), determine whether each placement direction to be detected will cause a collision between the tool and the workpiece, and remove the tool placement directions that will cause a collision, retain the placement directions to be detected that will not cause a collision and store them as candidate placement directions in the candidate set;
[0043] (4-5) Traverse all candidate placement directions in the candidate set and select the optimal tool placement direction based on the principle of minimum change.
[0044] As a further optimization, if the number of elements in the candidate set is zero, the swing angle is adjusted to a larger range until the number of elements in the candidate set is greater than or equal to 1.
[0045] Furthermore, the specific steps for modifying the swing angle to a wider range are as follows:
[0046] 1) Expand the upper and lower limits of the tool swing angle range. The range of the tool axis swing angle for the kth increase is: ;
[0047] 2) Take values at equal intervals within the newly added swing angle range and calculate the newly added placement direction to be detected;
[0048] 3) Following steps (2) to (3), collision detection is performed on the newly added placement directions to be detected, and the non-collision placement directions to be detected are added to the candidate set Set_Candidate as candidate placement directions;
[0049] If the number of elements in the candidate set Set_Candidate is less than 1, repeat steps 1) to 2) until the number of elements in the candidate set Set_Candidate is greater than or equal to 1.
[0050] As a further optimization, the method for selecting the optimal candidate placement orientation is as follows:
[0051] When considering only the candidate placement direction at a single contact point where the change from the initial tool placement direction is minimal, the option with the same placement direction as the initial tool placement direction is selected. Candidate placement direction with the smallest included angle The optimal candidate placement direction;
[0052] Alternatively, considering the scenario where the change in tool orientation between adjacent contact points on a machining path is minimized, the optimal candidate tool orientation is the tool orientation of the two contact points adjacent to the initial tool orientation. , The candidate placement direction with the smallest sum of the included angles. .
[0053] Among them, the candidate placement direction The tool placement directions of the two contact points adjacent to the initial tool placement direction respectively , The sum of the included angles between them, i.e. and The included angle between and The sum of the angles between them.
[0054] In actual machining, the optimal candidate placement direction can be selected according to needs. When considering only a single cutting contact point, the selected optimal candidate placement direction minimizes the change in the adjusted tool axis compared to the original path; when considering adjacent cutting contact points, the selected optimal candidate placement direction ensures a relatively smooth change in the tool placement direction of the adjusted machining path. The method of this invention provides corresponding processing for different situations, making it more targeted.
[0055] Furthermore, when considering the minimum change in tool placement direction between adjacent cutting points on a machining path, the method for calculating the change for the first and last cutting points of the path is the same as the collision detection and avoidance method for considering the minimum change in candidate placement direction from the initial tool placement direction at a single cutting point.
[0056] As a further preferred option, the orientation of the two cutting tools , The angle between It can be converted into the tool axis vector corresponding to the placement direction. , Calculate using the included angle:
[0057] .
[0058] The CNC machining tool and workpiece collision detection and avoidance method of the present invention, targeting tapered ball end mills and tools that can be approximated as tapered ball end mills, can efficiently determine whether a collision has occurred between the tool and the workpiece, and adjust the colliding tool axis to a suitable direction based on the principle of minimum tool axis change, ensuring the stability and safety of the machining process. The method proposed in this invention does not rely on machining path planning and post-processing, and can be integrated into machining path generation software as an independent module, showing broad application prospects.
[0059] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0060] (1) The present invention is a method for detecting and avoiding collisions between CNC machining tools and workpieces. It can efficiently determine whether a non-cylindrical ball-end tool and a workpiece have collided, and adjust the colliding tool axis to a suitable direction based on the principle of minimum tool axis change, so as to ensure the stability and safety of the machining process.
[0061] (2) The detection and avoidance method proposed in this invention is simple in logic and highly efficient. When adjusting the direction of the tool axis that causes the collision, it can not only handle the case where the change between the new tool axis (candidate placement direction) and the original tool axis (initial tool placement direction) at a single cutting contact point is minimal, but also handle the case where the change between the tool axis (tool placement direction) between adjacent cutting contact points is minimal.
[0062] (3) The tool collision detection and avoidance method proposed in this invention does not depend on machining path planning and post-processing. It can be integrated into machining path generation software as an independent module and has broad application prospects. Attached Figure Description
[0063] Figure 1 This is a flowchart of a method according to an embodiment of the present invention;
[0064] Figure 2 This is a schematic diagram of the construction of rays;
[0065] Figure 3 A schematic diagram illustrating collision detection by simplifying the cutting tool into a cluster of rays;
[0066] Figure 4 A schematic diagram illustrating the calculation of the intersection point between a ray and a mesh model;
[0067] Figure 5 A flowchart for adjusting the orientation of the cutting tools that cause collisions;
[0068] Figure 6 This is a schematic diagram of the orientation of the tool to be tested and the workpiece model in Application Example 1;
[0069] Figure 7 This is a schematic diagram of the tool placement after collision detection and adjustment in Application Example 1. Detailed Implementation
[0070] like Figure 1 As shown, a method for collision detection and avoidance between CNC machining tools and workpieces includes the following specific steps:
[0071] Step 1: Offset each triangular facet in the triangular mesh model of the workpiece to be inspected outward along its own normal vector to obtain the offset model.
[0072] This step will be implemented based on the VTK library. First, the STL model file of the workpiece is read, and the vtkSTLReader function in the VTK library converts the model file to vtkPolyData format. Then, the vtkTriangleFilter is used to extract triangular facets, and the vtkPolyDataNormals function calculates the normal vector (normals) corresponding to each triangular facet. Based on the vtkWarpVector function, given the normals as the direction of the mesh element offset, the triangular mesh elements are offset outwards along the given normal vector (normals) by a distance. (Usually equal to the ball-end radius R of the tool), to obtain the offset model.
[0073] Step 2: Take any untraversed contact point as the current contact point. Based on its initial tool placement direction, construct a set of rays with a common endpoint (a ray cluster composed of multiple rays with a common endpoint) as a simplified collision model of the tool, with the center point of the ball head of the tool as the endpoint.
[0074] like Figure 2 As shown, firstly, a ray is constructed with the center point of the ball end of the tool as its endpoint, and the ray is parallel to the generatrix of the tool surface. Within any plane (intersection plane) containing the tool axis, the non-ball end portion of the tool is intersected by the plane to obtain two profile lines (intersection generatrixes). For a tapered tool, the two intersecting profiles are line segments, which are the generatrixes of the geometry of the non-ball end portion of the tool; for a non-tapered tool, the two intersecting profiles are not line segments. Therefore, the tool is approximated as a minimal cone, and any point on the tool surface lies inside or on the approximate cone. The approximate cone is used instead of the tool to obtain the two generatrixes by the plane's intersection.
[0075] Translate any generatrix within the cutting plane until its lower endpoint coincides with the tool's center point, and extend its other endpoint to infinity, resulting in a ray originating from the tool's center point and parallel to the generatrix on the tool surface. Rotate this ray around the line containing the tool axis, using its endpoint as a reference, to obtain a set of rays (a ray cluster), which will serve as a simplified model for tool collision detection.
[0076] like Figure 3 As shown, the specific steps to obtain the simplified tool collision detection model by rotating the ray around the line containing the tool axis with its endpoint as a reference are as follows:
[0077] (1) Establish a three-dimensional coordinate system with the center point of the ball end of the tool as the origin and the tool axis direction as the Z-axis direction. Let the unit vectors representing the X-axis, Y-axis and Z-axis directions be respectively. and .
[0078] (2) Let the angle between the ray and the line containing the cutter axis be y. This angle is only related to the taper angle of one side of the tool; let the angle between the projection of the ray in the XOY plane of the coordinate system and the X-axis direction be denoted as . , and set the angle in [0 , 360 By taking values at equal intervals within a range, a set of rotation angle values is obtained. }, where i∈[1,m].
[0079] (3) According to the angle With rotation angle ,calculate The corresponding number The direction vector of the ray Iterate through all rotation angle values in sequence to obtain a result from... A cluster of rays that share the origin as their common endpoint.
[0080] Step 3: For a ray cluster, iterate through and calculate the intersection points of each ray with the offset model. Determine whether a collision between the tool and the workpiece has occurred based on the number of intersection points between the ray cluster and the offset model.
[0081] When all the intersections between the rays in the ray cluster and the offset model are 0, it means that the tool and the workpiece will not collide, and the placement direction is safe and does not need to be adjusted.
[0082] If any ray in the ray cluster intersects the offset model at a point greater than or equal to 1, it is determined that the tool and the workpiece will collide, and the process proceeds to the next step.
[0083] In this step, when calculating the number of intersections between a ray and the offset workpiece, the ray will be replaced by a line segment of sufficient length.
[0084] like Figure 4 As shown, an initial line segment length setting value L, which is much larger than the tool length, is given. huge According to the ray endpoint With unit direction vector A point on the ray is calculated. , From point and points Determine a length of Seg, replace the ray with a line segment. Used to determine the number of intersection points.
[0085] The process of finding intersection points can be quickly implemented using the VTK library. Using the vtkCellLocator class in the VTK library, a cell locator for the bias model's triangular mesh is created. Using the IntersectWithLine function of the locator, the triangular mesh cells in the bias model that intersect with line segment Seg are quickly located. The function ultimately returns the number of intersection points pNum between the bias model and line segment Seg.
[0086] By iterating through the rays within the ray cluster, if pNum>1 is found to be true during the process of solving the intersection point of a ray with the offset model, it can be determined that the corresponding tool placement direction will cause a collision between the tool and the workpiece. The intersection calculation of the remaining rays with the offset model is not required.
[0087] If the intersection points of all rays within a ray cluster with the bias model are calculated sequentially, and the value pNum=0 for all intersection points with the bias model for all rays is true, then the corresponding tool placement direction will not cause a collision between the tool and the workpiece, and the tool placement direction is safe and feasible.
[0088] Step 4: For the contact point where a collision occurs, find candidate placement directions that will not cause a collision near the original tool axis placement position (initial tool placement direction), and select the optimal candidate placement direction to replace the original tool axis direction (that is, adjust the tool placement direction of the current contact point to the optimal candidate placement direction), thus completing the adjustment of the tool placement direction of the current contact point.
[0089] like Figure 5 As shown, the specific steps for step four are as follows:
[0090] (1) Establish a three-dimensional coordinate system with the center point of the ball end of the tool as the origin and the tool axis direction as the Z-axis direction. Let the unit vectors representing the X-axis, Y-axis and Z-axis directions be respectively. and .
[0091] (2) Based on a given range of swing angles [ ], taking values at equal intervals, to obtain a set of swing angle values { },in Indicates the number of swing angles; based on the rotation angle range [0...]. , 360 ), taking values at equal intervals, to obtain a set of rotation angle values { },in Indicates the number of rotation angles.
[0092] (3) Based on the swing angle With rotation angle Calculate the tool axis vector corresponding to the tool placement direction. Calculate sequentially to obtain There are three orientations to be detected; where i∈[1,k] and j∈[1,l].
[0093] (4) Detect the vector of each tool axis according to steps two and three. The corresponding placement direction to be detected will cause a collision between the tool and the workpiece. Placement directions that will cause a collision will be eliminated, and placement directions that will not cause a collision will be retained and stored as candidate placement directions in the candidate set Set_Candidate.
[0094] (5) Check the number of elements in the candidate set, candidateNum. If candidateNum < 1, it means that a safe tool placement direction cannot be found within the currently set swing angle range. The swing angle needs to be modified to a larger range, and steps (2) to (5) are repeated until the number of elements in the candidate set is greater than or equal to 1.
[0095] (6) Traverse all tool placement directions in the candidate set and select the candidate direction with the smallest change from the original tool placement direction (initial tool placement direction) as the final tool placement direction.
[0096] In step (5) above, the specific steps for modifying the swing angle range are as follows:
[0097] 1) Expand the upper and lower limits of the tool swing angle range. The range of the tool axis swing angle for the kth increase is: ; Take values at equal intervals within the newly added angle range, and calculate the placement direction to be detected based on the swing angle and rotation angle;
[0098] 2) Following steps two and three, perform interference detection (collision detection) on the newly added placement directions to be detected, and add the non-collision tool placement directions (candidate placement directions) to the candidate set Set_Candidate;
[0099] 3) If the number of elements in the candidate set Set_Candidate is less than 1, repeat steps 1) to 2) until the number of elements in the candidate set Set_Candidate is greater than or equal to 1.
[0100] The method for selecting the optimal candidate placement direction in step (5) is as follows:
[0101] When considering only the candidate placement direction at a single contact point where the change from the initial tool placement direction is minimal, the option with the same placement direction as the initial tool placement direction is selected. Candidate placement direction with the smallest included angle The optimal candidate placement direction;
[0102] Alternatively, considering the scenario where the change in tool orientation between adjacent contact points on a machining path is minimized, the optimal candidate tool orientation is the tool orientation of the two contact points adjacent to the initial tool orientation. , The candidate placement direction with the smallest sum of the included angles. .
[0103] Among them, the candidate placement direction The tool placement directions of the two contact points adjacent to the initial tool placement direction respectively , The sum of the included angles between them, i.e. and The included angle between and The sum of the angles between them.
[0104] In actual machining, the optimal candidate placement direction can be selected according to the needs. When considering only a single cutting contact point, the selected optimal candidate placement direction minimizes the change in the adjusted tool axis compared to the original path; when considering adjacent cutting contact points, the selected optimal candidate placement direction ensures a relatively smooth change in the tool placement direction of the adjusted machining path.
[0105] When considering the minimum change in tool orientation between adjacent contact points on a machining path, the method for calculating the change for the first and last contact points of the path is the same as the collision detection and avoidance method for considering the minimum change in candidate orientation from the initial tool orientation at a single contact point.
[0106] The two knives are placed in the following directions , The angle between Convert to the unit tool axis vector corresponding to the placement direction , Calculate using the included angle:
[0107] .
[0108] The change in tool placement direction is calculated sequentially in the candidate set, and the tool placement direction is adjusted to the point where the change is minimized (the optimal candidate placement direction).
[0109] Step 5: Repeat steps 2-4 until all contact points on the processing path have been traversed.
[0110] Application example:
[0111] 1. Input the orientation of the tool to be inspected and the workpiece model, such as... Figure 6 As shown, the cutting tool is a taper ball end mill with a taper angle of 5°, a ball end radius of 2mm, and a total tool length of 100mm. There are 3 cutting contact points to be detected, and the tool placement direction at one of the cutting contact points causes a collision.
[0112] 2. Set the model's offset distance D along the normal direction. offset1 The initial maximum tool swing angle α at the time of collision is 2mm. init It is 3°.
[0113] 3. Using the method described in the above embodiments, collision detection is performed on the tool placement, and the tool placement direction causing the collision is adjusted according to the condition where the change from the original tool placement direction (initial tool placement direction) at a single cutting contact point is minimal. Figure 7 To detect the results of adjusting the tool placement orientation after a collision.
Claims
1. A method for detecting and avoiding collisions between CNC machining tools and workpieces, characterized in that, Includes the following steps: (1) Offset each triangular facet in the triangular mesh model of the workpiece to be inspected outward along its own normal vector to obtain the offset model; (2) Take any untraversed contact point as the current contact point, and construct a ray cluster consisting of multiple rays with a common endpoint, based on its initial tool placement direction and the center point of the ball head of the tool as the endpoint; (3) Calculate the number of intersections between each ray in the ray cluster and the offset model, and determine whether the tool and the workpiece will collide: When all the intersections between the rays in the ray cluster and the offset model are 0, it means that the tool and the workpiece will not collide. If any ray in the ray cluster intersects the offset model at a point greater than or equal to 1, it is determined that the tool and the workpiece will collide, and the process proceeds to step (4). (4) Solve for candidate placement directions that will not collide near the initial tool placement direction, and adjust the tool to the optimal candidate placement direction to complete the adjustment of the tool placement direction at the current cutting point; (5) Repeat steps (2) to (4) until all contact points on the processing path have been traversed.
2. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 1, characterized in that, In step (2), the plane containing any tool axis is intersected with the non-ball end portion of the tool to obtain two intersecting generatrices on the tool surface; within this plane, any one of the intersecting generatrices is translated so that its lower endpoint coincides with the center point of the ball end of the tool, and the other endpoint extends to infinity to obtain a ray that originates from the center point of the ball end of the tool and is parallel to the generatrices on the tool surface; the ray is rotated around the straight line containing the tool axis with its endpoint as a reference to obtain the ray cluster.
3. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 1, characterized in that, In step (3), the steps for calculating the number of intersections between a ray and the bias model are as follows: Given a line segment length setting that is much larger than the tool length. According to the ray endpoint With unit direction vector Find the endpoint on the ray. The distance is point From point and points Define a line segment and use the VTK library to calculate the number of intersections between the line segment and the bias model.
4. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 1, characterized in that, In step (3), when determining whether the ray cluster collides with the bias model, if the number of intersections between a certain ray and the bias model is greater than or equal to 1, the calculation of other uncalculated rays is terminated.
5. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 1, characterized in that, The specific operation process of step (4) is as follows: Based on the initial tool placement direction, according to the set swing angle range [ Swing the tool slightly to obtain a set of placement directions to be detected near the initial tool placement direction; according to steps (2) to (3), determine whether each placement direction to be detected will cause the tool to collide with the workpiece, retain the placement directions to be detected that will not cause collision and store them in the candidate set as candidate placement directions, and select the optimal candidate placement direction in the candidate set to replace the initial tool placement direction based on the principle of minimum change.
6. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 5, characterized in that, If the number of elements in the candidate set is zero, the swing angle is adjusted to a larger range until the number of elements in the candidate set is greater than or equal to 1.
7. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 5, characterized in that, The principles for selecting the optimal candidate placement orientation are as follows: When considering only the candidate placement direction at a single contact point where the change from the initial tool placement direction is minimal, the option with the same placement direction as the initial tool placement direction is selected. Candidate placement direction with the smallest included angle The optimal candidate placement direction; Alternatively, considering the scenario where the change in tool orientation between adjacent contact points on a machining path is minimized, the optimal candidate tool orientation is the tool orientation of the two contact points adjacent to the initial tool orientation. , The candidate placement direction with the smallest sum of the included angles. .
8. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 7, characterized in that, The two knives are placed in the following directions , The angle between It can be converted into the tool axis vector corresponding to the placement direction. , Calculate using the included angle: 。 9. The method for detecting and avoiding collisions between CNC machining tools and workpieces according to claim 1, characterized in that, In step (1), the offset distance is the ball-end radius of the ball-end tool.