# Programming of Industrial Robots Using Virtual Reality and Digital Twins
## 2 Programming Robots Using Virtual Reality and Digital Twins  
This section proposes a developed robot programming method based on the operator's interaction with elements of the virtual environment. It is a method developed to replace a human being with a robot when performing an operation, during which an experienced employee performs a sequence of movements that are difficult to copy without direct measurements of the movements. Such situations occur when the sequence of movements leading to the achievement of a specific goal was selected by the employee based on many years of experience. Examples include painting, manually grinding turbine blades, cleaning casting moulds, moving bulky components, and complicated assembly of components. This approach is particularly advantageous when it is necessary to move objects that are in fact large in mass and the operator can easily manoeuvre them in a virtual environment.  
The virtual environment is a digital twin of a robotic station, built based on CAD models of existing station elements. With the help of a virtual visualization system, the operator is placed in a virtual robotic station. His role is to perform such manoeuvres with a selected object or tool as is the case during the implementation of real processes.  
The digital twin of the robot was created on the basis of the CAD model offered by the robot manufacturer. This model accurately determines the mass of links and mass distribution, which is important for modeling dynamic properties. In this model, the geometrical features of the robot are sufficiently represented, because the robot does not come into contact with a rigid environment. Otherrobot features such as deformability under load or temperature changes in the described application do not have a significant impact on the robot's movement.  
The virtual reality system was built based on the Oculus Rift (Facebook, Inc., Menlo Park, CA, USA) solution and an efficient PC. The system (Figure 2) consists of goggles, two controllers for hand control (Oculus Touch), two vision position sensors, and a computer with appropriate software. The goggles are equipped with two displays--one for each of the user's eyes. In the case of VR goggles, specialized lenses placed in each of the screens, whose task is to maximize image curvature, are the key. This is necessary to create the impression that the virtual reality is as realistic as possible. For a good reception of virtual reality, a smooth image at a level of at least 90 frames per second is also needed. After the user puts the goggles on their head, they display in front of the user's eyes a computer-generated image of a world or a film recorded in 360 degrees. In the environment the user can look around in a natural way, i.e., by moving their head or whole body. This is possible thanks to the acceleration sensor and gyroscope placed in the goggles and diodes generating infrared radiation, whose position is tracked by external sensors that are part of the system.  
Each of the diodes located on the goggles and hand controllers sends a unique pulse signature. Thanks to this, vision sensors record information on the position of the diodes and on this basis the position and orientation of the goggles and hand controllers are determined. The Oculus Touch is a small size device that surrounds the user's hands, which are constantly tracked by an external vision sensor system. The devices detect all movements of the wrists and simultaneously track the fingers: Thumbs, index and middle, which significantly improves immersion and allows the user, for example, to grasp objects in a three-dimensional environment. The option of grasping objects was used to program the robot's movements during the cleaning of casting moulds.  
The work [37] presents data on the accuracy of the Oculus Rift system. These data are summarized in Table 1.  
Figure 2: The idea of functioning of the virtual reality system.