Intelligent Dynamic Identification of Industrial Productsin a Robotic Workplace

The article deals with aspects of identifying industrial products in motion based on their color. An automated robotic workplace with conveyor belt, robot and industry color sensor is created for this purpose. Measured data are processed in a database and then statistically evaluated in form of standard uncertainties of type A and B, in order to obtain combined standard uncertainties results. Based on the acquired data, control charts of RGB color components for identified products are created. Influence of product speed on the measuring process identification and process stability is monitored. In case of identification uncertainty i.e. measured values are outside the limits of control charts, the K-nearest neighbor machine learning algorithm is used. This algorithm, based on the Euclidean distances to the classified value, estimates its most accurate iteration. This results into the comprehensive system for identification of product moving on conveyor belt, where based on the data collection and statistical analysis using machine learning, industry usage reliability is demonstrated.


Introduction
Requirements for fast and accurate product's identification and its measured parameters are currently increasing in the industry production [1,2]. Intelligent solutions with a multidisciplinary approach is one possible solution. In our case we decided to combine and use available statistical mathematical methods together with database and computer solutions based on machine learning. The combination of these approaches, allow us to provide appropriate solutions for industry deployment with fast response and accuracy, which would otherwise be difficult to implement.
One of the new challenges in the industry is rapid detection and identification of moving products with various parameters. Nowadays, in the spirit of intelligent industry, there is a trend to leave mass series production and switch to variant customized small series production according to [3,4,5,6,7,8]. We know many methods for products detection such as (the most common used) barcodes, QR, RFID codes etc. [9]. From production point of view, recognition price and speed are decisive factors. Therefore we have concentrated in the article on low-cost universal industrial color sensor [10]. From product recognition accuracy perspective, static product recognition is the best, i.e. perform product identification when the conveyor belt stops. Although this procedure is most accurate, it takes time within the production cycle. Therefore, we deal with the dynamic recognition of products in motion. This is more complicated in terms of accuracy, because uncertainties arise in product's identification, when measured value is outside the limits of control charts. For this case, we have demonstrated usage of the K-nearest neighbor machine learning algorithm described in [11,12], which corrects inaccuracies and based on the practical experiments performed in this article proves, that is fully sufficient for industry usage.

Subject and methods
The main ambition of the article is to present a universal solution for fast detection of industrial products based on their color. In order to have sufficient base of relevant data, we have prepared sample workplace shown in Figure 1. This workplace fully replicates industrial application and is equipped with industrial components such as: robot KUKA KR3R540, color sensor SICK CSM-WP117A2P and conveyor belt from Automatica (length 1.5 , width 0.25 , height 1 , three-phase Nord electric motor controlled by frequency converter Siemens Sinamics V20). For the purpose of experiment (simulation of custom production) we selected 6 products. Each in the form of calibration cube with different color as shown in the Figure 2. We applied measurements for 3 different distances from the sensor based on its technological specifics (10, 12.5 and 15 ) and 3 different lighting conditions (natural and artificial light, darkness). We performed 22 000 measurements in total to obtain statistical data to determine whether the accuracy of sensor is sufficient for moving products identification. We eval-uated Type A standard uncertainty for each product (color) separately from these measurements. Then we calculated Type B standard uncertainties and subsequently resulting combined uncertainty, based on which we declare the best settings for simulated process and after for the real operation. The next step is to set regulatory limits and create control charts for accurate identification. We can then evaluate if identified products are within the control limits and their identification is unambiguous. In other case, they are outside the control limits and their identification is ambiguous [13]. For these cases, we use the machine learning algorithm K-nearest neighbors. We have used values acquired during the measurements of color sensor accuracy as training dataset.
The methodologies are explained and analyzed in more detail in the following subchapters.

Preparation of test robotic workplace
It was necessary to set up workplace to test identification by the color sensor which simulates real operation and it is automated. An automated workplace enables to perform large number of measurements at different combinations of monitored factors. The workplace is represented by conveyor belt, along which colored calibration cubes move. After passing the cube and performing measurement, the cube is catched by robot's vacuum gripper and moved to the beginning of conveyor belt. This process is repeated for given number of measurements. The color sensor is located on the side of conveyor belt so that its detection zone faces the belt. To attach and position sensor, we designed a tool, which was printed on 3D printer. We first designed and assembled the workplace using Process Simulate simulation tool. We tested there the reachability of individual points needed for execution of catching and releasing cube operations.
The KUKA KR3 R540 robot with a load capacity of 3 kilograms is one of the low payload capacity robots. However, in our case it far exceeds the requirements, as the weight of the transferred calibration cubes is up to 100 grams. The robot range declared in the documentation is 540 millimeters. After testing the range in the Process Simulate tool, we found this range as not sufficient for the application. Therefore it was increased by adding a flange designed to allow insertion of suction cup mechanism. After repeated simulation of flanged robot range, prototype of flange was created on 3D printer. Robot range was also verified at the physical workplace. The repeatability of return to programmed position for this robot defined by the standard STN 18 6508 (in the past also covered by the standard STN EN ISO 9283: 1998) for handling industrial robots, reaches value of 0.02 millimeters, which is sufficient for our purposes. We also took this information into the account when calculating resulting uncertainty of measurement by the color sensor, according to [14,15].
We installed the KUKA ethernet KRL extension into the robot for measurement process purpose. This extension allowed us to communicate via Ethernet connection between robot and computer and collect the data. After correct configuration, it was possible to monitor inputs coming to the robot and based on them control outputs, in our case conveyor belt and suction cup shown in Figure 3. We also used conveyor belt from Automatica in the workplace implementation. The conveyor has length of 1.5 meters, height of 1 meter and belt width of 25 centimeters. The belt is rubber with anti-slip surface. The conveyor uses a three-phase motor Nord for its operation, with maximum of 1415 revolutions per minute. We used Siemens Sinamics V20 frequency converter to control the motor, which was controlled by the robot's output signals based on data from control computer. Motor speed was regulated to 30 percent of maximum rpm, which corresponded to the setting in real operation.
We chose the CSM-WP117A2P color sensor from Sick for color cubes identification, shown in Figure 4. The sensor emits white light on the scanned object using additive color mixing from three color diodes. Based on the reflection of light evaluates combination of red, green and blue components, which finally defines scanned color. Sensing distance of sensor is 12.5 millimeters with tolerance of 3 millimeters. Sensor relative sensitivity curve shows dependency on the sensing distance in Figure 5.  [16] Compact size of sensor is one of the advantages, which facilitates its placement at the workplace. Measurement is performed based on the light beam with size (1.5 x 6.5) of millimeter, emitted by the sensor. Therefore large color area is not required for identification. Another advantage is the possibility of using communication via IO Link. We integrated the sensor using SIG100 gateway.
The advantage of such integration is ability to connect multiple sensors through single gateway. This significantly facilitates communication and data collection from the sensors. The SIG100 uses REST application programming interface, so it was possible to query data from the sensor via JSON string generated by the control computer. After obtaining data from the sensor, this data was recorded to the MySQL database, which made their categorization and evaluation easier.

Results
The measured output of CSM WP117A2P sensor is three numerical values. Each value represents percentage of primary color. Values range in size from 0 to 100 percent. The first value represents percentage of red (R), the second percentage of green (G), and the third value percentage of blue (B) of the subject color. Based on this information, we defined following measurement model according to [17,18]: Where is resulting color percentage composed from contributions of red , green and blue component . When determining the overall measurement result, we did not consider correlations of values. Due to the fact that this is new proposal for which it is necessary to perform further experiments.
In experimental measurements using color sensor, we found that the highest influence on measured values had illumination of scanned object, distance of sensor from scanned object and whether scanned object was moving or stopped [18,19,20]. Therefore we decided to perform measurements with different combinations of these factors. The optimum sensing distance specified by the manufacturer is 12.5 millimeters, with tolerance of 3 millimeters. We chose values approaching to the limit distances of 15 millimeters, 10 millimeters and the optimal measuring distance of 12.5 millimeters. The illumination of scanned object had another major influence on measurement. We performed the measurements in natural daylight, with artificial light and in the dark. The main goal of measurements was to determine whether the measurement accuracy would be sufficient to identify the cubes even when the conveyor belt is running. Therefore we performed measurements of stopped and moving cubes and compare deviations.
We measured all settings combinations for six cubes with edge size of 30 millimeters and following colors: red, blue, pink, green, yellow and brown. The measured calibration cubes are shown in Fig. 2.
By the combination of influencing factors we created 18 combinations. We performed 200 measurements for each of the cube, from which we created the resulting dataset containing 22 000 measurements. In the first phase we evaluated Type A standard uncertainty for individual color components measured by the sensor. Subsequently we calculated total Type A standard uncertainty for given combination. The following part of work contains results of Type A standard uncertainty evaluation for individual color for above mentioned combinations, in a tabular form. When calculating uncertainties, we used procedures published in the literature [18,21,22]. Table 1 shows Type A standard uncertainty of red cube calculated from measurements performed when the cube stops. The table shows that smallest uncertainty was achieved in artificial light at scanning distance of 10 millimeters. The highest uncertainty was achieved when performing measurements in the dark at the distance of 12.5 millimeters.  Table 2 shows Type A standard uncertainty of red cube calculated from measurements made while moving on the conveyor. It is clear that uncertainties are higher in all combinations of factors than for the stopped cube. This fact confirms that movement of conveyor has significant effect on measurement. The lowest uncertainty was achieved in measurement performed in natural daylight at sensor distance of 15 millimeters from the scanned object. The highest overall uncertainty was achieved when measuring in artificial light at sensing distance of 12.5 millimeters.  Table 3 shows resulting Type A standard uncertainty for blue cube calculated from measurements performed when the cube stops. The lowest uncertainty is shown by the combination factors darkness and distance of sensor 12.5 millimeters from the scanned object. The highest uncertainty was recorded when measuring in natural daylight at sensor distance of 10 millimeters.  Table 4 contains the values measured when blue cube moves along the conveyor belt. Similarly as for red cube, data show higher variability than static measurement, which again indicates significant effect of motion on measurement accuracy. The lowest total uncertainty was achieved when measuring in the dark at measuring distance of 12.5 millimeters, same as for static cube. The highest uncertainty was achieved when measuring in artificial light at the distance of 10 millimeters.  Table 5 lists Type A standard uncertainty calculated from data obtained when measuring the stopped pink cube. The lowest total uncertainty was recorded when measured in the dark, at the distance of 15 millimeters. The combination of factors darkness and scanning distance of 10 millimeters showed the highest uncertainty. Similarly as for previous color cubes, overall uncertainty has increased with cube's motion on the conveyor. The lowest uncertainty was recorded when measuring in the dark, at the distance of 15 millimeters. The highest uncertainty was recorded when measuring in artificial light, at the distance of 10 millimeters.  Table 7 shows total Type A standard uncertainty calculated for the stopped green cube measurements. The lowest uncertainty was achieved in artificial light, at measuring distance of 10 millimeters. The highest uncertainty was recorded when measuring in artificial light, at measuring distance of 12.5 millimeters. The measurement of green cube again confirms effect of movement on measurement. It is clear from Table 8 that measurement performed on green cube in motion achieved higher uncertainties than for the stopped cube. The lowest uncertainty is shown by measurements performed in the dark, at the distance of 12.5 millimeters. The highest uncertainty was recorded for measurements performed in natural daylight and at the distance of 15 millimeters.  Table 9 lists Type A standard uncertainty calculated for the stopped yellow cube. Table shows that the lowest uncertainty was achieved when measuring in artificial light, at the distance of 12.5 millimeters. Measurements in artificial light, at distances of 10 and 15 millimeters, showed the highest uncertainty. We can see in Table 10 calculated Type A standard uncertainty for the measurements made for yellow cube moving on the conveyor. As for all previous cubes, measurements made in motion show higher overall uncertainty. The lowest uncertainty was recorded when measuring in artificial light, at measuring distance of 12.5 millimeters. The highest uncertainty was achieved when measuring in artificial light at the distance of 10 millimeters.  Table 11 contains Type A standard uncertainty calculated for measurements performed for the stopped brown cube. The lowest total uncertainty was recorded when measured in natural daylight, at the distance of 10 millimeters. Measurements show the highest uncertainty in natural daylight and darkness, at the distance of 12.5 millimeters.  Table 12 lists Type A standard uncertainty measured for brown cube moving on the conveyor. Same as for all previous measurements, the resulting total uncertainty is several times higher than the same combinations of influencing factors at stopped cube. The lowest total uncertainty was achieved when measuring in the dark, at the distance of 12.5 millimeters. The highest uncertainty was recorded when measuring in the dark, at the distance of 10 millimeters. The lowest total Type A standard uncertainty is shown in the dataset for brown cube, when the stopped cube is measured under different conditions. The highest uncertainty is shown by measurements performed for pink cube. When evaluating the data measured on the conveyor without stopping the cube, measurements made on green cube achieve the lowest Type A standard uncertainty, while values measured for yellow cube show the highest uncertainty.
By further examining data from object's illumination point of view, we came to conclusion that values of Type A uncertainties are lowest when measuring in the dark. This conclusion was confirmed by data obtained in both static and motion measurement. The highest Type A uncertainties were recorded in daylight static measurements, which may be due to its variance. When measuring in motion, we recorded the highest Type A uncertainties in artificial light measurements, which could be affected by reflection of light from moving object.
From object's distance point of view the lowest Type A uncertainties showed the data measured at the distance of 15 millimeters and the highest uncertainties showed measurements performed at the distance of 10 millimeters between sensor and measured object. We came to the same findings when evaluating the data from static as well as motion measurements.
As already mentioned in the tables, measurements performed for cubes in motion show several times higher Type A uncertainties for all colors and all factor combinations than measurements performed for the stopped cubes.
In the following article part we focus on Type B uncertainties, which we determined based on identifiable sources of uncertainties affecting measurement. After analysis of measurement process, we identified six components of Type B uncertainty. These sources and their values distribution are listed in Table 13 [18,21,22].
The first identified component of Type B uncertainty is uncertainty of cube placement by the robot. We estimated value of uncertainty based on repeatability of robot's return into specified position. This is stated in the robot documentation, according to standards for industrial manipulators. We also took into account calibration deviation of the robot effector and flange shape deviation caused by inaccurate assembly of individual 3D printed parts. Based on combination of these factors, we finally estimated the resulting component called cube placement by robot, hereinafter as 1 . As the second component of Type B uncertainty, we identified sensitivity of sensor at different sensing distances. Since we measured at three distances of sensor from scanned object, namely at distances of 10 millimeters, 12.5 millimeters and 15 millimeters, we determined its sensitivity at mentioned distances based on sensor documentation. The sensitivity for the individual distances is hereinafter referred as 2 and its values for individual distances are given in Table 13.
The third component of Type B uncertainty is the effect of illumination. We determined this component by estimation based on experimental measurements. As already mentioned in previous subchapters, data measured in the dark achieved the lowest variability. Based on this, the lowest uncertainty value was assigned to uncertainty component in the dark measurement. The uncertainty values for individual illumination are given in Table 13 with designation 3 . As next component of Type B uncertainty we determined the effect of conveyor movement. When estimating value of this uncertainty component, we used documentation of conveyor belt motor, specifically motor speed. The values of this uncertainty component for measurement of static cube and moving cube are given in Table 13 under the designation 4 . The component uB5 was determined from range of measured values, based on the difference between maximum and minimum measured value of individual color component. We determined interval for each combination of measurement settings for each color. The resulting interval of calculated values is shown in Table 13.
The last component of Type B uncertainty is the microclimate. This component includes the effect of external environment on measurement. The determined value of this uncertainty component is given in Table 13, defined according to [23]. 0.1% equal * value estimated based on the documentation, ** value estimated from experimental measurements, *** estimated value. The lowest total Type A standard.
Based on uncertainty components listed in Table 13, we calculated combined standard uncertainty and expanded uncertainty. When determining the expanded uncertainty, we chose the expansion coefficient = 2, i.e. the Gaussian distribution for coverage probability of 95.45%.
We calculated combined standard uncertainty based on total standard Type A uncertainty from data in Tables 1-12 and total standard Type B uncertainty given in Table  13. These total uncertainties listed as and are recalculated for every color cube, representing the customized product separately.
We can state based on the calculations (sample calculation presented in subchapter 3.1.) that influence of conveyor belt movement on measurement uncertainties is considerable. Measurements made on moving conveyor belt show higher values of uncertainties. This was confirmed for all cube colors and combinations of measurement process settings.
During data evaluation we found the lowest uncertainty recorded for measurements performed on brown cube. The brown cube achieved best results when measuring at stopped, even moving conveyor belt. On the other side, the highest uncertainty was achieved for static green cube and for yellow cube in motion.
We investigated the effect of sensor distance from scanned object as next factor. The data indicate 15 millimeters as most suitable measuring distance for both static and motion measurements. In the static measurement, the highest uncertainties were recorded when measuring at the distance of 12.5 millimeters. Measurements in motion reached the highest uncertainties at measuring distance of 10 millimeters. It can be stated that measuring distance was affecting motion measurements more than static measurements. While for static measurements uncertainties at individual distances reach similar values, for motion measurements uncertainty at the distance of 10 millimeters is significantly higher than at distances of 12.5 and 15 millimeters.
When evaluating uncertainties of data in terms of used lighting, we found the lowest measurement uncertainties for measurements of stopped as well as moving cube on the conveyor, accomplished in the dark. We recorded the highest values of uncertainties when measuring in artificial light. For static measurements, value of uncertainties in artificial light is significantly higher than in daylight. This is not the case for measurements in motion, where uncertainties recorded in daylight and artificial light have very similar values, which may be caused by reflection of cube color.
Our findings show, that if we want to use all colors of cubes, the best combination of setting of measurement process is measuring distance of 15 millimeters and the measurement should be performed in the dark, ideally with stopped cube.

Statistical evaluation if measured data
To demonstrate sample procedure of statistical evaluation of uncertainties, we chose brown color as customized product, based on best results whether stopped or in motion. Table 14 shows values of individual measured color RGB components, measured for moving brown cube at scanning distance of 15 mm, in the dark. Column R indicates percentage of red component, column G indicates percentage of green component and column B indicates percentage of blue component. In the first evaluation step we determined standard Type A uncertainty for individual color component using statistical methods, according to formulas (3) and (4).
Total Type A standard uncertainty is then [11,15]: In the next step, we defined individual sources of Type B uncertainties based on documentation and experimental measurements. The sources of uncertainties we used for determination of combined standard uncertainty are shown in Table 15, as mentioned in [15]. The first uncertainty component is Repeatability and indicates total standard uncertainty determined by the Type A method. The uncertainty component called Cube placement by the robot determined by the type B method, was estimated based on return repeatability of robot manipulator with considered assembly deviation of robot vacuum gripper. The uncertainty component Sensor distance sensitivity was determined based on documentation of color sensor CSM-WP117A2P. When determining Illumination effect, we used experimental data obtained with different types of lighting (darkness, daylight, artificial light) from experiments. The uncertainty component called Conveyor movement effect is calculated based on the conveyor speed specified in documentation. The uncertainty component Range of measured values was determined based on calculations performed on experimental data. The influence of microclimate includes impact of surrounding environment, in our case air-conditioned laboratory as mentioned in [15,21].
From individual components of uncertainty determined by the type B method, we subsequently calculated total Type B uncertainty according to the formula: After calculation of total Type A standard uncertainty and total Type B standard uncertainty, we determined the combined standard uncertainty based on formula given in [20]: When defining the expanded uncertainty, we chose expansion coefficient = 2, i.e. the Gaussian distribution for coverage probability of 95.45%. The relationship in sense of [15,22] then applies to expanded uncertainty: The result of color measurement (for the brown calibration cube) using color sensor CSM-WP117A2P after merging the color components and rounding, according to the balance table in Table 16, can be written as follows: The resulting color = (82.857 ± 2.844)%; = 2 Similar calculation was applied to all other colors representing customized industrial products. Based on their results, the brown color was evaluated as the best and therefore its sample calculation was presented in this subchapter.

Definition of control limits and control charts creation
For proper functionality of logistics system, it is necessary to ensure that sensors located at workplaces are able to correctly identify calibration cube based on red, green and blue color components. We decided to use statistical tool the Control Chart to secure stability of measurement process. It is graphical method using the principle of statistical tests of significance. The purpose of control chart is to compare and visualize current state of measurement towards predefined limits. When defining the limits, we take into account internal variability of measured process. The basic parts of Shewart control chart are [23,24]: • Central line CL; • Upper control limit UCL; • Lower control limit LCL.
The central line represents reference value of displayed characteristic, in our case average of measured values ̅ . We assume normal distribution therefore control limits are set at the distance of 3 on both sides of the central line. Where denotes the standard deviation. The control limit above central line represents the High control limit and the control limit below the central line represents the Low control limit.
We initially assumed possibility to create two charts for each calibration cube, which would cover all combinations of measurement process settings. While one of chart would monitor the process stability when measuring the stopped cube, the second then moving conveyor belt. As mentioned in evaluation of uncertainties, data measured during movement of cube on conveyor belt showed several times higher uncertainties than data measured when calibration cube was stopped. Based on this finding, two control charts would allow to define control limits for a larger number of colors in static measurement without overlapping.
The color components values of measured color within one setting combination, show relatively low degree of variability. However, comparison of individual sets showed that average measured value of color component differs depending on used settings combination. Further testing revealed that illumination is the main factor influencing change of these values. Other variability of values occurred for scanning distance changes, but this difference was not so significant. Based on these findings, the best way to increase number of identifiable colors, would be to create database of control limits for each combination of measurement process settings. Limits could be then selected based on conditions at the measurement site.
From the part of work describing measurement uncertainties, we can see the lowest achieved measurement uncertainties for brown calibration cube. The best combination of measurement settings was in the dark, at the distance of 15 millimeters. Therefore, we chose brown cube measured in the dark, at scanning distance of 15 millimeters, as example for determining the stability of the measuring process using control charts.

RGB color component charts for measurement of stopped brown cube
Graphs 1 -3 show color components control charts created from measurement of stopped brown cube, in the dark, at scanning distance of 15 millimeters. We used whole set of measurements for given settings combination when determining control limits, but we printed only first 45 measured values to keep the clarity in charts. The vertical axis of charts shows values of measured color components in percent. The horizontal axis shows measurement number at which the value was recorded. We used procedures described in the literature to define control limits [25].

Graph 1.
Red color component control chart for measurement of stopped brown cube, in the dark, at scanning distance of 15 millimeters Graph 1 shows red color component control chart. When determining control limits, we originated from normal distribution, i.e. we set control limits at the distance of 3 from central line. However, this distance was not sufficient for upper control limit, as several values exceeded this limit, which caused instability of control chart. Therefore we moved upper control limit to the distance of 4 , which proved to be sufficient for the stability of control chart.  Graph 3 shows control chart for blue color component of measured color. After determining control limits based on the normal distribution, we found that control limits are not sufficient to ensure the stability of measurement process, so chart is unstable. Based on this finding, in case of blue color component, we extended the lower control limit to 4σ. This covered all measured data, also did not unnecessarily expand interval too much by shifting both control limits.

RGB color component charts for measurement of brown cube in motion
Graphs 4 -6 show control charts for individual color components created from measurements performed for brown cube moving on the conveyor belt, in the dark, at scanning distance of 15 millimeters. In the measurement uncertainties part, we proved that measurements performed in motion show several times higher uncertainties than data measured for stopped cube. This fact was also reflected in the setting of control limits. Graph 4 shows control chart created for red component of measured color. We used normal distribution when determining the limits, i.e. we set limits at the distance of 3 . It was proved to be sufficient based on visualized dataset from measurement, as all measured values were within control limits. We also set limits for green and blue color components. After application of measured data, we found that control chart is stable. The control chart for green color component is shown in Graph 5 and control chart for blue color component is shown in Graph 6. As we can see from charts, the lowest variability in values was again identified for green color component, when measuring the stopped calibration cube.

Stability monitoring of measuring process
Based on created control charts for individual color components for all combinations of measurement settings for calibration cubes, it is possible to continuously monitor the stability of measurement process at individual workplace in production. After implementation of color sensor into production process, combination of settings is selected based on measurement conditions at given workplace and respective control charts are selected for individual color component of calibration cubes. If measuring process is stable, i.e. all measured values are inside the range of control limits, it will also ensure the smooth operation of logistics system, because it will work with correct data.
Color identification is essential to ensure smooth logistics operations. Without correct color identification, inaccuracies in calculations of current state of material on the line arise. Inaccuracy has negative impact on functionality of the system in long running operation. By implementing control charts, we can identify values that are outside the control limits and examine their origin.
The aim of application of control charts is to maintain the stability of measuring process. In case of process instability, it is necessary to assess each measured value individually. The value can be also excluded, if this is isolated case with large deviation from control limits. If this case is repeated and values accumulate outside the control limits, it is possible to implement some of appropriate corrective mechanism e.g. shortening the calibration interval, extending the control limits, reduction of impurities on calibration cube or sensor.
If one of sensors writes to the database value that is outside control limits for color component of measured color, the color is not successfully identified. In the next part, we address failure of color identification and possibility to solve the issue with minimum impact on logistics process. At the same time we must be able to identify the origin of measurement error.

K-nearest neighbors algorithm for identification of values outside the control limits
After the value is scanned by sensor, this value is recorded into the database table corresponding to particular sensor, based on the unique sensor identifier. Measurement number which is unique in the table is assigned to the value. The measured values of individual color components are thereafter loaded into the logistics system. Once values are available, they are checked whether color components are within the control limits of any of the defined colors. The color is identified, if component values are inside the control limits. If values fall outside the control limits, we still need to identify the color to avoid the disruption of logistics processes, which is controlled by the colors. For identification of colors based on values that are outside the control limits, we decided to use the Knearest neighbor machine learning algorithm, which we implemented in the Python programming language.
The K-nearest neighbor is classification algorithm often used in the analysis of large data based on common attributes. In the first step, the algorithm assigns training data to certain group based on their designation. The training data in our case are values measured during experimental measurements. These data have 6 independent variables based on which the resulting dependent variable is defined and determining the group [26]: Measured value of red, blue and green color component.
Since we divided the data for control charts according to combinations of measurement settings, the dependent variables conveyor belt speed, illumination and scanning distance are constant for all measured colors. Based on this fact, we need only 3 variables to define the dependent variable, in our case color. These variables are measured values of individual RGB color components.
The training sets for algorithm at specific setting of measurement parameters thus contain 1200 measurements -200 for each measured calibration cube. We divided the data into training and testing data, in ratio of 80/20 (training/testing) for functionality testing purpose. We can test in that manner whether the algorithm has not adapted too much to the training data, and still be able to respond to new dataset. As sample data set, we chose measurements performed on moving conveyor belt, in the dark, at scanning distance of 15 millimeters. Figure 6 shows distribution of training data based on dependent variable, in our case color, where the coordinates of individual points are determined based on RGB coordinates. As we can see in Figure 6, the data are grouped according to the color of cube and there are visible gaps between individual colors. After application of algorithm on the training data, we verified its accuracy on test dataset. Thanks to the mentioned gaps, the algorithm achieved accuracy of 100% in categorization of test data. This algorithm configuration is subsequently used to check measured value outside the control limits. If during the process occurs measured value which does not fall inside the control limits of any color (at given workplace setting), this value is tested by algorithm trained for that setting. The algorithm attempts to classify this value. The K-nearest neighbor algorithm for classification uses the Euclidean distances of trained data to the value to be classified. According to the input parameter of algorithm, which is number of searched neighbors, it determines given number of points with the lowest possible Euclidean distance to the value to be classified. Class of the new value is identified based on the class where most of the selected neighbors belong to [11,27].
The trained algorithm is therefore the tool which can be used for immediate estimate of measured color when recorded value is outside the control limits. We can reduce inaccuracies between the real and digital control system by application of algorithm and ensure the smooth process running. It is necessary in our case to set the maximum distance of nearest neighbor, what can filter out the category of values created by incorrect measurement. If we did not set the maximum distance tolerance, each measurement would be identified as one of the color, no matter how far the measured values were from the control limits of defined colors. The application of the algorithm is important especially when deploying sensors to a new workplace, until all environmental influences are identified. However, the algorithm is only a possibility of temporary identification solution for values outside the control limits. If large number of values are outside the control limits during the measurements, one of the above-mentioned corrective mechanism must be applied, e.g. an extension of the control limits.

Conclusion
One of the main trends nowadays is shift away from mass series production and transition to custom production based on the increasing requirements of demanding customers. The consequence of this trend is often several variations of the same product on one production line at the same time. Each variation has its own specifics which must be taken into account within the production process. For this reason, it is currently essential to be able to recognize products with the highest possible accuracy and speed. Every single stop due to identification, increases work cycle and prolongs the production time of product. The customization of production also increases final products price and therefore there is high pressure from manufacturers to reduce the prices of production technology as much as possible. However, technology with intelligent recognizing capability is relatively expensive and difficult to maintain.
Possible starting point for this situation is deployment of simple technologies already proven in the industry operations. Such a solution forms the substantial content of our article. It involves simple static color sensor commonly used in the industry. Difference here is, its usage in dynamic identification, where it is not primarily suitable due to sensor characteristic. Based on our research and experiment including 22 000 measurements performed on an automated robotic workplace built for this purpose, we can responsibly declare that it is possible. However, the statistical methods mentioned in the work must be used in order to obtain combined standard uncertainties and control charts for given sensor. Subsequently the mentioned K-nearest neighbor machine learning algorithm used in the work allows us to rectify the sensor errors in dynamic color scanning. The static color sensor with the best scanning results when the product is stopped, by using proposed methodology is then able to identify the products even in motion. On-the-fly identification speeds up the entire production line and thus allows us to produce more products in the same time. Since the conveyor belt does not stop, it significantly extends the technology operating life (by minimizing the occurrence of mechanical shocks), reduces required service (because of less mechanical components damage) and saves electricity (thanks to skipped energy inefficient start-ups).
The article offers us advantageous alternative to expensive and complex technology of dynamic scanning and identification of products in motion, in the form of using cheap static industrial color sensor with simple maintenance and adjustment wherever the type of production allows.