1 Introduction

Laser additive manufacturing (LAM) is widely used in the fields of aerospace, power, resources, defense, and military, with the advantages of material saving, short construction time, and high geometric freedom [1]. Laser metal deposition (LMD), as one of the additive manufacturing processes, is capable of producing and repairing high-value parts, and it has a broad development prospect and significant research significance [2]. In the practical application of LAM, many parameters can affect the forming quality of parts, such as laser power, powder utilization, and path planning. Because laser energy usually needs to be deposited according to a pre-planned path, path planning is critical [3], which includes the deposition position and tool axis vector. In order to meet the current stage of the process, a five-axis machine is combined with LAM technology in the industrial field [4]. The five-axis structure adds two rotary axes compared to the three-axis structure, and although it can assist AM to be competent in parts with more complex structures, the motion of the tool is also more complex. The tool axis in a five-axis CNC machine is defined as a vector under the workpiece coordinate system, while it is expressed as an angular combination of two rotary axes in the machine structure. There are many ways to be able to obtain the angle of the rotary axis through forward and negative kinematic solutions [5,6,7,8,9]. The inclusion of two rotary axes (\(A-C\) or \(B-C\)) improves the accuracy and efficiency of the part forming compared to the previous three moving axes (\(X-Y-Z\)). The generation of tool axis vectors is usually determined only by the part model and can ignore the reality of machine machining. Only their continued optimization can improve the print quality of the part. Therefore, it is important to study the optimization of tool axis vectors associated with rotary axes.

This type of research is closely related to the characteristics of the equipment hardware, and machine tools or robots with a rotary base, whether equipped with subtractive or additive-related process modules, need to pay attention to the variation of the rotation angle. Since subtractive manufacturing has been around for a long time and is well developed, the first work on rotational angle started in the field of machine tool finishing. Munlin et al. [10] proposed the reduction of machining errors around stationary points to improve the milling accuracy in the reachable range of the rotary axis angle. Makhanov et al. [11] proposed two methods using the total value of the rotation angle as a cost function to reduce the kinematic error. Hu et al. [12] concluded that there is a performance constraint on the tool of a five-axis machine tool in high-speed motion, so the tool orientation is adjusted to generate machining paths with a less maximum angular acceleration of the rotary axis. Kvrgic et al. [13] used geometric, thermal, kinematic, and stiffness errors as objectives to optimize the tool axis vectors. Kono et al. [14] showed that the rotary axis of a five-axis machine affects the tool-workpiece suppleness and verifies their conjecture in cutting experiments. Tang et al. [15, 16] optimized the tool axis vectors in the tool position file to improve the machining range of the machine and to fully utilize the performance of the machine. To improve the machining accuracy of aero-engine blades, Zhang et al. [17] smooth the rotation and tilt angles of the tool to improve the area of sudden changes in the tool axis attitude and to shorten the machining time. Sun et al. [18] used dual NURBS interpolation to handle high-speed precision machining of complex surfaces and dealt with singularities to avoid sudden changes in the angle of motion employing the higher-order derivatives of tool axis vectors. Cui et al. [19] used a tool axis vector to improve the machining range of the engine blades and to fully utilize the performance of the machine tool. Fu et al. [20] avoided the effect of sudden changes in tool position on the surface quality of the part by adjusting the angle of the rotary axis in a defined range.

Then, with the rapid development of additive manufacturing, scholars have gradually realized that changes in the angle of the rotary axis will also have a greater impact on additive manufacturing. For additive manufacturing technologies such as the LMD process, to cope with more complex geometrical features, it is necessary to solve the problem of material dropping due to gravity by adding the rotary axes. However, the accompanying excessive speed of the rotary axis movement can bring about surface quality degradation and machine jitter [21]. A common way of obtaining the deposition head attitude is proposed by Flores et al. [22], where the vector can adapt to the surface curvature of the part, computed by the cross multiplication of the contour tangent vectors and the triangular slice normal vectors. Zhang et al. [23], while doing work on tool paths related to collisions and singularities, also realized the impact that the angular minimum transformation brings to the surface quality, to avoid overstacking or understacking. Although it reveals that the impact brought by abrupt changes in the angle of the rotational axis on additive manufacturing is different from subtractive manufacturing, this is not a dedicated and in-depth work on angle optimization-related research. Therefore, Wang et al. [24] optimized the tilt angle of the tool axis vector within process-related tolerances to improve the anomalies of the nozzle translation speed during the linkage process. Chalvin et al. [25] found that in the multiaxis deposition process, the CAM software usually sets the tool axis attitude as a vector that adheres to the local surfaces of the part, thus ignoring the problems that can be caused by the sudden change of the rotation angle. Therefore, a path optimization method is proposed to smooth the vector transformation trend of the tool axis. Campocasso et al. [26] found that after obtaining the original tool axis vectors, they discovered that a sudden change of angle in the local region of the clamping angle would bring defects. Therefore, they triggered the optimization operation by setting a threshold value to determine the rotational angle change through their process experience. This optimization was also noted by Jayakody et al. who re-used and validated the effectiveness of the method to demonstrate that optimizing the rotation angle improved the surface quality [27].

Fig. 1
figure 1

Conversion between tool axis vector and rotary axis angle

Previous methods have mostly been aimed at avoiding sudden changes in the tool axis as a way to maintain a constant processing speed. The methods involved in laser additive manufacturing are often borrowed from subtractive manufacturing, but some need to be improved given their process differences. The mismatch between the direct transfer of methods is notable in the tool spindle, where subtractive manufacturing is concerned with overcutting, undercutting, and machine vibration, whereas laser metal deposition needs to take into account laser leak and heat accumulation. In the case of a five-axis CNC machine with a rotary table structure, for example, sudden changes in the tool axis can be constrained by the upper limit of motion of the machine’s axes, resulting in a large rotation of the rotary table about the C-axis and a near-stop of the deposition head’s motion. The LAM’s deposition head is the equivalent of the tool in subtractive manufacturing, and its deceleration or stopping of motion has a much more negative impact. However, most of the methods for generating and optimizing tool axes are for subtractive manufacturing, and only a few studies focus on additive manufacturing. Therefore, the method in this paper focuses on the optimization of the tool axis vector, in the LMD process. First, the kinematic forward inverse solution associated with the method is derived and used to subsequently transform the tool axis vector and rotary angle. Then, the tool axis vector is optimized by smoothing the trend of changing in C-axis angles under the constraint of the molten pool-attached deposition surface. Finally, the feasibility and effectiveness of the method in improving the surface quality of the parts are verified by printing S-shaped and elbow test parts on a five-axis machine. At present, no relevant methods have been found to exist in the field of laser additive manufacturing in academic research and industrial applications.

2 Conversion between vector and angles

In this paper, the forward and negative kinematics solutions are implemented by defining three-dimensional coordinate points and corresponding vectors in the data structure of each deposition position. These two types of variables are usually based on data obtained from the workpiece coordinate system, and even though most of today’s machines are equipped with RTCP functionality so that the coordinate points do not need to be converted, the tool axis vector still needs to be decomposed into the angles of motion of the two rotary axes. The moving axes are usually denoted as X, Y, and Z, and the two rotary axes correspond to \(A-C\) or \(B-C\). The rotary operation involved in the conversion process is set to rotate in the counterclockwise orientation when the angle is positive and to rotate in the counterclockwise orientation when the angle is negative. The purpose of the conversion method is to restore the tool axis vector to a state parallel to the Z-axis. The deposited surface on the substrate is orthogonal to the original tool axis vectors by a combination of rotational motions (if the vectors themselves are not adhering to the surface of the part model, then the tilt angle is additionally taken into account). Assuming that all vectors are defined by the state of outward emission from the origin when the tool axis vector reaches the state of coincidence with the Z-axis through two rotational operations, the angle required to rotate along the Z-axis to coincidence with the Y-axis is the angle of the C-axis (the angle of rotation of the tool or the rotary table about the C-axis), and the angle required to rotate along the Y-axis to coincidence with the Z-axis is the angle of the A-axis or the B-axis (the angle of rotation of the tool or the rotary table about the A-axis or B-axis). Taking the \(B-C\) structure as an example, the conversion between the tool axis vector and the rotary axis angle is shown in Fig. 1.

First, project the tool axis vector T onto the \(X-Y\) plane to obtain the vector \(T'\). The angle \(\alpha \) between \(T'\) and the Y-axis is obtained and used as the angle of rotation for the tool or rotary table to move around the C-axis. Then, rotate the X-axis clockwise by \(\alpha \) degrees about the Z-axis to make the new axis \(X'\) and use \(T'\) as the new axis \(Y'\). In the \(X'-Y'-Z\) coordinate system, the tool axis vector T is rotated around the \(X'\) axis to coincide with the Z-axis, and the angle \(\beta \) required for this process represents the angle of rotation of the tool or rotary table about the B-axis.

If it is necessary to obtain the tool axis vector based on a combination of \(A-C\) or \(B-C\) rotary axes angles, the process is the reverse of the inverse kinematics solution, which consists mainly of completing the rotational motion of the Z-axis based on two angles in sequence. First, the X-axis is rotated clockwise about the Z-axis by an angle of \(\alpha \) to become the new axis \(X'\). Then, the Z-axis is rotated clockwise by an angle of \(\beta \) about the \(X'\)-axis, and its attitude after completing the motion is the tool axis vector.

Fig. 2
figure 2

Definition notes. a Demonstrate the meaning of “laser leakage.” b Demonstrate the meaning of “rotary table idling”

3 Method

Before describing the methodology in detail, two definitions are used throughout the paper. The first is the phenomenon of “laser leakage,” as shown in Fig. 2a. Due to the characteristics of the LMD process, the high-energy laser needs to contact a solid surface to form a molten pool to absorb the material. When the laser leaves the current position, the molten pool disappears. This principle allows the material to undergo a transition from a hot liquid state to a cooled solid state in a very short period. If the laser is not aimed squarely at the deposition surface (the rotary table is also usually tilted to some degree), this can result in the laser not being intercepted by the partially formed solid, but leaking to a location outside the planned area. This situation is referred to in this paper as “laser leakage.”

The second is the phenomenon of “rotary table idling,” as shown in Fig. 2b. The change in tool axis vector between two deposition positions is accomplished by five axes working together, and the velocity of the deposition head motion is shared among each axis in a way that may exceed the upper-performance limit of that axis. When one axis is unable to reach the speed it is supposed to carry, the other axes slow down and wait for that axis until it reaches the specified position. A detailed explanation of “rotary table idling” will be based on the example of a five-axis CNC machine with a double rotary table configuration. When the rotary table needs to rotate about the C-axis at a specified angle that is too large, it may not be able to reach the specified position in time for the other axes to complete their motions. However, if the five axes do not complete their respective tasks, the prescribed tool axis attitude cannot be achieved. However, each deposition position has its own matching tool axis vector, which must change to the specified attitude before the deposition head can move to the next position. Therefore, the deposition head needs to be decelerated to almost a standstill, in order to wait for the rotary motion of the rotary table to complete. This phenomenon of only the rotary table performing the motion in the laser-on state of the five-axis linkage is referred to in this paper as “rotary table idling.”

When “laser leakage” or “rotary table idling” occurs, the laser is usually on. In the case of “laser leakage,” once a molten pool is formed on the substrate or other location, the area where material should have been deposited will not continue to be formed. In the case of “rotary table idling,” heat accumulates on the surface of the deposited layer and melts the excess material, resulting in the formation of an abnormal bulge. Both of these phenomena result in a degradation of the print quality of the part surface or even a manufacturing failure. Whether it is an \(A-C\) or \(B-C\) rotary axes combination, they can control the tool or rotary table to tilt and rotate. For the LMD process, the rotational motion has a greater impact on deposition speed compared to the tilting motion. Therefore, the tool axis vector smoothing method requires the automatic detection and elimination of “rotary table idling” within the constraint of avoiding “laser leakage.”

Fig. 3
figure 3

Classification of paths in the deposited layer according to their functions

The method proposed in this paper is divided into two steps. The first step is local optimization, where the trend of changing in C-axis angles is mostly expressed as a broken line pattern. First, the qualified tool axis vector is calculated at each deposition position when the A-axis or B-axis retains its initial value, and the corresponding C-axis angle of this vector is recorded as the angle without “laser leakage.” Then, the “rotary table idling” is detected and eliminated. If the change in the angle of the C-axis between neighboring deposition positions is greater than a given threshold, then idling is determined to exist. The optimization interval is adaptively expanded based on the previous recordings, and the C-axis angle is updated within the local interval to optimize the tool axis vector. The second step is global smoothing, which deals with the corner locations of the broken line to globally smooth the broken line to a curve. This prevents abnormal vibrations when the machine moves according to the tool axis vectors at the corners of the broken line and reduces the wear and tear on the machine hardware.

3.1 Local optimization

According to the process characteristics of additive manufacturing, each deposited layer has its own planned path, but these paths serve different purposes. The paths can be divided into print paths and transition paths according to their functions, and the transition paths include both approaching and leaving states, as shown in Fig. 3. During the manufacturing of a part, only the print path turns on the laser. Each deposited layer is divided into print regions because of possible holes, and transition paths connect these print regions. All deposition points on the path have associated tool axis vectors, and since the transition paths do not require the laser to be turned on, the smoothing method only handles the print regions within each deposited layer.

3.1.1 Constraints on “laser leakage”

The target of the optimization operation is adjusted from the deposited layer to the print regions and traverses all the deposition points therein. After obtaining the tool axis vector in the workpiece coordinate system, two rotary angles \(\alpha \) and \(\beta \) are calculated by the inverse kinematics method described in Section 2. The variable \(\alpha \) represents the angle at which the deposition head or rotary table moves around the C-axis, while the variable \(\beta \) represents the angle at which the deposition head or rotary table moves around the A-axis or B-axis. The specific definition for the angle \(\beta \) needs to consider the structural configuration of the machine. The method in this paper focuses on the motion associated with the C-axis, and the other rotary angle is kept at an initial value to calculate the constraint range for the angle adjustment. Subsequent optimization of the C-axis angle will bring about a change in the attitude of the tool axis vector concerning the workpiece, and a threshold value needs to be given as a reference range to constrain its change. Therefore, the new tool axis vector needs to be calculated from the changed C-axis angle and the original A-axis or B-axis angle, to compare whether the angle between the new vector and the original vector exceeds the threshold value. As shown in Fig. 4, calculate all the tool axis vectors for \(\alpha \) from 0 to \(360^{\circ }\) at a certain deposition position when \(\beta \) is kept at the initial value.

Fig. 4
figure 4

Calculation of the tool axis vector for the C-axis angle from 0 to \(360^{\circ }\)

The C-axis angle \(\alpha \) is calculated according to the formula below to obtain \(\alpha '\), and the variable i is determined by n. The variable n represents the interval of the detection operation, in order to confirm the existence of “laser leakage” for this angle combination.

$$\begin{aligned} \alpha ' = \alpha + (i+1) \times n \end{aligned}$$
(1)

where

$$ {\left\{ \begin{array}{ll} \alpha '\in [0^{\circ },360^{\circ }]\\ i\in [0^{\circ },360^{\circ }/n] \end{array}\right. }$$

The X-axis is then rotated clockwise by \(\alpha '\) degrees to obtain a new axis \(X_i\). The \(\alpha '\) obtained at each time is combined with the \(\beta \) at that deposition position to form a new tool axis vector \(T'\), and the angle between T and \(T'\) is calculated. Depending on the geometric characteristics of the part, it is known that the deposition positions may not be uniformly distributed. Therefore, the change in C-axis angle also needs to take into account the distance between neighboring coordinates. When the result of dividing the angle difference by the distance difference is less than the specified threshold, the C-axis angle associated with the current qualified tool axis is recorded. Because the pass intervals may be separated by “laser leakage” intervals, the set of pass angles corresponding to each deposition position should use a nested structure where they are all associated with the current position. As shown in Fig. 5, the qualified intervals corresponding to the deposition position P in the current print region are \(([\alpha _1,\alpha _2],[\alpha _3,\alpha _4])\), which are denoted by blanks. And the leakage intervals are \(([0^{\circ },\alpha _1],[\alpha _2,\alpha _3],[\alpha _4,360^{\circ }])\), which are denoted by regions covered with shadows. These intervals will subsequently be used to constrain the optimization range of the C-axis angle to avoid the tool axis vectors from being adjusted to the “laser leakage” state.

Fig. 5
figure 5

Classification of passing and “laser leakage” intervals by given threshold

3.1.2 Detection and elimination of “rotary table idling”

When a “rotary table idling” is detected using the method described above, the current location where the idling occurred is recorded. Multiple idling may occur within the current print region, and each idling location is a target interval. Different print regions contain different numbers of deposition positions. When the traversed numbers in a print region exceed 1/10 of the total numbers, if there is an idling location waiting to be optimized, the mechanism to eliminate idling will be triggered once. The larger the range involved in each optimization interval, the better it is for reducing the slope of segments in broken lines, so the deposition positions involved need to be increased as much as possible. With the idle target interval as the central region, the width of the qualified interval is used as a constraint to expand the region to be optimized in both directions, further forward and further back from the deposition position. The operation of eliminating idling will use different schemes for the three cases.

Fig. 6
figure 6

Three solutions for eliminating “rotary table idling” in different positions. a For the head and tail of the print region. b For the center of the print region. c Breakpoint divides subintervals

The first scheme is to deal with idling that occurs near the edges of the print region, also called the head and tail of the region, as shown in Fig. 6a. In dealing with such locations, it is possible to allow the optimization interval to involve either the first deposition position or the last deposition position of that print region. Especially if the width of the qualification interval is large, it is possible to update the coordinates of all deposition positions within the optimization interval to the same value. For example, when the optimization interval is at the head of the print region, the coordinates of all positions within the interval are referenced to the coordinates of the last position within the interval, while when the optimization interval is at the tail, the reference value is the coordinates of the first position within the interval. The second scheme is to deal with idling that occurs in the middle of the print region, as shown in Fig. 6b. After determining the optimization interval based on the width of the qualification interval, the C-axis angle difference between the first deposition position and the last deposition position within the interval is averaged based on the total number of positions. Then, the average value is used as a tolerance to sequentially update the C-axis angle of the remaining positions within the interval according to the principle of equal increment. The third scheme has a higher priority than the above two and is an additional protection mechanism, as shown in Fig. 6c. The rotary table of a machine, when rotating about the C-axis, usually moves in the orientation of a much smaller angle. For example, the C-axis angle parameters of \(0^{\circ }\) and \(360^{\circ }\) for neighboring positions are the same for the machine. When the C-axis angle parameters for adjacent positions are \(1^{\circ }\) and \(359^{\circ }\), their angular difference is \(2^{\circ }\). Therefore, when this occurs in the optimization interval, such a position should be used as a breakpoint to divide the complete interval into two subintervals. Compared to the original trend of changing angles in the complete interval, the trend of angles update in the first sub-interval is inverse to it, and the trend of angles update in the second sub-interval is consistent with it. Due to the large angular variation in the full interval, the two subintervals have different angular incremental tolerances, which depend on the deposition positions at the ends of their intervals. Such a treatment can optimize the tool axis vectors while protecting positions that can be easily misclassified as subject to idling.

3.2 Global optimization

Detection of idling is for the complete print region, and elimination of idling is for partial intervals within the region. Thus, it is known that the elimination of idling is a partial auto-optimization, which leaves the problem of the corners of the trend line. When the machine works with the tool axis vector at the corner position, an abnormal phenomenon of machine vibration occurs. This occurs with little or no effect on the surface quality of the part, but it can dramatically wear out the machine’s hardware. Therefore, this anomaly needs to be dealt with by globally smoothing the curves to eliminate the corners.

The method for smoothing corners is shown in Fig. 7, where three deposition positions are detected as a group and the slopes of the two segments in the broken line are compared. If the detection is started for deposition positions p1, p2, and p3, form the first line segment from p1 and p2, and form the second line segment from p2 and p3. The slope of the line segments is determined by dividing the angular difference between the ends of the segments by their distance. If the ratio of the slopes of the two line segments is greater than a given threshold, then the C-axis angle of p2 is updated to the average of the C-axis angle of p1 and p3. Positions p2, p3, and p4 are then detected and updated as the next set, and so on for the remaining positions.

Fig. 7
figure 7

Curve smoothing eliminates corners

3.3 Pseudo-code description

To show the implementation process of the method more clearly, the relevant algorithms are described using pseudo-code. The inputs to the algorithm have three variables P, A, and C which are the path data, the A-axis angle list A and the C-axis angle list. The objective is to output the angle list Copt which has undergone smoothing. The structure is expressed in the form of nested loops. Loops throughout the process are traversing the full path data. In steps 4 through 9, the first mini-loop for local optimization. In steps 11 through 17, the second mini-loop for global optimization. Local and global optimization are not computationally intensive, and the running time of the algorithms is mainly consumed in the phase of calculating the non-light leakage intervals. Although it is not a central part of the algorithm, a measure of constraint adjustment is necessary.

Algorithm 1
figure a

Smoothing of Rotation Angles

4 Results

In order to validate and evaluate our proposed method, it is implemented in a Windows 11 (64-bit) environment using C\(\#\) language. The input to the method is a reliable path planning file, so commercial CAM industrial software was chosen to handle the part models. S-shaped and elbow parts with curved surface features are printed to validate the method through their surface quality as they are more representative and challenging. The parameters related to this algorithm are shown in Table 1. PL is the number of deposited layers, DP is the total number of deposition positions in the path planning file, PR is the number of regions where only print paths exist, and OR is the number of regions to optimize.

Table 1 Quantitative parameters related to method calculations

Using the method to smooth the trend of changing in C-axis angles, only a portion of the typical results are shown as an example due to the large number of layers and print regions. As shown in Fig. 8, the results of angular smoothing for S-shaped and elbow are shown.

Fig. 8
figure 8

C-axis angle smoothing optimization results. a Results before and after angle optimization in the tool axis of an S-shaped part. b Results before and after angle optimization in the tool axis of an elbow part

Each column represents a region, and the location of the result is indicated in the format of “\(\{layer\ index\}\)-\(\{region\ index\}\): \(\{number\ of\ deposition positions\}\).” The broken line and curve represent the trend of changing in C-axis angles, the blue pixels represent “laser leakage,” the white pixels represent passing, and the gray pixels represent transition. The first line is the result before smoothing optimization, and the second line is the result after smoothing optimization. The running results of the method show that the broken line with sudden changes stays in the pass region to become a smooth curve, which represents the optimized tool axis vector without “laser leakage” and “rotary table idling” problems.

The path file usually needs to go through a post-processor in order to obtain the CNC program file so that it can be recognized and applied by the machine. After obtaining the two rotary angles, the process parameters need to be considered. So it is necessary to continue setting the process parameters related to printing S-shaped and elbowed parts. The layer thickness is 0.7 mm, the spot diameter is 3.5 mm, the scanning speed is 600 mm/min, and the laser power is 2000 w. A five-axis CNC machine with a double rotary table structure is selected to use the LMD process, as shown in Fig. 9.

Fig. 9
figure 9

Coaxial powder feeding equipment. a Five-axis CNC machine tool. b Equipped with LMD process

The results printed before optimization are shown in Fig. 10, with the red box marking the problem. For the S-shaped part, its curved profile caused the laser deposition head’s tool axis to change more frequently, making the rotary table more prone to idling. The laser heat accumulates here and the powder is over-utilized, resulting in a lumpy bulge on the surface. For the elbow part, the chosen path strategy was to tilt the rotary table at \(20^{\circ }\) intervals along the center axis of the model. However, a quality problem with the contour of the deposition layer would result in an inability to continue stacking material upwards. To avoid bulges from idling, the laser was turned off here, but material would be lacking.

Fig. 10
figure 10

Unoptimized print results. a S-shaped part. b Elbow parts

The smoothed C-axis angle is updated into the CNC program and, in conjunction with the other four axes, the five-axis linkage technique is implemented. The machine configuration and process parameters are kept constant in order to rationally verify the effectiveness of the method in improving the quality of the part printed. In the actual printing process, there is no “rotary table idling,” the laser scanning speed is also maintained at a constant level. The printing results of S-shaped and elbow parts are shown in Fig. 11, and the contour accuracy and surface fineness are better, significantly improving the quality of the parts printed, which is able to prove the effectiveness and feasibility of the proposed method.

Fig. 11
figure 11

Results using the proposed method. a S-shaped part. b Elbow part

5 Conclusion

Tool axis vectors are usually determined by the geometric features of the 3D model of the part, ignoring the machine structure and process characteristics. This will lead to the idling of the machine rotary table, which makes the deposition surface suffer from thermal accumulation problems, thus affecting the print quality of the part. To address this problem, this paper proposes a tool axis vector optimization algorithm based on automatic C-axis angle smoothing. Currently, similar reliable methods in the field of laser additive manufacturing have not been found in academic research and industrial applications, mainly through the following ways to solve the problem to improve the print quality of the part surface:

  1. (1)

    Deriving the conversion relationship between the tool axis vector and the angles of the two rotary axes through forward and inverse kinematics. At each deposition position, calculate the tool axis vector corresponding to the C-axis angle from 0 to \(360^{\circ }\) when the A-axis or B-axis angle keeps the initial value. And record the C-axis angle at those positions where there is no “laser leakage.”

  2. (2)

    By adjusting the line representing the trend of changing in C-axis angles, the problem of “rotary table idling” is detected and eliminated. Then, the optimization interval is adaptively adjusted under the “laser leakage” constraint for local optimization. The problem of heat accumulation caused by idling is effectively solved, and the sudden change of the tool axis vector is avoided.

  3. (3)

    Global optimization is performed for the results after local optimization, smoothing the corners of the broken line into curves. Ensure a significant improvement in part printing quality while reducing the hardware loss of the machine.