Optimal Robot Motion Planning of Redundant Robots in Machining and Additive Manufacturing Applications

: The paper deals with the generation of optimal trajectories for industrial robots in machining and additive manufacturing applications. The proposed method uses an Ant Colony algorithm to solve a kinodynamic motion planning problem. It exploits the kinematic redundancy that is often present in these applications to optimize the execution of trajectory. At the same time, the robot kinematics and dynamics constraints are respected and robot collisions are avoided. To reduce the computational burden, the task workspace is discretized enabling the use of efﬁcient network solver based on Ant Colony theory. The proposed method is validated in robotic milling and additive manufacturing real-world scenarios.


Introduction
The growing demand for advanced industrial robotic applications such as machining and additive manufacturing highlights the importance of motion planning algorithms in this field [1,2]. As a consequence of this trend, a strong effort has been put into the improvement of the algorithm efficiency, especially in terms of reduction of the computing time. Moreover, researchers have investigated path and/or trajectory planners that are able to avoid collisions also taking into account the robot dynamics constraints [3][4][5][6].
The easiest motion planning problem consists in finding a collision-free point-to-point trajectory from a starting configuration to an end configuration without any constraints on the intermediate points. This problem is often addressed by means of path planning algorithms, which compute a suitable path between the points without taking into account constraints on velocity, accelerations, and torques [7][8][9][10]. The trajectory is then obtained by using a suitable time parametrization of the path [11,12]. Other approaches also consider constraints on velocity, acceleration and motor torque during the planning phase [13,14]. This class of problems is known as kinodynamic motion planning [15].
The lack of constraints on the intermediate points is an important drawback in many applications. For example, one might want to keep the robot tool oriented toward the floor during the whole trajectory for safety reasons. Recent works addresssed problem of this kind when the closed form of the constraints is not known a priori [16,17]. In this paper, we consider a more specific but still important class of trajectories, in which the number of degrees of freedom of the task is smaller than the one of the robot. This is a common scenario, as technological tasks often require to constrain only some of the Cartesian coordinates and velocities. Thus, the kinematic redundancy of the robot with respect to the task can be exploited to optimize a desired criterion [18][19][20][21]. It is worth stressing that, in this kind of tasks, path constraints are known a priori. This is a fundamental difference with respect to [16], because the dimension of the problem can be reduced by only exploring the subspace given by the kinematic redundancy.
The robotic machining and the additive manufacturing tasks are two significant technological examples where the use of industrial robots has become important and the motion planning strategies cover a crucial role [20,21]. However, the use of dedicated motion planning algorithms for these kind of applications is not common in the literature and in industry.
Thank to the improvements of robots kinematics and dynamics performance, the use of industrial robots in the field of machining applications has profitably increased during the last years [22]. However, industrial robots still have low kinematics and dynamics performance if compared to CNC machines, hence a kinodynamic motion planning can be a suitable solution to tackle such limitations. In machining tasks, kinematics constraints strictly depend on the process and hence by the adopted tool. In general, all the machining processes using a rotating tool have at least one redundant degree of freedom (DoF). The redundancy permits to choose an optimized robot configuration among an infinite set of solutions, as also clarified in Figure 1. Depending on the technological requirements of the specific machining task the redundant DoF/DoFs can be optimized to improve the process results [23]. Another emerging field for industrial robots is represented by the additive manufacturing and laser cladding, that is, metal material deposition with techniques such as laser metal deposition or electron beam melting [24][25][26]. The kinematic constraints with laser metal deposition technique consists in keeping the translation speed constant and identifying the best tilt of the laser head with respect to the underlying surface. [27][28][29][30] highlight that the process is feasible, although not optimal, for a large range of relative orientations between the deposition axis and the line perpendicular to the surface. Thus, it is possible to optimize the trajectory in order to keep the tilt angle as small as possible and respecting also kinodynamic constraints at the same time.
In particular, the main axis of the operating tool and the axis perpendicular to the surface to be machined/coated define an angle that should be always kept within certain limits depending on the specific process. As consequence, there is always (i) an operative redundancy (the rotation around the main axis of the operating tool) and (ii) a range of permitted angles around the axis perpendicular to the surface. The operative redundancy, namely the allowed cone around the axis perpendicular to the surface, can be exploited to find an optimal orientation able to satisfy both the technological constraints and the robot kinematics/dynamics limits. Figure 2 describes the general idea of these motion planning issues in additive manufacturing. Pipe welding [20] and gluing [31] applications can also be described with a similar optimization problem. Although a-priori knowledge of closed-form Cartesian constraints reduces the complexity of the problem, it is not trivial to find the solution of the optimization problem. Indeed, the problem is PSPACE-hard [32], highly nonlinear and the constraints make the feasible subset of the configuration space disconnected due to direct kinematics is surjective but not necessary injective. Moreover, to obtain an effective obstacles avoidance, collision checks are mandatory with a consequent increment of the computing time. Thus, solvers face local minima and computational burden issues. Many works proposed tailored solutions on the specific application or the number of redundant DoFs: welding [20,33], machining and 5-axes applications [34,35], additive manufacturing [21]. However, there is a lack of a general solution for the entire family of problems. Looking at the 5-axes CNC machines, some works deal with a simplified version (because of the lower number of DoFsand the particular structure of CNC machines) of the technologically constrained planning problem. In [36] a complete overview of motion planning for CNC machines is presented. In particular, the focus of the paper is on the definition of the tool orientation in order to: avoid collisions with gauges, preserve the position within joints limits, and get smooth speed profiles. Moreover, [37] investigated the optimization of the orientation of the cutting tools in 5-axes machines. Unfortunately, most of the assumptions valid for a 5-axes CNC machine do not hold for industrial robots, where high rotation speed leads to high dynamic effort with resulting motion inaccuracies and vibrations.
This work proposes a unified framework to deal with kinodynamic motion planning applied to machining, welding, gluing, and additive manufacturing tasks. This allows us to cope with different technological constraints and objectives, avoiding the need of tailored solutions.
The approach is based on the formulation of the redundant task as a net, whose vertices are the admissible joint configurations and the edges are the movements between two subsequent configurations. In this formulation, path constraints define the set of admissible joint configurations, that is, the vertices of the net. Then, kinodynamics constraints determine the admissible edges. The resulting net represents the constrained motion planning problem.
The paper shows examples of industrial processes that can be expressed in this framework. It is worth noticing that also complex tasks can be addressed, such as the minimization of elastic deformations during milling processes. Moreover, the discrete nature of the approach also permits to set a trade-off between the quality of the solution and the computational time. This is especially true considering that the granularity of the discretization directly affects the number of collision checks that the algorithm needs to perform, which represent the main bottleneck from the computational point of view.
To solve the discrete motion planning problem, we propose a modified Ant Colony Optimization algorithm. Ant colony optimization is a meta-heuristic technique to find optimal path through graphs [38]. It is inspired by the behavior of some species of ants to find the optimal route from the anthill to food resources. The idea behind the algorithm is that the ants release a pheromone track on the nodes, which attracts other ants. This track evaporates through iterations but is reinforced by other ants if the nodes belong to good paths. In the end, the high-pheromone tracks converge to the optimal route from the starting point to the goal. Ant colony optimization is particularly suitable for nonlinear high-dimensional discrete optimization problems, which makes it a good candidate for the problem at hand. Different variants of the ant colony algorithm have been proposed in the literature, as detailed in [39]. In this paper, we combine two strategies to develop an improved Ant Colony solver. First, we exploit the rank-based ant-colony strategy proposed in [40], in which only the best ants of each iteration are selected to update the pheromone trails. This approach is very promising for the problem considered in this paper, because it makes possible to dramatically reduce the computational burden by performing lazy collision checking (namely, to check collisions only for the most promising vertexes). Then, we use the modified version of the Ant Colony algorithm proposed in [41] to avoid premature convergence to local minima, which is a typical issue in motion planning problems. In the proposed approach, a rank-based ant-colony with pheromone saturation is used to solve the planing problem. Comparison with other ant-colony approaches shows its effectiveness to manage redundancy in technological trajectories.
The proposed approach is applied to a real-work milling and additive manufacturing scenarios, where the deflection of the robot tool is successfully minimized throughout the process. Moreover, the proposed algorithm shows faster convergence rate compared to other Ant Colony Optimization solvers.
The paper is organized as follows. Section 7 introduces the notation used in the paper. Definitions related to the technological processes and constraints are given in Section 2. Section 3 describes the proposed framework and the definition of the motion planning problem as a discrete optimization problem. Section 4 focuses on the application of the proposed framework to common technological tasks in industrial processes. Section 5 describes the modified Ant Colony Optimization solver used in this work. Then, case study on machining applications is discussed in Section 6, where the proposed solver is compared with other ant-colony strategies. Conclusions are drawn in 7.

Technological Trajectories And Constraints
Technological trajectories are typically generated by CAM software as an ordered set of couples containing tool center point coordinates and the tool z-axis orientations, and the corresponding time instant. Therefore, it is possible to define:

Definition 2.
A technological trajectory is a technological path where an execution time instant t k is assigned to each kth pose.
Definitions 1 and 2 define the user input to the optimization problem. Given a technological trajectory, the desired velocity and acceleration twist vectors W w c k andẆ w c k can be derived through numerical differentiation.
Notice that a technological trajectory does not define a unique Cartesian trajectories, but it corresponds to a family of possible Cartesian trajectories that have to satisfy some hard constraints (for example, the position of the tool center point) and some soft constraints (for example, limitations of the maximum tilt of a laser with respect to the surface). Hard constraints are mathematically represented as a set of equalities, whereas soft constraints can be modeled as a set of inequalities. It is worth stressing that time parametrization is an input for the motion planner, as well as the number of trajectory steps N. Definition 3. The path hard constraints HC pos are a set of equality constraints that limit the pose of the tool with respect to the base such that, for all k = 1, . . . , N: The path soft constraints SC pos are a set of inequality constraints that limit the pose of the tool with respect to the base such that, for all k = 1, . . . , N: Definition 4. Kinodynamics hard constraints are defined as a set of equality constraints that limit the tool velocity and acceleration with respect to the base such that, for all k = 1, . . . , N: Definition 5. Kinodynamics soft constraints are defined as a set of inequality constraints that limit the tool velocity and acceleration with respect to the base such that, for all k = 1, . . . , N:

Proposed Framework for Task Formalization
By considering constraints (1)-(2), the set X w ee k of feasibile Cartesian paths can be defined as the set of all possible transformation matrices T w ee that satisfy (1) and (2) at each step k, that is: Technological tasks typically have a small number of redundant DoFs. For example, milling and deburring tasks require 5 DoFs and are typically performed by a 6-DoF manipulator. The exploration of the subset of Cartesian given by the redundancy is therefore practical. In particular, such space can be discretized and, for each sample, the closed-form inverse kinematics of the manipulator can be solved. We therefore refer to X w ee k as the discretization of the continuous set X w ee k . Inverse kinematic problem is then solved for all the elements of X w ee k . Details about the discretization process for different technological tasks are described in Sections 4.1 and 4.2.

Definition 6.
For each k, the feasible configuration set Q k is the set of all joint configurations which correspond to a transformation matrix in X w ee k and that respect the joint limits, that is: The elements of each set Q k are the net vertex. The joint configuration q i k is the element i k of set Q k , while T w ee (i k ) = f kin,p (q i k ) is the corresponding transformation matrix. The transition between the element i k of set Q k to the element i k+1 of set Q k+1 is the net edge.
In order to check if constraints (3)-(4) are satisfied, it is necessary to know the edges that connect Q 1 to Q N . We therefore define a network path as follows.

Definition 7.
A network path p is an ordered sequence {q i 1 , · · · , q i N } that connects the configuration sets This idea is also clarified in Figure 3. Given a network path p, it is possible to compute the finite-difference approximations of Cartesian velocities, joint velocities, joint accelerations, and joint efforts. Joint velocity and acceleration at step k are computed as: Joint effort can be computed using inverse dynamics: Velocity and acceleration twists are computed as: A path is feasible if these values are inside the joint limits and Equations (3) and (4) hold.
In order to evaluate the goodness of the paths, it is necessary to define a cost function which depends on both the vertices and the edges. Vertex costs depend only on the path, while edge costs depend on kinodynamics quantities. The following definition of the trajectory planning problem therefore can be applied: Definition 8. The robot trajectory optimization is a minimization problem defined as follows: where: and where f V and f E are cost functions depending respectively on the vertices and the edges of the network path.

Examples of Common Technological Tasks
Based on the definitions given above, two typical problems of additive manufacturing, welding, and gluing applications are discussed in details: (i) a 5-DoF task, typical of machining applications, where the goal is to execute the trajectory by minimizing the deflections caused by the material removing forces; (ii) a 3-DoF task, where the goal is to reduced the angle between the end-effector and the surface normal to the tool z-axis.

5-DoF Tasks
In 5-DoF tasks (such as deburring and milling), path hard constraints are related to the end-effector position and its z-axis orientation, while there are no soft path constraints. Path constraints are therefore given by: Moreover, machining tasks require hard constraints on end-effector Cartesian linear velocity, that is, for all k = 1, . . . , N: The redundancy can be exploited to optimize the manipulator stiffness along the direction of the cutting forces of the milling process. A possible choice of f V (q k ) is therefore the squared norm of the so-called Cartesian Compliance Index, that is: where · M is the 2 -norm weighted by vector M, and w δx ee ∈ R 6 is a vector representing angular and linear deflections of the end-effector due to the milling force. The Cartesian Compliance Index is a scalar measure that represents the weighted norm of deflections introduced by robot elasticity. Minimizing this index improves quality of the technological task.
Deflection w δx ee is computed as where W e (k) ∈ R 6 is the wrench vector given by the torque and the force generated by the milling process at the step k, J is the geometric Jacobian matrix, and K is the joint stiffness matrix. Milling force is computed by using model proposed in [42], force application point is the end-effector frame origin the milling torque is null.
The edge cost function f E is chosen as the sum of the squared norms of the joint velocity and acceleration vectors, that is: where λ v > 0 and λ a > 0 are weighting constants.
Since there is only one redundant DoF, uniform gridding can be applied without curse of dimensionality. As mentioned in Section 3, the redundant degree of freedom is uniformly sampled between its limits obtaining a set of transformation matrices. Inverse kinematics is then computed to compute sets Q 1 , · · · , Q N . The discretization step can be chosen as a trade-off between the computational burden and the quality of the solution.

3-DoF Tasks
In 3-DoF tasks (such as additive manufacturing, welding and gluing), path hard constraints are related to the end-effector position and its z-axis orientation. The following path constraints should therefore hold for all k = 1, . . . , N: Soft path constraints consist in imposing the z-axis of T w ee to be inside a cone with aperture equal to 2θ such that, for all k = 1, . . . , N: These tasks also require hard constraints on end-effector Cartesian linear velocity, that is, for all k = 1, . . . , N: Vertex cost f V is the norm of the angle between the z-axis of the end effector and the z-axis of the desired pose, that is: Edge cost term f E minimizes the sum of squared norms of the joint velocity and acceleration vectors as in the 5-DoF case (14).
Since redundancy subspace is three-dimensional, memory footprint can be a limit factor. In this case, uniform random sampling can be used. By using ZYX Euler angles coordinates, the y-and x-axis are rotated by a randomly sampled angle in [−θ, θ], while the z-axis angle is randomly sampled in [−π, π]. Then, the resulting transformation matrix is stored if (16) is respected. In order to avoid oversampling in some regions of the redundant subspace, a new sample is discarded if the distance with the closest sample is smaller than a chosen threshold. The number of samples can be chosen as a trade-off between computational burden and the quality of the solution.

Ant Colony Optimization Algorithm
The robot trajectory optimization stated in Definition 8 is a discrete optimization problem that can be solve by means of an Ant Colony Optimization solver. The proposed solver uses a Max − Min strategy [41], where a rank-based selection of the best m ants contribute to pheromone updates [40].
The quantity of pheromone added to the vertex depends on the quality of the ant network path (namely, it is inversely proportional to the related cost function). The pheromone evaporation is performed by applying an exponential decay after the passage of all ants. In order to avoid early stalling, the values of the pheromone is bounded between ν min and ν max as in [41]. The ants choose the next vertex based on a probability inversely proportional to the vertex cost f V . Such probability is given by: where π(i k |i k−1 ) is the probability to go from vertex i k−1 to i k , ν(i k ) is the pheromone value of vertex i k , C k is the cardinality of Q k , and ξ > 0 has a small value to avoid division by zero. Thus, the Ant Colony algorithm can be summarized as: 1. Set X w ee k is discretized into set X w ee k , sampling in redundancy subspace;

2.
Set Q k is obtained by solving the inverse kinematic problem for all elements of X w ee k ; 3.
The pheromone value of each vertex is initialized equal to ν max ; 4.
Each ant randomly selects the next vertex based on the transition probability Equation (19); 5.
Ants are ranked based on the path cost; 6.
m best ants are selected, collision checking is performed on the vertexes which are selected the first time. If an ant path is in collision, this ant is replaced by the next ant in the ranking; 7.
The best solution found since the beginning of the whole optimization is added to the set of the best ants found at the current iteration; 8.
The best ants update the pheromone values of the vertexes of their path by adding a quantity that is inversely proportional to the cost function of its entire network path, that is: 9. The pheromone evaporation is performed for all the vertexes 10.
If termination conditions are not satisfied, go to step 4.
Termination conditions are the convergence of ants to the best path and the convergence of the pheromone level to a steady value, as suggested in [43]. It is worth highlighting that if in Step 6 there are less the m ants with a feasible path, all of them are selected. If no ant provides a feasible path, the optimization problem is aborted.

Milling Task
Algorithm effectiveness is analyzed in the milling task scenario shown in Figure 4. As stated in Section 4.1, the redundancy optimization criterion consists in minimizing the deflections caused by milling forces. by imposing that a linear deflection equal to 1 [mm] has the same influence of an angular deflection equal to 1 [deg], and neglecting deflections around the redundant axis. Weighting factors are set equal to λ v = 10 −5 and λ a = 10 −7 , respectively. The considered robot model is a 6-DoF Comau NS16. The algorithm runs on a laptop equipped with a Intel Core i7-8565U, 16 GB RAM-LPDDR3 and a 512 GB SSD. The stiffness matrix was derived by following the identification procedure described in Chapter 4 of [44] and is equal to: K = diag 3.7 · 10 5 , 4.5 · 10 5 , 10 6 , 10 6 , 10 6 [Nm/rad] The transformation matrix between the robot base frame and the workspace frame is The milling trajectory is a 100 [mm] × 100 [mm] square with rounded corner (radius 5 [mm]), the center of the square is shifted by 50 [mm] from the the workspace origin along x and y directions, as shown in Figure 5, where also milling forces are represented. The milling parameters are in Table 1.  The milling path is discretized in 157 points. In each of them, the redundancy angle is discretized by using 721 values equally spaced in the range [−π,π] (namely, sampling step equal to 0.5 [deg]). By computing the inverse kinematic for each value of the redundancy angle, the cardinality of sets Q 1 , · · · , Q N varies between 1442 and 1868, depending on joint limits and possible collisions. Memory footprint of each vertex is 64 Byte (6 double variables for joint configuration, one double variable for the cost f V (q i k ), one double variable for pheromone value), the footprint of the all net vertexes is 16 Mbyte.
We denote with RBMM (Rank-Based Max-Min) the solver proposed in Section 5. We compare it with: • a standard Ant Colony Optimization solver (denoted as ACO) [38]; • a rank-based Ant Colony approach (denoted as RB) [40]; • a Max − Min Ant Colony approach (denoted as MM) [41]; • a local solver (denoted as LS) where q i 1 is selected as the vertex with minimum cost in Q 1 and, for each step k, the next vertex q i k+1 is selected as the vertex with minimum cost in Q k+1 which can be reached from q i k with a feasible transition.
In order to compare different algorithms performances, Problem (7) is solved 10 times for each algorithm. The chosen performance indices are the root mean square value of the Cartesian Compliance Index (M w δx ee ) and the time taken by the algorithm to find a solution. Table 2 shows the average value and the standard deviation of the indices for the different methods. On the one hand, RBMM and MM converge to a better solution thanks to the pheromone saturation, which avoids stagnation in local minima. On the other hand, RBMM and RM show lower computational times, thank to the rank-based ant selection and the consequent reduction of collision checking. Notice that LS gives the worst solution, due to its deterministic and local nature. The obtained deflection trends during the 10 runs of RBMM algorithm are shown in Figure 6, highlighting the algorithm repeatability.

Additive Manufacturing
An additive manufacturing task is considered. The technological path is a spiral defined as where θ ∈ [0, 4π] is the curvilinear abscissa The curve is depicted in Figure 7. The end-effort has to follow the curve during the time period t ∈ [0, 20] with the following timing law In this way, the modulus of Cartesian velocity is constant when t ∈ [4,16], as shown in Figure 8. The considered robot model is a 6-DoF Comau NS16, while the algorithm runs on a laptop equipped with a Intel Core i7-8565U, 16 GB RAM-LPDDR3 and a 512 GB SSD.
The additive path is discretized in 200 points. The cone apperture is set equal to 2θ = 25 [deg]. In each of them, 2356 uniform-distributed transformation matrices respecting (16) are considered. By computing the inverse kinematic for each value of the redundancy angle, the cardinality of sets Q 1 , · · · , Q N varies between 9424 and 18,848, depending on joint limits and possible collisions. As in Section 6.1, memory footprint of each vertex is 64 Byte, the footprint of the all net vertexes is 171 Mbyte.
The comparison is made by using the same algorithm of Section 6.1. In order to compare different algorithms performances, Problem (7) is solved 10 times for each algorithm. The chosen performance indices are the root mean square value of the angle (in degrees) w.r.t. the nominal path and the time taken by the algorithm to find a solution. Table 3 shows the average value and the standard deviation of the indices for the different methods. Considerations of Section 6.1 are confirmed also in this case study. RBMM and MM converge to a better solution avoiding stagnation in local minima. Moreover, RBMM and RM show lower computational times, thank to the rank-based ant selection and the consequent reduction of collision checking. Finally, LS gives the worst solution, due to its deterministic and local nature. Also in this case, the algorithm repeatability is shown in Figure 9, where results of 10 runs are depicted.

Conclusions
This paper has proposed a unified motion planning framework to deal with under-defined Cartesian trajectories in technological applications, such as milling, additive manufacturing, welding, and gluing applications. In particular, we have used this framework to formulate two common technological problems by taking into account their particular technological requirements. The proposed formulation is based on the discretization of the configuration space: the allowed Cartesian space is sampled and a closed-form inverse kinematics is applied to obtain an admissible set of joint configurations for each point of the task. This leads to a discrete optimization problem, which is solved by a modified Ant Colony Optimization solver based on Rank-based and Max − Min strategies. Notice that the formulation of the problem implicitly respects the constraints of the robot such as position, velocity, acceleration, and torque limits. The effectiveness of the method is demonstrated in real-word milling and additive manufacturing scenarios. Results show that the proposed approach is able to optimize the task by also taking into account complex elastic behaviours during the process, such as the deflection of the robot tool. A comparison with other Ant Colony solvers shows that the proposed algorithm has faster converge rate and it has a better repeatability then other Ant Colony Optimization implementations.  acceleration twist vector from frame b to frame a, defined as ẍ a b ;ω a b T w ee transformation matrix from robot end-effector frame ee to workpiece frame w T w c k transformation matrix from CAM output frame c k to workpiece frame w at trajectory sample k N number of samples of the desired trajectory The following functions describe the kinematics and dynamics equation of the robot: -T w ee = f kin,p (q) is the forward kinematic function of the robot; -W w ee = f kin,v (q,q) is the velocity forward kinematic function; -Ẇ w ee = f kin,a (q,q,q) is the acceleration forward kinematic function; τ = f dyn (q,q,q) is the inverse dynamics function; -c = f col (q) is the collision function, which is equal to 1 in case of one or more collisions, 0 otherwise.
The following sets describe the feasible conditions: admissible joint configuration set I p = {q ∈ R n : q ≤ q ≤q} where q andq are, respectively, the lower and upper joint limits; -admissible joint velocities set I v = {q ∈ R n :q ≤q ≤q} whereq andq are, respectively, the lower and upper joint velocity limits; -admissible joint effort set I e = {τ ∈ R n : τ ≤ τ ≤τ} where τ andτ are, respectively, the lower and upper joint effort limits; -admissible Cartesian velocities set C v = {Ẇ w ee ∈ R 6 :ẋ ≤ẋ w ee ≤x ∧ ω ≤ ω w ee ≤ω} whereẋ,ẋ , ω, andω are, respectively, the lower and upper linear and angular velocity limits.