Abstract: This paper studies the application and implementation method of OpenGL in industrial robot simulation. It utilizes OpenGL's superior rendering capabilities to draw the scene and robot, forming a highly realistic simulation environment. The paper also introduces RobotM, a self-developed offline robot simulation program. RobotM has functions such as robot model creation, animation simulation, and automatic path generation, realizing an offline robot simulation system.
Keywords: robot; 3D simulation; OpenGL; offline simulation
1 Introduction
With the application and development of robotics technology, robot programming technology has become a very important issue. Offline programming (OIP) for robots has advantages such as not needing to stop the robot's operation and being able to avoid collisions during actual robot movement through graphical simulation. Currently, there are basically no prototype tools for robot simulation in China. There are some commercial software systems abroad, such as RoboCAD, ROTSY, and Evision, but RoboCAD is relatively expensive and cannot be widely adopted; ROTSY is a simulation system based on the Motoman robot, but its universality is not strong and its price is also relatively high. This paper takes the research and development of networked welding robots, a key project of Jiangsu Province during the "15th Five-Year Plan" period, as the background, and designs RobotM, an offline software for industrial robot 3D simulation based on OpenGL, and completes the development of an offline simulation program for the Couma robot.
OpenGL is a graphics hardware-independent programming interface. Its class library handles the low-level operations of 3D graphics and offers advantages such as convenient modeling, real-time 3D simulation, high realism, platform independence, and relatively low system requirements. Therefore, RobotM utilizes OpenGL, Microsoft's VC++ development tools, and the MFC class library as the underlying graphics library interface to implement simulation design. The offline simulation principle is shown in Figure 1.
2. Detailed System Structure
The system module diagram is shown in Figure 2.
Figure 2 illustrates that RobotM employs a hierarchical design approach, with the overall program designed as a three-layer structure. Each layer is designed relatively independently, thereby improving the program's portability and reducing the difficulty of program maintenance.
2.1 Model Layer Design
The model layer utilizes OpenGI and MFC class libraries to construct a series of low-level class objects. RobotM uses these encapsulated class objects to build scenes and complete scene-user interactions. The RobotM design incorporates the concepts of spatial entities, spatial models, and robot models.
A spatial entity is a single, simple component, while a spatial model is a combination of several entities arranged in a certain way. Due to the special nature of robot simulation, it is obviously inappropriate to define the robot as a single entity or a single model. Therefore, the robot can be divided into several parts with each axis of rotation as the boundary, and each of these parts can be used as a spatial model, thus forming a combination of several spatial entities and spatial models, and several spatial models and robot models.
This hierarchical combination approach makes it easy to control the display and interaction of simulation programs. For example, when simulating an automobile welding production line using RobotM, using a spatial model object to describe the automobile object makes it easy to control that automobile object. For each type of spatial entity, RobotM implements a set of construction/drawing functions using the GlgenList/glCallList functions provided by OpenGI. By utilizing the spatial entity-spatial model-robot model organization and the polymorphism in C++ object-oriented technology, the drawing of both the robot model and the spatial model is ultimately reduced to the drawing of spatial entity objects.
RobotM saves simulation content as stream files. These files are stored and designed in a hierarchical structure using relative paths, including workspace, robot model, spatial model, and path files, as shown in Figure 2. Users can open workspace files to search for and retrieve information from other file types to create scene objects. Robot, model, and path files can all be used in other projects, exhibiting good reusability. Relative paths ensure that changing the project directory location does not affect file retrieval, increasing RobotM's robustness.
2.2 Scene Layer Design
The main function of the scene layer is to create, save, draw, and interact with objects within the scene. As an intermediate layer between the model layer and the teaching layer, the scene layer is the connecting part of the robot simulation system. The process of creating the scene layer from a file is shown in Figure 3.
As shown in Figure 3, scene creation is a process of converting several files into spatial entity objects in the simulation program. RobotM converts the user-selected workspace and other files into data structure objects that RobotM can recognize; similarly, the data structure objects in RobotM are written to files according to certain rules to complete the saving process. Scene rendering is a crucial part of the simulation program. The scene layer utilizes the entity rendering interface of the model layer, calling their respective rendering functions in the manner of Scene 1 (Robot) → Spatial Model → Spatial Entity. RobotM needs to display animations on the screen to represent the simulation results, so the program's rendering efficiency is extremely important.
In addition to various efficiency-enhancing methods using standard OpenGL rendering, this paper proposes a "necessary reconstruction" method in RobotM to improve rendering efficiency. This involves using several BOOI values as reconstruction markers for various parts of the scene (including robot models, spatial models, etc.). (Reconstruction refers to using the glGenerator function provided by OpenGL to store the content to be drawn in a memory area, which is then directly retrieved during each rendering without reorganization.) RobotM only reconstructs objects whose position or rotation angle has changed (including robot and spatial model objects) in each frame of rendering, while directly calling glCallList to draw objects that have not changed. This significantly improves rendering efficiency per frame, preventing display stuttering during program simulation.
The OpenGI-based industrial robot simulation design and implementation provides users with convenient operation functions for scene interaction. Users can modify the way they observe and control the entire scene (such as rotation, translation, changing lighting, etc.) according to their needs, and can also directly select target points or spatial entities in the scene with the mouse.
2.3 Teaching Layer Design
The teach pendant layer primarily handles offline programming design. The two upper layers have laid a solid foundation for the teach pendant's design. A key aspect of offline robot programming is the ability to determine the robot's motion patterns and positions within the simulation program based on user input; this relationship is similar to that between an actual robot and a teach pendant. RobotM achieves simulation by storing the motion patterns between each position point to describe the robot's trajectory.
RobotM has a small interpreter that can convert between robot programming languages and motion file formats that RobotM can recognize. Because the motion program compiler implemented by robot programming has its own syntax and semantics, RobotM must be able to convert between the robot control files used by the control cabinet and the programs designed by RobotM.
RobotM provides two methods for determining the end point of robot simulation motion: cornering motion and stationary motion. Cornering motion is similar to teach pendant teaching in actual robot motion, allowing users to input information into the simulation program to move specific joints of the robot, thus achieving cornering motion. Stationary motion, on the other hand, is relatively more important in RobotM and is something that cornering motion cannot achieve. Using the interface provided by the scene layer, a unique ID is created for each spatial entity/spatial model/robot model in the scene that needs to have its position determined using glLoadName. When the user selects a point in space with the mouse, the ID is used to identify the selected object. After obtaining the object, the OpenGI glUnProjeet function is used to obtain the position of the mouse click location in the "world" coordinate system, completing the conversion from mouse planar coordinates to spatial coordinates. The simulated robot's motion methods are then used to move the end point of the simulated robot to this spatial coordinate system, thereby determining the position of a specific point that the robot needs to move to.
By repeating the two processes described above several times, the settings for this series of points are completed, and a path file can be created. The path file can be used for simulation or downloaded to the robot control cabinet.
2.4 Auxiliary Module Design
The robot simulation program also includes some independent modules that are not grouped into the three-layer structure mentioned above. However, these modules are closely related to the three layers.
2.4.1 Algorithm Module
Considering that robot simulation programs need to simulate paths, it is necessary to provide corresponding forward and inverse kinematics algorithms for the robot, as well as algorithms for joint interpolation, linear interpolation, and circular interpolation. Since different robots have different forward and inverse kinematics solutions, implementing a universal algorithm in the simulation system is difficult. Therefore, we attempted to describe the robot's various parameters using files, which yielded good results.
2.4.2 Other Model Modules
The simulation program provides different ways to build models, namely Mdl, 3DS, and Obj file formats. In other words, it provides different file interfaces, through which different model building methods can be implemented in the scene.
2.4.3 Communication Module
The files generated by the robot simulation program are downloaded to the control cabinet or read from the control cabinet. The file transfer is achieved using RS232/BSC. The RobotM system implementation is shown in Figure 4. First, a SIASUN robot model was constructed.
3. Conclusion
This paper introduces RobotM, the offline programming system for robots developed by the author, and describes the system's main functions and principles. Future work will focus on designing and adding path planning and collision detection modules.
References
[1] Lin Rui, Shi Jiaoying. Scene management, 3D interaction and user interface design of OpenGI [J]. Computer Applications, 2000, (3).
[2] Chen Zhixiang, Huang Yong. Analysis and design of offline programming system for arc welding robot [J]. Journal of Mechanical Engineering, 2001, (10).
[3] Pan Aimin, David Kruglinski J. Visual C++ Insider [M]. 4th ed. Translated by Wang Guoyin. Beijing: Tsinghua University Press, 1999.
Click to download: 3D Simulation Design and Implementation of Industrial Robots Based on OpenGL Editor: Chen Dong