All-position welding control system based on machine vision and nonlinear regression

Aiming at the problems of poor welding quality and low degree of automatic welding on the engineering site, a welding process parameter control method based on machine vision and nonlinear regression technology is proposed. Firstly, a vision unit and a peripheral sensor unit are designed to obtain the information of each influencing factor of the welding process parameters. Secondly, a clustering algorithm is used to improve the extraction accuracy of feature point coordinates of weld images. Thirdly, a nonlinear regression fitting method is proposed to determine the mathematical relationship between welding quality at different welding positions and corresponding process parameters. Experimental results show that the control system is easy to operate, and the flexible control of welding process parameters in the whole process is realized. The weld cumulative height and width deviations are less than 0.5 and 0.3 mm, respectively. The welding surface is stable and meets welding requirements. Therefore, this method is of great practical significance in engineering field welding.

The inspiration of my work 1. Through the analysis of a large number of welding experimental data, the results show that the welding current, welding voltage, and welding speed are related to the position of the groove to be welded and geometric information. We use the method of nonlinear regression to determine the mathematical relationship between the dependent variable and the independent variable. 2. Considering that the geometric information of the weld is difficult to measure with conventional methods, this paper designs a machine vision sensor to collect the characteristic information of the weld to be welded. 3. Considering the noise interference caused by slag splash and arc signal in the welding process, this paper proposes a clustering algorithm to improve the accuracy and stability of image feature extraction. According to the characteristics of the weld image and the distribution law of the sampling points, the direction and distance in the Euclidean geometry are used as the judgment standard, and the optimal threshold is set, and finally the classification of the sampling points is realized.

Introduction
Vision technology has developed into a mature stage, enabling more and more industrial robots to be used in enterprise production. 1,2 Welding system with multiple sensing technologies has a good application prospect in the welding field. [3][4][5] Welding technology and system play an important role in modern industrial application, 6 with all-position welding of pipelines always being a research hotspot, which has a broad application prospect to realize all-position low-cost and efficient welding while ensuring welding quality. 7 At present, all-position welding of most pipelines is manual or semi-automatic, which suffers low welding efficiency, and high dependence of the welding quality on the skill of welders, so it is difficult to guarantee the welding quality and the stability of weld formation. The core of all-position automatic welding is how to obtain the key information of welding area and weld preparation, and how to automatically match and control the welding parameters in the welding area, in a bid to meet the quality requirements of all-position welding. All-position welding of pipeline is composed of horizontal welding, vertical welding, and overhead welding, of which vertical welding is divided into vertical up welding and vertical down welding. The welding difficulties include the following: First, the requirements of welding parameters change accordingly with different positions. Second, the weld formation of a layer affects the setting of welding parameters of the next layer in multi-layer and multi-pass weld preparation, and the final shape of the molten pool is influenced by factors such as the direction toward which metal in the molten pool flows, the amount of supplementary metal, the retention time at high temperature, and the spreading height of the side wall. 8 For now, a traditional demonstration mode prevails in all-position welding robots for pipelines at home and abroad, making the robots expensive and mostly fixed, have high requirements on the working environment, and go against the promotion and application in industrial fields. In the rapidly developing manufacturing industry, work efficiency has become an important index to measure the automation of equipment. And the continuous advancement of Industry 4.0 makes it difficult for the traditional demonstration mode to meet the needs of industrial automation.
For all-position welding of pipelines, Xu et al. 9,10 conducted statistical modeling, prediction, and optimization of weld geometry. Guo et al. 11 established a visual servo control system for effectively integrating and extracting characteristic parameters of images, thereby achieving welding attitude control based on visual servo control by controlling the position of welding gun. By designing an appropriate excitation structure, Yue et al. 7 used an exterior high-frequency alternating field to generate eddy current in the metal molten pool, finally triggering electromagnetic force opposite to gravity. This scheme is of positive significance for restraining metal flowing and raising efficiency in all-position welding, but it is inapplicable to outdoor pipeline welding with complex working environment.
In all-position pipeline welding, the welding parameters of each position are greatly subject to the current welding position, and the thickness and width of the welding layer of weld preparation to be welded. In recent years, machine vision technology has developed rapidly and has been widely used in automaticallyguided welding due to its advantages of non-contact and high precision. 12,13 The application of sampling vision sensing technology to weld space measurement tends to mature. [14][15][16] Deep learning technology is gradually applied to the field of robot welding for image analysis and prediction. 17,18 In practice, the images collected on site are accompanied by a lot of noise primarily resulting from welding arc light, weld spatter, and weld fume. The noise will directly cause weld characteristic signals to be inconspicuous or even submerged, then reduce the accuracy of automatic matching of welding parameters, and finally lower the welding quality. To measure the welding seam, the most important task for the information processing unit of laser vision welding seam is to find the inflection point and accurately extract the characteristic parameters of the welding seam. 19 With that, this paper was proposed to design an allposition welding control system based on machine vision and nonlinear regression for all-position welding control of welding robots. Meanwhile, it provided a nonlinear regression-based optimization method for all-position welding parameters, which is effective in automatic control of welding parameters by analyzing welding parameters and weld preparation information at different positions of the pipeline and then fitting a function.
The rest of this paper is structured as follows. Section 2 presents the related work. Section 3 describes extraction of weld feature information. Section 4 presents comprehensive experiments and analyses. Section 5 concludes the paper.

Related works
Take 20# carbon steel pipe with a diameter of 400 mm as an example, with a thickness of 16 mm and a V-shaped groove. The content of carbon, silicon, and manganese in this carbon steel pipe are 0.2%-0.25%, 0.17%-0.37%, and 0.35%-0.65% respectively. The vision sensor used to collect the weld seam image is mainly composed of an industrial camera and a line laser. The resolution of the industrial camera is 1280 3 1024, the sensor type is CMOS, and the image color is black and white. The power of the line laser is 16 mW.
Through the analysis of experimental data, the non-linear regression method is used to establish the functional relationship between the weld feature information and the welding process parameters, and the control system is designed. Because the geometric information of the weld is difficult to measure with conventional methods, this paper designs a machine vision sensor to collect the characteristic information of the weld to be welded, and uses a clustering algorithm to improve the accuracy of the weld information, and the current welding area is determined by the angle sensor, thereby realizing the pipeline all-position welding.
The all-position welding control system based on machine vision and nonlinear regression was mainly composed of vision module, control module, and execution module, whose system architecture was shown in Figure 1.
The vision module consisted of an industrial camera, a line laser, and an industrial computer, as shown in Figure 2. According to laser triangulation, 20 the light bar projected on the pipeline weld by the line laser is deflected when it covers the welding seam. Considering the accessibility of field use, the industrial camera and the line laser form a visual sensing unit at relative positions in space to implement the image acquisition function. Weld spatter reduces the quality of images collected with the industrial camera. In order to eliminate noise interference and increase accuracy of image acquisition, the visual sensing unit, with an interval of 50 mm from the welding torch, is installed at the end of the trackless crawling welding robot. With an image processing algorithm, the Industrial Personal Computer (IPC) analyzes images collected using the visual sensing unit to attain the width and thickness of the welding layer.
The control module is composed of embedded PC, robot pose detection sensor and supporting electrical components, and controls trackless crawling welding robots and digital welding power supply through the embedded PC. The vision module, the basis of the allposition welding control system to control welding process parameters, transmits the processed weld data to the control module. The robot pose detection sensor is used to detect the crawling angle of a trackless crawling welding robot on pipeline, and transmit the data to embedded PC in real time. The embedded PC adopted in this paper had a minimum scan cycle of 50 ms, while it enjoyed fast data processing and supported large amount of information processing, compared with the programmable controller with millisecond scanning cycle, which fully met the requirements of the allposition welding control system for real-time information transmission and data processing speed. In order to minimize the equipment volume, the control module is embedded into the welding robot, so that the welding robot is spatially independent of the control module, and the volume of this system is only 60% of the traditional welding control system ( Figure 3).
The execution module consists of a trackless crawling welding robot and a digital welding power supply. The trackless crawling welding robot is a magnetic adsorption type four-wheel three-axis robot, which can go back and forth (X), swing (Y), and go up and down (Z).  The flow of the all-position welding control system is shown in Figure 4.
The research method used in this article is shown in Figure 5.

Weld seam image processing
As shown in Figure 3, the laser stripe emitted by the line laser was projected on the welding seam, and then regularly deflected along with the geometry of the weld preparation. The vision module was designed to accurately extract the welding seam image, obtain the weld contour and the coordinates of weld feature, and then work out the accurate weld layer width and height. In Gas Metal Arc Welding (GMAW), the quality of images collected by an industrial camera will be greatly reduced by weld spatter and the consequent weld fume, so it is difficult to obtain stable and accurate contour information via traditional contour extraction. Figure  6(a) and (b) respectively show the normal image and the image with noise.
The vision module was designed with process flow and the measurement experiment was performed in this paper, as shown in Figure 7, to improve the accuracy   and stability of weld images. After the vision module is started, the camera periodically collects weld images. First, the gray value of the image was transformed using linear function, and image details were highlighted via image contrast enhancement. Next, on the premise of not changing the whole feature information of the image, isolated image noise points were removed.
The key of the process flow is to collect key information points of weld image and remove interference sampling points by clustering algorithm. Weld feature information is always in the fixed area of an image consequently, a rectangular window can be set in the image to select the target area, which reduced the workload of subsequent image information processing to 50%. The image was then smoothed using a Gaussian filter to partially eliminate image noise; and to differentiate the profile curve, where a positive derivative indicates that the gray value increases from small to large, which is a positive edge, and negative derivative indicates that the gray value grows from large to small, which is a negative edge. In this paper, the negative edge points were selected as the edge sampling points of the target contour.

Obtain weld feature information by clustering algorithm
In recent years, so great progress has been made in the research of clustering algorithm that clustering, an unsupervised learning algorithm, has been widely used in image analysis. 21,22 In most cases, sample data sets have no subsets, and data samples have no fixed label, as well. Clustering is to integrate object members with similar attributes in a set into different subsets by classification and judgment. As illustrated in Figure 8, a large number of edge sampling points were extracted from the edge image of the welding seam after preprocessing, along with interference points. Figure 8(a) and (b) showed the sampling results of normal image and noise image, respectively. A fast and accurate clustering algorithm was designed here to screen sampling points, providing a prerequisite for the accuracy of weld feature values.
Clustering algorithm is a method whereby the similar samples in a data set are divided into several categories, with the measurement of the similarity between samples as its pivot. The key to improve the classification accuracy by the clustering algorithm is to set reasonable judging criteria and determine the optimal threshold based on the distribution of weld sampling points, so as to eliminate interference to the maximum extent and obtain stable, effective sampling points. In this paper, the direction and distance in Euclidean   geometry were taken as the judging criteria according to the characteristics of weld image and the distribution law of sampling points, so as to set the optimal threshold, and eventually realize the classification of sampling points. 23 D (X i , X j ) is the Euclidean distance between two adjacent sampling points X i , X j , and u(X i , X j ) is used to represent the angle formed by the connecting line between two adjacent sampling points and the horizontal direction, where l is the sample feature dimension and the vision module extracts the two-dimensional coordinates of all sampling points, so d is 2, then: Setting D T , u T as a distance threshold and an angle threshold respectively, and when X i , X j satisfy the condition (3), X i , X j are considered as the same class and put into the same subset. The clustering algorithm was performed as follows: (1) Initiate the clustering algorithm, read sampling points column by column, and if the sampling points in the first column are n, create n subsets of C 1 , C 2 , C 3 ,., C n , and record them as C i ; (2) Obtain the sampling points in the second column, and calculate the distance and angle with the sampling points of subset C i by using formulas (1)-(3) one by one, and then judge whether the two sampling points belong to the same class. If the threshold condition is met, the point will be attributed to C i , otherwise, it will be placed in the newly created subset C n + 1 . By analogy, create new subsets C n + 2 , C n + 3 , ., and record it as C i ; (3) Obtain the sampling points in the 3rd, 4th, ., i columns in turn, and classify the sampling points by performing the operation in step ffl. (4) The algorithm ends when all sampling points are read, calculated, and classified.
After classification by clustering algorithm, sampling points in weld images were displayed as shown in Figure 9, in which the sampling points in different categories are represented using different colors. Figure  9(a) and (b) showed the processed result of normal image and noise image by clustering algorithm, respectively. Sampling points in subsets with more elements were represented in green, which were weld outline points. Sampling points in subsets with less elements were represented in blue, red, and orange. The results showed that the clustering algorithm could effectively remove the interference and select the optimum sampling points.

Accuracy analysis and design of system software
The machined standard groove of 18 mm width was selected as the experimental object. Resolution of each image pixel was calibrated to 0.1 mm after feature extraction. In the welding process, 100 welding image frames were processed continuously without any deviation correction operation for the welding robot and welding gun, and the groove width deviation value was within 1 pixels, that is, the measurement accuracy of deviation of vision module was 0.1 mm.
C + + language was used to extract seam feature information, and QT was used to visualize image acquisition and processing. The system software interface was shown in Figure 10. According to the geometric relationship determined by the calibration system, the vision module performed data operation on the coordinates of weld feature points on the image, and sent the obtained actual weld information data to the control module.

Factors behind weld formation
For all-position welding of the pipeline, the welding torch performs a full circle welding along the pipeline, so the welding torch posture changes from 0°to 360°as the welding position changes. Since the sinking of the molten pool is under the combined action of gravity and the supporting force of the pipe wall, the degree of sinking of the molten pool changes with the change of the welding area. Experiments show that the molten pool forming in the same area for different pipes has regularity, and the molten pool forming in a fixed range area is consistent. Therefore, a strategy of summarizing the process parameters of each area by subdividing the welding area, and then using a nonlinear regression method to fit the pipeline all-position welding parameter equation. During all-position welding, the welding speed, the width of the welding layer to be welded and the angle of the welding gun have regular influence on the weld formation. 24 Besides, gravity makes the force of the molten pool unbalanced in different spatial positions, leading to instability of weld formation. Allposition welding positions of pipeline were shown in Figure 11.
Among which non-horizontal welding positions, such as vertical down welding, overhead welding, and vertical up welding, were subject to poor weld formation, incomplete fusion between welding layers and high bulge in the center of weld, as shown in Figure 12 In all-position welding process, parameters that affected weld formation vary from welding current, welding voltage, to crawling speed of welding robot, all of which directly affected the stability of welding process, and the appearance of weld. How to configure the parameters reasonably was a problem to be solved.

Nonlinear regression mathematical model
Welding parameters were directly linked to the width and thickness of the welding layer to be welded and the angle of the welding gun. Traditional univariate experiments fail to test the interaction between different parameters, and suffered low efficiency and were a huge workload. Regression modeling could describe the influence intensity of multiple independent variables on a dependent variable, while polynomial regression could fit the data of nonlinear relationships and deal with the complex relationships between dependent variables and independent variables more flexibly. In this paper, a mathematical model was established by means of experimental design to reduce the trial cost, increase test efficiency, and obtain scientific and reasonable test results.  Based on the fact that weld pool characteristics were enslaved to welding parameters in a regular way, the reference values of welding parameters were obtained through pre-experiments. The results showed that welding current I, welding voltage U, and crawling speed V of welding robot had great influence on the shape of molten pool and weld formation, and the three parameters were associated with welding layer width d, welding layer height h, and crawling angle a of welding robot.
Welding current I, welding voltage U, and crawling speed V of welding robot were taken as response values, while welding layer width d, welding layer height h, and crawling angle a of welding robot were considered as input variables.
Subsequently, a nonlinear regression equation was established with the response values and input variables to fit the function between them. If the response values were denoted as y j and the input variables were x i , the functional relationship can be expressed as y j = f(x 1 , x 2 , .., x i ), where y j was a multivariate quadratic function, the nonlinear regression equation could be expressed as formula (4), and the value set of j was{1, 2, 3}.
After a large number of welding data were obtained through experiments, the regression coefficients in the second-order nonlinear regression equation were clarified by the least square method with the relationship between response values and input variables, as shown in Tables 1 to 3. The second-order nonlinear regression equation of important welding parameters behind weld formation, such as welding current I, welding voltage U, and crawling speed V of welding robot, reflected the mathematical relationship between welding parameters, characteristics of welding seam characteristics, and the angle of welding gun. The results indicated that the first-order and quadratic terms of crawling angles a of  Processing parameter

Experimental results and analysis
The experimental device of all-position welding control system based on machine vision and nonlinear regression was shown in Figure 13. In order to verify the accuracy and stability of the welding control of the allposition welding control system, the welding seams to be welded were machined by lathe, with high straightness and consistent seam width values, which could eliminate the interference caused by the irregularity of initial welding seams and help to improve the accuracy of data analysis. The base metal and related parameters were displayed in Table 4. For the vision module, a 660 6 10 nm narrow bandpass filter was installed in front of the industrial camera lens to reduce arc noise and better the quality of image acquisition. The hardware carrier of the control module was C6015 from Beckhoff, an embedded IPC characterized by small physical volume, high integration, and microsecond operation speed, which provides a foundation for large-scale data processing and information interaction between the vision module and the control module. Panasonic YD-350GS digital welding machine with low spatter was used as welding power source, and the initial welding process parameters were shown in Table 5.
In all-position welding process, wireless remote control was employed to control the system. When the system was in operation, the vision module periodically collects and processes images, obtains welding layer width and height data, and sends them to the control module. The pose detection sensor was built in the allposition welding robot to obtain the current angle data of the welding gun in real time. With these data, the welding parameters are calculated by the control module through internal algorithm, and sent to the execution module. The all-position welding robot and digital welding machine receive and execute the instructions sent by the control module, thus realizing all-position welding of pipes with automatic matching of welding parameters in the welding process.
During the entire control process, extraction of welding layer information was critical. Its precision determines the welding seam's final forming effect. Traditional template matching algorithm utilizes mature technology, and the method based on feature matching had strong adaptability to circumstances with strong noise interference and large gray scale change. In order to analyze the stability of seam feature point extraction, template matching algorithm and clustering Table 3. Coefficients of second-order nonlinear regression equation of crawling speed V.  algorithm were used to extract the feature points at both ends of the groove of the same image with large interference noise. Figure 14(a) and (b) showed the extraction results of the template matching algorithm for ordinary pictures and noisy pictures, while Figure  14(c) and (d) showed the clustering algorithm for the extraction of the above two pictures result. As shown in Figure 14(a) to (d), under strong arc interference, when the image feature extraction method based on template matching was in error, the clustering algorithm could still achieve the accuracy of feature value coordinate extraction. The results showed that the feature extraction accuracy of template matching was only about 70%, while the feature extraction accuracy of clustering algorithm used in this paper was 90%.

Processing parameter
On the premise of ensuring that all other factors such as welding materials, pipe groove, and welding process parameters are consistent, cluster, and template matching algorithms were used to extract the height and width of welding layers, and complete all-position pipe welding. The error curves of welding layer width and height were shown in Figures 15 and 16. The results showed that the accuracy of feature point extraction using the template matching method was low. The maximum errors of width and height of single seam were 0.4 and 0.36 mm, and the root mean square errors were 0.24 and 0.21 mm, respectively. The accuracy of feature points extracted by the clustering algorithm in this paper was high. The maximum errors of width and height of single seam were 0.3 and 0.25 mm, and the root mean square errors were 0.17 and 0.15 mm, respectively.
Compared with the template matching algorithm, the clustering algorithm adopted in this paper improved the accuracy of the entire welding system. This was because feature extraction based on template matching was significantly influenced by a single template picture, and when arc interference information greatly    influenced template features, the accuracy and stability of weld feature coordinate extraction could not be guaranteed. As shown in Figure 17(a) and (b), the final welding effect showed that the method of extracting feature point coordinates by template matching had low stability and production of welding defects of incomplete fusion could be commonplace. In order to quantitatively verify the accuracy and stability of the all-position welding control system based on machine vision and nonlinear regression, the weld preparation of the same pipeline was welded in three ways: keeping welding parameters unchanged, manually adjusting welding parameters, and automatically matching welding parameters by using the allposition control system. As shown in Figure 10, the pipeline was divided into 16 areas according to varied welding positions. Figure 18(a) and (b) showed the width and thickness of the formed weld, respectively. The all-position welding control system designed in this paper benefitted from a stable molten pool and good weld formation. In addition, the maximum accumulative thickness deviation of four layers was 0.5 mm, and the width deviation was 0.3 mm. The actual welding effect was shown in Figure 19    respectively represent the surface morphology and section morphology of the weld.

Conclusions
This paper designed a welding process control method based on machine vision and nonlinear regression technology to improve welding quality of all-position pipeline welding. A visual sensor was designed to collect weld information, and the stability and accuracy of feature information extraction were improved through an optimized clustering algorithm. Experiments showed that the all-position welding system designed using the method outlined in this paper provided stable weld pool shape and a positive weld appearance during welding. Furthermore, the root mean square errors of width and height of single-layer welds were 0.17 and 0.15 mm, respectively. The stability and precision of the system met the requirements of the pipeline all-position welding process.