# Vision Systems for a UR5 Cobot on a Quality Control Robotic Station
## 2 Experimental Setup of the Robotic Station
### Communication System  
For communication at the PC\(\leftarrow\rightarrow\)UR5 level in the software layer, the Primary/Secondary and real-time interfaces were used (provided by the server implemented in the robot controller [62]). The server supports the URScript interpreter and broadcasts basic data about the robot's state (position of connectors, supply voltage of individual drives, etc.). For the purposes of communication with and control of the cobot, proprietary libraries were developed in Python 3.12, based on the URScript language. For instance, functions were implemented to control the movement of the cobot, enabling the execution of the manipulator's movement in joint and linear interpolation (equivalents of the MoveJ and MoveL cobot's commands). In the case of PC\(\leftarrow\rightarrow\)Mako G-125B communication, the Python programming interface (API) provided by Allied Vision as part of the Vimba software  
Figure 2: Layout of the cobot station: 1—UR5 CB2 cobot; 2—illuminator (backlight lighting); 3—Savio CAK-01 USB webcam camera; 4—Mako G-125B camera; 5—container where defective parts are rejected; 6—space warehouse; 7—piCOBOT vacuum ejector. was applied (Vimba Python API). In the case of PC\(\leftarrow\)-Savio CAK-01 connection, the mechanism for capturing system USB interfaces available in the OpenCV 4.7.0.68 libraries was employed. Within the framework of the integration of the robotic station with neighboring stations, in the case of the SCARA robot (i4-550L, Figure 1), a wired Ethernet connection between robot controllers and a connection of individual inputs/outputs of robot controllers (digital_in0, digital_out0, on the side of the UR5 robot controller) were implemented. As part of the Ethernet connection, the TCP/IP protocol was employed to exchange data regarding subsequent items from the unloading section and digital inputs/outputs to manage access to the collision zone. In the case of the mobile robot (LD90), a wireless connection was deployed using the WiFi protocol through distributed WiFi 1/O modules connecting the inputs/outputs of robot controllers (digital_in2, digital_out1, on the side of the UR5 cobot controller). The previously mentioned setup enabled the synchronization of the loading process of parts. A schematic diagram of the communication model is presented in Figure 1.  
Multithreading  
While the station is operating, the cameras' image acquisition processes and the cobot's data exchange processes must work independently of the main program loop, which is why they are launched as independent threads (Figures 3 and 4). The station's operating algorithm was divided into a few processes related to image acquisition, data exchange with the cobot and analysis of the captured image. According to the diagram presented in Figure 4, the MakoCamera class inherits from the threading.Thread class in order to work as an independent thread. Figure 4: Class diagram illustrating the system software architecture—vision system. Figure 3: Class diagram illustrating the system software architecture—robot management. The next step is to initialize the acquisition process by calling the start_streaming() (methods imported from vimba module) method, which takes a reference to the Handler class as a parameter. This class is a callable class (_call_() method defined); when it is called, after obtaining the FrameStatus.Complete (attribute available from vimba module) status, the captured image is converted to a format supported by the OpenCV libraries and assigned to the opencv_format_img variable. Synchronization between individual classes is carried out using the methods threading.Lock() and threading.Event() from the threading.Thread module. The sequence of work of the program analyzing the Primary/Secondary interface packets begins with creating a communication socket and connecting to the appropriate controller port (the port used by the Primary/Secondary interface service).