In modern manufacturing, the removal of flash—excess material formed along parting lines during the casting process—is a critical yet labor-intensive finishing operation for casting parts. Manual grinding is plagued by inconsistencies in quality, low efficiency, and high operational costs. The transition towards robotic automation for this task is inevitable. However, a significant challenge in robotic grinding lies in the accurate acquisition of the casting part’s geometric features and the precise planning of the grinding path. Traditional methods often rely on offline programming based on CAD models or limited 2D vision systems, which may not fully capture the dimensional variances present in individual physical casting parts, leading to suboptimal grinding results such as under-grinding, over-grinding, or tool damage.
To address these challenges, we propose a comprehensive method for flash extraction and grinding path fitting based on the 3D point cloud data of a physical casting part. This approach leverages the high-fidelity spatial information captured by 3D scanners to bridge the gap between the nominal CAD model and the actual workpiece. Our core methodology involves accurately registering the point cloud of a casting part to be ground with that of a standard model, segmenting the flash region, calculating its height distribution, and ultimately generating a smooth, accurate grinding path. This data-driven strategy ensures the grinding operation is tailored to the specific geometry of each individual casting part.

The foundational data for our method is the 3D point cloud. We acquire point clouds for two objects: the physical casting part requiring flash removal (target casting part) and a standard, defect-free model casting part or its CAD-derived point cloud (source/reference casting part). The point cloud of the target casting part contains all surface information, including the desired geometry and the unwanted flash. The process of aligning these two point clouds into a common coordinate system is paramount for subsequent steps.
Prior to registration, the raw point clouds often contain a massive number of points, which can hinder computational efficiency. To preserve geometric features while reducing data volume, we first apply voxel grid downsampling. This process divides the 3D space into uniform voxels and replaces all points within each non-empty voxel with their centroid. The centroid \(P_{\text{centroid}}\) of a voxel containing \(m\) points is calculated as:
$$P_{\text{centroid}} = \left( \frac{\sum_{i=1}^{m} x_i}{m}, \frac{\sum_{i=1}^{m} y_i}{m}, \frac{\sum_{i=1}^{m} z_i}{m} \right)$$
This results in a uniformly sampled point cloud that retains the overall shape of the casting part, setting the stage for efficient registration.
Point cloud registration is performed in two stages: coarse and fine. Coarse registration provides an initial alignment. We employ the RANSAC (Random Sample Consensus) algorithm. It randomly selects minimal point correspondences to hypothesize transformation matrices and iteratively seeks the matrix that yields the largest set of inlier correspondences (point pairs within a distance threshold). The key steps are summarized below.
| Step | Action |
|---|---|
| 1 | Initialize best transformation matrix \(T\) and inlier count. |
| 2 | For k iterations: Randomly pick 3 non-collinear point pairs \((p_i, q_i)\). |
| 3 | Compute a transformation hypothesis from these pairs. |
| 4 | Transform all source points. Find correspondences in target cloud. |
| 5 | Count inliers where distance \(e_i = \|q_i – T(p_i)\| < \Phi\). |
| 6 | Update best \(T\) if current inlier count is higher. |
| 7 | Apply best \(T\) to source cloud for coarse alignment. |
Following coarse alignment, we apply the ICP (Iterative Closest Point) algorithm for fine registration. ICP iteratively refines the transformation by minimizing the point-to-point distance between the two clouds. In each iteration \(t\), for each point \(q_i\) in the target cloud \(Q\), it finds the closest point \(p_i^t\) in the currently transformed source cloud \(P^t\). It then computes a new transformation \((R^{t+1}, T^{t+1})\) that minimizes the mean squared error:
$$E(R^{t+1}, T^{t+1}) = \frac{1}{n} \sum_{i=1}^{n} \| p_i^t – (R^{t+1} q_i + T^{t+1}) \|^2$$
This process repeats until the change in error \(E\) falls below a threshold or a maximum iteration count is reached, resulting in a highly accurate alignment of the two casting part point clouds.
With the two point clouds precisely registered, the flash region can be identified as the non-overlapping portion. We use a K-D Tree to perform a nearest neighbor search. For each point in the registered target casting part cloud, we find its closest point in the registered standard model cloud. Points whose distance to their nearest neighbor exceeds a defined tolerance are considered part of the flash or other geometric deviations. The set of these non-overlapping points is initially extracted. This raw set often contains sparse outliers due to sensor noise or minor registration imperfections. We apply statistical outlier removal to filter out points whose average distance to their \(k\) nearest neighbors is significantly larger than the global mean, yielding a clean point cloud representing the flash on the casting part.
Merely identifying the flash is insufficient for grinding; we must determine how much material to remove. This is achieved by calculating the distance from each point in the extracted flash cloud to the surface of the standard casting part model. A simple nearest-point distance can be error-prone due to point sparsity. Instead, we employ a point-to-surface distance estimation. For a flash point, we find its nearest point on the standard model surface and a small neighborhood around it (e.g., 6 neighboring points). A local surface patch (e.g., a plane) is fitted to this neighborhood using a least-squares method. The distance from the flash point to this fitted local surface is then computed, providing a more robust and accurate estimate of the flash height at that location.
Let the fitted local plane be defined by its normal vector \(\vec{n}\) and a point \(p_0\) on the plane. The signed distance \(d\) from a flash point \(p_f\) to this plane is:
$$d = \vec{n} \cdot (p_f – p_0)$$
Calculating this for all flash points generates a height distribution map and statistical data (mean, standard deviation, maximum error) for the flash on the casting part. This information is crucial for setting the grinding depth. The table below presents an example of statistical analysis from a flash point cloud.
| Statistical Metric | Value (mm) | Description |
|---|---|---|
| Mean Height | 1.29 | Average flash thickness. |
| Standard Deviation | 0.39 | Variability in flash height. |
| Maximum Error | 0.92 | Largest local flash protrusion. |
The final and most critical step is generating a continuous, smooth grinding path. The grinding tool should ideally follow the edge where the flash meets the main body of the casting part. The inner edge of the flash point cloud (the boundary adjacent to the casting body) provides the ideal data for this path. To obtain this, we first need the outer contour of the main casting body.
We isolate the point cloud of the main casting body (the overlapping region from the registration step). To simplify the complex 3D contour extraction, we project the 3D body point cloud onto a 2D plane. A unilateral forward projection along a dominant axis (e.g., the Z-axis) is performed, effectively creating a 2D point map of the casting part’s silhouette. Standard 2D edge detection algorithms (e.g., Canny) are then applied to this projection to extract the outer boundary. This 2D boundary represents the planar projection of the desired 3D grinding path contour for the casting part.
The extracted 2D boundary contains a dense sequence of points. Directly using all points for path planning is inefficient. Therefore, we apply downsampling to this boundary to create two sets: a Fitting Point Set containing a reduced number of points that faithfully represent the contour shape, and a separate Verification Point Set used later to validate the fitted path’s accuracy.
To generate a smooth, continuous grinding path from the discrete Fitting Point Set, we employ Non-Uniform Rational B-Spline (NURBS) curve interpolation. B-spline curves offer excellent local shape control and smoothness, making them ideal for representing the complex, free-form contours typical of casting parts. A k-th degree NURBS curve is defined by:
$$C(u) = \frac{\sum_{i=0}^{n} \omega_i d_i N_{i,k}(u)}{\sum_{i=0}^{n} \omega_i N_{i,k}(u)}$$
where \(d_i\) are the control points, \(\omega_i\) are the corresponding weights, and \(N_{i,k}(u)\) are the k-th degree B-spline basis functions defined on a non-uniform knot vector \(U = [u_0, u_1, …, u_{m}]\). For curve interpolation, we use a cubic NURBS curve (k=3). Given \(n+1\) fitting points \(Q_i\) (the downsampled boundary points of the casting part), we need to find \(n+3\) control points \(d_i\) and a knot vector \(U\) so that the curve passes through all \(Q_i\). The process, known as curve inversion, involves the following key steps:
1. Parameterization: Assign a parameter value \(\bar{u}_i\) to each data point \(Q_i\). We use the cumulative chord length method, which reflects the distribution of points along the contour:
$$\bar{u}_0 = 0; \quad \bar{u}_i = \bar{u}_{i-1} + \frac{|Q_i – Q_{i-1}|}{L}, \quad i=1,…,n$$
where \(L\) is the total chord length. These parameters are then mapped to the knot vector. For a cubic curve interpolating \(n+1\) points, the knot vector has \(n+7\) knots. We use a clamped knot vector where the first and last four knots are repeated: \(U=[0,0,0,0, u_4, u_5, …, u_{n+2}, 1,1,1,1]\). The internal knots \(u_{3+j}\) for \(j=1,…,n-3\) are computed from the averaged parameters.
2. Formulating and Solving the System: The condition that the curve passes through point \(Q_i\) at parameter \(\bar{u}_{i+3}\) gives a system of linear equations. For a cubic curve, the interpolation equation at point \(Q_r\) (where \(r=0,…,n\)) is:
$$Q_r = C(\bar{u}_{r+3}) = \sum_{i=0}^{n+2} d_i N_{i,3}(\bar{u}_{r+3})$$
Assuming weights \(\omega_i=1\) (simplifying to a non-rational B-spline for clarity), this becomes a linear system in the unknown control points \(d_i\). The system can be written in matrix form as \(N \cdot D = Q\), where \(N\) is a banded matrix of basis function values. Solving this system yields the control polygon \(D = [d_0, d_1, …, d_{n+2}]^T\).
| Step | Objective | Key Equation/Process |
|---|---|---|
| 1. Parameterization | Assign parameters to data points. | $$\bar{u}_i = \sum_{j=1}^{i} \frac{|Q_j – Q_{j-1}|}{L}$$ |
| 2. Knot Vector Generation | Create clamped knot vector. | $$U = [0,0,0,0, u_4,…, u_{n+2}, 1,1,1,1]$$ |
| 3. Build System | Set up interpolation equations. | $$Q_r = \sum_{i=0}^{n+2} d_i N_{i,3}(\bar{u}_{r+3})$$ |
| 4. Solve for Controls | Compute control points \(d_i\). | Solve \(N \cdot D = Q\) |
3. Curve Generation: With the control points \(d_i\) and knot vector \(U\) determined, the cubic NURBS curve \(C(u)\) is fully defined and can be evaluated at any parameter \(u\) to generate a continuous, smooth grinding path for the robot to follow along the contour of the casting part.
To validate the accuracy of the fitted grinding path, we use the independent Verification Point Set. For each point \(V_j\) in this set, we calculate its minimum distance to the fitted NURBS curve \(C(u)\). This involves finding the parameter \(u^*_j\) that minimizes the distance \(\|V_j – C(u)\|\), typically solved via Newton-Raphson iteration for each point. The validation metrics are the average distance error \(E_{avg}\) and the root mean square error \(E_{rms}\):
$$E_{avg} = \frac{1}{m} \sum_{j=1}^{m} \|V_j – C(u^*_j)\|$$
$$E_{rms} = \sqrt{ \frac{1}{m} \sum_{j=1}^{m} \|V_j – C(u^*_j)\|^2 }$$
In our experiments, these errors were found to be on the order of hundredths of a millimeter (e.g., \(E_{avg} \approx 0.036\) mm, \(E_{rms} \approx 0.004\) mm), which is well within the acceptable tolerance for robotic grinding of casting parts, confirming the high precision of the path fitting methodology.
In conclusion, we have presented a robust, point-cloud-based framework for automating the flash grinding process for casting parts. The method begins with the precise 3D data acquisition of the workpiece, followed by a two-stage registration process to align it with a standard model. This alignment enables the accurate segmentation of flash regions. By calculating point-to-surface distances, we obtain a detailed height map of the flash, providing essential data for determining grinding depth parameters. Finally, by extracting the casting body contour and fitting a smooth NURBS curve through it, we generate a highly accurate and continuous grinding path tailored to the specific geometry of the individual casting part. The entire process minimizes reliance on manual teaching or generic CAD paths, directly addressing the geometric uniqueness of each cast workpiece. Validation through independent point sets confirms the sub-millimeter accuracy of the generated paths, making this approach a viable and precise solution for the automated finishing of complex casting parts. Future work may focus on optimizing the computational efficiency of the point cloud processing algorithms and integrating this path planning module directly with real-time robotic grinding force control systems for a fully adaptive manufacturing cell.
