A new approach to find gouge free tool positions for a toroidal cutter for Bézier surfaces in five-axis machining

We implement and test a multi-point machining tool positioning technique that positions the tool using only a variation on gouge checking. The result is a method that is roughly twice as fast as an earlier method that performed a numerical search to find a tool position with multiple points of contact with the design surface. A GPU implementation provides an additional factor of ten speedup. Verification of the method was done via simulation and machining and measuring physical parts.


Introduction
Two types of machines, 3-axis and 5-axis machines, are commonly used in manufacturing industries. 5-axis machining have additional degrees of freedom in rotation and tilting about the zand x-axes, giving extra flexibility in machine kinematics as compared to 3-axis machines. This enhanced flexibility allows the tool to be positioned in close proximity to the desired surface, which leads to the machining with wider strips in a fewer number of passes [1,2].
Numerous methods have been proposed to position a tool with a 5-axis machine [3]. The method used in this paper Mukhmeet  is to position the tool in close proximity to the surface is to inclined the tool to make contact at least at two different points on the surface at the same time. A tool positioning method based on this attribute is known as a Multipoint Method (MPM) [4][5][6][7][8][9].
The MPM method has evolved to the Drop and Tilt method of Duvedi et al. for both triangulated surfaces [4,5] and for tensor product Bézier surfaces [11][12][13][14]. The implementation of Duvedi et al. [14] involves dropping the toroidal tool onto the surface using Newton's method to find a point of tangency between the tool and the surface. Since there are multiple points that satisfy the tangency equations between the toroidal tool and the surface, Duvedi et al. perform a gouge check on the resulting tool position to test if the correct solution was found; if the tool gouges the surface, Newton's method is restarted with a new seed point to find the non-gouging point of contact.
Kim et al. [10] take another approach to finding tool positions with two points of contact with a toroidal cutter. In their approach, they offset from the design surface by the inner radius of the torus. This converts finding two points of contact between the toroidal tool and the design surface into finding two tangential points of contact between a circle and the offset surface. Their approach requires solving systems of algebraic equations.
In this work, a new technique is proposed that eliminates the Newton's search to find the tangency between the surface and the tool; instead, we find tool positions having two points of contact with the design surface by just using a variation on the gouge detection step alone. The proposed method is implemented in C++ for bi-cubic Bézier surfaces.
The algorithm was tested by simulating three parts having concave and convex regions using the ToolSim machining simulator tool and by machining the parts on a DMU-80P five-axis machine. Our focus is on positioning the tool on the surface with two points of contact, and we do not look at related topics such as selection of tool size or global collision.
In this paper, a brief background on the tools used and a review of the literature is given in Section 2. Our method is described in detail in Section 3. Section 4 discusses testing of the method on several surfaces. The work is concluded in the Section 5 of this paper.

Background
To run a CNC machine, a toolpath is given to the controller of the machine. A toolpath is a sequence of tool positions that describe the location and the orientation of the tool. The machine controller moves the tool linearly from one position to the next position of the toolpath.
There are three elements that are required for generating the toolpath: (a) The definition or type of surface to be machined; (b) the geometry of the tool used; and (c) the footprint that the tool should follow.
Sculptured surfaces can be defined using parametric surfaces such as Bézier Surfaces, B-Spline Surfaces and Non-Rational B-spline surfaces. In this work bi-cubic Bézier surfaces are used, although the method should readily extend to the other two classes of surfaces. A Bézier surface is given by for 0 ≤ u, v ≤ 1, where P i,j are the control points of the surface, n is the degree of the surface, and B n i (u) are the Bernstein polynomials: In this work, the toolpath is generated for the radiused end mill, as shown in Fig. 1. The minor circle with radius R i represents the pseudo-insert that corresponds to the cutting edge on physical cutter. A pseudo-insert is a circle that is swept around a second circle (with radius R o known as the major circle) to generate the torus.
The sequence for the tool positions in a toolpath is guided by a footprint laid on a plane perpendicular to the tool axis, as shown in Fig. 2. The footprint lies in the xy-plane in this work with the x-axis as the side-step direction and the y-axis as the feed forward direction. The passes in the side-step direction are separated by Side step and the tool positions in the feed forward direction are separated by Forward step interval as shown in Fig. 2.

The method
The tool orientation and location are determined in two mathematical steps, as proposed by Duvedi et al. [11]. The tool is first dropped on the surface to find a point of tangency between the tool and the surface, and next the surface is tilted until a second point of contact between the tool and the surface is found; the resulting position and orientation is one tool position in the toolpath. The key algorithm used in both the steps emulates the dropping of a tool along a specified tool axis. This algorithm is referred to as the tool drop algorithm. The contribution of this work is a tool drop algorithm based solely on a variation of gouge detection. The drop and tilt processes are detailed below.

Dropping the tool via ray casting
To find a first point of contact between a dropping toroidal tool and a tensor product surface, Duvedi et al. [14] start at an initial seed location on the design surface, and use Newton's method to find a point of tangency between the tool and the surface (Fig. 3). However, there may be multiple points (at different tool drop heights) that have a point of tangency between the tool and the surface. The point of tangency that has the highest tool position is the desired one, as all the other points of tangency result in the tool gouging the surface. Thus, after finding a point of tangency, Duvedi et al. test if the tool gouges the surface. If the tool does gouge the surface, different seed points are tried until a gouge free solution is found. The key idea in this paper is to omit the first step of Duvedi et al.'s algorithm (finding a tangency with the surface), and instead perform a variation on the gouge checking step of Duvedi et al. In particular, rather than test if a tool position gouges the surface, the algorithm proposed in this paper finely discretizes the toroidal surface of tool and fires rays from the tool surface and determines the distance to the intersection with the tensor product surface. The closest point of intersection of these gives us the drop distance where the tool first touches the surface.
The points on the torus from which the rays are cast are given by wheret is the unit vector [0, 0, 1] T and with φ k sampled uniformly in [0, 2π ] and θ l sampled uniformly in [3π/2, 2π ]. Note that the tool axis and the minor circle of the torus are coplanar. From each point T ool l,k , a ray parallel to the tool axis is fired towards the Bézier surface. Figure 4a shows a set of rays emanating from points Tool l,k in a direction opposite tot. The ray from T ool l,k intersects the surface at S l,k . The projected patch of the toroidal cutter is shown as hatched area on the surface. The intersection point is the solution of The length of the ray, from the surface to the intersection of the rays with the surface, represents the distance the tool must be dropped to bring that specific surface point in contact with the tool. At each point of the surface this drop distance is different. The drop distance for all the points in the surface array shown in Fig. 4a form a drop distance set. The drop distance set D is where d l,k is a solution obtained from Eqs. 2 and 3 given bŷ The idea is that at the point of intersection, the surface point and the point on the tool surface are same. The difference of both the points gives the deviation of the points and form a set of three equations, derived from Eq. 3, ⎡ In Eq. 6, only the third equation corresponding to the zdirection is a function of the drop distance, d l,k . Based on this observation the solution of Eq. 6 is broken into two steps. In the first step, Newton's method is used to find the values of parameters u and v using the first and second equation of Eq. 6. Given a set of non-linear equations, the iterative step in Newton's method is J is the Jacobian matrix of Eq. 5 and x i is the vector of unknowns, u, v. The initial value of x 0 is set to the solution for the previous T ool l,k , and the subsequent values of x i are calculated iteratively until they are within a user specified tolerance. In the second step, the values of parameters u and v are used to solve for drop distance d l,k in the z-direction. The minimum of the drop distance set d min = min{D} gives the distance the tool should be dropped to just touch the surface without any gouging. Any distance greater than d min will result in over-cutting. The surface point S(u 1 , v i ) is the first point of contact. Note that the point of contact on the tool may lie on an internal (hyperbolic) point in the case of convex surfaces.
The accuracy with which this shaded area is represented depends on the discretization of the torus surface. We used adaptive discretization to obtain greater accuracy and quick convergence.
After dropping the tool, the first point of contact P lies on one of the pseudo-insert, as shown in Fig. 4b. This minor circle is the same size as the insert in a physical tool and as the tool rotates the physical insert coincides with the minor circle as it touches the surface. The center of the pseudo-insert O 1 is given by wheren is the surface unit normal at the point of contact S(u, v) given bŷ n =

∂S(u,v) ∂u
As mentioned by Duvedi et al. [5,12,14] a rotation about the axis of this pseudo-insert maintains the contact between tool and surface at P . The earlier works [5,12] tilted the tool about this axis thereby complicating the resulting drop equations and ray firing equations as transcendental terms due to rotation come into play. In this paper, we use the approach of [14], where the surface is rotated rather than the tool to find the second point of contact and the tool orientation. The tool with the tool axis still aligned to the z-axis is subsequently dropped on the rotated surface. This step is repeated within a bisection based algorithm until a second point of contact is found.

Rotating the surface
To rotate the surface, a new coordinate frame {û 1 ,v 1 ,ŵ 1 } is created at O 1 , the center of the pseudo-insert at P , the first point of contact, wherê The surface is defined in this coordinate frame and is then rotated aboutû 1 by an angle β to form a new rotated surface S (u, v). This rotation leads to the formation of third rotated coordinate frame {û 2 ,v 2 ,ŵ 2 } as shown in Fig. 5, wherê To rotate a tensor product surface, only the control points needed to be rotated. The surface is rotated initially with a minimum rotation angle β and the rotation is incrementally increased until the second gouge free point of contact Q is found. This results two points of contact P and Q, at which the surface and toroidal surface of tool are tangent to each other.
As the surface is tilted in {û 1 ,v 1 ,ŵ 1 }, the pseudo-insert maintains its contact with the surface; however, the position of first point of contact on the pseudo-insert will change, sliding along the pseudo-insert from P to p , as shown in Fig. 5b. The surface S(u, v) will stay tangent to the toroidal surface of the tool, as the rotation is about the center of pseudo-insert O 1 .
The bisection method is used to determine the rotation angle that gives the second point of contact Q. In the bisection method, the surface is rotated by an angle β and the tool is dropped over the rotated surface S in the same manner as the first point of contact. If the point of contact of the dropping tool is the same as the first point of contact the surface is tilted further for increasing β otherwise the The condition for the second point of contact Q to be gouge free is checked by comparing the two heights of drop, i.e., d min and d min at every stage of rotation. The rotation angle where both the heights are equal, gives the second point of contact. Again, note that in the case of convex surfaces, after rotation, the points of contact may be on interior (hyperbolic) points on the toroidal tool.
Additional implementation details and pseudo-code for the method may be found in [15].

Experimental results
The algorithm from Section 3 was implemented in C++ and tested on three bi-cubic Bézier surfaces: a convex surface, a concave surface and a saddle surface. All three surfaces have a span of 150 × 150 in the xy-plane. The xand y-coordinates are uniformly distributed with a span interval of 50 starting from the origin. The z-coordinates for the three bi-cubic Bézier surfaces are given in Table 1. The three test surfaces are shown in Fig. 6. The surfaces were machined using an xy-parallel toolpath as shown in Fig. 2 having 10 passes in total with the first 9 passes separated by Side step = 18.0mm and the 10th pass at x = 150mm. Each pass contains 78 tool positions separated by F orward step = 2.0mm, out of which the first and last tool position of the pass is used to lift the tool to avoid gouging on the surface as the tool shifts from one pass to another. The algorithm runs for 760 effective tool positions that are physically making contact with the surface to be machined. The toroidal cutter used for machining had a major radius of R o = 6.7mm and minor radius of R i = 6mm.
The convex and concave surfaces were used to check the accuracy of the algorithm and the saddle surface (which includes both the convex and concave regions) was used to check the behavior of algorithm as it transits from concave to convex and vice versa. Toolpath data for all three surfaces was generated for every tool position of all the passes of the toolpath footprint. The generated toolpath data was verified by first simulating the toolpath data using the ToolSim simulator [16], and then physically machined on aluminum stock using the same toolpath with a DMU-80P Hi-Dyn tilt-rotary simultaneous five-axis machining center. The results of the physical machining and the simulator match the design surfaces as shown in Fig. 7, which gives the side-by-side representation of the simulated part surface and machined part surface.
After machining, all three machined surfaces were geometrically measured using the Coordinate measuring machine (CMM) at a cross section taken in the sidestep direction at Y = 27.00mm in the xy-plane with a probe of diameter 4mm. Another set of geometrical data points was taken from the machined stock produced in the ToolSim simulator. The vertices for the cross section at Y = 27.00mm in the xy-plane are found and stored separately for the comparison. The obtained geometrical data from machined geometry and the simulated surface was  Figure 8 shows the graphical comparison of all the three surfaces, Convex, Concave and Saddle, for the three sets of geometrical data obtained from Simulated surface, Machined surface and Modeled surface.
It can be seen from the graphical representation of the surfaces in Fig. 8 that the surface data obtained from machined and simulated geometries for the three parts is similar and overlaps with each other, whereas deviation of the machined and simulated surfaces from the modeled surface in the form of scallops can be seen. The toolpath was designed with a fairly large side-step to intentionally produce scallops as a way to assist in aligning the CMM data with the simulated data; these scallops can be eliminated by reducing the side-step value as per the required surface finish. Table 2 gives the minimum and maximum values of deviation on the machined and simulated geometries from the modeled geometry for all the three test surfaces. Maximum deviation gives the value of maximum scallop height which is higher in case of the Concave surface as compared to the Convex and Saddle surfaces. The scallops can be eliminated by reducing the side step and having 12 tool passes instead of 10; as an indication of the accuracy of the method, we have also listed in Table 2 the maximum deviation of the machined and simulated surface   Table 3 gives a timing comparison of the current method with an earlier method (SR) of Duvedi et al. [14]. As seen in the table, the new method (DRC, CPU) is roughly a factor of two faster than the earlier method. Further, the new method lends itself to a GPU implementation.
We implemented two variations of a GPU implementation. Both implementations render the surface and the tool using an orthographic projection (in the direction of the tool axis) and using the z-buffer of these renderings to determine the drop distance. In the first variation of the GPU algorithm, we used a 500×500 pixel grid where the outline of the torus just fit within this pixel grid. This method gave timing numbers similar to the CPU implementation.
In the second version of the GPU algorithm, we used a 2-level algorithm, finding a initial drop distance and point of contact P i using a 50 × 50 grid (again where the outline of the torus just fit within this pixel grid), and then redid the drop computation again using a 50 × 50 pixel grid but only in a small region around P i . This second version of the GPU algorithm gave us tool paths that were numerically the same as the CPU version of the DRD algorithm, with a roughly factor of 10 improvement in performance.

Discussion
The method presented in this paper finds multi-point tool positions by dropping a toroidal tool onto a Bézier surface and finding the highest point of contact. By just using this variation of gouge detection from an earlier algorithm, Table 3 Timing comparison of new method (DRD) to earlier method of Duvedi et al. [14]. All values are in seconds SR DRD (CPU) DRD 500×500 DRD  a factor of two speed-up was obtained over numerically solving for tool positions with two points of contact. While the presented method tests for the highest point of contact at a discrete set of points, locally refining the grid in the neighborhood of the initial solution for the closest point of contact yields solutions comparable to the earlier method. Further, the discrete grid of rays cast to find the point of contact resulted in an efficient GPU implementation. When dropping the toroidal tool on a convex surface, the first point of contact will be on the interior of the torus if the surface normal is close to aligned with the z-axis (the tool drop direction). After rotation, both points on contact can both lie on the interior of the torus. If the entire interior of the torus is not a cutting surface, a flat disk may need to be inserted inside the interior of the torus at the limiting point of the cutting edge for the interior, and rays cast from this disk. When dropping, if the closest point lies on this disk, then a rotation about this closest point in a plane containing the tool axis will yield a second point of contact on the torus. However, since this disk is a non-cutting surface, the resulting tool position would have a single point of contact.
Funding This research was supported by NSERC.
Availability of data and material Some of the surfaces used in this work are given in the paper. The remaining surfaces and other data are available on request.
Code availability Pseudo-code for the work in this paper appears in the appendix; the actual code is available on request.