Multiple chromosomes particle swarm optimization-based coverage path planning for complex surfaces spray painting

Coverage path planning for complex three-dimensional surfaces spray painting is one of the challenging problems in robotics. In this article, we propose a multiple chromosomes particle swarm optimization approach to address the coverage path planning problem for complex three-dimensional surfaces spray painting. Firstly, a layered segmentation method, which is composed of three-dimensional hole identification and region partition, is proposed to divide the complex surface into multiple simple regions with little curvature change and no holes. Secondly, a zigzag path is determined in each region by considering the practical aspects for spray painting. Thirdly, by taking short distance, few turns and high coverage rate into account, a multiple chromosomes particle swarm optimization algorithm is presented to connect the zigzag paths of the regions. Experimental tests are carried out on a complex surface, and the results validate the effectiveness of the proposed approach.


Introduction
Spray painting is widely employed in the manufacturing industry, which plays an important role in automated production process, particularly in sectors such as the automotive industry. 1In recent years, automated spray painting has become the mainstream painting process in workshops and factories, which has lots of advantages compared with the traditional manual spray painting. 2Automated spray painting is performed by robotic manipulator and does not rely on the experience of the workers.There is no need for workers to be exposed to harsh environment for a long time.Moreover, automated spray painting enhances efficiency and precision, contributing to optimal paint utilization and reduced working time.
Coverage path planning (CPP) is one of the key technologies for automated spray painting.CPP is a challenging problem that involves finding a path that can effectively cover the entire task areas while avoiding obstacles. 3CPP of spray painting is easily applied to simple free surfaces while the application for complex surfaces is relatively rare since the geometry and topology of complex surfaces are complicated.Furthermore, the complex surfaces often contain many holes of different sizes and shapes, where obviously do not need to be painted.Consequently, it is necessary to study the CPP for complex surfaces spray painting.
The multiple chromosomes particle swarm optimization (MCPSO)-based CPP is proposed to address the CPP for complex surfaces spray painting problem.Multiple simple regions are generated by layered segmentation method which is composed of three-dimensional (3D) hole identification and region segmentation.Critical points are identified and recorded by the 3D identification algorithm.These critical points serve as boundaries, enabling the partitioning of the entire surface into several simple regions.For each region, a practical zigzag path is generated, considering the requirements for spray painting.It is important to highlight that each region presents four different types of zigzag paths, and the determination of each type is made with a consideration for the global optimization of paths.
To connect the zigzag paths, MCPSO algorithm is proposed to optimize the combination of paths.In the algorithm, a total reward function which is composed of four rewards, namely, Internal Path Length Reward, Connecting Path Length Reward, Fewer Turns Reward, and Coverage Rate Reward, is designed to achieve the optimal path for complex surface.Using the MCPSO algorithm, the optimal path with short path length, few turns, few overlaps, and high coverage rate can be generated.
The main contributions of this article can be summarized as follows: (1) A 3D hole identification algorithm is proposed to partition the complex surface hierarchically into regions that do not contain holes and have simple geometry and topology shapes.It is noteworthy that this algorithm utilizes a slicing method to identify holes after obtaining the surface model files, operating independently of sensors.(2) The CPP for waypoints within each region is simplified as the combinatorial planning of characteristic lines.Characteristic lines represent special line segments abstracted from waypoints.One zigzag path is obtained in each region by connecting these characteristic lines.(3) The MCPSO algorithm is proposed to connect the zigzag paths and generate the optimal path.
The rest of this article is organized as follows.The second section presents an overview of the research work related to CPP for complex surfaces.The third section provides a detailed mathematical description of the spray painting path planning problem.The fourth presents a layered segmentation method, which makes a preprocessing of the complex surface prior to the path planning.The fifth section introduces our novel MCPSO algorithm to address CPP for complex surface.Simulations are presented in the sixth section.A brief conclusion is given in the last section.

Related work
In this section, we present an overview of research work related to CPP for complex surfaces, which includes the CPP for 2D surfaces, the CPP for 3D surfaces, and combinatorial optimization.

CPP for 2D surfaces
There have existed many CPP methods for 2D surfaces, such as cellular decomposition-based coverage, landmark-based topological coverage, grid-based, and Voronoi-based coverage. 3,4One of the most robust approaches is cellular decomposition-based coverage.Using cellular decomposition, [5][6][7] complex regions are partitioned into several simple regions or cells, then heuristic optimization algorithms are proposed to perform global and local coverage planning.Boustrophedon decomposition, 8 triangular-based, 9 and Morse decomposition 8 are alternative methods to perform coverage tasks, which play an important role in nondestructive inspection.However, these decomposition-based coverage methods have bad performance when the surfaces have large curvature variations.Moreover, it is difficult for these methods to perform the coverage tasks with unknown environment.
In the present studies, multirobot collaborative CPP and online CPP have been researched.Aiming to improve the efficiency of coverage planning, recent advances present collaborative CPP methods to speed up the coverage and reduce the time consumption.Multirobot forest coverage 10 can improve the overall efficiency, especially when complex obstacles exist.Spanning tree coverage methods [11][12][13] have great performance when arbitrary obstacle exists and robots start at random initial position.Other approximation heuristics approach 7 achieves coverage by splitting the free space in smaller areas and performing efficient single robot coverage on each cell.Although these methods improve the efficiency of coverage, they still lack high robustness for complex surfaces path planning.Furthermore, the demand for a large number of robots significantly raises the cost of solution.
Online CPP methods tend to establish map using sensors or laser radars firstly, then perform the coverage tasks. 14ith unknown environment, the accuracy of map building directly affects the quality of CPP.Therefore, some researches utilize machine learning 15,16 or neural network 17 to establish and update map, then accomplish CPP based on it.As we can see, the quality of CPP is limited by the accuracy of sensors equipped on robots.Equipping with sensors will cause inconvenience and insecurity to some huge coverage tasks, such as spraying, blasting, and harvesting.

CPP for complex 3D surfaces
One effective CPP method for complex 3D surfaces is to decompose the surface into a set of regions or patches and then use a CPP algorithm to generate a path that covers all of the cells. 18Hierarchical decomposition based on the topology and normal directions of surfaces is one common decomposition method for complex surfaces. 19Subsequently, some functions or auxiliary models are proposed to guide the path planning of each patches, such as path fairness, 18 seed curve, 20,21 and cylindrical coverage model. 22However, these methods do not consider the optimization of the path planning between patches that loses global optimal path.
Another possible approach is to perform some iterative methods 16,[23][24][25][26] to generate adaptive paths with restrictions such as minimizing the intersections, twists, and overlaps.However, these methods can be potentially suitable for small-size surfaces coverage planning but not for large complex surfaces, since the high curvature and edge effects are not fully captured with these methods.
Online and adaptive coverage for large complex surfaces with unknown environment is one of the challenging tasks.Most researches scan the environment to establish maps with cameras or sensors, then provide CPP methods based on established maps. 27Wang et al. 28 modified a simple backand-forth path to reduce time and energy consumption for Unmanned Aerial Vehicle (UAV) with camera under photogrammetric constraints.In other similar works, Hassan et al. [29][30][31] proposed a predator-prey coverage path planning approach to perform CPP in complex environments where unexpected changes, for example, stationary and dynamic obstacles, can occur.These online coverage methods address the CPP problem in an unknown environment, but the robustness of generated path deserves further study.

Combinatorial optimization problem
Region segmentation is the common method of CPP approaches.The combinatorial path planning among regions is one of the key factors of CPP.A path among regions with short length, few turns, and few overlaps can greatly reduce the time and energy consumption of robots. 32Some popular intelligent optimization algorithms such as genetic algorithm (GA), 33 particle swarm optimization (PSO), 34 and ant colony optimization (ACO) 35 are regarded as the effective strategies for combinatorial optimization problems.Sheng et al. 36 modeled this combination problem as open-loop rural postman problem (Open-RPP) and employed GA to solve the Open-RPP.ACO is employed to modify the navigation points and find the shortest and safest coverage path for underwater gliders. 37However, these single optimization algorithms are easily trapped in the local optimum and appear premature convergence.Moreover, these algorithms rely heavily on the parameters adjustment that bring inconvenience to optimization.
To improve the search performance and avoid local optimum, recent methods tend to utilize the group of evolutionary algorithms to perform combinatorial optimization.Improved ACO 38 is proposed by using GA to find the parameters combination for the best performance of ACO.Similarly, ACO enhanced by chaos-based PSO 39 is proposed to deal with the path planning problem for landfill inspection robots in Asahikawa, Japan.A hybrid PSO 40 is creatively proposed to solve global path planning.In these methods, one swarm intelligence algorithm is employed to optimize the parameters for another, which improves the optimization performance.Therefore, combined swarm intelligence algorithms have become one of mainstream methods for combinatorial optimization.

Problem description
CPP for spray painting has its own unique characteristics.Firstly, the robot arm is not necessary to end at the start point.Secondly, CPP for spray painting aims to cover the entire given area with the shortest path considering as few as turns and energy consumption of robots and smooth connections.For complex surfaces spray painting, multiple regions are obtained with hole identification and region partition taking into accounts of curvature change.Zigzag motion patterns of the spraying robot arm are implemented in each region.Zigzag motion paths in each region and the connections among these zigzag paths could be described as a combinatorial optimization problem known as the generalized traveling salesman problem (GTSP).
Similar to traveling salesman problem (TSP), GTSP is Non-deterministic Polynomial-time hard (Np-hard).In GTSP, we define the line segment with two endpoints named characteristic line (see "3D hole identification" section) as a city.A characteristic line represents one straight motion of the robot arm, abstracted by numerous spray painting path waypoints within that motion.Our objective is to traverse all cities to determine the optimal path with a short length, minimal turns, and high coverage rate.GTSP can be depicted using graph theory, as outlined below.
Here, a complete coverage graph G ¼ ðV ; EÞ is introduced to account for GTSP.V ¼ fV i ; i ¼ 1; 2; . . .; ng denotes the vertex set, and the city is represented by V i (characteristic line).In contrast to the traditional TSP definition, the city V i in GTSP signifies a line segment with two endpoints A i and B i , that is, V i ¼ fA i ; B i g.We refer to A i as the head endpoint and B i as the tail endpoint.E ¼ fðV i ; V j Þ; i 6 ¼ j; V i 2 V ; V j 2 V g denotes the edge set, which signifies the connection paths between two cities.D ¼ fdðV i ; V j Þ; i 6 ¼ j; V i 2 V ; V j 2 V g is the set of distances between cities, where dðV i ; V j Þ is the distance between city V i and city V j .Given that each city comprises two endpoints, there are four distinct values of dðV i ; V j Þ, as illustrated in Figure 1.Two variables c i 2 f0; 1gði ¼ 1; 2; :::; nÞ and c j 2 f0; 1gðj ¼ 1; 2; :::; nÞ are introduced to determine the value of dðV i ; V j Þ. dðV i ; V j Þ can be expressed by the following equation Here, jB i A j j represents the distance from B i to A j , and jA i A j j represents the distance from A i to A j .The same definitions apply to jB i B j j and jA i B j j.If c i ¼ 1 and c j ¼ 1, the distance between V i and V j is the length between the head endpoint A i and the head endpoint A j .If c i ¼ 0 and c j ¼ 0, the distance between V i and V j is the length between the tail endpoint B i and the tail endpoint B j , The same definitions apply to c i ¼ 0; c j ¼ 1 and c i ¼ 1; c j ¼ 0, as shown in Figure 1.
The objective of GTSP is to determine the optimal path among all possible combinations of paths.Consequently, the combinatorial optimization problem for spray painting path planning can be formulated as follows S:t: Here, n is the number of cities, and dðV i ; V j Þ is the distance between the ith and jth city.The decision variable x ij ¼ 1 means the robot arm moves from city V i to city V j , otherwise not.Equation ( 3) ensures that each city can be only traversed once.

Proposed method
Figure 2 illustrates the workflow of the proposed CPP approach for complex surfaces spray painting.In essence, the approach includes three parts.Firstly, multiple regions are obtained by 3D hole identification and region partition.Secondly, Path planning is performed in each region.Thirdly, MCPSO algorithm optimizes the connecting path between regions.In the subsequent sections, we describe details of the three modules.

3D hole identification
Unlike simple surfaces, complex surfaces exhibit frequent changes in curvature and may contain some areas need not to be planned such as holes.To avoid the influence of curvature variation and holes, we propose a 3D hole identification algorithm to partition the surfaces.
The 3D hole identification algorithm operates on tessellated surface files, as depicted in Figure 3.A lot of intersection points are obtained by intersecting the sweep plane with triangles in the tessellated surface.The sweep planes, illustrated in Figure 4, consist of a series of tangent planes perpendicular to the sweep direction, facilitating the intersection process with the complex 3D surface.
We first sort and record intersection points from smallest to largest along the direction perpendicular to the sweep direction.Subsequently, we connect these intersection points on each triangle end-to-end, forming an intersection line.If the sweep plane does not intersect a hole, the latter point of the previous intersection line is connected to the former point of the next intersection line, indicating the absence of a hole.Conversely, if the sweep plane intersects a hole, the adjacent intersection lines situated on either side of the hole remain unconnected.And these unconnected points on either side of the hole are recorded as critical points.Multiple groups of critical points are obtained by intersecting the sweep plane with tessellated surface along the sweep direction.As a result, the hole polygonal contours can be generated by fitting the critical points with nonuniform rational B-splines (NURBS) curves, as shown in Figure 5.It is important to note that this algorithm identifies holes using a slicing method after obtaining the surface model files, operating independently of sensors.The proposed hole identification algorithm is described in detail as follows.
(1) Calculate and obtain the intersection lines l i ¼ fðp i ; q i Þ; i ¼ 1; 2; . . .kg by intersecting one sweep plane with k triangles in the tessellated surface.Here, p i and q i are the two endpoints of ith intersection line.k is the number of intersection lines.Particularly, if sweep plane intersects the triangle with only one endpoint, we regard it as a line of length 0, that is, p i ¼ q i .(2) Adjust the position of the endpoint pair fðp i ; q i Þ; i ¼ 1; 2; . . .kg to ensure that the y-coordinate value of p i is less than the y-coordinate value of q i .(3) Sort the y-coordinate value of p i from smallest to largest to ensure that the intersection lines l i ¼ fðp i ; q i Þ; i ¼ 1; 2; . . .kg increase sequentially.(4) The distance between p iþ1 and q i is defined as d i ¼ p iþ1 À q i ; i ¼ 1; 2; . . .; k.Given a hole identification  threshold e, d i > e denotes the endpoint p iþ1 and q i are critical points.In addition, the accumulated number of d i > e, denoted by N holes signifies the count of holes intersected by the current sweep plane.Theoretically, all holes can be identified if e is set to 0. However, in practical applications,  the threshold e is often assigned to a positive empirical value to ignore some small holes.

Region partition
The critical points of holes on complex surface can be identified by performing hole identification algorithm.The type of critical points on the hole boundary can be divided into two types according to the location of the critical points.Based on the two different types of critical points, we propose a region partition method consisting of coarse partition and precise partition.This method effectively divides the complex surface into multiple geometrically and topologically simple regions.
Coarse partition: Coarse partition aims to roughly partition the surface into multiple simple regions.To achieve this, we introduce an auxiliary plane named splitting plane, as depicted in Figure 4. Splitting planes occur where the count of holes N holes changes from zero to nonzero or vice versa.By considering the splitting plane as the dividing plane, the entire surface can be segmented into multiple simple regions along the sweep direction, labeled as region 1, region 2, and region 3.It is important to note that minimizing the curvature change of each region can significantly reduce the difficulty in CPP and result in uniform paint deposition.To minimize the curvature change of each region, the sweep direction is often determined by the geometric features of the surface.In this work, we choose the vertical direction as the sweep direction since surfaces have small curvature change in the horizontal direction.
Precise partition: Precise partition aims to further divide the region with holes into several hole-free regions.For instance, region 2 is expected to be partitioned into region 2-1 and region 2-2, as shown in Figure 4. Critical points play a crucial role in this process, and we categorize the critical points obtained by the hole identification algorithm into two types: upper critical points and lower critical points, as well as left critical points and right critical points.Taking left and right critical points as example, these refer to critical points located on the left and right sides of the hole, respectively.
To achieve precise partition, we employ NURBS to interpolate the left and right critical points separately.This results in the generation of several continuous critical curves, as depicted in Figure 5. Consequently, the coarsesegmented region with holes can be further divided into hole-free regions bounded by the generated critical curves.
After the hierarchical partition described above, the complex surface is segmented into multiple simple regions without holes, each containing numerous intersection points.To simplify the complexity of coverage planning, we abstract a group of intersection points into a characteristic line.It means that each characteristic line can be formed by connecting one group of intersection points sequentially.The definition of a characteristic line is based on the types of its first and last intersecting points, resulting in five distinct types: non-left critical point (type 1), right-left critical point (type 2), right-noncritical point (type 3), non-noncritical point (type 4), and left-right critical point (type 5).For example, a characteristic line belonging to type 1 represents a group of intersection points whose first intersection point is not a critical point, and the last intersection point is a left critical point.Consequently, each region can be viewed as covered by multiple characteristic lines, facilitating the complete CPP of the entire surface, as illustrated in Figure 5.

Path planning for each region
Movement patterns are usually used to design the spraying tool path.The two widely used movement patterns are zigzag, triangular, and spiral. 18Compared with a spiral path, a zigzag path is more operationally efficient for robotic manipulator and is more common choice for spray painting.Zigzag paths, characterized by shorter lengths and fewer turns, significantly reduce the energy consumption of robots and minimize paint waste in practical applications.4][25] Therefore, this article adopts the zigzag path as the movement pattern in each region.
As discussed in "Region partition" section, we know that each region contains multiple characteristic lines, and these characteristic lines can be considered as a unit, easily forming zigzag paths.It is noteworthy that the number of characteristic lines in each region varies, resulting in different types of zigzag paths.Importantly, we observe that although different regions contain different numbers of characteristic lines, they can be categorized into only two situations: odd numbers of characteristic lines and even numbers of characteristic lines.In each situation, there are four distinct ways to form zigzag paths, as illustrated below.
To distinguish between different zigzag paths, we label the two endpoints of the first characteristic line as A i and B i , and the two endpoints of the last characteristic line as A j and B j in a region.As depicted in Figure 6, if a region contains an odd number of characteristic lines, the zigzag path starting from one endpoint will end at the diagonal endpoint, such as the path from A i to B j in Figure 6(a).Conversely, if a region contains an even number of characteristic lines, the zigzag path starting from one endpoint will end on the same side of the endpoint, as illustrated by the path from A i to A j in Figure 7(a).Specifically, when a region contains only one characteristic line, the zigzag path starting from one endpoint will end at the other endpoint.The zigzag paths reduce the length of the connection path between characteristic lines within each region, thereby contributing to the overall shortening of the total coverage paths.
The analysis of zigzag paths within regions reveals four possible path traversal ways for each region.While connecting regions, there are numerous possibilities to create a complete coverage path plan.The challenge lies in planning paths within and between regions to achieve a globally optimal path.Based on the characteristic lines abstracted by groups of waypoints, we transform the planning of waypoints for the entire surface into the combinatorial optimization of characteristic lines.Consequently, a novel optimization algorithm is proposed to address this combinatorial optimization problem.

Multiple chromosomes particle swarm optimization approach
MCPSO approach is described in this section.The MCPSO algorithm is employed to achieve an overall path for the complex surface, ensuring short length, few turns, and a high coverage rate.

Definition
Building on previous academic research, combinations of popular intelligent computation algorithms, such as GA and PSO, have been recognized as effective strategies for combinatorial optimization problems. 39As a result, we propose the MCPSO algorithm, which retains the core mechanisms of PSO while incorporating the chromosome crossover and variation mechanisms of GA to optimize the zigzag paths.There are some definitions in MCPSO algorithm.Definition 1: Three chromosomes, namely, X, Y1, and Y2, are introduced to represent an individual, as illustrated in Figure 8.Each chromosome represents a distinct full coverage path.In this context, each chromosome consists of multiple genes, with the number of genes equal to the number of regions after region partition.The gene on chromosome X denotes the sequence index of regions, and chromosome X can be represented by function p 1 , signifying a traversal order O X of regions Here, O i ði ¼ 1; 2; . . .; nÞ denotes the sequence index of region, n means the number of regions.For example, O X ¼ f4; 5; 3; 1; 2g represents the complex surface is divided into five regions and is visited sequentially in 4-5-3-1-2 order.
Definition 2: Chromosome Y is composed of chromosomes Y1 and Y2 as shown in Figure 8, whose genes represent different types of zigzag path in region.Similar to chromosome X, chromosome Y contains the same number of genes, and the values of these genes correspond to those on chromosome X.The genes on chromosome Y adopt values of 1 or À1, denoted as v i 2 f1; À1gði ¼ 1; 2; . . .; nÞ.Consequently, chromosome Y can be expressed by the function p 2 to represent various zigzag paths in each region with v Y 1 i 2 f1; À1gði ¼ 1; 2; . . .; nÞ v Y 2 i 2 f1; À1gði ¼ 1; 2; . . .; nÞ where O Y 1 and O Y 2 represent the gene sequence of chromosomes Y1 and Y2, respectively, and n denotes the number of regions.As illustrated in Figure 9, in the ith region, v Y 1 i ¼ 1 represents that the zigzag path enters from one endpoint of the first characteristic line.Otherwise, v Y 1 i ¼ À1 signifies that zigzag path enters from one endpoint of the last characteristic line.v Y 2 i ¼ 1 signifies that the zigzag path enters from the right endpoint of the first or last characteristic line, while v Y 2 i ¼ À1 means that zigzag path enters from the left endpoint of first or last characteristic line.Therefore, the binary value of v i acts as a sign that determines from which endpoint the path enters.The combination (v Y 1 i ,v Y 2 i ) indicates which endpoint of region O i the path enters from.
In summary, different values of the ith (i ¼ 1, 2, . . ., n) gene on chromosomes Y1 and Y2 correspond to various types of zigzag paths.For example, 9 means that the zigzag path in the ith region enters from point A of the first characteristic line.The choice of the endpoint from which to leave depends on the number of characteristic lines in the ith region, as described in "Path planning for each region" section.For instance, the zigzag path will leave from point C/D if this region contains an even/odd number of characteristic lines.It is important to note that we can exchange v Y 1 i and v Y 2 i , as the pair ðv Y 1 i ; v Y 2 i Þ merely acts as a sign determining from which endpoint the path enters.
After determining the zigzag path in each region, a global path is obtained by connecting each region according to the traversal order specified in chromosome X.
Definition 3: The Dist in the MCPSO is a distance matrix that represents the length of connecting path between regions.The connecting path length between regions is a significant factor affecting the total path length.The formula of calculating the distance of connecting path is expressed as follows where D ij is the Euclidean distance between waypoint p i ðx i ; y i ; z i Þ and p j ðx j ; y j ; z j Þ in 3D space.Definition 4: Crossover and mutation operations are introduced to explore the entire solution space.Crossover operation is used to exchange the substrings between selected chromosomes.The Order Crossover (OX) 36 operation is employed in the algorithm which guarantees the creation of legal permutation of the regions in the resulting offspring.Mutation operation is used to maintain the diversity of the population and prevent it from falling into the

MCPSO algorithm
The proposed MCPSO algorithm is as illustrated in Algorithm 1. Table 1 provides a list of symbols used along with their definitions.
In the initial stage, the cities matrix records the information of characteristic lines in each region.An individual is initialized, with P_best and G_best assigned as the initial individual.During the iteration stage, crossover and mutation operations are performed in individuals.Note that we perform crossover and mutation with the global best individual, that is, G_best, ensuring the evolution of the populations toward a superior direction.Subsequently, we calculate the fitness of each individual in this generation and assign the optimal fitness to F_best.F_best provides a metric for the ongoing iteration.If the fitness of an individual surpasses G_best, we update G_best with this individual.
Remark 1.In the practical application of spray painting, the complex surfaces required to be sprayed are typically specific and do not change over time.As a result, the optimal spray painting path generated by the algorithm tends to remain consistent after iteration.In essence, there is often no need for path regeneration in the field of spray painting due to the nonvariable nature of the input surfaces.Spraying quality is affected by various factors, such as path length, uniformity of paint thickness and coverage rate.To evaluate the optimal path with good quality, we introduce a reward function R. The reward function R is composed of four rewards: (1) internal path length reward LðP I Þ; (2) connecting path length reward LðP C Þ; (3) fewer turns reward T ðqÞ; (4) coverage rate reward C R .Upon completing the iteration process, the best individual is determined, and the optimal global path can be obtained.

Reward function
(1) Reward for minimizing the internal path length of region (internal path length reward): One of the primary goals of spray CPP is to obtain the shortest or nearly shortest coverage path, aiming to conserve spraying paint and reduce energy consumption in robotic manipulators.The internal path length of a region is the total length of the zigzag path within this region.The function for calculating the internal path length reward is formulated as equation ( 8) Here, k p s j À p j1 k represents the distance from the start waypoint to the next waypoint in the jth region, p s j denotes the start waypoint in the jth region, and p j1 denotes the first waypoint behind p s j in the jth region.n and N k represent the number of regions and the number of the waypoints in the jth region, respectively, with k Á k representing the Euclidean distance in our work.This reward minimizes the path length of each region, making the global coverage path shorter.For example, Figure 10(a) shows the coverage path without utilizing the internal path length reward, which exhibits many overlaps and turns.In Figure 10(b), a shorter and smoother coverage path is generated in the same environment by utilizing the internal path length reward.
(2) Reward for minimizing the connecting path length between regions (connecting path length reward): The connecting path between regions is another important factor that significantly influences the length of the total coverage path.The length of the connecting path is expected to be as short as  possible to ensure that the robotic manipulator traverses a short distance, thereby reducing energy consumption.The function for this reward is formulated as equation ( 9) Here, n is the number of regions, p l j denotes the leaving endpoint of the jth region, and p e jþ1 denotes the entering endpoint of the ð j þ 1Þ th region.k p l j À p e jþ1 k represents the connecting path length between the adjacent jth and ð j þ 1Þ th regions.
(3) Reward for minimizing turns (fewer turns reward): During the spraying process, the turning movement of the robotic manipulator significantly impacts the uniformity of spray paint thickness.
Frequent turning movements can lead to nonuniform spray paint distribution, causing defects on the painted surface.In addition, frequent turning movements may contribute to the wear and tear of robot joints.Therefore, minimizing the number of turns is crucial for effective CPP.In this article, the turning movement is represented by the non-flat angle of the path.For example, when three waypoints p 1 , p 2 , and p 3 are connected in order, as shown in Figure 10(a), the angle ffp 1 p 2 p 3 2 ð0 ; 180 Þ represents a turning movement.The reward for minimizing turns can be expressed as the ratio of the number of waypoints with a non-flat angle to the total number of waypoints, formulated as follows Here, P is the number of waypoints of the entire path, q i ði ¼ 1; 2; . . .; PÞ is the angle ffp iÀ1 p i p iþ1 2 ð0 ; 180 formed between vectors ðp iÀ1 À p i Þ and ðp i À p iþ1 Þ, and 'ðÁÞ is defined as a function used to determine whether q i is a non-flat angle, that is, whether it represents a turning movement.
(4) Reward for maximizing coverage rate (coverage rate reward): Coverage rate is a crucial indicator for evaluating the quality of CPP.The coverage rate is defined as the ratio of the area covered by the generated path to the total area that needs to be covered.The coverage rate reward is formulated as equation ( 12) i¼1 Area i Area all (12)   where Area i represents the area covered by the generated path in the ith region, and Area all is the total surface area that needs to be covered.
(5) Total reward (sum of all rewards): The total reward for CPP on a complex surface is the sum of all rewards previously stated, that is, where !L , !T , and !C R are the weighting factors related to path length reward, fewer turns reward, and coverage rate reward, respectively.These three weighting factors affect the importance of the corresponding rewards, and the values are determined after several experimental optimizations.Based on equation ( 13), the optimal coverage path, that is, the optimal sequence of waypoints w Ã , can be found.

Simulations
In this section, several case studies are employed to validate the proposed approach.In addition, the approach has been performed on a professional robot simulation software named PQArt to assess its performance.

Experiment setup
The model employed in this study is an actual car rear model presented in STL format.The car rear has dimensions of 2.5 Â 3 Â 0.3 m, as depicted in Figure 11.In our study, these very small holes distributing on the four corners of the bus rear are ignored for the purpose of reducing planning resources, and this is also a common practice in industrial settings.Regarding parameters setting, the optimized weighting factors are obtained based on the experience gained from several experiments and previous researches.The weights of the reward function are set as !L ¼ 0:52, !T ¼ 0:24, and !C R ¼ 0:24.The population size is 500, the maximum number of generations is 200, the crossover fraction is 0.9, and the mutation fraction is 0.05.The development environment is MATLAB R2020a on a 64-bit windows 10 system.All experiments are conducted on a PC with an Intel core (TM) i7-4790 CPU @ 3.6 GHz processor and 16 GB RAM.

Simulations and comparative analysis
Numerous studies have identified swarm intelligence optimization algorithms, including GA, ACO, and PSO, as the most commonly employed methods for spray painting path planning.This section presents a series of simulation studies to validate the proposed approach.
(1) Analysis of GA and PSO coverage path: GA and PSO are widely employed methods for solving the path planning problem.The coverage paths generated by GA and PSO are illustrated in Figure 11.It can be seen that there are numerous turns in the coverage path, significantly increasing the total length.In addition, frequent path transitions contribute to higher energy consumption and extended working time for robots.In this case, GA and PSO achieve the appropriate combination of characteristic lines but neglect the impact of holes.The details of GA and PSO performance are shown in Table 2. (2) Analysis of im-GA and im-ACO coverage path: In a comparative experiment, we integrate the hole identification and layered segmentation strategy into the GA and ACO algorithm.As shown in Figure 12, the improved versions, im-GA and im-ACO, exhibit shorter path lengths and smoother paths compared to the initial GA and PSO.This case study underscores the substantial improvement in the quality of coverage paths achieved through the hole identification and layered segmentation strategy.The details of im-GA and im-ACO performance are presented in      algorithms, demonstrating quick convergence to optimal solutions through the combination of GA and PSO, and producing high-quality paths through the integration of hole identification and layered segmentation strategies.(5) Comparison and analysis of algorithm performance: To further illustrate the performance of the six algorithms, Table 2 provides a comparative analysis, including path length, turns, coverage rate, and running time.In the table, "avg" and "opt" represent the average and optimal values, respectively.Notably, the path length and the number of turns of the improved algorithms surpass those of the initial GA and PSO, attributed to the layered segmentation of the complex surface, facilitating coverage tasks.The path length of our MCPSO decreases by approximately 19.7% compared to that of improved GA and 16.2% compared to that of improved ACO.The number of turns of our MCPSO decreases by approximately 5.3% and 2.6% compared to that of improved GA and improved ACO, respectively.These results indicate that the MCPSO, combining the advantages of GA and PSO, outperforms individual bio-inspired algorithms.The MCPSO approach also outperforms CCIBA* in path length and turns due to global path optimization.It is worth mentioning that the coverage rate of these algorithms is similar, thanks to the zigzag movement pattern.Last but not least, the running time of MCPSO exhibits clear advantages over the aforementioned algorithms.
In summary, the analysis of these performances indicates that the integration of hole identification and layered segmentation processes contributes to obtaining regular paths and a relatively high coverage rate.In addition, the proposed MCPSO algorithm exhibits significant improvements in path length, smoothness, number of turns, and running time.
As shown in Figure 14, the proposed MCPSO approach is applied to the real bus rear.The used simulation software is PQArt, a professional industrial robot offline programming software.The zigzag path width is set as 108 mm, equivalent to seven-eighths of the radius of the spray circle, to achieve uniform paint thickness. 25In industrial settings, multiple robots are often employed for spraying to enhance painting efficiency.Consequently, the bus rear is evenly divided in half, with each part being sprayed by a separate robotic manipulator.The path for each part is generated using our proposed approach.
As depicted in Figure 14, the zigzag path is horizontally arranged due to the slight changes in bus surface curvature in the horizontal direction.This arrangement contributes to the generation of uniform paint thickness.The green points represent the path waypoints traversed by the robotic manipulator.Following these green waypoints, the coverage path is generated, as indicated by the orange lines.The position of the spray gun can be determined by offsetting the spraying height of these waypoints along their respective normal vectors.The simulation using the real bus rear model demonstrates that the generated path is smooth, with a short length, fewer turns, and a high coverage rate.These simulation results effectively validate the strong performance of our proposed approach.

Conclusion
In this article, a novel MCPSO-based CPP approach is proposed for complex 3D surfaces spray painting.The approach involves a layered segmentation of the surface prior to path planning.Utilizing the 3D hole identification algorithm, critical points around holes are identified and fitted into smooth boundary curves using NURBS.Subsequently, the entire surface is partitioned into several simple regions with the assistance of critical points.We discuss various movement patterns within each region to enhance CPP efficiency.The MCPSO algorithm is then applied to the partitioned regions, yielding the optimal zigzag path.
Experiments and simulation are conducted to evaluate the performances of the MCPSO algorithm and other improved heuristic algorithms.The results indicate that the MCPSO algorithm has preferable performance in path length, turns, coverage rate, and running time.In the future work, additional experiments on different complex 3D surfaces will be carried out, and multirobot collaborative CPP for complex surfaces will be studied.

Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.

Figure 1 .
Figure 1.Four distinct distances between adjacent cities: (a) A j is connected withB i (c i ¼ 0, c j ¼ 1); (b) A j is connected with A i (c i ¼ 1, c j ¼ 1); (c) B j is connected with B i (c i ¼ 0, c j ¼ 0); (d) B j is connected with A i (c i ¼ 1, c j ¼ 0).

Figure 2 .
Figure 2. The workflow of the proposed CPP approach.CPP: coverage path planning.

Figure 3 .
Figure 3. Intersection of sweep plane and tessellated surface.

Figure 5 .
Figure 5. Segmentation of the bus rear model.

Figure 6 .
Figure 6.Zigzag path in odd situation: (a) A i in and B j out; (b) B i in and A j out; (c) A j in and B i out; (d) B j in A i out.

Figure 7 .
Figure 7. Zigzag path in even situation: (a) A i in and A j out; (b) B i in and B j out; (c) A j in and A out; (d) B j in B i out.

Figure 9 .Algorithm 1 .
Figure 9.The selection of in and out endpoint in the mth region with different gene values of chromosome Y.

F_bestFigure 10 .
Figure 10.(a) The coverage path without internal path length reward.(b) The coverage path with internal path length reward.

Figure 11 .
Figure 11.(a) The coverage paths generated by GA.(b) The coverage paths generated by PSO.GA: genetic algorithm; PSO: particle swarm optimization.

( 4 )
Analysis of MCPSO coverage path: In Figure13(b), it is evident that the proposed MCPSO algorithm efficiently traverse all regions with a shorter length and fewer turns.The occurrence of the trajectory crossover is rare, effectively reducing the energy consumption of robots.Furthermore, the total path length is significantly reduced, minimizing the movement path length of the robotic manipulator and saving working time.The proposed MCPSO algorithm outperforms both aforementioned

Figure 12 .
Figure 12.(a) The coverage paths generated by improved GA.(b) The coverage paths generated by improved ACO.GA: genetic algorithm; ACO: ant colony optimization.

Figure 14 .
Figure 14.Coverage path planning for the real bus rear model.

Table 1 .
Symbols and definition.
max Maximum time allowed to the path planning task n Number of regions indiNum Number of individuals individual_X Traversal sequence of regions matched with chromosome X individual_Y1 Choices of different zigzag path matched with chromosome Y1 individual_Y2 Choices of different zigzag path matched with chromosome Y2 P_best Best individual with min.reward of each generation G_best Best individual with min.reward of all generations

Table 2
ber of units and coverage rate.However, CCIBA* executes the coverage tasks by planning units individually, overlooking global path planning, resulting in long connectivity distances between regions, as depicted in Figure13(a).The details of CCIBA* performance are presented in Table2.

Table 2 .
Performance analysis table of six algorithms.