원시데이터 수집 시스템
선정목록으로

Optimal Spraying Path Generation for Complex Concave Surfaces

간접 관련 모빌리티 소재 · (3) 자동차 인테리어 소재 (23) 컴파운드

기본 정보

저자
  1. David Ramírez-Ríos — School of Engineering and Sciences, Tecnologico de Monterrey, Mexico City, Mexico
  2. Javier Izquierdo-Reyes — School of Engineering and Sciences, Tecnologico de Monterrey, Mexico City, Mexico
  3. David Romero — School of Engineering and Sciences, Tecnologico de Monterrey, Mexico City, Mexico
DOI
10.1109/access.2025.3617926
저널
IEEE Access
발행년도
2025
발행기관
Institute of Electrical and Electronics Engineers
피인용수
0
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1109/access.2025.3617926
토픽
Tribology and Lubrication Engineering
OpenAlex ID
W4414871483

평가 내용

관련도
간접 관련
사업분야
모빌리티 소재 · (3) 자동차 인테리어 소재
부 분야
(23) 컴파운드
R&D 측면
공정·제조
확신도
0.80
근거 용어
robotic spray painting, coating thickness, complex concave surfaces, automation, path planning
판단 근거
이 논문은 복잡한 오목한 표면에 균일한 코팅을 수행하기 위한 로봇 스프레이 경로 최적화 기술을 다룹니다. 이는 자동차 인테리어 소재(3)나 컴파운드(23) 제조 공정 중 표면 처리 및 코팅 자동화 공정에 응용될 수 있는 기술입니다.
R&D 활용 포인트
자동차 내장재나 기능성 부품의 표면 코팅 공정 자동화 시, 복잡한 형상에서도 균일한 두께를 유지하기 위한 로봇 경로 설계 및 공정 제어 알고리즘 개발에 활용 가능합니다.
평가 입력
본문 110,912자 중 30,032자 발췌

초록

Automatic spray path planning is crucial to successfully automate spray coating processes. Several methodologies have been developed for optimal path generation. However, few have been reported to cope with complex and concave surfaces such as those encountered in semi-permanent molds. This work proposes a framework for automatic spray path planning for complex concave surfaces. It employs a segmentation algorithm and two-dimensional cubic Bézier curves to generate spraying strokes without loops and collisions with the surface, and with limited curvature. This methodology was tested on a surface that embodies the main characteristics of real semi-permanent molds employed on gravity die casting achieving low coating thickness error and high coverage of the surface.

본문 110,912자

본문 펼치기
Received 19 August 2025, accepted 30 September 2025, date of publication 6 October 2025, date of current version 20 October 2025. _Digital Object Identifier 10.1109/ACCESS.2025.3617926_ # Optimal Spraying Path Generation for Complex Concave Surfaces DAVID RAMÍREZ-RÍOS, JAVIER IZQUIERDO-REYES, (Member, IEEE), AND DAVID ROMERO, (Member, IEEE) School of Engineering and Sciences, Tecnológico de Monterrey, Mexico City 14380, Mexico Corresponding author: Javier Izquierdo-Reyes (jizquierdo.reyes@tec.mx) This work was supported in part by the National Council for Science and Technology (CONAHCyT), under Grant 839911, and in part by Tecnológico de Monterrey, under Grant a01338802. ABSTRACT Automatic spray path planning is crucial to successfully automate spray coating processes. Several methodologies have been developed for optimal path generation. However, few have been reported to cope with complex and concave surfaces such as those encountered in semi-permanent molds. This work proposes a framework for automatic spray path planning for complex concave surfaces. It employs a segmentation algorithm and two-dimensional cubic Bézier curves to generate spraying strokes without loops and collisions with the surface, and with limited curvature. This methodology was tested on a surface that embodies the main characteristics of real semi-permanent molds employed on gravity die casting achieving low coating thickness error and high coverage of the surface. INDEX TERMS Bézier-based paths, complex concave surfaces, optimal spraying path generation, robotic spray painting, semi-permanent mold coating, spray path planning. I. INTRODUCTION Spray painting or spray coating process involves transporting a material from the tip of an applicator (spray gun) to a surface to impregnate it with the desired material to change some characteristics of the workpiece. Industry started employing robots for these processes in the 1970s to manufacture all kinds of industrial parts since it increases efficiency and reduces costs while keeping human operators away from hazardous environments [1]. Nowadays, robot path programming represents a bottleneck in the automation process of spray coating tasks, especially for complex surfaces. Computer Aided Tool Path Planning (CATP) for spray painting operations connects the CAD model of the workpiece with the spraying process to find the best (or good enough) spray gun trajectories without the need of physical experiments, effectively reducing human labor and health risks [2]. Therefore, many methods have been developed to help robot programmers find optimal spraying paths, combining offline robot programming, opti The associate editor coordinating the review of this manuscript and approving it for publication was Zheng H. Zhu . mization techniques, and coating thickness approximation methods on what can be called CATP for Spray Painting. Since the early 1990s, academia and industry have been publishing studies on CATP for Spray Painting [3], [4]. One of the most cited works in this context is found in [5], where the authors divided the surfaces to be painted into small patches of low normal vector deviation to optimize the overlapping distance and velocity of the spraying strokes. A two-step optimization process was proposed in [6]; first the surface was divided into patches as in [5], then spray gun velocity and overlapping distance between strokes were optimized for each patch independently; finally, they were optimized again for each stroke considering other patches. Later, [7] presented a path generation method based on exponential mean Bézier curves avoiding the need for surface segmentation; their work optimized the paint flow rate and the position of the spray gun over time to obtain a homogeneous thickness. Even though many of the methods developed base the path generation on the CAD model of the surface to be painted, some researchers have also included laser scanning methods to acquire the surface spatial data instead of the CAD model to generate the spraying trajectory. In [8] the workpiece was scanned to obtain surface point cloud data, such data was post-processed and ‘‘sliced’’ with parallel planes to acquire ‘‘contours’’ that describe the local geometry (this is also known as the slicing technique), finally, the spraying paths were generated by offsetting the contours a certain distance in the direction of their normal vectors. Similarly, [9] proposed a method to scan a workpiece and generate spraying strokes with the slicing technique, however, the author also addressed the importance of the ‘‘slicing direction’’ with regard to the complexity of the generated spraying strokes, by adopting the slicing direction as the dominant eigenvector of the covariance matrix of the point cloud data, the resulting spraying strokes are simpler. Another interesting work is found in [10], where the authors employed the slicing technique to find the surface contours and obtained the convex hull from each contour and used them to generate the spraying path; however, this method could only be applied to mainly convex surfaces and was focused on water spraying where constant velocity is not relevant. There are also works focused on specific cases. For example, in [11] the authors used a traditional raster-like spray pattern and optimize its gun to target angle to reduce the spraying time, their work was aimed at irregular flat surfaces. Hua et al. [12] developed a coating thickness model for camouflage applications and a framework for the optimization of the overlapping distance and stroke velocity that consider the boundary between the convex and concave regions of the surface. Wu and Tang [13] developed a method to generate optimal spraying strokes for surfaces with irregular geometrical boundaries, employing the slicing technique on an STL model and smoothing the spraying path with a fourth polynomial. In [14] a previously generated spraying trajectory was optimized to reduce the thickness error and spraying time while producing smooth spraying strokes; to achieve this, each pose that formed the trajectory was optimized individually in an objective function that considered thickness error, spraying time, and smoothness using the weighted sum method. Although not very common, some researchers have included robot kinematics in the generation of spraying trajectories. For example, [15], first found a contour on the surface, then generated the spraying path by approximating the offset contour, robot joints were optimized to keep the angle between the target normal vectors and the spraying directions as low as possible while minimizing the spray gun path length; finally, the spraying time and material flow between way points were optimized to obtain the coating thickness as close as possible to the target thickness. Another example is found in [16], where the authors proposed a method to optimize time intervals of a 7th order polynomial trajectory controlling maximum velocity, acceleration, and jerk to generate a smooth trajectory that ensured a homogeneous coating thickness of a rectangular spray gun application. However, both kinematics-based methods were tested on simple and regular surfaces. The incorporation of robot kinematics in the spray path generation of complex surfaces is yet to be investigated. Recent articles have focused on more complex surfaces. A surface segmentation based on normal vectors and curvatures was proposed in [17], then each spraying trajectories for each region were generated using [12], finally, the sequence of trajectories was optimized to minimize processing time. In [18] the authors proposed an innovative sphere wrapping method to find and filter key surface features that would be used in the spraying path generation; the path was generated with the ‘‘classical’’ approach of using surface contours and offsetting them in the normal vector direction; finally, speed and paint flow were optimized to reduce the thickness error. An interesting approach was presented in [19] where a geometric feature guided segmentation network (GFGSNet) was developed to segment the surface to be painted into geometrically similar regions, then special spraying patterns based on the classical raster pattern that were previously designed by the authors were used at their discretion on each region; the spray gun speed and overlapping distances were optimized to minimize the thickness error. Focused mainly on automobile parts like hoods and doors, many researchers have developed innovative techniques to ease the automation task of spray path planning. However, little attention has been paid to other important processes for the automotive industry, such as coating of semi-permanent (SMP) molds for aluminum gravity die casting. These molds are manually coated with different materials to control the solidification process and protect the mold [20]; as they are painted by a human operator, the quality of this critical process is completely dependent on the skill and experience of the operator [21], moreover, these processes expose humans to heat-related illnesses [22], [24] and increase the risk of cancer [23]. Despite the urgent need to automate these processes, it is impractical to apply the previously mentioned methods to SMP molds, as they present highly complex concave geometries. Applying these methods to SMP molds could result in collisions with the surface, paths with loops, high curvature paths, self-shadowing (the surface blocks the direct path between the spray cone and a point on the surface); additionally, many methods heavily depend on local geometry, making them vulnerable to surfaces with high density of small features. In the present work, a methodology is proposed for automatic generation of optimal spraying trajectories for complex concave surfaces. The method started with a two-step segmentation process, first based on the curvature of the surface followed by a second segmentation based on the spatial data and normal vectors of previously segmented regions. Then, each segmented sub-region was sliced with a set of strategically aligned parallel planes to then generate optimal spraying strokes that were completely embedded in the slicing planes; the strokes were generated with two-dimensional cubic Bézier curves, avoiding high FIGURE 1. Spraying experiment diagram. curvatures, loops, and collisions with the surface. Finally, combinatorial optimization was implemented to select the spraying strokes and find each of their velocities, ensuring that the resulting coating thickness was close to the given target coating thickness. The remainder of this manuscript describes, in order, each of the steps developed to generate spraying paths. Section II introduces the coating thickness modeling method adopted here. Section III describes the algorithm to segment complex surfaces into simpler regions. Section IV delves into how spraying strokes are described and generated in this work. Section V is devoted to the description of the algorithm that generates optimal spraying strokes. The final step of the developed framework is presented in Section VI. The results and analysis of applying this framework are presented in Section VII. This paper concludes in Section VIII with the final remarks of the developed framework and future works. II. SPRAY GUN MODELING Modeling the resulting coating thickness of following a certain path with a certain spray gun active is the baseline for the optimization of spraying trajectories. There are several methods to model the resulting thickness, Chen et al. [1] categorized them as explicit function-based methods and computational fluid dynamics (CFD)-based methods. Even though the latter method is able to compute the thickness for any spraying system, in the context of spraying trajectory planning the former is preferred, as CFD-based methods take orders of magnitude more time to compute the coating thickness [25]. Explicit function-based methods fit a certain function to the coating thickness distribution that results from a one-second activation of a spray gun fixed _h_ 0 millimeters above a flat surface (see Fig. 1) with system settings held constant (pressure, paint flow rate, etc.). Several mathematical models have been proposed, the elliptic model, Gaussian distribution, Cauchy distribution, _β_ distribution, elliptical _β_ distribution [3], [26], [27], [28] and [29], to mention a few. Here, the ellipse dual _β_ model [30] is employed to model In order to model the coating thickness over curved surfaces, this methodology employed the method for curved surfaces introduced in [31]. In previous research, this method has been reported to accurately predict the coating thickness on complex geometries [35]. Therefore, the coating thickness flow distribution is _q_ ( _x, y, α, θ_ ) = _q_ 0( _x_ <sup>′</sup> _, y_ <sup>′</sup> ) <sup><u>(</u></sup> <sup>_<u>h</u>_</sup> <sup><u>0)2 cos</u></sup> <sup>_α_</sup> (2) _l_ <sup>2</sup> cos <sup>3</sup> _θ_ <sup>_._</sup> where _α_ is the angle between the normal vector at the point of interest on the surface and the line connecting the spray gun center point with said point on the surface, _θ_ is the angle between the spraying direction and the line connecting the spray gun center point with the point of interest, _h_ 0 is the distance between the spray gun center point and the center of the flat surface on which the experiment to find the _β_ parameters (i.e., the parameters in (1)) was performed, _l_ is the distance between the gun center point and the point of interest, finally, _x_ <sup>′</sup> and _y_ <sup>′</sup> are the coordinates of the intersection point at the imaginary plane _C_ . A detailed diagram is shown in Fig. 2, where the imaginary plane _C_ is a plane orthogonal to the spray direction with origin (i.e., ( _x_ <sup>′</sup> _, y_ <sup>′</sup> ) = (0 _,_ 0)) at the intersection between the spray direction ( _z_ ˆ of { _G_ }) and the plane _C_, the imaginary plane represents the original painted surface in the experiment to obtain the _β_ parameters. It is important to note that (2) is only FIGURE 2. Spray gun model for free form surfaces. how the coating thickness is accumulated on the surface over time, as shown in (1), where _q_ max is the maximum thickness flow rate in _µ_ m/s, _a_ and _b_ are the major and minor axis of the ellipse respectively (in millimeters), and _βx_ and _βy_ are the shaping parameters of coating the distribution (i.e., how the thickness varies from the center in each direction). _q_ 0( _x, y_ ) = _q_ max(1 − <sup>_<u>x</u>_</sup> <sup>2</sup> _a_ <sup>2</sup> _<u>y</u>_ <sup>2</sup> _b_ <sup>2</sup> (1 − _x_ <sup>2</sup> _/a_ <sup>2</sup> ) <sup>)</sup> <sup>_βy_</sup> <sup>−1</sup> <sup>(1)</sup> <sup>_<u>x</u>_</sup> <sup>2</sup> _<u>y</u>_ <sup>2</sup> _a_ <sup>2</sup> <sup>)</sup> <sup>_βx_</sup> <sup>−1(1 −</sup> _b_ <sup>2</sup> (1 − _x_ defined and has valid values under the constraints |2 _α_ | _<_ _π_, |2 _θ_ | _< π_ and <sup>_<u>x</u>_</sup> _a_ <sup>22</sup> <sup>+</sup> _b_ <sup>_<u>y</u>_</sup> <sup>22</sup> <sup>_<_</sup> <sup>1.</sup> <sup>_<u>x</u>_</sup> _a_ <sup>22</sup> <sup>+</sup> _b_ <sup>_<u>y</u>_</sup> <sup>22</sup> _b_ <sup>_<u>y</u>_</sup> <sup>22</sup> <sup>_<_</sup> <sup>1.</sup> _A._ _DEDUCTION OF THICKNESS DISTRIBUTION FOR_ _FREE-FORM SURFACES AND FREE POSITION AND_ _ORIENTATION SPRAY GUN WITH MOVING FRAME_ _METHOD_ Equation (2) takes into account that the surface to be painted is defined relative to the coordinate system { _G_ }, which is centered at the spray gun center point (see Figs. 1 and 2), this could be interpreted as the tool coordinate system (TCS). However, in the CAD model, the surface spatial data is defined relative to its own coordinate system { _S_ }. Knowing the pose _ψ_ ( _t_ ) = [⃗ _G_ ( _t_ ) _,_ R ( _t_ )] of the spray gun relative to the surface coordinate system { _S_ } at any given time _t_, where⃗ _G_ ( _t_ ) is the position and R ( _t_ ) is the orientation in rotation matrix form, the instantaneous coating thickness at the surface point _p_ = [ _px, py, pz_ ] <sup>_T_</sup> with normal vector⃗ _n_ = [ _nx, ny, nz_ ] <sup>_T_</sup> (both defined relative to { _S_ }) can be modeled using (2). Note that in the present work, all transposed matrices are denoted by _A_ <sup>_T_</sup> where _A_ is the matrix to be transposed. Then, for (2), the parameters can be deducted as follows the path is completely embedded within a plane and if both _y_ axis and _z_ -axis of the TCS are also completely defined within the same plane along the entire stroke (see section IV). Let _�_ = { _ψl_ = [⃗ _Gl,_ R _l_ ] : _l_ ≤ _L, l_ ∈ Z <sup>0+</sup> } be the set of spray gun via points of a given planar spraying stroke defined relative to the surface coordinate system { _S_ } ( Z <sup>0+</sup> the set of all integers equal to or greater than zero). That is, the pose of the next via point _ψl_ +1 relative to the current via point _ψl_ can be described as where: _ψl_ <sup>_l_</sup> <sup>_l_</sup> _l_ +1 <sup>_, zl_</sup> _l_ _l_ <sup>_l_</sup> +1 <sup>= [[0</sup> <sup>_, yl_</sup> _l_ <sup>_l_</sup> _l_ +1 <sup>]</sup> <sup>_T,_</sup> <sup>R</sup> <sup>_x_</sup> <sup>(</sup> <sup>_ωl_</sup> <sup>)]</sup> <sup>_,_</sup> where _ωl_ is the angle between the _ψl_ and _ψl_ +1 frames and R _x_ ( _ωl_ ) is the rotation matrix around the _x_ -axis at angle _ωl_ . In this paper, the spray gun velocity is considered constant during all the stroke, therefore, the spray gun move from one pose _ψl_ to the next one _ψl_ +1 at a constant speed _v_ . The spraying stroke is composed of _L_ line segments, then the resulting coating thickness at point⃗ _p_ with normal vector⃗ _n_ for the _l_ -th segment is expressed as _T_ (⃗ _p,_ ⃗ _n, �, l, v_ ) = - _τ_ _q_ ( _p_ ⃗ _,_ ⃗ _n,_ _�_ <sup>¯</sup> ( _�, l, t, v_ )) _dt,_ (4) 0 <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup>· (−⃗</sup> <sup>_<u>p</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup><u>)</u></sup> =⃗ <sup>_<u>n</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup>· (−⃗</sup> <sup>_<u>p</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup><u>)</u></sup> |⃗ _n_ ( _t_ ) <sup>_G_</sup> ||⃗ _p_ ( _t_ ) <sup>_G_</sup> | |⃗ _p_ ( _t_ ) <sup>_G_</sup> | cos _α_ ( _t_ ) =⃗ <sup>_<u>n</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup>· (−⃗</sup> <sup>_<u>p</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> <sup><u>)</u></sup> |⃗ _p_ ( _t_ ) <sup>_G_</sup> | _,_ R _l_ R _x_ ( _tωl/τ_ ) - _Gl_ + _vt_ ⃗ <sup>_<u>dl</u>_</sup> |⃗ _dl_ | _�_ ¯ ( _�, l, t, v_ ) = cos _θ_ ( _t_ ) = | <sup><u>[0</u></sup> [0 <sup>_,_</sup> _,_ <sup><u>0</u></sup> 0 <sup>_,_</sup> _,_ <sup><u>1]</u></sup> 1] <sup>_TT_</sup> ||⃗ <sup>·⃗</sup> _p_ <sup>_<u>p</u>_</sup> ( <sup><u>(</u></sup> _t_ <sup>_<u>t</u>_</sup> ) <sup><u>)</u></sup> <sup>_GG_</sup> | <sup><u>[0</u></sup> [0 <sup>_,_</sup> _,_ <sup><u>0</u></sup> 0 <sup>_,_</sup> _,_ <sup><u>1]</u></sup> 1] <sup>_TT_</sup> ||⃗ <sup>·⃗</sup> _p_ <sup>_<u>p</u>_</sup> ( <sup><u>(</u></sup> _t_ <sup>_<u>t</u>_</sup> ) <sup><u>)</u></sup> <sup>_GG_</sup> | <sup>=</sup> |⃗ <sup>_<u>p</u>_</sup> _p_ <sup>_<u>z</u>_</sup> ( <sup><u>(</u></sup> _t_ <sup>_<u>t</u>_</sup> ) <sup><u>)</u></sup> <sup>_GG_</sup> | _τ_ = <sup>|⃗</sup> <sup>_<u>dl</u>_</sup> <sup>|</sup> _v_ _dl_ =⃗ _Gl_ +1 −⃗ _Gl._ |⃗ _p_ ( _t_ ) <sup>_G_</sup> | _l_ ( _t_ ) = |⃗ _p_ ( _t_ ) <sup>_G_</sup> | _x_ ( _t_ ) <sup>′</sup> = <sup>_<u>h</u>_</sup> <sup><u>0</u></sup> <sup>_<u>px</u>_</sup> <sup><u>(</u></sup> <sup>_<u>t</u>_</sup> <sup><u>)</u></sup> <sup>_G_</sup> _pz_ ( _t_ ) <sup>_G_</sup> By dividing the _l_ -th segment into _K_ segments, the resulting coating thickness can be approximated from (4) as in _y_ ( _t_ ) <sup>′</sup> = <sup>_h_</sup> <sup><u>0</u></sup> <sup>_py_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_G_</sup> _pz_ ( _t_ ) <sup>_G_</sup> where:⃗ _p_ ( _t_ ) <sup>_G_</sup> = R ( _t_ ) <sup>_T_</sup> <sup>⃗</sup> _p_ - R ( _t_ ) <sup>_T_</sup> <sup>⃗</sup> _G_ ( _t_ ) = [ _px_ ( _t_ ) <sup>_G_</sup> _, py_ ( _t_ ) <sup>_G_</sup> _, pz_ ( _t_ ) <sup>_G_</sup> ] <sup>_T_</sup> _n_ ( _t_ ) <sup>_G_</sup> = R ( _t_ ) <sup>_T_</sup> <sup>⃗</sup> _n_ = [ _nx_ ( _t_ ) <sup>_G_</sup> _, ny_ ( _t_ ) <sup>_G_</sup> _, nz_ ( _t_ ) <sup>_G_</sup> ] <sup>_T_</sup> _._ Finally, the instantaneous coating thickness can be written as: _K_ _T_ ( _p, �, l, v_ ) ≈ _T_ <sup>˜</sup> ( _p, �, l, v_ ) = _k_ =0 with: _q_ ( _p,_ _�_ <sup>¯</sup> ( _�, l, tk_ _, v_ )) _�t,_ (5) _p_ = (⃗ _p,_ ⃗ _n_ ) _tk_ = _k�t_ _�t_ = <sup>_τ_</sup> _n_ <sup>=</sup> <sup>|⃗</sup> _vK_ <sup>_<u>dl</u>_</sup> <sup>|</sup> <sup>_._</sup> Therefore, the resulting coating thickness at⃗ _p_ for a given spraying stroke _�_ at constant speed _v_ is _q_ ( _p_ ⃗ _,_ ⃗ _n, ψ_ ( _t_ )) = _q_ 0 where: - _<u>h</u>_ <u>0</u> _<u>px</u>_ <u>(</u> _<u>t</u>_ <u>)</u> _G_ <u>0</u> _ppz_ ( _<u>xt</u>_ <u>()</u> _<u>t</u>_ <sup>_G_</sup> <u>)</u> _G_ <sup>_,_</sup> <sup>_h_</sup> _p_ <sup><u>0</u></sup> <sup>_p_</sup> _z_ ( <sup>_<u>y</u>_</sup> _t_ <sup>(</sup> ) <sup>_tG_</sup> <sup>)</sup> <sup>_G_</sup> _pz_ ( _t_ ) <sup>_G_</sup> ∗ _q_ 0 _,_ 1 _,_ (3) <u>(</u> _<u>h</u>_ <u>0)</u> <sup>2</sup> _q_ 0 _,_ 1 = ( _pz_ ( _t_ ) <sup>_G_</sup> ) <sup>3</sup> <sup>(−⃗</sup> <sup>_n_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_G_</sup> <sup>·⃗</sup> <sup>_p_</sup> <sup>(</sup> <sup>_t_</sup> <sup>)</sup> <sup>_G_</sup> <sup>)</sup> <sup>_._</sup> _q_ ( _p,_ _�_ <sup>¯</sup> ( _�, l, tk_ _, v_ )) _._ (6) _K_ _k_ =0 _L_ −1 |⃗ _dl_ | _l_ =0 Note that (3) is only valid when _pz_ ( _t_ ) <sup>_G_</sup> _>_ 0 (the surface is in front of the spray gun, not behind), and when _n_ ( _t_ ) <sup>_G_</sup> ·⃗ _p_ ( _t_ ) <sup>_G_</sup> _<_ 0 _._ _B._ _THICKNESS OVER A TRAJECTORY COMPOSED OF_ _SEVERAL STROKES_ In this manuscript, a spraying stroke (spray gun movement during which the gun is fully active) is considered planar if _T_ ˜ (⃗ _p,_ ⃗ _n, �, v_ ) = <sup><u>1</u></sup> _vK_ _T_ ˜ (⃗ _p,_ ⃗ _n, �, v_ ) = <sup>_<u>v</u>_</sup> <sup><u>0</u></sup> _T_ ˜ (⃗ _p,_ ⃗ _n, �, v_ 0) _._ (7) _v_ From the previous equations, it is evident that the resulting coating thickness of following a spraying trajectory composed of multiple spraying strokes is the sum of the resulting thickness of each stroke. Moreover, if the resulting thickness from following a certain stroke at a certain speed _v_ 0 is known, then it is known for all velocities, as shown in Another way to demonstrate this is to re-parametrize the integral in (4) from time to path length with _s_ = _vt_, _s_ ∈ [0 _,_ |⃗ _dl_ |] and _ds_ = _vdt_, then (4) can be written as does not guarantee identical normal vectors but rather that they follow a certain behavior within the region. To reduce the variation between normal vectors, a second segmentation based on the spatial data of the region is needed. Yu et al. [9] stated that simpler cross section contours (set of coordinates that describe local geometry and are used to generate the spraying strokes) can be found if such contours are orthogonal to the dominant eigenvector of the point cloud data; therefore, the concept of eigenvector coordinate system [9] is implemented here recursively to divide the regions into sub-regions. Let _P_ = {⃗ _p_ ∈ R <sup>3</sup> } be the set of centroids of the surface, the subset _Pi_ ⊆ _P_ of the centroids of the _i_ -th region (from the first segmentation), and _Pi,j_ the set that contains all the _j_ -th components of _Pi_ . Then, the covariance matrix _Mi_ of _Pi_ is _T_ (⃗ _p,_ ⃗ _n, �, l, v_ ) = <sup><u>1</u></sup> _v_ - |⃗ _dl_ | _q_ ( _p_ ⃗ _,_ ⃗ _n,_ _�_ <sup>¯</sup> ( _�, l, s_ )) _ds,_ (8) 0 then _�_ <sup>¯</sup> ( _�, l, s_ ) is _�_ ¯ ( _�, l, t, v_ ) = - _Gl_ + _s_ ⃗ <sup>_<u>dl</u>_</sup> |⃗ _dl_ | _,_ R _l_ R _x_ ( _sωl/_ |⃗ _dl_ |) Finally, as the focus of this methodology is complex concave geometries with tens of thousands of facets, the computation of the resulting coating thickness must include the obstruction of the surface with itself in the painting process; this work employs the ray-triangle intersection algorithm of Möller-Trumbore [32] for this purpose. That is, for every instantaneous coating thickness computed, it is crucial to ensure that there is a clear path between the spray gun center point and the point of interest, if the path is not clear, the instantaneous coating thickness on that point at that time is zero. III. SEGMENTATION ALGORITHM Very complex surfaces can be locally similar but completely different in far regions. The stroke direction has great impact on the resulting thickness, and two adjacent regions may require two completely different stroke directions. Therefore, this paper performs a two-step segmentation to break down the problem and to simplify the process of generating spraying strokes. The first segmentation process divides the surface to be painted into regions with low curvature variation. There are many methods to segment a mesh, in this context, the surface could also be segmented manually with the help of a skilled painter. Here, this first segmentation is achieved by implementing the segmentation based on the curvature tensor proposed by Lavoué et al. [33] to the stereo-lithography (STL) format of the surface to be painted. The mesh-segmentation method proposed in [33] comprises two main stages, both driven by curvature-tensor analysis, to decompose a 3D mesh into patches of near-constant curvature and well-defined boundaries. First, the ‘‘constant curvature region segmentation’’ stage identifies sharp edges, computes the discrete curvature tensor at each vertex, clusters the principal curvatures, assigns vertices to connected patches by cluster membership, and finally merges adjacent patches via a region-growing process to form uniformcurvature regions. Second, the ‘‘boundary rectification’’ stage refines these regions by aligning their boundary edges with the principal curvature directions. This method produces smoothly bounded regions while simultaneously detecting both sharp edges and also subtle curvature transitions. The result of applying the mesh segmentation algorithm based on the curvature tensor to the surface is a group of regions with similar curvature. Even though the curvature and normal vectors are related, similar curvature along the region    _._ (9) _Mi_ =  cov( _Pi,x, Pi,x_ ) cov( _Pi,x, Pi,y_ ) cov( _Pi,x, Pi,z_ ) cov( _Pi,y, Pi,x_ ) cov( _Pi,y, Pi,y_ ) cov( _Pi,y, Pi,z_ ) cov( _Pi,z, Pi,x_ ) cov( _Pi,z, Pi,y_ ) cov( _Pi,z, Pi,z_ ) The covariance matrix can be decomposed into the eigenvalues _Vi,d_ and their corresponding eigenvectors _Vi,e_, with _Vi,e_ a 3 × 3 matrix formed by the normal eigenvectors in column form. As the covariance matrix _Mi_ is symmetric, the matrix _Vi,e_ is orthonormal and can be employed as a coordinate system. In this article, the following convention is taken: _x_ ˆ _i,e_ is the dominant eigenvector, _y_ ˆ _i,e_ is the second dominant eigenvector, _z_ ˆ _i,e_ = _x_ ˆ _i,e_ × _y_ ˆ _i,e_, and _Ri,e_ = [ _x_ ˆ _i,e,_ ˆ _yi,e,_ ˆ _zi,e_ ] is the eigenvector rotation matrix with relative to the surface coordinate system { _S_ }. Finally, this new coordinate system has its origin at the barycenter _Bi_ of _Pi_ . As the optimal value of _α_ from (2) is 0 <sup>◦</sup> (see Fig. 2), the base eigenvector coordinate system will be rotated to set the angle between its _z_ ˆ _i,e_ and the area-weighted average normal vector _n_ ˆ _i,µ_ of the region as close to 180 <sup>◦</sup> as possible. For this purpose, first, the eigenvector coordinate system of the region is rotated around its _x_ -axis. The resulting eigenvector coordinate system of the _i_ -th segmented region in the homogeneous transformation matrix form is = - _Ri_ _Bi_ 0¯ 1 _,_ (10) - _Ri,eRx_ ( _ϕi,_ 1) _Bi_ 0¯ 1 _k_ ∈region _i_ area _k_ ⃗ _nk_ where:⃗ _Ti_ = _ni,µ_ = ( area _k_ ) <sup>−1</sup> _k_ ∈region _i_ _n_ ˆ _i,µ_ = _R_ <sup>_T_</sup> _i,e_ <sup>(⃗</sup> <sup>_ni,µ/_</sup> <sup>|⃗</sup> <sup>_ni,µ_</sup> <sup>|)</sup> _ϕi,_ 1 = atan2(− _ni,µ,y,_ - _ni,µ,z_ ) _Rx_ := Rotation around _x_ - axis _._ _A._ _RECURSIVE SEGMENTATION_ Once the eigenvector coordinate system for the _i_ -th region { _Ti_ } is computed, the region is split into two sub-regions. If the _x_ component of a given centroid facet coordinates (in the _i_ -th region) described relative to { _Ti_ } is less than zero, then it belongs to sub-region1, else it belongs to sub-region2. In this second stage, for every new sub-region, a new coordinate system is computed. First eigenvector coordinate system _Ti_ of the _i_ -th region is centered at the barycenter _Bi,j_ of the points belonging to the _j_ -th sub-region. After that, it is rotated around its _y_ -axis in order to set its _yz_ plane as parallel as possible to the mean normal vector of the sub-region. This new coordinate system is expressed as in _,_ (11) - _RiRy_ ( _ϕi,_ 2) _Bi,j_ 0¯ 1 area _k_ ⃗ _nk_ ) where:⃗ _ni,j,µ_ = ( _Ti,j_ = _k_ ∈sub-region _j_ area _k_ ) <sup>−1</sup> _k_ ∈sub-region _j_ _n_ ˆ _i,j,µ_ = _R_ <sup>_T_</sup> _i_ <sup>(</sup> <sup>_n_</sup> <sup>⃗</sup> <sup>_i,j,µ/_</sup> <sup>|⃗</sup> <sup>_ni,j,µ_</sup> <sup>|)</sup> _ϕi,_ 2 = atan2(− _ni,j,µ,x,_ - _ni,j,µ,z_ ) _Ry_ := Rotation around _y_ - axis _._ Finally, each sub-region is divided into smaller sub-regions employing now { _Ti,j_ } as the base coordinate system until the desired number of sub-regions is reached. The result of applying this method is a region divided into sub-regions with low normal vector deviation and a transformation matrix whose _y_ -axis is aligned to the optimal stroke direction and _z_ axis is opposite to the area-weighted average normal vector of the sub-region. IV. SPRAYING STROKE GENERATION _A._ _THE CONTOURS_ With the surface to be painted segmented into regions and each region segmented into sub-regions, each sub-region will be ‘‘sliced’’ with multiple parallel and equally spaced planes to find contours that describe the local geometry of the sub-region. For each sub-region _j_ in each region _i_, the set of parallel slicing planes are planes that are parallel to the _yz_ plane of its eigenvector coordinate system { _Ti,j_ } (see Fig. 3) with constant distance between them _�x_ (in this paper, _�x_ = 20 mm); that is, the eigenvector coordinate system { _Ti,j_ } of the sub-region is offset along its _x_ -axis and the offset _yz_ planes are employed to slice the region, this is named the slicing eigenvector coordinate system and it is expressed in its homogeneous transformation matrix form as FIGURE 3. Slicing plane. in such a way that the point sequence correctly represents the geometry locally; if the total length of the contour or the distance between the first and last contour points is less than a certain threshold, the contour is discarded. _B._ _PLANAR STROKE GENERATION_ At this point, the sets of contours and the homogeneous transformation matrices _Ti,j,k_ that generated them are known. Although the contour points are usually offset in the direction of their normal vectors, applying that method to very complex concave surfaces leads to impossible trajectories with multiple collisions with the surface, infinite curvature, and loops. In this paper, a planar cubic Bézier curve is optimized to outline the spraying stroke, i.e., the way points that conform the stroke will be points on the curve, not the curve itself. This allows producing a vast set of strokes with just four 2D coordinates while controlling the curvature, loops, and collisions. The purpose of the curves is to generate _n_ way points with fixed parametric distance _�τ_ . Let B = {⃗ _bj_ ∈ R <sup>3</sup> : _j_ = [0 _,_ 1 _,_ 2 _,_ 3]} the set of four control points of the cubic Bézier curve. Then, such curve can be defined as _B_ ( _τ_ ) = (1 − _τ_ ) <sup>3⃗</sup> _b_ 0 + 3(1 − _τ_ ) <sup>2</sup> _τ_ ⃗ _b_ 1 + 3(1 − _τ_ ) _τ_ <sup>2⃗</sup> _b_ 2 + _τ_ <sup>3⃗</sup> _b_ 3 _,_ 0 ≤ _τ_ ≤ 1 _._ (13) Subsequently, its derivative with respect to _τ_ is _B_ <sup>′</sup> ( _τ_ ) = 3(1 − _τ_ ) <sup>2</sup> ( _b_ ⃗ 1 −⃗ _b_ 0) + 6(1 − _τ_ ) _τ_ ( _b_ ⃗ 2 −⃗ _b_ 1) + 3 _τ_ <sup>2</sup> ( _b_ ⃗ 3 −⃗ _b_ 2) _,_ 0 ≤ _τ_ ≤ 1 _._ (14) Since the curve will form a planar spraying stroke contained in the _yz_ plane of the corresponding eigenvector coordinate system { _Ti,j,k_ }, it is easier to describe the via points relative to { _Ti,j,k_ }. Therefore, a via point of the spray gun along the Bézier curve described relative to { _Ti,j,k_ } is defined, _Ti,j,k_ = _Ti,j_ - _I_ 3×3 [ _xk_ _,_ 0 _,_ 0] _T_ 0¯ 1 _,_ (12) where: _I_ 3×3 := Identity matrix of dimension 3 × 3 _xk_ := The offset, _x_ min + _k�x_ ≤ _x_ max _x_ min _, x_ max := respectively, the minimum and maximum _x_ components of the sub-region facets described relative to { _Ti,j_ } _._ It is important to note that the slicing is not performed on the whole surface, if the _j_ -th sub-region of the _i_ -th region is being sliced, only the region spatial data is taken into consideration. Moreover, each contour should be reordered in its homogeneous transformation matrix form, as  The Stone-DeRose method goes as follows: 1) transform the control points to what the authors call the canonical form; 2) depending on the region of the two-dimensional (2D) canonical map (see Fig. 4) where the fourth control point⃗ _b_ 3 (in its canonical form) is located, the curve will present one inflection, two inflections, a cusp, a loop, or will be a pure arc. Of course, as the canonical map was developed only in two dimensions, this method only applies to 2D curves; since the Bézier curves in this paper are embedded in a plane, they can be interpreted as two-dimensional curves. The regions of the canonical map are defined by four equations (17)-(20), such regions are shown in Fig. 4. In practice, not every set of control points can be transformed into the canonical form, the authors highlighted three cases where the cubic Bézier mapping is degenerate: 1) the curve is a straight line; 2) all the control points are coincident; 3) the internal control points⃗ _b_ 1 and⃗ _b_ 2 are coincident. _f_ ( _x_ ) = <sup>−</sup> <sup>_<u>x</u>_</sup> <sup>2 + 2</sup> <sup>_<u>x</u>_</sup> <sup>+ 3</sup> _,_ _x_ _<_ 1 (17) <u>4</u> _ψ_ <sup>_i,j,k_</sup> ( _τ, r_ ) = where: _r_ 0 0 0 0 _B_ ` <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) - _rB_ <sup>`</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _y_ <sup>_,j,k_</sup> 0 _B_ ` <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) - _rB_ <sup>`</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) 0 _B_ ` <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _rB_ <sup>`</sup> <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ )  <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) - _rB_ <sup>`</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _rB_ <sup>`</sup> <sup>_i_</sup> _y_ <sup>_,j,k_</sup> <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _z_ <sup>_,j,k_</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _y_ <sup>_,j,k_</sup> 0 _B_ ` <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) _rB_ <sup>`</sup> <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) _B_ <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ ) 0 0 0 1   _,_ (15) _B_ <sup>_i,j,k_</sup> ( _τ_ ) = [ _B_ <sup>_i_</sup> _x_ <sup>_,j,k_</sup> <sup>_i_</sup> _x_ <sup>_,j,k_</sup> ( _τ_ ) _, B_ <sup>_i_</sup> _y_ <sup>_,j,k_</sup> <sup>_i_</sup> _y_ <sup>_,j,k_</sup> ( _τ_ ) _, B_ <sup>_i_</sup> _z_ <sup>_,j,k_</sup> <sup>_i_</sup> _z_ <sup>_,j,k_</sup> ( _τ_ )] <sup>_T_</sup> _B_ ` <sup>_i,j,k_</sup> ( _τ_ ) =⃗ <sup>_<u>B</u>_</sup> <sup>′</sup> <sup>_i,j,k_</sup> <sup><u>(</u></sup> <sup>_τ_</sup> <sup><u>)</u></sup> |⃗ _B_ <sup>′</sup> <sup>_i,j,k_</sup> ( _τ_ )| _._ In this sense, the _y_ -axis of the spray gun is the unit tangent vector to the Bézier curve, while its _z_ -axis is orthogonal to the _y_ -axis, both fully defined in the _yz_ plane of { _Ti,j,k_ }; the _x_ -axis is orthogonal to the plane. Additionally, the control parameter _r_ is zero or one and manipulates the spraying direction ( _z_ ˆ of { _G_ }) according to the right-hand rule. Therefore, a planar spraying stroke _�_ based on cubic Bézier curves with fixed control points B and fixed control point _r_ can be defined as _�_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) = { _ψl_ <sup>_i,j,k_</sup> ( _τ_ 0 + _l�τ, r_ ) : _l_ ≤ _L, l_ ∈ Z <sup>+</sup> } _,_ (16) provided that: 0 ≤ _τ_ 0 + _l�τ_ ≤ 1 _,_ 0 ≤ _τ_ 0 _<_ 1 _,_ 0 _< �τ_ ≤ 1 _,_ 1 ≤ _L_ ≤ _�τ_ <sup>−1</sup> _,_ _�τ_ <sup>−1</sup> ∈ Z <sup>+</sup> _,_ where _�τ_ is the constant parametric distance, while _τ_ 0 is the lower boundary of the parameter of the Bézier curve, and Z <sup>+</sup> is the set of integers greater than zero. 1) BÉZIER CONTROL As the objective of this paper is to generate feasible seed spraying trajectories, the generated spraying strokes must be smooth, with no loops and with no collisions with the surface. The three constraints limit the solution space to produce strokes that are most likely to be feasible for a given robot. The third-order Bézier curves are employed in this paper because of its versatility to create complex curves and because their characteristics can be easily found with their control points. Stone and DeRose [34] developed a method to determine the characteristics of cubic Bézier curves within the boundary 0 ≤ _τ_ ≤ 1. The characteristics of these curves are loops (intersection of the curve with itself), cusps (points where its first derivative is discontinuous), and inflection points (points where the curvature is zero). A nondegenerate parametric third-order curve can present, at most, two inflection points, one loop, or one cusp; furthermore, these characteristics are mutually exclusive [34]. _y_ ( _x_ ) = 1 (20) In addition to the characteristics of the curve, the curvature of the proposed curve also determines the feasibility of the stroke. In this context, the curvature takes on great relevance because of its relationship with change of direction of the tangent vector. As the _y_ -axes of the stroke way points are the unit tangent vector of the curve, greater curvatures demand grater accelerations to keep a constant velocity, which in turn makes the proposed path less feasible. Therefore, controlling the curvature of the proposed curve is necessary to find feasible spraying strokes. For a given 2D parametric curve, the curvature _κ_ is _κ_ ( B _, τ_ ) = <sup>_<u>x</u>_</sup> <sup>¨(</sup> <sup>_τ_</sup> <sup><u>)</u></sup> <sup>_<u>y</u>_</sup> <sup>˙(</sup> <sup>_τ_</sup> <sup><u>) −¨</u></sup> <sup>_<u>y</u>_</sup> <sup><u>(</u></sup> <sup>_τ_</sup> <sup><u>)</u></sup> <sup>_<u>x</u>_</sup> <sup>˙(</sup> <sup>_τ_</sup> <sup><u>)</u></sup> _._ (21) ~~<u>�</u>~~ _x_ ˙( _τ_ ) <sup>2</sup> + ˙ _y_ ( _τ_ ) <sup>2</sup> With the characteristics of the curve known, the curve can be controlled to behave in a manner that is useful for this context. In the optimization step, this information will be used as constraints to the control points and to ensure a feasible solution. V. OPTIMIZATION OF SPRAYING STROKES Ideally, a spraying stroke paints a flat surface at a constant distance and speed, while the spraying direction remains orthogonal to the surface, as shown in Fig. 5. In said figure, it can be seen that the resulting coating thickness is smooth and completely symmetrical, varying only along the _x_ -axis, this means that a set of equally spaced spraying strokes will result in an even coating across the surface. Therefore, an optimal planar spraying stroke is a stroke whose resulting coating thickness is similar to that which _g_ ( _x_ ) = ~~�~~ <u>3(4</u> _<u>x</u>_ - _<u>x</u>_ <sup>2</sup> <u>) −</u> _<u>x</u>_ _,_ 0 ≤ _x_ ≤ 1 (18) 2 _h_ ( _x_ ) = <sup>−</sup> <sup>_<u>x</u>_</sup> <sup>2 + 3</sup> <sup>_<u>x</u>_</sup> <sup><u>3</u></sup> <sup>_<u>x</u>_</sup> _,_ _x_ ≤ 0 (19) 3 FIGURE 4. Bézier canonical map. FIGURE 5. Resulting coating thickness over a flat plane at constant speed _v_ = 100 mm/s with a constant gun to target distance _h_ = 220 mm. Observe that the spraying cone starts before the surface and ends after the plane to ensure uniform coating. would be encountered when painting a plane at the same velocity and distance at which the curved stroke will be made; in addition, said curved stroke must avoid high curvatures, loops, collisions with the surface, and more than one inflection point. Since the resulting coating thickness of following a certain stroke at different velocities is proportional to the base velocity _v_ 0, it is not necessary to optimize said velocity at this stage. However, changing the gun to target distance (mean distance between the spray gun and the surface in the _z_ -axis of the spray gun) completely changes the coating distribution, increasing or reducing the area affected. For this reason, one Varying the gun to target distances _h_ produce different parameters ( _T_ max, _a_ and _β_ ), which results in unique characteristic distributions, as shown in Fig. 6; therefore, for every gun to target distance _h_ desired to be part of the global optimization (see section VI), a new target coating thickness distribution will be needed. Then, the target coating thickness distribution will be symmetrical to the _y_ -axis of the slicing eigenvector coordinate system of interest; in Fig. 7 two examples of target coating thickness distributions are shown on the same surface but different gun to target distances _h_ . When computing the target coating thickness distribution for the _k_ -th slicing eigenvector coordinate system in the _j_ -th subregion in the _i_ -th region ({ _Ti,j,k_ }), the objective will be to paint optimal spraying stroke will be found for each gun to target distance desired by the user for each (not discarded) contour. _A._ _CHARACTERISTIC COATING THICKNESS DISTRIBUTION_ In order to provide a target coating thickness distribution for a given gun to target distance, it is necessary to know such distribution. For that, a simulation can be executed for a linear spraying stroke at constant base velocity _v_ 0 and constant gun to target distance _h_ over a plane. As shown in Fig. 5, the coating distribution is symmetric along the _y_ -axis, hence, a one-dimensional beta distribution model [28] can be fitted to the simulation data and used as the characteristic coating thickness distribution: (22) _<u>x</u>_ <sup>2</sup> 0 _,_ _a_ <sup>2</sup> <sup>≥</sup> <sup>1</sup> <sup>_._</sup> - _β_ −1 _<u>x</u>_ <sup>2</sup> _,_ _a_ <sup>2</sup> <sup>_<_</sup> <sup>1</sup> _T_ max �1 − <sup>_<u>x</u>_</sup> <sup>2</sup> _a_ <sup>2</sup> _Th_ ( _x_ ) =    FIGURE 6. Characteristic distribution at different gun to target distances. the region as close to the target coating thickness distribution as possible while affecting other regions as low as possible, which means that the target thickness (in this stage) is the characteristic coating thickness distribution on the _i_ -th region of interest and zero micrometers on the remaining regions. _B._ _OBJECTIVE FUNCTION_ Once the characteristic coating distribution curves for the desired gun to target distances are known, a planar spraying stroke based on third-order Bézier curves can be optimized for every valid contour and for every desired gun to target distance. Let _P_ <sup>_i,j,k_</sup> be the set of facet centroids coordinates in the surface to be painted described relative to the slicing eigenvector coordinate system { _Ti,j,k_ }; consequently, _P_ <sup>_i_</sup> _i_ <sup>_,j,k_</sup> ⊆ _P_ <sup>_i,j,k_</sup> and _P_ <sup>_i_</sup> _i_ <sup>_,_</sup> _,_ <sup>_j_</sup> _j_ <sup>_,k_</sup> ⊆ _P_ <sup>_i_</sup> _i_ <sup>_,j,k_</sup> are (respectively) the set of facets centroids coordinates member of the _i_ -th region and the set of facets centroids coordinates member of the _j_ -th sub-region in the _i_ -th region, both described relative to { _Ti,j,k_ }. Then, the target coating thickness distribution for a given gun to target distance _h_ can be described employing (22), resulting in the target coating thickness for the _m_ -th facet in the surface to be painted _th,m_ as in FIGURE 7. Two examples of target coating thickness distribution for different gun to target distances at the same slicing plane (gray plane), (a) 150 mm and (b) 220 mm. Red, green and blue arrows represent (respectively) the _x_, _y_, and _z_ axes of the slicing eigenvector coordinate system. <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ∈ _P_ <sup>_i_</sup> _i_ <sup>_,j,k_</sup> <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ∈ _/_ _P_ <sup>_i_</sup> _i_ <sup>_,j,k_</sup> _i_ (23) <sup>_i_</sup> _i_ <sup>_,j,k_</sup> _,_ of the _m_ -th facet, _M_ is the total number of facets in the surface to be painted,⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> and⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> are, respectively, the coordinates and normal vector of the _m_ -th facet described relatively to { _Ti,j,k_ }, _v_ 0 is the base velocity at which all optimizations will be performed in this stage. Additionally, function _�_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) is described in (16). Two important problems arise in the previous objective function. Firstly, it does not take into account that the area of the surface to be painted with zero target thickness _th,m_ could be significantly greater than the area with _th,m_ _>_ 0, resulting in strokes that do not paint at all as long as they do not paint the undesired areas ( _th,m_ = 0). Secondly, (24) does not take into account the total length of the spraying strokes; Although the present work is oriented to the coating quality and not to the efficiency of the painting process, leaving the total length of the spraying stroke unrestricted could lead to spraying strokes that waste too much paint and time without having any impact on the objective function. _th,m_ = - _Th_ ( _p_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> _m,x_ <sup>)</sup> <sup>_,_</sup> _m_ _i_ 0 _,_ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ∈ _/_ _P_ <sup>_i_</sup> _i_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> <sup>)</sup> <sup>_,_</sup> _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> where,⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> = [ _p_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> <sup>_, pi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_, pi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> where,⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> = [ _p_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> <sup>_, pi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_, pi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>]</sup> <sup>_T_</sup> <sup>are the coordinates of the</sup> _m_ -th facet centroid described relative to { _Ti,j,k_ }, and _Th_ ( _p_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _x_ <sup>_k_</sup> <sup>)</sup> is the characteristic coating thickness distribution at gun to target distance _h_ at a given _x_ coordinate. Consequently, the objective function could be described as the area-weighted mean square error (MSE) between the resulting thickness and the target thickness distribution, as in arg min _Eh_ ( B <sup>_i,j,k_</sup> ) <u>1</u> = ( <sup><u>�</u></sup> <sup>_M_</sup> _m_ <sup>_M_</sup> _m_ =1 <sup>area</sup> <sup>_m_</sup> <sup>)</sup> _M_ _m_ =1 area _m_ [ _T_ <sup>˜</sup> (⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _, �_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) _, v_ 0) − _th,m_ ] <sup>2</sup> _,_ (24) where, B <sup>_i,j,k_</sup> is the set of control points for a third-order Bézier curve (described relative to { _Ti,j,k_ }), area _m_ is the area The objective function for this step of the framework takes into account the total stroke length and the weight of the painted areas in assessing the quality of the proposed stroke. Let _�_ = {area _m_ ∈ R : _m_ ≤ _M_ _, m_ ∈ Z <sup>+</sup> } the set of areas of the facets in the surface to be painted, _�_ =0 ⊆ _�_ and _�_ ̸=0 ⊆ _�_ be the sub-sets of facet areas with target thickness zero and not zero, respectively. Then, the weight _wm_ of each facet in the objective function is determined by (25), where _w_ =0 and _w_ ̸=0 are the weights for facet areas with target thickness zero and greater than zero, respectively. and _E_ ln( B <sup>_i,j,k_</sup> _, τ_ 0 _, L_ ) = _L_ _l_ =0 |⃗ _B_ <sup>_i,j,k_</sup> ( _τ_ 0 + ( _l_ + 1) _�τ_ ) <u>(</u> _w_ ̸=0)area _<u>m</u>_ <u>�area</u> _m_ ∈ _�_ ̸=0 <sup>area</sup> <sup>_m_</sup> <u>(</u> _<u>w</u>_ =0)area _<u>m</u>_ <u>�area</u> _m_ ∈ _�_ =0 <sup>area</sup> <sup>_m_</sup> −⃗ _B_ <sup>_i,j,k_</sup> ( _τ_ 0 + _l�τ_ )| _._ (31) _C._ _CONSTRAINTS_ Although the objective function described in the previous subsection can output strokes with resulting coating thickness close to the target distribution, it can also lead to curves with collisions and loops, as it does not consider the Bézier characteristics or possible collisions with the surface, those will be considered constraints in the optimization problem. Firstly, for collisions with the surface, the Euclidean distance between each facet and each gun position of the stroke at every instant is evaluated, if the minimum distance min(|⃗ _G_ ( _t_ ) −⃗ _p_ |) is less than a given threshold _d_ th, the path is discarded. Secondly, to evaluate the Bézier characteristics, the Bézier control points are mapped into their canonical form [34] and if the canonical position of the fourth control point⃗ _b_ 3 on the canonical map is in unwanted regions, the path is discarded. Therefore, the constraints are established as inequalities in (32), where _g_ 1 is the inequality for the Bézier characteristics, described in (33), given that _xc_ and _yc_ are components of the canonical form of⃗ _b_ 3, and _g_ ( _x_ ) and _h_ ( _x_ ) are the functions described in (18) and (19), respectively. _wm_ =    _,_ area _m_ ∈ _�_ ̸=0 _,_ area _m_ ∈ _�_ =0 (25) Additionally, two penalty functions are employed. On the first hand, the percentage of the covered area whose target thickness is not zero is taken into account, the smaller the total covered area the greater the penalty, when the covered area is zero the penalty infinite, as that stroke is useless; for cases where the left uncovered area is small, the penalty barely affects, this penalty is described in (26). Where, _ξm_ is zero if the thickness is zero and one if the thickness is greater than zero, as described in (27). _λc_ = 1 − ln - <sup>�</sup> area _m_ ∈ _�_ ̸=0 <sup>_ξm_</sup> <sup>area</sup> <sup>_m_</sup> <u>�area</u> _m_ ∈ _�_ ̸=0 <sup>area</sup> <sup>_m_</sup> (26) ≤ 0 (32) - 1 _,_ _T_ ˜ (⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> - _g_ 1 - min(|⃗ _G_ −⃗ _p_ |) + _d_ th    _ξm_ = 1 _,_ _T_ ˜ (⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ ⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _, �_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) _, v_ 0) _>_ 0 0 _,_ _T_ ˜ (⃗ _p_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ ⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _, �_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) _, v_ 0) = 0 ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ ⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ ⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _, �_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) _, v_ 0) = 0 - _yc_ + 1 _,_ _yc_ _>_ 1 - _xc_ + 1 _,_ _xc_ _>_ 1 _, yc_ ≤ 1 _yc_ - _g_ ( _xc_ ) _,_ 0 ≤ _xc_ ≤ 1 _, yc_ ≤ 1 _yc_ - _h_ ( _xc_ ) _,_ _xc_ _<_ 0 _, yc_ ≤ 1 −1 _,_ Stroke is truly linear 1 _,_ Any other case (27) On the other hand, (28) takes into account the maximum absolute curvature of the curve, if it is greater than a a given curvature threshold _κ_ th, a big penalty is added to the objective function. With these penalties, the optimization method is forced to find a solution with high coverage and limited curvature. _g_ ( B ) = _g_ 1 = (33) _λκ_ = - 0 _,_ max(| _κ_ ( B <sup>_i,j,k_</sup> _, τ_ )|) _< κ_ th 1000 _,_ max(| _κ_ ( B <sup>_i,j,k_</sup> _, τ_ )|) ≥ _κ_ th (28) The last two cases of (33) are worth clarifying. First, a Bézier stroke is truly linear if its maximum absolute curvature max(| _κ_ ( B ) _, τ_ |) is zero and the distance between endpoints is the same as the total path length. Second, if the cubic Bézier curve cannot be mapped into its canonical form and it is not a linear stroke, then the stroke is discarded; this does not mean that the proposed stroke is infeasible, however, since they occur when the control points are exactly collinear or some control points are exactly coincident, an algorithm to take these cases into account was not developed. Additionally, the arguments B, _τ_ 0, and _L_ of the objective function are constrained to specific intervals, these intervals will be different in each optimization step and will be discussed in the appropriate sections. _D._ _OPTIMAL STROKE GENERATION_ The generation method for optimal planar spraying strokes developed here is composed of six steps and summarized in Fig. 8. First, determine if the sub-region is ‘‘paintable’’ with Finally, the total stroke length and the coating thickness error are employed in the same objective function by using the weighted sum method, with _w_ er the weight of the coating thickness error and _w_ ln the weight of the stroke length, as described in arg min _Eh_ ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L_ ) = _λcw_ er _E_ er( B <sup>_i,j,k_</sup> _, τ_ 0 _, L_ ) + _w_ ln _E_ ln( B <sup>_i,j,k_</sup> _, τ_ 0 _, L_ ) + _λκ_ ( B <sup>_i,j,k_</sup> ) _,_ (29) where: _E_ er( B <sup>_i,j,k_</sup> _, τ_ 0 _, L_ ) = _M_ _m_ =0 _wm_ ( _T_ <sup>˜</sup> ( _p_ ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ ⃗ _n_ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j,k_</sup> _,_ _�_ <sup>_i,j,k_</sup> ( B <sup>_i,j,k_</sup> _, τ_ 0 _, L, �τ, r_ ) _, v_ 0) − _th,m_ ) <sup>2</sup> (30) FIGURE 8. Generation of optimal planar spraying stroke. the current slicing plane, that is, a planar spraying stroke embedded within the slicing plane can be found such that the portion painted of the sub-region is greater than a given threshold (if there is too much obstruction, even an optimized planar stroke would perform poorly). Second, if the subregion is ‘‘paintable’’, optimize a linear spraying stroke, that is, keep the Bézier control points collinear. Right after, a cubic Bézier stroke is optimized employing surrogate optimization with _τ_ 0 and _L_ fixed at zero and 1 _/�τ_ respectively; if a feasible stroke was not found within the time and iterations limits, the linear stroke previously found will be employed as an initial searching point and the surrogate optimization will be restarted. Subsequently, a pattern search optimization will perform a fine adjustment to the previously found Bézier control points. Then, a ‘‘trimming’’ optimization will change _τ_ 0 and _L_ from the resulting Bézier stroke to find a stroke that achieves the best result without wasting too much paint and time. Finally, the optimal planar spraying stroke will be chosen between the trimmed stroke and the initial linear stroke (depending on their performance), the selected stroke will be transformed to be described relative to the surface coordinate system { _S_ } and stored for the final optimization step. 1) ‘‘PAINTABLE’’ SUB-REGIONS As each proposed stroke has to be evaluated employing the ray-triangle intersection algorithm, this stroke generation process is quite slow. Therefore, if for a given contour at a given distance it is very unlikely to find an optimal planar stroke, no time should be wasted trying to find an optimal stroke and move on to the next contour. In order to determine if a sub-region is ‘‘paintable’’, an initial linear stroke will be simulated and the total coverage of the sub-region will determine whether the sub-region is ‘‘paintable’’ or not. Let B <sup>_i_</sup> 0 <sup>_,j,k_</sup> be the initial Bézier stroke with TABLE 1. Parameters for optimal stroke generation. control points TABLE 2. Parameters for global optimization. As the task in this step is to find a linear stroke, the optimization only depends on four variables _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>,</sup> <sup>_bi_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>,</sup> <sup>_bi_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>,</sup> _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>⃗</sup> <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>, the internal control points⃗</sup> <sup>_b_</sup> 1 <sup>_i,j,k_</sup> and⃗ _b_ <sup>_i_</sup> 2 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>,</sup> <sup>_bi_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>,</sup> <sup>_bi_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>,</sup> ⃗ _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>, the internal control points⃗</sup> <sup>_b_</sup> 1 <sup>_i,j,k_</sup> and⃗ _b_ <sup>_i_</sup> 2 <sup>_,j,k_</sup> are functions of the remaining control points (to ensure a linear stroke). Moreover, because the spraying stroke generated is planar, the _x_ components of the control points are set to zero. _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _x_ <sup>_,k_</sup> _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> _τ_ 0 = 0 _L_ = 1 _/�τ_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> ⃗ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _x_ <sup>_,k_</sup> = 0 _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>∈</sup> [min( <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> ⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> _b_ <sup>_i_</sup> 1 <sup>_,j,k_</sup> _b_ <sup>_i_</sup> 2 <sup>_,j,k_</sup> _b_ <sup>_i_</sup> 3 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> + [0 _,_ - _bβ_ _,_ −0 _._ 75 _h_ ] <sup>_T_</sup> _,_ <sup>_i_</sup> _M_ <sup>_,j,k_</sup> + [0 _, bβ_ _,_ −0 _._ 75 _h_ ] <sup>_T_</sup> _,_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> =⃗ _q_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 1 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 2 <sup>_,j,k_</sup> = _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 3 <sup>_,j,k_</sup> =⃗ _q_ <sup>_i_</sup> _M_ <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> + _._ 25( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> + _._ 75( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> ) _,_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ) _,_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>_i_</sup> 1 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 2 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> + 0 _._ 25( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> <sup>_i_</sup> 0 <sup>_,j,k_</sup> + 0 _._ 75( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> _b_ <sup>_i_</sup> 0 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> _b_ <sup>_i_</sup> 1 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> + 0 _._ 25( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ) (34) <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> where⃗ _q_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ⃗ <sup>_i_</sup> 0 <sup>_,j,k_</sup>,⃗ _q_ <sup>_i_</sup> _M_ <sup>_,j,k_</sup> <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> where⃗ _q_ <sup>_i_</sup> 0 <sup>_,j,k_</sup>,⃗ _q_ <sup>_i_</sup> _M_ <sup>_,j,k_</sup> <sup>,</sup> <sup>_h_</sup> <sup>,</sup> <sup>and</sup> <sup>_bβ_</sup> <sup>are</sup> <sup>the</sup> <sup>first</sup> <sup>contour</sup> <sup>point,</sup> <sup>the</sup> last contour point, the desired gun to target distance and the double beta parameter _b_, respectively. Initially, the control parameter _r_ (which controls the _x_ -axis and _z_ -axis of the spray gun coordinate system) is _r_ = 1, if the dot product of the resulting _z_ -axis of this Bézier stroke with the mean normal vector _n_ ˆ <sup>_i,j,k_</sup> _i,j,µ_ <sup>of</sup> <sup>the</sup> <sup>sub-region</sup> <sup>defined</sup> <sup>relative</sup> <sup>to</sup> <sup>{</sup> <sup>_Ti,j,k_</sup> <sup>}</sup> <sup>is</sup> greater than or equal to zero, then the control parameter is _r_ = −1, the remaining optimization steps for this contour will employ the same control parameter _r_ . Finally, the initial stroke B <sup>_i_</sup> 0 <sup>_,j,k_</sup> is simulated and if the coverage portion of _�_ ̸=0 is lower than a given threshold _�_ th, then the contour of that gun to target distance is deemed not ‘‘paintable’’, and the process continues with the next contour. In this paper, the threshold is _�_ th = 0 _._ 1. Additionally, if the total length of the contour is less than a given threshold, or the distance between the first and last contour points is lower than a given threshold, the contour will be discarded, in this manuscript both thresholds are 20 mm.    _b_ <sup>_i_</sup> 1 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> + 0 _._ 25( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ) _b_ <sup>_i_</sup> 2 <sup>_,j,k_</sup> =⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> + 0 _._ 75( _b_ ⃗ <sup>_i_</sup> 3 <sup>_,j,k_</sup> −⃗ _b_ <sup>_i_</sup> 0 <sup>_,j,k_</sup> ) _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _x_ <sup>_,k_</sup> = 0 _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _x_ <sup>_,k_</sup> = 0 _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _y_ <sup>_,k_</sup> <sup>∈</sup> [min( _b_ <sup>_i_</sup> 3 <sup>_,_</sup> _,_ <sup>_j_</sup> _z_ <sup>_,k_</sup> Finally, the initial stroke B <sup>_i_</sup> 0 <sup>_,j,k_</sup> 2) OPTIMAL LINEAR STROKE In this step, a linear stroke is optimized and the initial stroke B 0 from the previous step is employed as an initial searching point. The surrogate optimization method is performed in conjunction with the objective function in (29). The boundaries of the arguments of (29) are presented in (34), where min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _λ_ <sup>_k_</sup> <sup>)</sup> <sup>and</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _λ_ <sup>_k_</sup> <sup>)</sup> <sup>are,</sup> <sup>respectively,</sup> the minimum and maximum value of the _λ_ -th component of all points conforming the contour, while _h_ 0 is the double beta parameter _h_ 0 (gun to target distance from the experiment to obtain the characteristic coating thickness distribution). Employing surrogate optimization in this step allows to find a very good solution with few function evaluations. In addition, if the sub-region to be painted is a plane, this step is more likely to find the optimal spraying stroke, provided that the linear stroke has no collisions with the surface. This step is finished when the surrogate optimization method converges or reaches the function evaluation limit, in this step, it is 120. 3) GENERATE OPTIMAL BÉZIER STROKE Once the optimal linear stroke has been generated, a new optimal Bézier stroke is generated employing the surrogate optimization method. In contrast to the previous step, this optimization depends on eight variables, the _y_ and _z_ components of the four control points of the cubic Bézier curve. The boundaries of the objective function arguments are in (35), where _b_ <sup>_i,j,k_</sup> _α,λ_ <sup>is the</sup> <sup>_λ_</sup> <sup>-th component of the</sup> <sup>_α_</sup> <sup>-th control</sup> point of the Bézier curve.    _b_ <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _y_ <sup>_k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> _b_ <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _z_ <sup>_k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) + 2</sup> <sup>_h_</sup> <sup>0]</sup> _τ_ 0 = 0 _L_ = 1 _/�τ_ _b_ <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _x_ <sup>_k_</sup> _b_ <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _x_ <sup>_k_</sup> = 0 _b_ <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _y_ <sup>_k_</sup> <sup>∈</sup> [min( <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>) −</sup> <sup>2</sup> <sup>_h_</sup> <sup>0</sup> <sup>_,_</sup> <sup>max(</sup> <sup>_qi_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _y_ <sup>_k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _y_ <sup>_k_</sup> <sup>_i_</sup> _α,_ <sup>_,j,_</sup> _z_ <sup>_k_</sup> <sup>∈</sup> [min( _q_ <sup>_i_</sup> _m_ <sup>_,j_</sup> _,_ <sup>_,_</sup> _z_ <sup>_k_</sup> (35) FIGURE 9. Object to be painted (‘‘mock’’ mold). The red, green, and blue lines represent the _x_, _y_, and _z_ axes of the CAD model. TABLE 3. Parameters of double _β_ distribution. Surrogate optimization is the most appropriate when the objective function takes a relatively long time to evaluate and the global solution must be found within the boundaries of search space. It also reduces the dependency on the initial points by resetting the problem several times and using new random initial points. However, depending on the size and complexity of the surface, this process could take several minutes or even hours for a single stroke; thus, it is necessary to limit the number of function evaluations. In this step, the number of function evaluations is set to 400. As the number of function evaluations is limited, the method is more influenced by the initial points; hence, in the first run, the linear stroke previously found is not employed as an initial point to avoid being dragged to a local solution. If the optimization failed to find a solution within the constraints or if the objective value obtained is, at least, twice the objective value in the linear stroke, this step is restarted employing now the optimal linear stroke as an initial searching point. If a linear stroke was not found in the previous step, this step is restarted with all the initial points randomly. If, in this second run, the method fails to obtain a feasible stroke, the contour is discarded, and the process continues with the next one. 4) FINE-TUNING OF OPTIMAL BÉZIER STROKE Provided that the previous step successfully generated an optimal planar spraying stroke, this step performs a fine-tuning on the Bézier control points previously generated employing the pattern search optimization method. This method requires a viable initial point (within boundaries and constraints) provided externally, and is prone to be dragged to local minima close to the initial point. Nonetheless, this characteristic is used to fine-tune the solution found by the surrogate method, since the surrogate method could have been reset before finding the local minimum. In this step, the argument boundaries of the objective function are the same as in the previous step (see (35)), and the optimization method FIGURE 10. Surface segmented. Region zero (blue) represent the surface area which coating thickness is irrelevant but could still interfere with the spraying process. The remaining regions are one (cyan), two (green), three (yellow), and four (red). TABLE 4. Mean normal angle per region and sub-region. is stopped when the number of function evaluations reaches 200 or when the mesh size is less than 10 <sup>−6</sup> . 5) OPTIMAL STROKE TRIMMING After the pattern search method tuned the stroke generated by the surrogate optimization method, the Bézier stroke is trimmed to reduce the waste of sprayed material, the total length of the stroke and the impact on other regions. For this purpose, the surrogate optimization method is employed on the objective function (29). In this step, the boundaries of the arguments of the objective function are changed, and a new constraint is added to the constraints defined previously. The new boundaries are presented in (36) and the additional constraint in (37).    _b_ <sup>_i_</sup> _α_ <sup>_,j,k_</sup> = Previously found optimal control point _τ_ 0 ∈ [0 _,_ 1 − _�τ_ ] _L_ ∈ [1 _,_ 1 _/�τ_ ] (36) _g_ 3( _τ_ 0 _, L_ ) = [ _τ_ 0 + _L�τ_ - 1] ≤ 0 (37) FIGURE 11. Regions segmented into sub-regions. The red, green, and blue vector represent the _x_, _y_, and _z_ axes (respectively) of the eigenvector coordinate system of the sub-regions. Additionally, the cyan vectors represent the mean normal vector of the the sub-region. 6) TRANSFORM SPRAYING STROKE Finally, the optimal trimmed stroke from the previous step and the optimal linear stroke from the second step are compared, and the one with the lowest objective value is chosen. After finding the optimal stroke, it is transformed from the slicing eigenvector coordinate system { _Ti,j,k_ } to the surface coordinate system { _S_ }. _E._ _OPTIMIZATION FOR SEVERAL GUN TO TARGET_ _DISTANCES_ The optimal stroke generation method can be employed as is to find the optimal stroke for a contour for every desired gun to target distance. However, it is important to note that the present methodology took the following approach. If an optimal spraying stroke was not found for an initial gun to target distance _h_ 1, it is very unlikely to find an optimal stroke for longer distances. Therefore, if no optimal stroke was found for the initial gun to target distance _h_ 1, then the entire contour is discarded, that is, no stroke will be generated for that contour regardless of the gun to target distance. _F._ _PARAMETERS EMPLOYED_ In Table 1, the values of the parameters employed in this project for the generation of optimal planar spraying strokes are summarized. It is important to note that the values of the parameters and penalties were obtained through several simulations; however, there is no guarantee that they are the best. VI. COMBINATORIAL OPTIMIZATION After the set of optimal strokes have been generated at a constant base velocity _v_ 0, in this final step, they will be optimally selected and their respective velocities are optimized to minimize the coating thickness error. For this purpose, a two-step optimization method is employed in this stage. First, the strokes and their velocities are optimally selected for each region employing only the strokes generated for that region without considering the impact on other regions. Then, the resulting selections and velocities are used as initial search points for a global optimization, that is, consider all the generated strokes for all the regions and the impact of each stroke on all of the surface to be painted. This step of the framework employs several key sets: _�_, the set of all generated planar spraying strokes; v, the set of all possible gun speeds; _P_, the set of coordinates of facets centroids of the surface to be painted; and _N_, the set of normal vectors of the facets conforming the surface to be painted. These are formally defined as: _�_ = { _�k,s_ : _k_ ≤ _K_ _, s_ ≤ _Sh, s_ ∈ Z <sup>+</sup> _, k_ ∈ Z <sup>+</sup> } _,_ v = { _v_ ∈ R : 0 _< v_ min ≤ _v_ ≤ _v_ max} _,_ _P_ = {⃗ _pm_ ∈ R <sup>3</sup> : _m_ ≤ _M_ _, m_ ∈ Z <sup>+</sup> } _,_ _N_ = {⃗ _nm_ ∈ R <sup>3</sup> : _m_ ≤ _M_ _, m_ ∈ Z <sup>+</sup> _,_ |⃗ _nm_ | = 1} _,_ where _�k,s_ is the planar spraying stroke for the _k_ -th contour (contours with failed spraying stroke optimization are not taken into account) at the _s_ -th gun to target distance (subscript _s_ represents the number of gun to target distance, not the distance value), _Sh_ ∈ Z <sup>+</sup> is the total number of gun to target distances, _K_ ∈ Z <sup>+</sup> is the total number of contours with optimal spraying strokes successfully generated, and _M_ ∈ Z <sup>+</sup> the total number of facets in the surface to be painted. Then, the three-dimensional (3D) matrix C | _dim_ ( _C_ ) = _M_ × _K_ × _Sh_ will store the resulting coating thickness on all the facets of the surface to be painted for each generated stroke at a constant velocity _v_ 0 ∈ v (here, _v_ 0 = 100 mm/s), as described in C = ( _cmks_ ) = _T_ <sup>˜</sup> (⃗ _pm,_ ⃗ _nm, �k,s, v_ 0)∀⃗ _pm_ ∈ _P,_ ⃗ _nm_ ∈ _N_ _, �k,s_ ∈ _�._ (38) TABLE 5. Mean objective value of the stroke generation process per region and sub-region. Therefore, the resulting coating thickness of following a combination of planar strokes _�k,s_, each at a certain gun velocity _vk_, is stored in the column vector F of size _M_ and it is described in (39). Note that for every contour with generated optimal strokes, only one gun to target distance can be selected, or all the strokes for the contour can be discarded. F ( A _, ν,_ S ) = ( _fm_ ) = _K_ _k_ =1 _<u>v</u>_ <u>0</u> _vk_ _ak_ _cmksk_ _,_ (39) where, A, _ν_, and S are matrices of dimension _K_ ×1 containing the selection data of the spraying strokes. A = ( _ak_ ) ∈{0 _,_ 1} is the selection matrix, if _ak_ = 1 the _k_ -th contour is selected and its taking into account in the final resulting thickness, _ν_ = ( _vk_ ) ∈ v is the velocity matrix, _vk_ is the desired velocity for the _k_ -th contour, and S = ( _sk_ ) ∈{1 _,_ 2 _, .., Sh_ } is the matrix of selected gun to target distances, _sk_ is the selected distance for the _k_ -th contour. Notice that regardless of the selection _ak_ for the _k_ -th contour, a gun velocity and a gun to target distance is assigned to the contour, if _ak_ = 0 the contour is not selected and its strokes have no impact on the final thickness. Similar to the method for optimal stroke generation, the mean square error is employed here as an objective function. Therefore, the objective function is expressed as <u>1</u> arg min _E_ ( A _, ν,_ S ) = area _T_ _M_ _m_ =1 area _m_ ( _fm_ - _Tt_ ) <sup>2</sup> _,_ (40) where _Tt_ is the target coating thickness, area _m_ is the area of the _m_ -th facet, and area _T_ is the total area of the surface to be painted. Of course, if only the _i_ -th region is being optimized (as that is the first step of this stage of the methodology), then _ak_ = 0 for all the contours outside the region and the objective function (40) only takes into account the surface areas of the region of interest. Since global optimization will have 3 × _K_ variables, trying to find the best combination can take an unrealistic amount of time without good initial guesses. For that reason, initially, each region is optimized individually (as mentioned before) to obtain those good guesses. As each individual optimization only employs the strokes generated for the FIGURE 12. Regions 1 and 2 target and resulting coating distribution with generated spraying strokes. The red, green, and blue vector represent the _x_, _y_, and _z_ axis (respectively) of the way points of the stroke. Additionally, the cyan line represent the spraying path. In all cases, the desired gun to target distance _hk_ is 220 mm. regions, the number of variables is reduced, greatly reducing the number of possible combinations. Both optimization steps are performed employing the particle swarm optimization method. The final trajectory is the selected strokes and their respective velocities. Finally, table 2 presents the parameter values employing in this article. The method was tested on the same surface but with three different target thicknesses. VII. RESULTS AND ANALYSIS The results obtained in each step of the framework are presented in this section. The developed methodology was tested on a mold completely designed by the authors of the present work and it is heavily inspired on a real SMP mold used in aluminum gravity die casting for the manufacturing of automotive gearboxes. The designed piece is shown in Fig. 9 and its dimensions are 300 mm×800 mm×800 mm. Moreover, to simulate the resulting coating thickness, this paper employs the coating thickness profile presented by Yu et al in [9], the parameters of such double _β_ distribution are shown in table 3. Additionally, the optimized spraying strokes were further evaluated in a virtual robotic station. This simulation was conducted using RoboDK software, employing a virtual IRB6700 robot from ABB equipped with a generic spray gun. The robot was programmed to execute the final spraying strokes for 50 _µ_ m target coating thickness, which were defined relative to the workpiece, at their optimized velocities with a nominal TCP linear acceleration of 2 m/s <sup>2</sup> . The objective of the virtual robotic spray painting simulation was to assess the impact of non-constant velocities on the final coating thickness. Consequently, the resulting coating thickness was computed using the methodologies presented here and compared against the resulting coating thickness from the constant-velocity strokes. It is important to note that the robot was programmed to start and end each spraying stroke at zero velocity without the inclusion of additional via points or other techniques to mitigate the effects of acceleration. Furthermore, the workpiece was positioned to ensure execution of all the spraying strokes. This allows understanding how a robot might perform the generated trajectories raw, unadapted trajectories. FIGURE 13. Regions 3 and 4 target and resulting coating distribution with generated spraying strokes. The red, green, and blue vector represent the _x_, _y_, and _z_ axes (respectively) of the way points of the stroke. Additionally, the cyan line represent the spraying path. In all cases, the desired gun to target distance _hk_ is 220 mm. _A._ _SEGMENTATION RESULTS_ As not all the mold surface is going to be painted, the first step is to remove irrelevant faces (such as the rear of the mold) and leave the surface that is going to be painted as well as those regions that could interfere with the painting process (shadowing and collisions); in addition, it is necessary to mark the area of the surface to be painted in order to apply the segmentation only to that area. The result of applying the first segmentation algorithm is shown in Fig. 10. As can be seen, the main concave area is going to be painted and it was segmented into four regions. Therefore, the surface is now composed of five regions, region zero is the area that is not going to be painted, but could interfere with the painting process. The remaining regions (one to four) can be described as a box, a smaller box, a paraboloid, and a plane. Now each region is sub-segmented into sub-regions. Regions one and three were divided into four sub-regions, while regions two and four into two and one sub-regions, respectively. Fig. 11, shows the results of such subsegmentation, additionally each sub-region has its own eigenvector coordinate system { _Ti,j_ } which are also shown; finally, the mean normal vector of each sub-region is represented as cyan vectors. It is observable that the _z_ -axis of the eigenvector coordinate system is almost antiparallel to the mean normal vector of each sub-region, that is the result of the series of rotations described in the sub-segmentation section. Moreover, it is clear how these series of rotations are executed (in the same region) only over the _y_ -axis (green vector); it is worth remarking that the initial rotation on the _x_ axis is not shown in Fig. 11 but is a necessary step to produce the eigenvector coordinate systems from which the slicing coordinate systems will be derived. For a better understanding of the effect of segmentation, Table 4 presents the mean normal angles (mean angle between the normal vectors and the mean normal vector) of the surface to be painted, of each region and of each subregion. It is observed that the mean normal angle decreases with segmentation. For example, the surface starts with a mean normal angle of 66 _._ 19 <sup>◦</sup>, after the first segmentation the mean normal angles of regions three and four are reduced, especially for region four (which is a plane). Moreover, the greater reductions are obtained in the second segmentation, this effect is particularly big in region three where each sub-region has a mean normal angle of ≈ 20 <sup>◦</sup> or less; of course, as region four is already a plane, no sub-segmentation is needed. Regions one and two are interesting since their mean normal angles did not get reduced more than 17 <sup>◦</sup> and this will have an impact on the resulting coating thickness error. These regions are boxes and have faces with high angles between them, affecting the performance of the second segmentation. Albeit, one might expect that the first segmentation would separate these faces, such faces are smoothly connected (the curvature change is smooth), suggesting a vulnerability of the implemented segmentation algorithm to smooth transitions. However, the authors of the present work did not go into the effects of the different possible parameters in the method proposed in [33]. _B._ _PERFORMANCE OF OPTIMAL BÉZIER STROKES_ For the current workpiece, a total of 158 planar spraying strokes were generated, 79 for each desired gun to target distance. Figs. 12 and 13 demonstrate how this stage of the framework works by showing some of the resulting strokes and comparing the characteristic coating thickness distribution and the resulting coating thickness. Furthermore, Table 5 presents the mean final objective values of sub-regions and regions, that is, the value obtained in (29) at the end of the optimization of each planar stroke is averaged to ascertain the performance of the algorithm developed. The sub-regions with lower mean normal angle (see Table 4) in regions one and three present a lower mean objective value. Regions two and four do not present the same behavior; it was expected to have a smaller mean objective value on a region with lower mean normal angle, however, the mean objective value is greater in region four than in region two. This suggests that, despite having a lower mean normal angle can improve the performance of the Bézier-based spraying strokes, another important factor is not being considered and it presents a bigger effect on the performance; a shadowing effect from adjacent regions is probably the cause of this phenomenon; this hypothesis is further supported by the final resulting coating thickness. _C._ _PERFORMANCE OF COMBINATORIAL OPTIMIZATION_ As mentioned above, the proposed optimization method consists of a two-step process. First, each region is optimized individually (without considering effects on other regions and only using the spraying strokes generated for such region). The individual solutions are then used as initial search points to minimize the coating error globally. Fig. 14 presents a summary of the results obtained. It depicts several perspectives of the final resulting coating thickness when the target is 25 _µ_ m, including the selected spraying strokes that produce such a coating thickness. The resulting coating thickness is homogeneous and close to the target thickness; however, some over-painted and TABLE 6. Performance of combinatorial optimization. under-painted areas can be appreciated; this phenomenon is more prevalent at the boundaries between regions, which suggests the need of an extra step or modification in the stroke generation step to take this into account. The under-painted zones at the boundary between region three and four are particularly interesting, it is evident that a shadowing effect is responsible for the lack of paint, this could also be the cause of the low performance of the stroke generation process on region four. Albeit the segmentation step produces sub-regions with low normal vector deviation, it does not take into account possible shadows from other regions. In those cases, a slicing plane that is not orthogonal to the surface could minimize the shadowing effect. Regarding the generated spraying strokes, some notes must be highlighted. It is observed that each generated stroke is in fact planar, that is, completely contained within a plane. FIGURE 14. Final coating thickness and the spraying strokes that produce such coating thickness. The red, green, and blue vector represent the _x_, _y_, and _z_ axes (respectively) of the way points of the stroke. Additionally, the cyan line represent the spraying path. In all cases, the target coating thickness is 25 _µ_ m. More important, there is no link between one stroke and another, this means that there is no specific order in which they must be executed. Since the execution order does not have an impact in the resulting thickness, such an order only impacts the total execution time, which is not optimized in the present work. However, it is necessary to mention that FIGURE 15. Histograms of the resulting coating thickness at different target coating thickness. Blue bars represent the final thickness resulting from the global optimization while the the orange bars represent the results from the individual solutions. this framework assumes that the spray gun is fully activated during the execution of a spraying stroke and fully deactivated during the transition to another stroke. TABLE 7. Performance of robotic spray painting at 50 _µ_ _m_ target coating thickness. More information can be retrieved from the histograms resulting from different target thicknesses presented in Fig. 15. In all cases, the thickness distribution is closely centered at the target; additionally, the distributions obtained with the individual solutions are shifted to greater thicknesses, indicating that the individual solution causes more over-spraying as they do not take into account other regions. Furthermore, the histograms from the final thickness (blue bars) are skewed to lower thicknesses; this is to be expected, as the minimum possible thickness is zero, ‘‘dragging’’ the distribution to lower thicknesses will generate skewness to the left; however, in some cases it would be preferable to have over-painted than under-painted areas, for those cases, an asymmetrical objective function may serve as a simple solution. Additionally, the histograms for each region shown in Fig. 16 together with Table 6 may shed more light on the behavior of the framework developed and implemented here. Although the surface has good results overall (see ‘‘Surface’’ block Table 6 and Fig. 15), some regions have very poor results, like region two where less than half of its surface is in the 20% range the target. Region two is a peculiar case; its histograms show more dispersion in the global solution than in the individual solution (see Figs. (d), (e), and (f) of Fig. 16), the most probable cause is that its generated strokes have too much impact on other regions, as a result, such strokes are not used in the global optimization, in fact, the biggest over-spray is appreciated in the boundary between region one and two (see Fig. 14). Moreover, its small opening and very concave geometry also have an impact in its resulting thickness, this is further supported by its histograms, as they are more skewed to lower thicknesses than any other region. This shows that having good performance in the stroke generation step (see Table 5) is not enough to guarantee a good thickness distribution in the global optimization. In contrast, region four presents the best performance, as more than half of the region is inside the 10% range of the target despite having zones that are barely coated. This is attributed to its planar geometry. Finally, regions one and three have an informative behavior, while region one is adversely affected by global optimization (its histograms are more dispersed after global optimization), region three benefited the most from global optimization. Furthermore, FIGURE 16. Histograms of the resulting coating thickness in each region at different target coating thickness. Blue bars represent the final thickness resulting from the global optimization while the the orange bars represent the results from the individual solutions. For the individual solutions only the strokes generated for the specific region. an important coat accumulation is observable at boundary between region one and region three (see Fig. 14). Of course, the more complex geometry of region one can cause that performance, nevertheless, the fact that its histograms got more disperse after the global optimization suggests that the larger area of region three (which also means a bigger impact in the final objective function) forces the thickness distribution of region one to be ‘‘sacrificed’’ to ensure a better overall thickness distribution. _D._ _EFFECTS OF ROBOTIC SPRAY PAINTING_ The developed virtual robotic spray painting is shown in Fig. 17. The results of the simulation are shown in Figs. 18 and 19, and summarized in Table 7. The thickness FIGURE 17. Virtual robotic spray painting station. FIGURE 18. Resulting coating thickness from virtual robotic spray painting and coating thickness error (relative to constant-velocity simulations). error shown in Figs. 18b and 19b is the resulting coating thickness from the constant-velocity simulation minus the coating thickness from the robotic spray painting. These FIGURE 19. Histogram of resulting coating thickness from virtual robotic spray painting and histogram of coating thickness error (relative to constant-velocity simulations). results demonstrate a similar performance between the constant-velocity simulations and the robotic spray painting. It can be observed more coating accumulation in the robotic spray painting, this is the result of the acceleration needed to start and end each stroke at zero velocity. If the robot can follow the strokes generated at the set velocities, a nominal TCP linear acceleration of 2 m/s <sup>2</sup> is sufficient to obtain a similar performance to the constantvelocity simulations. The spray gun center point path was guaranteed to have limited maximum absolute curvature, one or less inflection points, no loops, and to be collision-free with the surface. However, it is important to note that this methodology did not generate strokes guaranteed to be achievable or safe by any real robot, as only the spray gun center point was taken into account during the stroke generation process. The surface was positioned so the robot can follow the final strokes; additionally, the via points of some strokes were rotated 180 <sup>◦</sup> around their _z_ -axis to allow the virtual robot to perform the movement, this did not change the spray gun path (as the coating thickness distribution is symmetrical with respect to this specific rotation), but it did change the virtual robot trajectory. VIII. CONCLUSION The method developed demonstrated being able to generate spray painting paths for complex concave surfaces with selfshadowing. Moreover, it introduced the novel application (in this context) of planar spraying strokes, defined by 2D cubic Bézier curves, enabling the generation of a highly diverse set of spraying strokes from a minimal set of control parameters (control points and parameter intervals) and revealed their capabilities for spraying path optimization. The main contributions of this methodology are: - Spraying stroke generation without loops and collisions with the surfaces, and with limited curvature. - Low dependence of the spraying stroke generation on local geometry. - Spraying stroke generation for surfaces with selfshadowing effects. - Simple spraying stroke generation for very complex surfaces. This framework provides an alternative to optimal spraying path generation with coating thickness modeling coupled with ray-triangle intersection detection algorithms to ensure coverage of complex concave surfaces. Moreover, it demonstrated that the spraying strokes generated are feasible for a virtual industrial robot. Nonetheless, much work is needed to improve its performance. The methodology presents two major drawbacks. First, the boundaries between regions got over-painted, forcing the global optimization process to reduce the thickness quality in some regions to obtain an overall better result. Even though the stroke generation process builds strokes with minimum impact on other regions, this is evidently insufficient, at least with the parameters used. In this regard, a possible next step would be to optimize each via point that conforms the selected strokes without the limitation of two-dimensional cubic Bézier curves. The other major drawback is the shadowing effect from other regions, as it was shown, some areas barely got coated. The segmentation process generates slicing planes that are as orthogonal to the sub-region as possible to aid the stroke generation process. Nevertheless, with some regions blocking the spray cone, there is a limit to the performance of a stroke with orthogonal planes. In those cases, tilted planes could provide better results; of course, it would be necessary to detect when inclined planes are required. Furthermore, although the segmentation algorithm reduced the geometric complexity, it is not guaranteed to be the best segmentation for spray painting processes, which could negatively affect the final performance. An alternative could be to replace the automatic segmentation with a manual segmentation performed by an experienced spray painter. Another future step is the inclusion of different thickness distributions in the optimization process. That is, generate strokes not only for different gun to target distances but also with different coating thickness distribution (different double _β_ parameters). This is expected to offer a significant improvement in the resulting final thickness, as a skilled painter changes the gun settings depending on the specific area being painted. Additionally, coupling a given robot into the spraying stroke generation process to ensure that the final trajectory is feasible and safe for a real robot will provide great progress in the automation of the spraying process of very complex surfaces. In general, the framework has proven to be robust to the diversity and complexity of regions encountered on the surface studied here, producing satisfactory results. However, this is far from being a general solution that is universally applicable to any surface. Hence, improvements are not only possible, but necessary. ACKNOWLEDGMENT The authors acknowledge Dr. David Navarro-Durán for his feedback and help during the realization of this project. REFERENCES [1] Y. Chen, W. Chen, B. Li, G. Zhang, and W. Zhang, ‘‘Paint thickness simulation for painting robot trajectory planning: A review,’’ _Ind._ _Robot,_ _Int._ _J._, vol. 44, no. 5, pp. 629–638, Aug. 2017, doi: [10.1108/ir-07-2016-](http://dx.doi.org/10.1108/ir-07-2016-0205) [0205.](http://dx.doi.org/10.1108/ir-07-2016-0205) [2] H. Chen, T. Fuhlbrigge, and X. Li, ‘‘Automated industrial robot path planning for spray painting process: A review,’’ in _Proc._ _IEEE_ _Int._ _Conf._ _Autom._ _Sci._ _Eng._, Arlington, VA, USA, Aug. 2008, pp. 522–527. [3] S.-H. Suh, I.-K. Woo, and S.-K. Noh, ‘‘Automatic trajectory planning system (ATPS) for spray painting robots,’’ _J. Manuf. Syst._, vol. 10, no. 5, [pp. 396–406, Jan. 1991, doi: 10.1016/0278-6125(91)90057-9.](http://dx.doi.org/10.1016/0278-6125%0x2891%0x2990057-9) [4] E. D. Goodman and L. T. W. Hoppensteradt, ‘‘A method for accurate simulation of robotic spray application using empirical parameterization,’’ in _Proc. IEEE Int. Conf. Robot. Autom._, Sacramento, CA, USA, Jan. 1991, pp. 1357–1368. [5] H. Chen, W. Sheng, N. Xi, M. Song, and Y. Chen, ‘‘CAD-based automated robot trajectory planning for spray painting of free-form surfaces,’’ _Ind. Robot, Int. J._, vol. 29, no. 5, pp. 426–433, Oct. 2002, doi: [10.1108/01439910210440237.](http://dx.doi.org/10.1108/01439910210440237) [6] C. Wei and Z. Dean, ‘‘Tool trajectory optimization of robotic spray painting,’’ in _Proc._ _2nd_ _Int._ _Conf._ _Intell._ _Comput._ _Technol._ _Autom._, Changsha, China, 2009, pp. 419–422. [7] W. Chen, J. Liu, Y. Tang, J. Huan, and H. Liu, ‘‘Trajectory optimization of spray painting robot for complex curved surface based on exponential mean Bézier method,’’ _Math._ _Problems_ _Eng._, vol. 2017, no. 1, pp. 1–10, [Jan. 2017, doi: 10.1155/2017/4259869.](http://dx.doi.org/10.1155/2017/4259869) [8] W. Chen, X. Li, H. Ge, L. Wang, and Y. Zhang, ‘‘Trajectory planning for spray painting robot based on point cloud slicing technique,’’ _Electronics_, [vol. 9, no. 6, p. 908, May 2020, doi: 10.3390/electronics9060908.](http://dx.doi.org/10.3390/electronics9060908) [9] X. Yu, Z. Cheng, Y. Zhang, and L. Ou, ‘‘Point cloud model ing and slicing algorithm for trajectory planning of spray painting robot,’’ _Robotica_, vol. 39, no. 12, pp. 2246–2267, Jun. 2021, doi: [10.1017/s0263574721000308.](http://dx.doi.org/10.1017/s0263574721000308) [10] S. Brown and H. A. Pierson, ‘‘Adaptive path planning of novel complex parts for industrial spraying operations,’’ _Prod._ _Manuf._ _Res._, vol. 8, no. 1, pp. 335–368, Jan. 2020, doi: [10.1080/21693277.2020.](http://dx.doi.org/10.1080/21693277.2020.1792374) [1792374.](http://dx.doi.org/10.1080/21693277.2020.1792374) [11] Y. Zeng, Y. Yu, X. Zhao, Y. Liu, J. Liu, and D. Liu, ‘‘Trajectory planning of spray gun with variable posture for irregular plane based on boundary constraint,’’ _IEEE_ _Access_, vol. 9, pp. 52902–52912, 2021, doi: [10.1109/ACCESS.2021.3070566.](http://dx.doi.org/10.1109/ACCESS.2021.3070566) [12] R.-X. Hua, W. Zou, G.-D. Chen, H.-X. Ma, and W. Zhang, ‘‘A model of spray tool and a parameter optimization method for spraying path planning,’’ _Int._ _J._ _Autom._ _Comput._, vol. 18, no. 6, pp. 1017–1031, [Nov. 2021, doi: 10.1007/s11633-021-1310-3.](http://dx.doi.org/10.1007/s11633-021-1310-3) [13] H. Wu and Q. Tang, ‘‘Robotic spray painting path planning for complex surface: Boundary fitting approach,’’ _Robotica_, vol. 41, no. 6, [pp. 1794–1811, Feb. 2023, doi: 10.1017/s0263574723000152.](http://dx.doi.org/10.1017/s0263574723000152) [14] D. Gleeson, S. Jakobsson, R. Salman, F. Ekstedt, N. Sandgren, F. Edelvik, J. S. Carlson, and B. Lennartson, ‘‘Generating optimized trajectories for robotic spray painting,’’ _IEEE_ _Trans._ _Autom._ _Sci._ _Eng._, vol. 19, no. 3, [pp. 1380–1391, Jul. 2022, doi: 10.1109/TASE.2022.3156803.](http://dx.doi.org/10.1109/TASE.2022.3156803) [15] A. Verduyn, J. De Schutter, W. Decré, and M. Vochten, ‘‘Shape-based path adaptation and simulation-based velocity optimization of initial tool trajectories for robotic spray painting,’’ in _Proc._ _IEEE_ _19th_ _Int._ _Conf._ _Autom. Sci. Eng. (CASE)_, Aug. 2023, pp. 1–8. [16] F. Xu, B. Zi, and D. Zhang, ‘‘Trajectory optimization for spray-painting robot in Cartesian space based on consistency index of paint film thickness,’’ in _Proc._ _3rd_ _Int._ _Conf._ _Innov._ _Develop._ _Inf._ _Technol._ _Robot._ _(IDITR)_, Hong Kong, May 2024, pp. 84–93. [17] R.-X. Hua, H.-X. Ma, W. Zou, W. Zhang, and Z. Wang, ‘‘A spraying path planning algorithm based on point cloud segmentation and trajectory sequence optimization,’’ _Int._ _J._ _Control,_ _Autom._ _Syst._, vol. 22, no. 2, [pp. 615–630, Jan. 2024, doi: 10.1007/s12555-022-0203-8.](http://dx.doi.org/10.1007/s12555-022-0203-8) [18] S. N. Bastida and C.-Y. Lin, ‘‘Autonomous trajectory planning for spray painting on complex surfaces based on a point cloud model,’’ _Sensors_, [vol. 23, no. 24, p. 9634, Dec. 2023, doi: 10.3390/s23249634.](http://dx.doi.org/10.3390/s23249634) [19] Z. Liu, S. Cheng, Y. Su, G. Duan, and J. Tan, ‘‘Semantic segmen tation based spraying trajectory planning for complex product,’’ _IEEE_ _Trans._ _Ind._ _Informat._, vol. 20, no. 7, pp. 9416–9426, Jul. 2024, doi: [10.1109/TII.2024.3383865.](http://dx.doi.org/10.1109/TII.2024.3383865) [20] N. Jagan, ‘‘Engineering of gravity permanent mold castings,’’ in _Aluminum_ _Castings_ _Engineering_ _Guide_, 1st ed., Novelty, OH, USA: ASM International, 2018, pp. 170–174. [21] ‘‘Mold coatings,’’ in _Aluminum Permanent Mold Handbook_ . Schaumburg, IL, USA: AFS, 2001, ch. 14. [22] R. Khosla and K. K. Guntupalli, ‘‘Heat-related illnesses,’’ _Am. Fam. Phys._, vol. 15, no. 2, pp. 251–263, Apr. 1999. [23] N. Guha et al., ‘‘Lung cancer risk in painters: Results from the SYNERGY pooled case–control study consortium,’’ _Occupational_ _Environ._ _Med._, [vol. 78, no. 4, pp. 269–278, Oct. 2020, doi: 10.1136/oemed-2020-106770.](http://dx.doi.org/10.1136/oemed-2020-106770) [24] J. C. Wesdock and A. M. Donoghue, ‘‘Life-threatening heat-related illness with severe hyponatremia in an aluminum smelter worker,’’ _Amer. J. Ind._ _Med._ [, vol. 62, no. 12, pp. 1068–1075, Oct. 2019, doi: 10.1002/ajim.23061.](http://dx.doi.org/10.1002/ajim.23061) [25] Y. Chen, S. Chen, W. Chen, J. Hu, and J. Jiang, ‘‘An atomization model of air spraying using the volume-of-fluid method and large eddy simulation,’’ _Coatings_, vol. 11, no. 11, p. 1400, Nov. 2021, doi: [10.3390/coatings11111400.](http://dx.doi.org/10.3390/coatings11111400) [26] W. Persoons and H. V. Brussel, ‘‘CAD-based robotic coating of highly curved surfaces,’’ in _Proc._ _Int._ _Symp._ _Ind._ _Rob._, Tokyo, Japan, 1993, pp. 611–618. [27] J. K. Antonio, ‘‘Optimal trajectory planning for spray coating,’’ in _Proc._ _IEEE_ _Int._ _Conf._ _Robot._ _Autom._, San Diego, CA, USA, Jun. 1994, pp. 2570–2577. [28] T. Balkan and M. A. S. Arikan, ‘‘Modeling of paint flow rate flux for circular paint sprays by using experimental paint thickness distribution,’’ _Mech._ _Res._ _Commun._, vol. 26, no. 5, pp. 609–617, Sep. 1999, doi: [10.1016/s0093-6413(99)00069-5.](http://dx.doi.org/10.1016/s0093-6413%0x2899%0x2900069-5) [29] M. A. Sahir Arikan and T. Balkan, ‘‘Modeling of paint flow rate flux for elliptical paint sprays by using experimental paint thickness distributions,’’ _Ind. Robot, Int. J._, vol. 33, no. 1, pp. 60–66, Jan. 2006, doi: [10.1108/01439910610638243.](http://dx.doi.org/10.1108/01439910610638243) [30] Y. Zhang, Y. Huang, F. Gao, and W. Wang, ‘‘New model for air spray gun of robotic spray painting,’’ _Chi. J. Mech. Eng._, vol. 42, no. 11, pp. 226–233, 2006. [31] D. C. Conner, P. N. Atkar, A. A. Rizzi, and H. Choset, ‘‘Development of deposition models for paint application on surfaces embedded in R <sup>2</sup> for use in automated path planning,’’ in _Proc. IEEE/RSJ Int. Conf. Intell. Robots_ _Syst._, vol. 2, Lausanne, Switzerland, Jun. 2003, pp. 1844–1849. [32] T. Möller and B. Trumbore, ‘‘Fast, minimum storage ray/triangle intersection,’’ in _Proc._ _ACM_ _SIGGRAPH_, Los Angeles, CA, USA, 2005, pp. 1–7. [33] G. Lavoué, F. Dupont, and A. Baskurt, ‘‘A new CAD mesh segmentation method, based on curvature tensor analysis,’’ _Comput.-Aided_ _Design_, [vol. 37, no. 10, pp. 975–987, Sep. 2005, doi: 10.1016/j.cad.2004.09.001.](http://dx.doi.org/10.1016/j.cad.2004.09.001) [34] M. C. Stone and T. D. DeRose, ‘‘A geometric characterization of parametric cubic curves,’’ _ACM Trans. Graph._, vol. 8, no. 3, pp. 147–163, [Jul. 1989, doi: 10.1145/77055.77056.](http://dx.doi.org/10.1145/77055.77056) [35] W. Xia, S.-R. Yu, and X.-P. Liao, ‘‘Paint deposition pattern modeling and estimation for robotic air spray painting on free-form surface using the curvature circle method,’’ _Ind. Robot, Int. J._, vol. 37, no. 2, pp. 202–213, [Mar. 2010, doi: 10.1108/01439911011018984.](http://dx.doi.org/10.1108/01439911011018984) DAVID RAMÍREZ-RÍOS received the B.S. degree in digital systems and robotics and the M.S. degree in engineering sciences from Tecnológico de Monterrey, Mexico City, Mexico, in 2021 and 2024, respectively, where he is currently pursuing the Ph.D. degree in engineering sciences. His research interests include optimal path planning and, recently 3D printed electronics. JAVIER IZQUIERDO-REYES (Member, IEEE) received the bachelor’s degree in communications and electronics engineering from the Instituto Politécnico Nacional. He is currently a Faculty Member with the Mechatronics Department, Tecnológico de Monterrey, Mexico City campus. He is also an Associated Staff with MIT.Nano giving a course in micro manufacturing. He has collaborated on industryacademic projects, including propulsion system dimensioning for scaled vehicles and control algorithms. His expertise also includes hands-on simulation development and educational activities that bridge theoretical concepts with practical implementation. His teaching and research interests focus on electric vehicles, control systems, and mechatronics, particularly in the areas of propulsion systems, behavioral cloning for autonomous driving, and sensor-actuator integration. DAVID ROMERO (Member, IEEE) is currently a Professor of advanced manufacturing with the Department of Industrial Engineering and the Department of Mechatronics, Tecnológico de Monterrey, Mexico, and the Scientific Vice-Chairman for the World Manufacturing Foundation. He has published more than 200 journal and international conference articles. His research interests include circular manufacturing, service engineering and product-service systems, cyber-physical systems and human systems, advanced production management systems, green virtual enterprises, and technology and engineering management in the context of the fourth industrial revolution. He is a Member of the Society of Collaborative Networks, the IFAC TC5.3 on Enterprise Integration and Networking, the IFIP WG5.7 on Advances in Production Management Systems, the IFIP WG5.12 on Architectures for Enterprise Integration, the IEEE Technology and Engineering Management Society, and the IEEE Internet of Things Community. Furthermore, he is an Agenda Contributor with the World Economic Forum (WEF) Council on ‘‘Shaping the Future of Advanced Manufacturing and Value Chains’’, and a World Manufacturing Forum (WMF) Ambassador. He serves on different technical and scientific committees and advisory boards in academia, industry, and government in the disciplines of business and industrial engineering. Nowadays, he is focused on promoting the concepts of the ‘‘Operator 4.0/5.0’’ and ‘‘Digital Lean Manufacturing’’; the father of both terms.

섹션 본문

섹션 본문이 없습니다.

참고문헌

참고문헌 정보가 없습니다.