Finding Optimal Manipulator Arm Shapes to Avoid Collisions in a Static Environment

In situations of a confined workplace with a lot of obstacles and a complicated required trajectory of the endpoint of an industrial or collaborative robot, it may be impossible to find a suitable robot and its position within the workplace to fulfill the given task. In some cases, it could be favorable to design a custom manipulator arm with an unusual kinematic structure or shapes of some of its links. This article presents a novel way of finding the optimal lengths and shapes of two crucial links of a manipulator arm, where the target lengths are as short as possible to reduce mass, and the shape in the form of a Bézier curve is chosen to avoid collisions. The chosen type of kinematic structure of the manipulator arm is fixed and is based on the most typical structure of existing industrial robots, with six degrees of freedom. Two algorithm variants were proposed; one method uses iterations to find the solution based on in-depth collision analysis, and the second method uses the particle swarm optimization algorithm. Both methods were implemented in a simulation system and verified in several testing workplaces.


Introduction
The number of industrial robots applied in the industry has been steadily increasing for many years. Nowadays, robots are also considered in situations where the application of an industrial robot was unimaginable in the past. A big role in this is played by the introduction of collaborative robots that can operate in close proximity to human workers without the need for expensive and space-demanding safety measures and can even directly work together with a human on a particular task.
However, there are still situations where the presence of a human operator in the workplace is not the main issue, and the workplace itself is confined, with inadequate space for a standard industrial or collaborative robot-a small robot is not able to reach the whole trajectory, but a large robot collides with some obstacles in the workplace. In cases of a given complicated workplace, it may be hard to plan a trajectory for the industrial or collaborative robot to avoid collisions and keep the desired cycle time. Sometimes, it may even be impossible, making it necessary to change the layout of the workplace.
In cases when the workplace cannot be rearranged, it may be necessary to design a custom robot with a specific kinematic structure or with unusually shaped arms to avoid collisions while keeping the large reach of the robot. The research described in this paper focuses particularly on changing the shape of the arms while keeping the same type of kinematic structure, which is inspired by the most common structure of existing industrial robots.

Overview of Related Work
The following overview focuses on articles related to the topic of this paper-manipulator arm collision avoidance and manipulators with general shapes of arms. The most relevant articles with use cases that were as close to our research as possible were selected.
Collision avoidance for industrial robotic manipulators is typically associated with the selection of a proper trajectory. This can be done either manually during robot programming (teaching), which requires a lot of time and experience, or, quite effectively, by autonomous path planning in the configuration space [1][2][3][4][5][6]. Path planning can also be used in dynamically changing environments [7], where it can be beneficial to utilize some innovative methods, such as vision-based planning using neural networks [8].
As far as manipulators with a general shape of the links are concerned, there has been some related research, mostly focusing on theoretical and some practical issues of such manipulators-for example, real-time collision-free trajectory planning for manipulators with arbitrary shapes in point-to-point tasks [9], where the authors proposed a novel obstacle avoidance algorithm using a signed distance function to deal with collisions on the whole body of the manipulator.
Changing the shape and kinematic structure of a robot has been used to allow adaptation of the same robot for different tasks, effectively replacing the need for additional degrees of freedom with the possibility to manually change the kinematic structure as needed. This principle is applied to a low-cost home service robot with four degrees of freedom composed of rigid joints and two deformable links [10][11][12]. The deformable manipulator can create a relatively dexterous and extended workspace with fewer joints by bending its deformable links. A kinematic chain that allows mechanical modifications to match the desired Denavit-Hartenberg parameter set in a wide range is introduced in [13].
Another common topic of research is continuum robots; for example, the authors in [14] try to deal with the problem that, despite extensive research in kinematic and dynamic modeling, the inaccuracies and shape deformation of the robot due to unknown loads and collisions with the anatomy make shape sensing important for intraoperative navigation. To address this issue, vision-based solutions have been explored to find the actual shape of the robot. A similar issue regarding finding the actual shape of a surgical robot during a medical procedure using a small number of X-ray projection images has been addressed in [15,16].
General key issues involved in the design and implementation of continuum robots and the potential of these types of robots for enhanced productivity in novel applications are discussed in [17]. The challenges related to the control of continuum robots (stability and performance) emerging from the structural flexibility of such robots are addressed in [18] by presenting a robust tracking control approach using interval arithmetic and in [19] by a robust control for continuum robots that are modeled by Cosserat Rod theory.
So-called soft robots are, to some extent, also related to this research. The design and modeling of joints for inflatable robotic arms for long-range inspection are investigated in [20]. The authors in [21] propose a novel soft inflatable arm for telepresence robots using a common and low-cost inflatable material with a low weight. The focus of this research is on joint compressed models, joint kinematic models, and kinematic models for the whole inflatable robot arm.
As far as the possible mechanical construction of an arm with a changeable general shape is concerned, some research projects have focused on finding a method of making an object that can transform from a flexible into a rigid state and vice versa at will. Brandstötter et al. [13] present an arm containing a fusible alloy with a heating sleeve inside a rubber skin; the arm becomes soft when the alloy is heated up by means of an electrical current, and it becomes rigid when it cools down. A different principle with similar results was proposed by Clark and Rojas [22], who designed a malleable robot structure using layers of mylar sheets cut into flaps, where the transition between the soft and rigid states is done by changing the pressure inside the arm.

New Approach
Although industrial robots are universal systems, in real applications, they usually operate as single-purpose machines and repeat the same task in an enclosed work cell that represents a completely static environment (except for well-defined material transfer). In some cases, using a commercially available universal industrial robot can be very problematic, and could, for example, involve a much larger robot than theoretically necessary.
As can be seen from the presented overview of related work, collision avoidance of industrial robots is commonly done by changing the layout of the workplace, changing the placement of the robot, changing the trajectory during programming, or path-planning, but not by changing the shape of the robot itself.
The biggest fields of related research are soft robots and continuum robots. This is, however, a different topic-these systems can change the kinematic structure and shape drastically, even during operation, and the shape changing can be the source of the technological movement (typical for some inflatable robots). These robots are not rigid enough for tasks meant for an industrial robot.
Manual modification of the shape of some parts of a robotic arm, as described in [10][11][12], is close to our research, but these arms have some stiffness issues and can bend uncontrollably at higher loads. Each shape modification also changes the kinematic structure, which makes accurate control quite complicated-as can be seen from the articles focusing on control of continuum robots [14][15][16]18,19]. The advantage of such robots is that the shape can be changed as needed without having to manufacture a completely new arm. This advantage can be useful in some situations, especially in service robotics, and can outweigh the disadvantages. In industrial applications, however, the ease of precise and reliable control of the robot is crucial.
Our novel approach to collision avoidance in a static environment involves the use of a specific type of kinematic structure with six degrees of freedom (typical for commercial robots, as will be explained further) and changing the length and shape of the two main links of the manipulator (the lower and upper arm) while keeping the relative orientation of joints the same-thus also keeping the same type of kinematic structure. As can be seen from the overview of related work, this is an innovative approach, not just a modified method. The aim of this work is to present some possible methods for this approach and to demonstrate its possible use, because a custom-made manipulator could provide better performance parameters than a universal manipulator.
The custom-shaped arms are supposed to be designed and manufactured in advance for particular tasks, without the ability to be changed later (they can, however, be replaced by differently shaped parts when needed). It is also possible to utilize some of the abovementioned methods [13,22] that allow changing of the shape at will.

Kinematic Structure of the Robot
A survey on the types of kinematic structures typically used in collaborative and industrial robots by the selected well-known manufacturers (namely ABB, Fanuc, Yaskawa, Kawasaki, Kuka, Stäubli, and Universal Robots) shows [23] that approximately 76% of the robot series use some minor variations of the same kinematic structure (see Figure 1). This structure has six degrees of freedom with six rotational joints in a specific sequence that allow simple calculation of inverse kinematics and a good maneuverability, while also providing an easy mechanical design of the arm. The Denavit-Hartenberg parameters [24,25] uniquely describing this kinematic structure are listed in Table 1.
The length of the vertical link |P g P 0 | = d 0 (see Figure 1 and Table 1) does not have to be changed to make some meaningful modifications to the properties of the robot because the same effect can be achieved by mounting the robot higher or lower. The last three degrees of freedom (q 4 , q 5 , q 6 , |P 5 P 6 |) are responsible mainly for the orientation of the TCP (tool center point) and are considered as an integrated mechanical unit.
Important are the lower arm |P 1 P 2 | = a 2 and the upper arm |P 3 P 4 | = d 4 , which are mainly responsible for the position of the TCP. Making these lengths larger extends the workspace of the robot. However, making these lengths smaller reduces the torques and makes the robot lighter, so in theory, the arms should be as short as possible. These two links are also the links that are most commonly responsible for collisions of the robot with some obstacles in the workplace (this will be discussed later), so these links are the best candidates when shape changing is considered for collision avoidance.

Arm Shape Geometry
The idea of this work is to replace the straight manipulator arm shape (line) with a curve that allows better collision avoidance in some situations. For the implementation of the optimization algorithm, it is necessary to choose a curve that can be fully and unambiguously described by a mathematical function-for instance, a part of a conic section (circular of elliptic arc, hyperbola, parabola), a general polynomial, or a complex spline (B-spline, T-spline, Bézier curve, etc.). Examples of some possible shapes are displayed in Figure 2. The curves have different properties, but it can be anticipated that none of the shapes will represent a generally better solution as far as collision avoidance is concerned; the best shape can be selected only when dealing with one concrete situation. For a universal solution, we will select the shape under other conditions. circle arc quadratic Bézier cubic Bézier Although this stage of the research does not include physical verification of the results, it is important to ensure that it will be possible to make a physical prototype later. The circular arc and quadratic Bézier curve (see Figure 2) present a significant complication related to the mechanical construction of the joints located at the ends of the curved arm (represented by circles)-the angle of approach (tangent) differs with varying amounts of bending of the arm, which means that for each version of the arm, a different flange connecting the arm to the joint would have to be designed and manufactured. This problem is eliminated by using, for instance, a combination of two cubic Bézier curves, as in this case, the tangents at the outer control points are always pointing in the direction of the straight line connecting the joints.
The chosen spline consists of two cubic Bézier curves connected in the middle (see Figure 3). The first curve (green) is described by the control points A, Q 1 , Q 2 , D, and the second one (blue) by control points D, Q 3 , Q 4 , B. The points A and B theoretically lie at the corresponding joints of the robot-A = P 1 , B = P 2 for the lower arm, and A = P 3 , B = P 4 for the upper arm (see also Figure 1), but there will have to be some offset given by the construction of the joint. However, in this article, we consider this offset to be zero for simplicity. Vector e is the result of the optimization algorithm (see further) and represents the required bending amount and direction in a plane perpendicular to AB. The control points for the Bézier curves are calculated as follows: where m and n are scalars describing the pointedness of the curve near the particular boundary control point. The values of m and n can be constant or can be changed by the optimization algorithm. Finally, the curves are described by the following parametric equations for 0 ≤ t ≤ 1: Figure 3. Geometry of the chosen shape for an arm link consisting of two cubic Bézier curves; A and B represent locations of the two joints.

Simulation Model
To simulate and verify the idea of using curved robot arms to avoid collisions, a simulation model was designed and implemented as an application in C++ with 3D visual feedback based on the Direct3D graphics API (Application programming interface). The use of our custom-built simulation system allowed a huge degree of flexibility and speed compared to existing simulation systems.

Workplace and Trajectory
A trajectory is a 3D curve (path) that defines the required robot TCP movement. The trajectory is given by the actual task and is considered immutable in this research. The trajectory is defined by key points, where each point has the position and orientation (3 + 3 values), the velocity of the TCP, and the type of segment that connects this point with the previous one (linear or arc). This type of trajectory definition follows the common principle used in industrial robot teaching and programming.
For the simulation, the trajectory definition in the form of key points is replaced by a set of points in a constant time distance (0.005 s), where each point has only position and orientation (transformation matrix of the TCP). During the simulation, the robot TCP is placed into each of these points and inverse kinematics are calculated to get the joint angles of the robot (see Section 3.2).
In addition to the trajectory, the workplace is mainly defined by the objects that act as obstacles for the robot. Obstacles are used for collision checking and can be defined by various methods, for example, as bounding boxes, convex hulls, general meshes, or point clouds.
For simplicity (while also maintaining high flexibility), this research uses oriented bounding boxes to model the obstacles, which is mostly suitable for simple obstacles, forbidden areas, and borders like walls, ceilings, and floors.

Robot
The robot follows a trajectory given by its TCP, so it is necessary to calculate the inverse kinematics (IK) to get joint variables from the TCP position and orientation. As the kinematic structure of the robot is given and known, an analytical method of IK can be used. The calculation of IK with an analytical method is extremely fast and stable; the solution is calculated in one pass (it is not an iterative method). Changing the shape of the arms does not affect the IK calculation because the joints stay in the same relative positions. Changing the length of the arms affects just two constants in the algorithm-two Denavit-Hartenberg (D-H) parameters, namely a 2 and d 4 (see Table 1).
The first step in the IK calculation is getting the q 1 value. Based on the known TCP position P 6 , we calculate point P 4 (the origin of LCS 4 -local coordinate system of the fourth joint) as where d 6 = |P 4 P 6 | is a D-H parameter. Using the components of point P 4 = [x 4 , y 4 , z 4 ], we can write q 1 = atan2(y 4 , x 4 ). (11) Next, it is possible to calculate where d 0 = |P g P 0 | is a D-H parameter. Further calculations are done according to Figure 4: where a 2 = |P 1 P 2 | and d 4 = |P 2 P 4 | are D-H parameters. The mentioned condition is necessary for verification of whether the arm is able to reach the desired target-if not, the calculation can be aborted here with an error. As can be seen in Figure 4, for the given points P 1 and P 4 , it is possible to find two different solutions for the positions of P 2 . The calculations of the following auxiliary angles are identical for both cases: However, the way of expressing q 2 and q 3 is different-for the first solution, it is and for the second solution, it is At this stage, it is possible to calculate the transformation matrices T 0 g , T 1 0 (q 1 ), T 2 1 (q 2 ), and T 3 2 (q 3 ) from the Denavit-Hartenberg formula: and subsequently, to apply forward kinematics and get the positions and orientations of the coordinate systems LCS 0 , LCS 1 , LCS 2 , and LCS 3 . The remaining joint variables can be found using vector algebra. The value of q 5 is given simply as the angle between unit vectors z 6 (known as the IK input) and z 3 (already known as an axis of LCS 3 ): Afterward, we find the projection of the vector z 6 on the vector z 3 as and the normalized perpendicular vector from the vector z 6 to the vector z 3 : The angle between n and the axis x 3 represents the value q 4 (the reference vector z 3 is used to distinguish between an obtuse and acute angle): Now, it is possible to calculate the transformation matrix T 4 3 (q 4 ) and the position and orientation of LCS 4 , and to find the last missing value q 6 as the angle between vectors y 5 and y 6 : The last step is a check of whether all values q 1 , q 2 , . . . , q 6 lie in the allowed ranges given by mechanical limits of the joints.
The condition that has to be verified to find if the robot in its current form can fulfill the given task is that the robot is able to reach all parts of the trajectory. To do this, the TCP is successively placed into each point of the trajectory, and all of the following are tested: • IK calculation is done to verify that it has a valid solution (if it does not, the robot is not able to reach the point with its end effector). • Joint variables are checked against the limits (if at least one is out, the robot is not able to reach the point with its end effector). • Joint velocities are calculated as symmetric derivatives of the joint angles around this point and checked against the corresponding velocity limits (if at least one value is over the limit, the robot is not able to achieve the required end-point velocity).

•
Collisions of the robot parts are checked against the robot itself and also against the workspace obstacles (see the Section 3.3).
It is also necessary to verify that all points of the trajectory are reachable using the same solution variant of the IK (see Figure 4) because the robot cannot change the configuration abruptly during movement. Only two of the eight solutions of the IK are taken into account because the other solutions do not lead to a different geometry of the manipulator links, and, thus, cannot provide any advantage when collision avoidance is considered. The omitted solutions are related to calculation of q 1 (11) and q 5 (21).

Collision Detection
The actual mechanical structure of the robot is considered unknown in this stage, so the robot has to be replaced with simplified bounding volumes. A combination of bounding boxes and bounding spheres was chosen-boxes are used for the parts that do not change shape during the simulation, while spheres cover the lower and upper arm, which can bend (see Figure 5). The positions of the centers of all bounding spheres are calculated using the Equations (8) and (9), where the parameter t ∈ 0; 1 for each sphere is given by the order and the total number of spheres. The number of spheres depends on the effective length of the curve so that the spheres cover the whole shape without big gaps or overlaps. In each simulation step (each point of the trajectory), the robot's bounding boxes and spheres are transformed according to the corresponding robot link. Intersections of box-box or sphere-box pairs are checked using the standard separating axis theorem.

Optimization Algorithms
Given the robot's kinematic structure and simulation model described above, the goal is to find the shape of the lower and upper arms of the robot with the following conditions:

•
The trajectory and the layout of the workplace, including the location of the robot base, are fixed; • The robot must be able to reach all points of the trajectory without collisions; • The dimensions of the robot should be as small as possible.
The shape of each the lower and upper arm is described by the following parameters: • The linear distance between the boundary joints (|AB| in Figure 3); • The amount of bending (|CD| in Figure 3); • The direction of bending (vector e in Figure 3).
Two methods were proposed, implemented, and tested: an iterative algorithm that relies on an analysis of the character of the collisions to choose the next step of shape modification, and an algorithm based on the particle swarm optimization (PSO) method that does not require any additional information about the collisions.

Method 1-Iterative Algorithm with Collision Analysis
Collision checking requires special care in this case because the algorithm of this method relies on a simple analysis and classification of collisions.

Types of Collisions
Collisions with an obstacle in the workplace can occur at any part of the robot. The significance of the collision and possible ways of dealing with it are different, so we need to classify the collisions into five categories: C1, C2, . . . , C5 (see Figure 6 and Table 2).

C1:
Collisions of the base of the robot, the first link, and the first two joints (see an example in Figure 6b) are not related to the lengths and shapes of the arms higher on the kinematic structure, and can be eliminated only by changing the location of the robot, which is not a subject of this paper. C2, C4: Collisions within the lower or upper arm (Figure 6c,e) can be potentially fixed by changing the length or shape of the arm-making the arm elude the obstacle. This is the main focus of this paper.
C3: Collisions that occur near the joint (elbow) between the lower and upper arm (see an example on Figure 6d) can potentially be fixed by changing the robot's location or by changing the lengths of the lower and upper arms. In this work, the robot's location is fixed; changing the arms' lengths is therefore the option to be considered. C5: Collisions at or near the end effector of the robot or the wrist (the highest three degrees of freedom; see Figure 6f) cannot be fixed in most cases because the robot must go to that place to fulfill the given task. An option is to change the required orientation of the TCP, unless it is forced by the technology or by other constraints. This is not a subject of this work.  As already mentioned in Section 3.3, the lower and upper arms use collision spheres that cover the length of the arm. The type of a particular collision is determined as follows: • The first 10% of the spheres of the lower arm (counted from the bottom; rounded up) are considered too close to the shoulder joint and create C1 collisions.

•
The last 10% of the spheres of the lower arm and the first 10% of the spheres of the upper arm (all counted from the bottom; rounded up) are considered too close to the elbow joint and create C3 collisions.

•
The last 10% of the spheres of the upper arm (counted from the bottom; rounded up) are considered too close to the wrist joint and create C5 collisions.

•
All other spheres create C2 or C4 collisions.

Collision Events
In addition to the collision type, the algorithm also analyzes the required direction of the bend "out of the collision zone." To achieve this, collisions of the spheres of the upper and lower arms are stored as collision events. A collision event is a continuous intersection of a particular sphere and a particular workspace box. During each event, the direction vector p(t i ) from the center of the box (node) B to the center of the sphere C(t i ) is recorded in each time step t i (see Figure 7) as Afterward, the vectors p(t i ) are averaged throughout the event, which gives an imaginary spring force that will later be used to bend the arm: where t 0 denotes the start of the particular collision event (not the start of the simulation) and n represents the length of the collision event measured in time steps of the simulation. If the intersection ends and starts again later during the trajectory, a new event is created. Figure 8 shows the result of a simple testing trajectory verification. Green points of the trajectory represent sections that the robot was able to reach with no collisions and yellow points mean that a collision occurred. The arm bounding spheres rendered yellow mean that there exists at least one collision event for the sphere. A red arrow is drawn for each collision event of a sphere; it represents the vector p avg or the imaginary force pushing the sphere out of the collision. Multiple arrows originating from the same sphere mean that the sphere had several collision events during the trajectory.  The collision data, including the collision events, are used as input for the robot adaptation algorithm. The algorithm starts by finding the smallest possible arm lengths that can reach all points of the trajectory without taking collisions into account. This can easily be done by finding the largest value of p from (14) and then choosing where k ∈ (0; 1) is a coefficient describing the constant ratio between a 2 and d 4 (typically k ≥ 0.5 for a 2 ≥ d 4 ). Note that for simplicity, the lengths of the lower and upper arms are tied together; however, their bending is individual. The whole algorithm can be described by the following sequence of operations: 1. Start with straight arms of the smallest theoretically possible length. 2. Run the simulation for every point of the trajectory. 3. If no collision occurred ⇒ solution found, end. 4. If at least one C1 or C5 collision occurred ⇒ impossible to solve, end. 5. If at least one C3 collision occurred ⇒ remove any existing arm bending, make the lower and upper arms longer by a chosen value, and go to step 8.
6. If some C2 or C4 collisions exist ⇒ use the force vectors p avg calculated from collision events to bend the arm by a chosen amount (the bending is added to any already existing bending). 7. If the overall bending of an arm is larger than a set threshold ⇒ remove the bending, and make the lower and upper arms longer by a chosen value. 8. If the arm lengths are larger than a set threshold ⇒ impossible to solve, end. 9. Go to step 2.
As can be seen, the proposed algorithm is iterative. The force vectors p avg from collision events are used only to determine the direction in which the bending of the arm is increased at the particular iteration, not the total amount of bend. The bending and/or lengths of arms increase progressively until a solution is found or until boundary conditions are reached.

Method 2-PSO Algorithm without Collision Analysis
The algorithm based on the particle swarm optimization (PSO) method relies purely on the ability of PSO to find the solution to the given problem; there is no need for the detailed collision classification described above, and collision events are not recorded. Collisions still have to be checked, but the feedback is only in the binary form (no collision occurred; some collision occurred). This algorithm starts directly with the arms in any configuration (unlike the previous algorithm, which required the arms to initially be as short as possible). PSO [26] solves the problem using a population of particles that move in the search space in a way that eventually converges to the optimal solution based on the specified fitness function. This particular optimization method was chosen because it is one of the commonly used methods in various applications and because it can be implemented efficiently. The aim of this work is not to compare various optimization methods, but merely to demonstrate that optimization methods can be used for our purpose.
The search space in our case is six-dimensional, with the following variables, all normalized to the range −1; 1 : The fitness function was chosen with respect to the goal of finding the smallest robot: where all the individual factors (as mentioned above), and thus also the resulting value of F, are in the range −1; 1 . The chosen weights give slightly more importance to the bending amount (0.3 for each link) than to the distance between the joints (0.2 for each link), which means that even a slightly longer straight arm is considered better than an arm with a curve. The PSO variation implemented uses the fully connected neighborhood structure (also called the Global Best PSO), which typically provides the fastest convergence speed, but can be worse in exploring outside the locally optimal regions [27,28]. The termination of the iterative process is configured according to the "no improvement" method, with a slight alteration: A particle becomes inactive (not updated anymore) if its personal best fitness function value has not improved by more than 0.0001 over the last 10 eras; the whole swarm calculation stops when no particles are updating. To increase the initial coverage and diversity of the particles, a large number of 1000 particles was used; this simplified approach provides acceptable results, but could preferably be replaced by some of the Multi-Start PSO methods and a lower number of particles [28]. Particles that correspond to a robot configuration that is not able to fulfill the given task (i.e., the robot is in a collision or the IK failed) are always given the fitness value F = 10,000.

Results
Three simplified testing workplaces will be presented in this section, in which the optimal solution is discovered using both of the above-described methods. The initial states of all testing workplaces are shown in Figure 9; each successive example has a higher difficulty. A detailed comparison of the results for all three testing workplaces is available in Table 3. The results for the first (simplest) testing workplace are presented in Figure 10 with the arm visualized as a curved tetrahedron. Figure 11a shows the time progression of all three optimized parameters for the iterative method: In step 1, the length of both arms is shortened; in step 2, the bending amount of the upper arm is increased by 0.01 m, and then, finally, in step 3, the bending is increased by another 0.01 m, which is the solution. The PSO method found a similar solution, but it was slightly better according to the fitness function F, as the bending amount of the upper arm is smaller. The lower arm stays straight in both cases. The time progression for the best particle is shown on Figure 11b.
The second example (see Figures 9b and 12) shows a more complicated situation, with both arms having multiple collision events at the initial configuration. The arms were made longer by the algorithms, and both the lower and upper arms have a significant curve in a different orientation. The iterative method required 48 iterations in this case (see the graph in Figure 13a)-first, the arms were shortened, which caused C3 collisions, until the lengths were increased to the final value; then, the bending of the arms was increased until there were no C2 and C4 collisions. The PSO method required 65 generations (see the graph in Figure 13b).  The results for the third example (Figure 9c) are shown in Figures 14 and 15a,b. This example has a very tight solution space, which turned out to be problematic for the PSO method. The particles start at random positions in the six-dimensional space, and if none of the particles in the starting position have a valid solution, the particles do not converge to the optimal solution. This required several executions of the algorithm to find a solution. It is also important to mention that the PSO method can converge to a local minimum instead of a global minimum, which can be seen in Figure 14calthough this solution is valid, it is clearly not optimal, and it is possible only because of some simplifications in the workspace model (in a real situation, it would probably be unacceptable to reach above the obstacle).  The important values for all three examples are listed in Table 3. The fitness function was calculated with (30) from the values of joint distances and bending amounts. Smaller values are considered better; a zero for the bending amount represents a straight arm. The time was averaged for five executions on an Intel R Core TM i7-6700K (4.00 GHz) with 16 GB RAM on Windows 10. Table 3. Results for the testing workplaces, including the time required to run the corresponding optimization algorithm (PSO* denotes the non-optimal solution).

Discussion
The two proposed methods for finding optimal manipulator arm shapes to avoid collisions were tested on multiple testing workplaces, three of which are presented in this article.
The importance of the results is demonstrated in Figure 16, which shows alternative solutions for the first and second testing workplaces with strictly straight arms (the third workplace does not have any valid solution with straight arms) together with the corresponding solutions acquired using the PSO method. As can be seen, the manipulators are much larger than when using arms with curvature, and the arms must have very specific lengths, so the manipulator would have to be custom made anyway. Moreover, these solutions could be invalid in real conditions, as there can be more obstacles at the top (or even a ceiling), which are not included in the simplified simulation model. In general, it can be stated that the PSO method proved to be better in finding the optimal solution, as the fitness function value of the result is typically better (lower), but at the expense of much longer simulation times (see Table 3). The PSO method is sometimes prone to finding a non-optimal solution and requires multiple executions to find the global minimum, which further extends the calculation time. This was demonstrated in the third example (see Figure 14c). The iterative method is limited by using dependent lengths of the lower and upper arm-being able to analyze the situation more deeply and change the lengths individually would require a substantial modification of the algorithm.
PSO was chosen just to demonstrate that it is possible to use a population-based optimization algorithm in this application, and to roughly compare the performance of a general-purpose optimization method with an iterative method designed directly for the particular problem. Thorough analysis and comparison of various PSO variations and configurations, and even different optimization methods, was not the aim of this work, and could be performed in future research. Other optimization algorithms could probably be able to find the solution in a shorter time or find a slightly better solution.
A big advantage of the PSO method is its simplicity-as it is not necessary to perform the in-depth analysis of collisions-and its scalability. In this paper, PSO operated in a six-dimensional space with six parameters of each particle (solution candidate). However, this number can be extended; thus, it is also possible to optimize other parameters of the robot, which will be the focus of further research on this topic by the authors. Although the execution times are much longer for this method, this is typically not a concern, as the times are still in the order of minutes in the worst cases, which will probably be acceptable during the design phase of a robotized workplace. However, it is important to keep in mind that with each added parameter, the simulation times will increase and the chance of not finding any solution (or finding a local minimum) will intensify.
The following possible ways of extending the optimization algorithm are considered: • Additionally allowing the position of the robot base to be changed, either freely or within some defined limits. This requires the addition of 1, 2, or 3 additional parameters (all or a subset of the x, y, z coordinates).

•
Allowing more precise modification of the curve; for example, the tangents near the boundary key points or the middle key point-the parameters m and n in Figure 3. The curve can also be more complex than the combination of two cubic Bézier curves.

•
Allowing some minor changes to the trajectory at defined sections that are not strictly given by the technology.

•
To better approach reality, it could be also convenient to modify the simulation to only allow certain defined effective lengths of the arm shapes. This would reflect a possible physical implementation using bendable tubes that could be available in specific lengths (for example ,400, 500, 600 mm, etc.)-this restriction binds the values of joint distance and bending amount into a single variable.

•
The weight values given to individual factors of the fitness function (30) can be selected differently; this could be the aim of further investigation.
This method has some limitations and drawbacks that must be taken into consideration. Although keeping the same type of kinematic structure of the robot (and, thus, also the IK algorithm) greatly simplifies the control of the real robot, the mass properties of the modified arms will change together with the arm shapes, and dynamic calculations will be affected. The control system of an industrial robot has to take dynamics into account, as the movements are often very quick. Thus, the inertia tensor has to be calculated according to the actual shapes of the arms, and the control system regulator has to be adapted (tuned) appropriately. Another possible problem related to dynamics could be caused by the elasticity of the arm link, especially with a large amount of curvature. This could also be necessary to address by the control system to minimize overshooting and to improve positioning accuracy in general.
The custom-shaped arms are supposed to be designed and manufactured in advance solely for the particular task, so this method is suitable mostly for usage in mass production lines. This process is time-consuming, and the manufacturing of the arm will be more expensive compared to simple straight arms. The links can, however, be replaced by differently shaped parts when needed. The physical construction of a manipulator arm that allows modifications of the link shapes without the need to manufacture a new piece every time is also the subject of further research.