A Real-Time Estimation Method of Soil-Bucket Interaction of an Autonomous Excavator via Marching Cube and Constructive Solid Geometry Methods

: In this paper, a combination of marching cubes and the constructive solid geometry method were merged to develop a simple, fast, and accurate method to estimate the shape of the soil in addition to the volume of the soil in the bucket during the digging process of an autonomous excavator. A simulation test was designed to verify the proposed method. The result of the implemented software simulation was compared with the analytical solution to validate the accuracy of the proposed method.


Introduction
The control of an autonomous excavator during the digging process is a complex task as the interaction of bucket and soil creates significant external forces and moments on the excavator's attachment. Due to the harsh working environment of the excavators, it is not practical to install sensors on the bucket of the excavator to measure parameters. Additionally, external noises such as vibrations, impacts, dust, etc. can affect the sensor measurements.
In this paper, a real-time simulation method based on the marching cube method is presented, which can capture the initial condition of the soil and estimate the shape of the soil as well as the amount of the soil banked into the bucket. So, the complex and computationally intensive processes required in previous studies using the voxel simulation method is eliminated.
The marching cube methods were initially introduced to construct a constant density representation of 3D data mainly for medical purposes [1]. D. Holz et al. extended the fundamental equation of earthmoving via marching cubes to determine the deformation of the soil in interaction with the bucket [2]. A variety of voxel-based approaches were investigated for simulations of the deformation of sand and soil [3]. The dynamics of soil-bucket interaction were also studied [4]. The estimation of the soil shape during the excavation was investigated [5]. However, in most cases, the simulations were computationally heavy and cannot be used for a real-time process on decent hardware.
In the proposed method, ground shape is captured and represented by the marching cube method. This step is executed only once before starting the excavation process. Then, the pose of the bucket is determined by the joint angles to define the bucket traverse. The bucket volume is estimated by moving the bucket through the soil. By subtracting the bucket volume from the initial shape of the ground, the updated ground shape is estimated. The constructive solid geometry algorithm is used to apply the subtraction operation. In addition, the volume of soil in the bucket is equal to the volume of the bucket motion. Using the proposed method, the soil-bucket interaction can be estimated without requiring any extra sensory information. Since the proposed method does not require high computational power, it can be applied in real-time applications, overcoming the limitations of existing approaches that demand high computational power and make real-time calculation difficult.

Marching Cubes
The initial purpose of the marching cube was to illustrate the sliced medial scan images as a 3D-represented object. Figure 1 represents a marching cube in between two neighbor slices. To achieve this, the whole volume is divided into discrete cubes while each cube contains an isosurface. The 3D object can be represented by merging the isosurfaces of cubes together.
Eng. Proc. 2022, 24, 1 2 of 6 estimated. The constructive solid geometry algorithm is used to apply the subtraction operation. In addition, the volume of soil in the bucket is equal to the volume of the bucket motion.
Using the proposed method, the soil-bucket interaction can be estimated without requiring any extra sensory information. Since the proposed method does not require high computational power, it can be applied in real-time applications, overcoming the limitations of existing approaches that demand high computational power and make real-time calculation difficult.

Marching Cubes
The initial purpose of the marching cube was to illustrate the sliced medial scan images as a 3D-represented object. Figure 1 represents a marching cube in between two neighbor slices. To achieve this, the whole volume is divided into discrete cubes while each cube contains an isosurface. The 3D object can be represented by merging the isosurfaces of cubes together. Each cube is constructed by eight different vertices. Figure 2 shows those vertices. For each vertex, an occupancy value is assigned based on the linear interpolation of the connected vertices. Thus, the shape of isosurfaces will be generated based on the occupancy values of the vertices. In this paper, the occupancy level is limited to two binary values that represent whether the vertex is occupied by the soil or not. If the occupancy values of the two connected vertices are the same (on or off), it means that the isosurface does not pass through that line. If one vertex is on and the other one is off, one vertex is in the soil and the other one is in the air. Thus, the surface of the soil must pass through the line between these two vertices. Figure    Each cube is constructed by eight different vertices. Figure 2 shows those vertices. For each vertex, an occupancy value is assigned based on the linear interpolation of the connected vertices. Thus, the shape of isosurfaces will be generated based on the occupancy values of the vertices. In this paper, the occupancy level is limited to two binary values that represent whether the vertex is occupied by the soil or not. If the occupancy values of the two connected vertices are the same (on or off), it means that the isosurface does not pass through that line. If one vertex is on and the other one is off, one vertex is in the soil and the other one is in the air. Thus, the surface of the soil must pass through the line between these two vertices. Figure 2 illustrates the intermediate points of a marching cube. estimated. The constructive solid geometry algorithm is used to apply the subtraction operation. In addition, the volume of soil in the bucket is equal to the volume of the bucket motion.
Using the proposed method, the soil-bucket interaction can be estimated without requiring any extra sensory information. Since the proposed method does not require high computational power, it can be applied in real-time applications, overcoming the limitations of existing approaches that demand high computational power and make real-time calculation difficult.

Marching Cubes
The initial purpose of the marching cube was to illustrate the sliced medial scan images as a 3D-represented object. Figure 1 represents a marching cube in between two neighbor slices. To achieve this, the whole volume is divided into discrete cubes while each cube contains an isosurface. The 3D object can be represented by merging the isosurfaces of cubes together. Each cube is constructed by eight different vertices. Figure 2 shows those vertices. For each vertex, an occupancy value is assigned based on the linear interpolation of the connected vertices. Thus, the shape of isosurfaces will be generated based on the occupancy values of the vertices. In this paper, the occupancy level is limited to two binary values that represent whether the vertex is occupied by the soil or not. If the occupancy values of the two connected vertices are the same (on or off), it means that the isosurface does not pass through that line. If one vertex is on and the other one is off, one vertex is in the soil and the other one is in the air. Thus, the surface of the soil must pass through the line between these two vertices. Figure     By creating a volume around the digging area and applying the marching cube algorithm to it, a simple, fast, yet accurate model of the soil can be generated.

Constructive Solid Geometry
Constructive solid geometry (CSG) is a simple method to create a complex 3D object by applying Boolean 3D operations to geometric primitives. Boolean operations include union, difference, and intersection while the geometric primitives are cuboids, cylinders, prisms, pyramids, spheres, and cones. Figure 4 illustrates the Boolean operation on a cube and sphere. The complex 3D object can be created by the series of Boolean operations on geometric primitives.  In this paper, the CSG method was implemented to subtract the volume created by the bucket from the initial shape of the soil. If a soil vertex is located inside the bucket By creating a volume around the digging area and applying the marching cube algorithm to it, a simple, fast, yet accurate model of the soil can be generated.

Constructive Solid Geometry
Constructive solid geometry (CSG) is a simple method to create a complex 3D object by applying Boolean 3D operations to geometric primitives. Boolean operations include union, difference, and intersection while the geometric primitives are cuboids, cylinders, prisms, pyramids, spheres, and cones. Figure 4 illustrates the Boolean operation on a cube and sphere. The complex 3D object can be created by the series of Boolean operations on geometric primitives.  By creating a volume around the digging area and applying the marching cube algorithm to it, a simple, fast, yet accurate model of the soil can be generated.

Constructive Solid Geometry
Constructive solid geometry (CSG) is a simple method to create a complex 3D object by applying Boolean 3D operations to geometric primitives. Boolean operations include union, difference, and intersection while the geometric primitives are cuboids, cylinders, prisms, pyramids, spheres, and cones. Figure 4 illustrates the Boolean operation on a cube and sphere. The complex 3D object can be created by the series of Boolean operations on geometric primitives.  In this paper, the CSG method was implemented to subtract the volume created by the bucket from the initial shape of the soil. If a soil vertex is located inside the bucket In this paper, the CSG method was implemented to subtract the volume created by the bucket from the initial shape of the soil. If a soil vertex is located inside the bucket volume, the soil will be moved from the ground into the bucket. Thus, the vertex no longer contains soil.

Methodology
The proposed method combines marching cubes and constructive solid geometry to evaluate the soil shape as well as the soil volume amount contained in the bucket during the digging process. A grid of cubes is created around the digging area so that the grid of cubes later will be used for marching cubes purposes. Then, the occupancy value of each cell is determined based on the location of a vertex and the height of the soil surface at the same place. For example, the vertex (i, j, k) has the Cartesian location of (x, y, z). Based on the ground surface, the measured soil height at the same location (x, y) was z s . Thus, the occupancy value of the vertex (i, j, k) is 1 (on) if z s ≥ z or zero (off) if z s < z.
where (x, y, z) is the location of the (i, j, k) vertex and z s (x, y) is the height of the soil at the provided (x, y) location. O(i, j, k) represents the occupancy value of the (i, j, k) vertex. During the digging process, the location of the bucket is determined by the measured joint angles and kinematic analysis. Thus, the bucket face also can be determined accordingly based on its location and the manipulator's dimensions.
By moving the manipulator, the new location of the bucket face can be identified. Then, an irregular parallelepiped volume is generated by connecting the previous location of the bucket face with its new location after one step time.
In the next step, the CSG method is applied to subtract the generated volume from the initial ground shape, and any vertices that are inside the shape and already occupied by the soil are replaced by the air as there is no more soil on the location of the vertex. So, the occupancy value is set to off and the marching cubes can be updated.
Finally, after each update on marching cubes, the volume of the current marching cube representation is subtracted from the previous volume. In this case, the difference in the soil volume is considered the amount of soil that has been transferred from the ground to the bucket. Thus, the amount of soil contained in the bucket can be estimated.

Simulations and Results
To implement the proposed method and evaluate its accuracy, software was written using C++ and OpenGL. Figure 5 demonstrates the written simulation software. The developed software is able to calculate the bucket motion based on the provided trajectory of the joints. It can also apply the proposed marching cubes and CSG methods to estimate the volume of the soil in the bucket as well as the modified shape of the ground during the excavation process.
Eng. Proc. 2022, 24, 1 4 of 6 volume, the soil will be moved from the ground into the bucket. Thus, the vertex no longer contains soil.

Methodology
The proposed method combines marching cubes and constructive solid geometry to evaluate the soil shape as well as the soil volume amount contained in the bucket during the digging process. A grid of cubes is created around the digging area so that the grid of cubes later will be used for marching cubes purposes. Then, the occupancy value of each cell is determined based on the location of a vertex and the height of the soil surface at the same place. For example, the vertex (i, j, k) has the Cartesian location of (x, y, z). Based on the ground surface, the measured soil height at the same location (x, y) was zs. Thus, the occupancy value of the vertex (i, j, k) is 1 (on) if zs ≥ z or zero (off) if zs < z.
where (x, y, z) is the location of the (i, j, k) vertex and zs(x, y) is the height of the soil at the provided (x, y) location. O(i, j, k) represents the occupancy value of the (i, j, k) vertex. During the digging process, the location of the bucket is determined by the measured joint angles and kinematic analysis. Thus, the bucket face also can be determined accordingly based on its location and the manipulator's dimensions.
By moving the manipulator, the new location of the bucket face can be identified. Then, an irregular parallelepiped volume is generated by connecting the previous location of the bucket face with its new location after one step time.
In the next step, the CSG method is applied to subtract the generated volume from the initial ground shape, and any vertices that are inside the shape and already occupied by the soil are replaced by the air as there is no more soil on the location of the vertex. So, the occupancy value is set to off and the marching cubes can be updated.
Finally, after each update on marching cubes, the volume of the current marching cube representation is subtracted from the previous volume. In this case, the difference in the soil volume is considered the amount of soil that has been transferred from the ground to the bucket. Thus, the amount of soil contained in the bucket can be estimated.

Simulations and Results
To implement the proposed method and evaluate its accuracy, software was written using C++ and OpenGL. Figure 5 demonstrates the written simulation software. The developed software is able to calculate the bucket motion based on the provided trajectory of the joints. It can also apply the proposed marching cubes and CSG methods to estimate the volume of the soil in the bucket as well as the modified shape of the ground during the excavation process.  A test scenario was designed to validate the accuracy of the proposed method. In this scenario, the information on the ground's initial shape and the bucket motion during Eng. Proc. 2022, 24, 1 5 of 6 the digging process was provided in analytical equation forms. Therefore, the exact shape of the ground and the amount of soil in the bucket can be determined. By comparing the analytical results with simulations results from the next subsection, the validity and accuracy of the proposed method can be examined.

Test Scenario
In this scenario, the shape of the ground is assumed to be flat at ground level and the bucket moves in a half sin motion based on Equations (3)-(5). The initial shape of the ground and the area covered by the motion of the bucket are illustrated in Figure 6.
Eng. Proc. 2022, 24, 1 5 of 6 A test scenario was designed to validate the accuracy of the proposed method. In this scenario, the information on the ground's initial shape and the bucket motion during the digging process was provided in analytical equation forms. Therefore, the exact shape of the ground and the amount of soil in the bucket can be determined. By comparing the analytical results with simulations results from the next subsection, the validity and accuracy of the proposed method can be examined.

Test Scenario
In this scenario, the shape of the ground is assumed to be flat at ground level and the bucket moves in a half sin motion based on Equations (3)-(5). The initial shape of the ground and the area covered by the motion of the bucket are illustrated in Figure 6. It is assumed that the bucket's width is 0.2 m and the amount of soil removed by the bucket is equal to the bucket width times the area between the curve and the initial ground level.
Therefore, the exact volume is 0.0393 m 3 while the result of the proposed method is 0.0390 m 3 . The difference between the result of the proposed method and the analytical value is around 0.76%. The occupancy map of the generated marching cube is shown in Figure 7. The test was done on a laptop which has a Core™ i7-8750H processor with 6 cores and 32 GB of RAM. Each iteration of the simulation took 20 ms. So, the developed algorithm can estimate the shape of the soil around 50 times per second.  It is assumed that the bucket's width is 0.2 m and the amount of soil removed by the bucket is equal to the bucket width times the area between the curve and the initial ground level.
Therefore, the exact volume is 0.0393 m 3 while the result of the proposed method is 0.0390 m 3 . The difference between the result of the proposed method and the analytical value is around 0.76%. The occupancy map of the generated marching cube is shown in Figure 7. The test was done on a laptop which has a Core™ i7-8750H processor with 6 cores and 32 GB of RAM. Each iteration of the simulation took 20 ms. So, the developed algorithm can estimate the shape of the soil around 50 times per second. A test scenario was designed to validate the accuracy of the proposed method. In this scenario, the information on the ground's initial shape and the bucket motion during the digging process was provided in analytical equation forms. Therefore, the exact shape of the ground and the amount of soil in the bucket can be determined. By comparing the analytical results with simulations results from the next subsection, the validity and accuracy of the proposed method can be examined.

Test Scenario
In this scenario, the shape of the ground is assumed to be flat at ground level and the bucket moves in a half sin motion based on Equations (3)-(5). The initial shape of the ground and the area covered by the motion of the bucket are illustrated in Figure 6. It is assumed that the bucket's width is 0.2 m and the amount of soil removed by the bucket is equal to the bucket width times the area between the curve and the initial ground level.
Therefore, the exact volume is 0.0393 m 3 while the result of the proposed method is 0.0390 m 3 . The difference between the result of the proposed method and the analytical value is around 0.76%. The occupancy map of the generated marching cube is shown in Figure 7. The test was done on a laptop which has a Core™ i7-8750H processor with 6 cores and 32 GB of RAM. Each iteration of the simulation took 20 ms. So, the developed algorithm can estimate the shape of the soil around 50 times per second.

Conclusions
The proposed method uses a combination of the marching cubes method in addition to a constructive solid geometry algorithm to estimate the shape of the ground and the volume of the soil which is inside the bucket during the excavation process. So, the proposed method can estimate this volume in a real-time, yet accurate way. The accuracy of the proposed method was investigated through a simulation and the relative error was around 0.76%. This accurate result indicates that the proposed method can be used for excavation.
As the ground is not completely rigid, its shape will change during digging due to soil failure. The proposed method cannot detect this change, but the shape of the ground will be updated by using a depth camera in future work.