## 3 Optimization and Analysis  
### Corner Optimization Theory  
In order to solve the problem of corner deviation in CFRP printing, a compensation algorithm was proposed. Figure 5a shows a corner trajectory diagram of CFRP printing. The radius difference between the fiber nozzle and the fiber filament is D. The following cases are discussed:  
Figure 4: **(a)** Theoretical and practical printing effects of the contour offset method. **(b)** Schematic diagram of CFRP printing. 1. The length of BC is much larger than d, and the angle B is obtuse: The comparison between the actual printing condition and the ideal path is shown in Figure 5b. As can be seen from Figure 5b, the error value of BC is much smaller than d due to the large corner angle, which has little impact on the path characteristics and small error accumulation. In this case, there is no need for optimization. 2. Length of BC and close to or less than d, and angle B is the obtuse angle: the situation of the actual printing compared with the ideal path as shown in Figure 5c, this situation often occurs on the minimum curvature radius of the circular arc (the circular slice in the path of the line for the multiple angle is close to 180\({}^{\circ}\)). It can be seen from the figure that, due to the limited side length, it is not sufficient to pull the CFRP to the correct path in time, resulting in a large error. When this happens on the minimum curvature radius of the circular arc, there will often be many similar corner points in the follow-up, which means that the error will continue to accumulate. So, there is a need to optimize paths in this situation. 3. Angle B is an acute angle: The comparison between the actual printing condition and the ideal path is shown in Figure 5c. It can be seen from the figure that this condition has a great influence on the accuracy of path characteristics, and the error generated is close to d, which is also large, so it needs to be optimized. The above three cases have included all corner cases, so it is necessary to carry out targeted optimization for situations (2) and (3). The optimization method is to make the actual printing path conform to the original ideal path completely or, as far as possible, by modifying the print path. The optimization is as follows:  
1. Optimization of the acute angle: by analyzing the comparison between the theoretical path and practical path of the acute angle, the compensation-regression optimization method is adopted, that is, one edge before the corner is extended from point B with a length of d to obtain the new point B', and the next edge is extended with a length of d from point B to obtain B\", as shown in Figure 6a. Figure 5: (**a**) Schematic diagram of CFRP printing corner trajectory. (**b**) The corner is obtuse, and the length of BC is long. (**c**) An example of the error generated in the case of small arcs. (**d**) The error generated in the case of acute angles. The optimized printing path is A-B'-B-B\", in which the B'-B\" section is empty and does not feed. In this way, it can be ensured that the center of the CFRF cross section is exactly located at the theoretical point B when the nozzle goes to point B'. When the nozzle returns to point B, the fiber still stays at point B due to an absence of force. When the nozzle comes to point B\", the nozzle contacts the fiber again and begins to drive the fiber to move to the next point C. The whole process has no theoretical error, as shown in Figure 6b. The trip between this point and the previous point is a blank trip, which is not fed to the CFRF, and an identification program is added at the subsequent g-code generation. Small arc optimization: small arc optimization requires that attention be paid to two points: first, the small arc corners are many, if they are the same as in the acute angle optimization method, which will greatly increase the amount of data, increase the g-code, increase the printing time, and may also cause machine vibration.