3D printing path planning algorithm for thin walled and complex devices

With the popularity of stereo printing technology, 3D printers are widely used in industry, manufacturing, medicine, and other industries to quickly manufacture small devices. Before 3D printing, it is necessary to plan the printing path. Unreasonable printing path will not only increase the time consumption of printing products, but also cause printing failure due to the accumulation of stress and deformation in the printing process. In order to overcome the superimposed stress and deformation in the process of printing thin-walled complex devices, this article introduces the idea of balanced stress based on the basic damage of the path planning based on the potential field method. In the printing process, the ring path, island path and cross path are added to overcome the stress deformation phenomenon and improve the printing quality. Finally, the 3D printer is used to manufacture thin-walled complex devices, and the feasibility of the balanced potential field method is verified by physical comparison.


Introduction
3D printing technology, also known as a layered rapid prototyping technology, is a kind of technology based on the digital model file, which uses nylon glass fiber, gypsum material, aluminum material, and other powder metal or plastic and other adhesive materials to manufacture devices of arbitrary shape by slicing and accumulating. Compared with the traditional manufacturing industry, 3D printing technology is widely used in medical devices, aerospace, automobile manufacturing, and other fields because of its low-cost production mode, short cycle development time, and convenient and complex process, and even known as the subversive technology to promote the "third industrial revolution." As shown in Figure 1, common 3D printing technologies mainly include stereolithography, fused deposition (FDM), selective laser sintering, and laser near net forming. No matter what technology is selected, it is necessary to plan a reasonable printing path before printing, to make the 3D printing process fast and accurate and to improve the printing efficiency and quality.
To plan a reasonable printing path, researchers have conducted extensive research on 3D printing path planning to improve printing efficiency and molding quality. The planning methods of reciprocating linear scanning [1,2], which is a traditional way of 3D printing. Its technology is relatively mature and has the characteristics of fast speed and simple algorithm. However, planning in one direction will not only cause a lot of empty paths, but also lead to serious stress bending. In order to reduce the time-consuming of empty paths in printing and to improve the printing efficiency, Rui-Shi et al. [3] applied "Z" planning algorithm to print devices. To some extent, it can reduce the warpage of printing, but it cannot solve the problem of excessive burr at the inflection point. Literature [4][5][6] proposes two simple algorithms and plans the offset contour according to the model contour. In the process of printing, the path is planned step by step and layer by layer according to the object contour from outside to inside and from bottom to top. Although the printing time and the edge burr are reduced, it is only suitable for regular shapes with smooth boundary and simple structure. In the process of step-by-step printing inward, "fracture" phenomenon is more serious [7]. The above methods consider devices to be printed as a whole, which are not suitable for special devices with "island." Xiao-ya and Zheng et al. [8][9][10] divided the "isolated island" in the object into sections by the method of type slicing to improve the printing quality. In addition, intelligent algorithms such as genetic algorithm, ant colony algorithm, hash algorithm and Hilbert curve method [11][12][13][14] are also applied to 3D printing to find new and efficient planning methods.
Although these algorithms improve the 3D printing performance to a certain extent, they are not suitable for the special case of thin-walled devices. In order to improve the efficiency of 3D printing, this article proposes a path planning method based on balanced potential field (BPF) algorithm. The reasonable printing path is quickly planned by using the balanced field method. Based on this the stress deformation is abstracted as a potential field function, and the stress is reduced by the method of BPF. Force deformation can not only effectively print thin-walled complex devices, but also greatly reduce the warping of edge area in printing process, and improve the success rate and quality of printing.
2 3D printing path planning based on BPF method 2.1 Potential field method Extensive research on potential field methods has proved the effectiveness in path planning, but those research mainly focuses on robots and unmanned aerial vehicles [15,16].
The main idea of path planning using the potential field (PF) is to find the global potential field function. In the process of path planning, the path that has been traversed and the potential field target in the unknown path is constantly changed, so that the algorithm can completely traverse the global environment. The principle is that in the process of path planning, the target position is set to attract the next trend of the path, and the repulsion position is set to prevent the path. In the global process, the potential function U sum is the superposition of gravitational function U att and repulsive function U rep .
The gravity function U att is defined as a monotonic function that grows with the distance function ( ) d n n , goal between the current position node n and the target node n goal , goal , ξ is the gravitational coefficient and d goal ⁎ is the gravitational threshold function. The gravitational potential field function ( ) U Diff att is:  The repulsion potential field function ( ) U Diff rep is as follows: is the repulsion threshold function. By superposing the repulsion functions of all calculation points in the repulsion region, the repulsion function U rep can be formed as: In path planning, based on completing the current path point, the gradient direction of the next step is the superposition direction of the gravitational gradient field and the repulsive gradient field: If the printed path points and blank areas are set as repulsive points, and the unprinted path points are gravity points, the global path can be traversed by using the potential field method. Although the ergodic potential field method has great advantages in fast path planning, the application to 3D path planning is not much. Yu-jie [17] introduced the potential field method into the path planning, and finally determined the optimal traversal path through the fast traversal method. Xiao-lei et al. [18] combined the grid complete traversal with artificial potential field method, so that the planned path has better performance in practicability, rationality and real-time.
The potential field method has great potential in the path planning of 3D printing, but the disadvantages are also obvious [19]. In the printing process, only how to traverse the path quickly is considered, but the stress mutation in the printing process is ignored, for example, the edge is easy to warp and the joint is easy to deform. It is necessary to improve the PF method to improve the printing quality and success rate.

Balanced potential field method 2.2.1 Basic thought
The traditional potential field method only considers the optimization of the printing path but ignores the stress of special printing positions such as inflection point and thin-walled edge. As shown in Figure 2, a plane in the printing process is extracted, in which the black arrow represents the print path and the red arrow indicates the stress direction. At the edge of the device, due to the stress warping, the device is easy to deform, resulting in printing failure. Moreover, because only the potential field method is used to print step by step and line by line, the warping is more serious, even leading to the printing failure of the whole device.
The main idea of the BPF method is to balance the sudden change of stress direction at the edge of the device and the stress superposition in the process of the device plane printing step by step. To eliminate this adverse effect, it is necessary to change the path direction in real-time according to the stress change trend in the printing process, as shown in Figure 3, to plan the circular path, cross path, and island path, so as to reduce the stress deformation effect.

Algorithm derivation
Before 3D printing, assuming that the global path of the printed device is a two-dimensional point set . The resultant force of potential field function ( ) U p next is obtained as follows: , , then the optimal trend point of the next printing path is = p p opt next . Although the printing path can be drawn according to the potential field law, the problem of stress and deformation is not eliminated. Therefore, the region of balanced potential field ( ) B X Y , is introduced to balance the problem of global uneven stress ( ) , as a partial region of ( ) G X Y , : For any printing path ( , , take continuous two points = ( ) ∈ p x y L , 1 1 1 and = ( ) ∈ p x y L , 2 2 2 given in the printing process on path L, and define the deformation stress → → F p p 2 1 of p 2 to p 1 as: where γ is the deformation force calculation coefficient, × is the cross multiplication symbol, the deformation force → → F p p If → → F L is greater than the threshold value, it may cause stress deformation of the device, even lead to the failure of printing in ( ) B X Y , . When the superposition effect force → → F L is close to the deformation threshold force, the path → L should be truncated to eliminate the superposition effect of stress, that is to balance the stress potential field. According to the different situations encountered in printing, ring path, cross path, and island path are planned respectively to balance the stress potential field.
(1) Printing path based on balanced stress potential field For a printing path ( ) L X Y , , if the current superimposed effect force → → F L is greater than the set stress threshold, the cross path needs to balance the current stress and reduce stress deformation. The optimal point of the next printing path p opt is as follows:  where p balance is the direction point perpendicular to p next . When the algorithm feels that the path may produce stress deformation, it balances the stress deformation effect by changing the printing path direction to a normal direction perpendicular to the original direction. (2) Printing area based on balanced stress potential field For a partial area of the device ( , , the path of the printing area is L 1 , L 2 , L 3 ,… L j , it can be considered that the region is equal to the superposition of multiple paths: , , , Then the stress superposition of the region → F B is calculated as the superposition stress of each path: When the superimposed stress of the region → F B is greater than the maximum deformation stress threshold F B thresh , the stress and deformation of a small part of the region may occur. Therefore, when the stress superposition approaches the maximum deformation stress threshold, the island path = { … } Θ l l l l , , , n 1 2 3 is replanned in the region to balance the device deformation caused by regional stress superposition. The printing area ( ) B X Y , is: of thin-walled edge needs to contain at least one connecting path to construct a circular path. As shown in Figure 5, when calculating the stress of the thin-walled edge (blue curve), there must be one connecting path at least (red line segment) to make C end to end.
In other words, the path C of the edge can be divided into two cases according to the relationship between → F C and the maximum deformation stress threshold F C thresh : The BPF method can be used in 3D printing for thinwalled complex devices based on three situations. By calculating the relative situation of superimposed stress and stress threshold, the superimposed stress effect can be cut off, and the printing quality and success rate can be improved.
3 Algorithm flow of 3D printing path planning based on balanced potential field method Figure 6 is the algorithm flow chart of 3D printing path planning based on BPF method. After the algorithm starts to run, the parameters are initialized and their initial values are set, then the current print node is obtained. Based on the current print node, the next step print node is planned. According to the gravity function and repulsion function of the global node, the next optimal print node is obtained until all nodes of the device are traversed to generate the planned print path. At this time, the BPF method is introduced to determine whether there are paths and areas that may produce stress deformation in the generated path. According to different situations, the balanced printing path, balanced printing area and balanced thin-walled edge are used to balance all the stress within the threshold range and to improve the printing efficiency and success rate.

Comparative experiment and analysis 4.1 Configuration of 3D printing environment
Before comparing 3D printing, we need to configure the experimental environment. The 3D printer used and its printing consumables are shown in Figure 7. It can carry out secondary development for the self-developed planning program and printing path. It adopts the printing principle of FDM and Cura slicing software to output designed model under the threedimensional software ring as G-code for common path planning and 3D printing. If the path planned by the balanced potential field method is in G-code format and the point set part of the path planning is replaced, the absolute control of the nozzle can be carried out according to the designed path.

Experimental verification
For practical comparison, the general potential field (GPF) method and the balanced potential field method are used respectively for the 3D printing of thin-walled complex devices. For example, Figure 8(a) is the model of thin-walled complex devices planned by computer, and Figure 8(b) shows the equipment and devices.
The devices printed by GPF and BPF are shown in Figure 9(a) and (b), respectively. The device printed by the GPF method has serious deformation. When printing thin-walled connections, the GPF method always prints in the same direction, it is easy to produce stress deformation, which makes the printed device partially deformed and difficult to meet the quality of high-precision printing. But the device printed based on BPF method can maintain the characteristics of the virtual model and overcome the stress effect.
To make a more intuitive comparison between BPF and GPF, both algorithms for 3D printing are tested 10 times. From the formal operation of the 3D printing machine to the end of the device printing, the printing time and the quality of the printed device are recorded, respectively, and the results are shown in Figure 10. (The quality of the device is defined as the number of lines without stress deformation. The maximum number of line segments of the device is 32, so the best-printed quality of the device is 32.) The printing time of the GPF method is less than BPF, but the printing effect is not satisfactory. The GPF method can only print a small number of good line segments, moreover, it cannot control the printing quality, with large variance and many defective products. While the BPF method sacrifices a small part of printing time to exchange for printing quality, which not only improves the printing quality but also ensures that the stress  deformation is reduced as much as possible in each 3D printing. The success rate of thin-walled complex devices is greatly improved.

Conclusion
This article first briefly introduces the path planning process of GPF, summarizes its advantages and disadvantages. Then GPF is improved to BPF, to balance the stress and deformation, which improves the strength of each print segment. Finally, actual devices are printed out by a 3D printer. Comparative experiments and analyses have proved the effectiveness of BPF method. Although the possible extension of this work has great prospects, still there are several issues in need of further study. (a) In this article, a thin-walled device is printed, but the extension of BPF method to big prototypes needs more study. (b) Research on putting this work from theory to structural study needs further study.

Conflict of interest:
Authors state no conflict of interest.