Research and Application of General Collision Detection Simulation Platform L. Zeng1, T. Ning1, P. Xi1 1 School of Mechanical Engineering and Automation, Beihang University, Beijing 100191 (lzeng2012@sina.cn) Abstract - System architecture of simulation platform based on assembly model with constrained motions is presented. By using accurate collision detecting algorithm library, collision detection function is implemented in the simulation platform. Control mechanism of the simulation platform is illustrated. To verify the practicality of the system and validity of the algorithm, a three dimensional numerical control tube bender simulation system is built based on this platform. Keywords - assembly model, collision detection, constrained motion, pipe bending machine, simulation I. INTRODUCTION Collision detection simulation system has a wide range of practical applications, for example, there are great demands for it in engineering fields, such as assembly process simulation, motion simulation of CNC machining, scheduling of transport equipment in warehouse, port constructing simulation, cargo handling management and so on [1-4]. The main research of this paper is about the collision detection simulation system for mechanical equipment. The related softwares include Dassault Systèmes’s VirtualNC, CGTech’s VeriCut, etc. Existing simulation systems generally use OpenGL as internal graphics platform, models that can be imported include 3DS [5], VRML and so on. Chen [6] uses Solid works to establish simulation system directly. SimMechanics[7] realizes the export of assembly model of commonly used CAD software by plug-in method, it can also be exported through the API function provided by SimMechanics. Yang [8] uses XML technology to store assembly model information, which facilitates the followup data retrieval and application. Literature [5] uses sample-point method to implement collision detection. Literature [4] adopts bounding box subdivision to deal with collision detection. Ali[9] uses linear programming to implement real-time collision detection of convex polyhedral in translation and rotation conditions. Zheng[10] implements collision detection of assembly model by fast detection method based on hierarchical subdivision. Miguel[11] uses double-layer multi-resolution to improve detection efficiency, and OBB-tree[12] is a common method. However, existing collision detection simulation systems have the following problems: VirtualNC and other software are basically for CNC machine tool, but can’t implement the simulation of other types of mechanical equipment (such as CNC pipe bending machine). In assembly modeling, some simulation systems depend on the specific CAD software, or lack the necessary assembly relations, assembly constraints and some other information, which would hinder the subsequent simulation application. In the collision detection algorithm, the current literatures generally adopt discrete method based on bounding box, which is hard to ensure the detection precision and speed. To improve the practicality and usability of the simulation platform, this paper derived assembly relations, constraint relations and parts geometric data based on the assembly model of CAD software. Related assembly information is recorded in text file, and parts geometric information is stored in file similar to STL. Objects defined in simulation platform correspond to these defined in CAD system’s assembly models, which would facilitate data transformation and motion constraint relations building. The G-code is used to define the system’s trajectory and control equipments’ running status. To improve the precision and efficiency of collision detection, we developed our own exact algorithm library, based on which we implemented collision detection in simulation platform. The rest of this paper is organized as follows. In the methodology, Section A introduces the relations and definitions of three kinds of objects in assembly model. Section B discusses kinematics constraint object based on the degrees of freedom of assembly model and the driven approach. Section C introduces the interface design of collision detection algorithm library. Section D gives the process analysis of model simulation. The results analyze the collision detection algorithm library and the test results of assembly model simulation. The last section summarizes the research contents of this paper. II. METHODOLOGY A. Representation of simulation model Product assembly mathematical model mainly describes hierarchical relations and assembly relations between product parts and components, as well as the constraint relations among assembly design parameters in different levels of assembly body: 1) Hierarchical relations. Product parts and components have hierarchical relations. A product can be decomposed into several components and parts, a component can be decomposed into several parts. These hierarchical relations can be visually represented as the assembly tree. The root node of the assembly tree corresponds to the product, every leaf node stands for each part, and the mid-side nodes stand for components. Assembly tree visually expresses the affiliate relations among products, components and parts. 2) Assembly relations. Assembly design in product parts and components is expressed by assembly relations between each other. The basic assembly relations include positional relation, connection relation and fit relation, etc. 3) Kinematic relations. Kinematic relations describe the relative motion and transmission relations between components. The core data of assembly mathematical model in this paper is component and fit relations. Component consists of parts and subassemblies, while fit relations consist of fitting, aligning, coaxial, parallel, vertical and tangent, etc. All components in assembly model constitute a hierarchical model according to the nested relations between each other. Components in the same level belong to the same assembly, and they have fit relations but no nested relations. Components in different level do not belong to the same level, and they have no fit relations but nested relations. Degrees of freedom (DOF) of a part is the number of possible movement patterns of the part while it is assembled with the connected parts under the constraints relations, and the connected parts are assumed to be fixed. Degrees of freedom can be divided into translational degrees of freedom (TDOF) and rotational degrees of freedom (RDOF), DOF=TDOF+RDOF. If a part is connected with no any other parts, then its DOF=6, that means it has three translational degrees of freedom and three rotational degrees of freedom. When the six degrees of freedom have all been constrained, then DOF=0, it is full constraint state. When 6>DOF>0, it is under constrained state. Related model objects are briefly described as follows. The data members of assembly model object CAsm mainly include name, bounding box and component set. The data members of Component object CComp mainly include local coordinate system, part model (or assembly model) and degrees of freedom attribute. The data members of part model object CPart mainly include name, material property, triangle set and bounding box. The degrees of freedom attribute of component contains specific geometric information. For example, rotation axis information is recorded for the rotational degrees of freedom. The geometric information will be used to define kinematics constraints. B. Realization of the constrained motion First we should note that each component of assembly model has a local coordinate system and a number of assembly constraints (such as fitting, aligning or coaxial, etc). Moving parts have certain degrees of freedom, such as for 3D CNC pipe bending machine, the bending arm (C axis) has a rotational degrees of freedom, and the car (Y axis) has a degrees of freedom of straightline motion. To associate the moving parts in assembly model with the straight-line motion and rotational motion of mechanism, we proposed axis object (CAxis) simulation servo motor. Since this paper is only for collision detection simulation, we deal with simplified motion control model, and the change of acceleration and deceleration is not in our consideration. The main attribute of CAxis include motion type (straight-line or rotational), current coordinate, movement direction signs, total displacement, speed, movement starting time and so on. The main interfaces of CAxis: Initialize. The interface is used to initialize a movement, and to specify the movement direction, coordinate increment, movement speed and starting time. Get the current coordinate (YBC data). Status update. The interface function is constantly updating CAxis coordinates, and inputting the current time, positive and negative limit position, outputting coordinate increment and limits. Reset. This interface is used to reset all state parameters of CAxis. Every motion axis of machine tool corresponds to a CAxis object. When a movement starts, if it is a singleaxis movement, then a corresponding axis CAxis is initialized; if it is interpolation, then several corresponding axes CAxis are initialized at the same time. The input parameters are movement direction, coordinate increment and starting time. Then, current axes CAxis coordinates would be updated every time slice and the local coordinate system of the corresponding components in assembly model are updated according to axes CAxis coordinates, then the whole assembly model starts to move. C. Collision detection algorithm library Six types of geometry were defined in collision detection library to enhance the generality of the system. These geometries are half-space, cube, cylinder, sphere, torus and polyhedron. The surface of polyhedron is triangular mesh, as shown in Fig. 1. Fig. 1 basic geometries and general polyhedron To ensure the collision detection precision, the algorithm library doesn’t adopt discrete algorithm but dozens of geometrical and algebra accurate algorithm. There is no complete collision detection algorithm based on accurate calculation in existing literatures, for example, no accurate algorithm for cutting torus has been provided at present. Results from collision detection contain two collision geometries, collision marks, interference depth, collision point and some other information. To detect the collision of assembly model, first we use the bounding box of each component in assembly model to judge the collision roughly, then for the parts whose bounding box intersected, we use algorithm in collision detection library to detect the collision precisely. The algorithm is developed by our own research group and is in patent application, and will be introduced in another paper. This paper only gives the test results. To realize the openness of the general simulation platform, the collision detection algorithm is designed to be independent algorithm library, and is associated with simulation platform by standard interface. D. Control mechanism of simulation platform The motion trajectory and running status of model in simulation platform is defined by G-code in ISO standard. G-code consists of word and block. Each word has a key word, key word G stands for movement, M stands for ready to action, S stands for speed of main axis and F stands for feed rate. A number of words form a block. For example, G00 X0 Y100 Z50 is a block formed by three words, G00 stands for fast straight-line motion, XYZ stands for coordinate values. collision detection library in Windows XP system. Based on the simulation platform we implemented 3D CNC pipe bending machine simulation system. The whole mechanical model of pipe bending machine consists of 7 assemblies and 18 parts, and occupies 5.3MB space. The YBC three axes of pipe bending machine can be manually controlled to rotate by single step. Pipe can be bent continuously by executing G-code, and it can also be bent step by step manually. The simulation system displays the current coordinates and G-codes real-time. Wall and ground can be added to the system as collision constraints. The system status (that is collision detection) updates every 0.01 second. The pipe bending simulation system implements collision detection between pipe fitting and machine tool, pipe fitting and pipe fitting, pipe fitting and wall or ground. Parts in collision section are shown in red during the simulation, as shown in fig. 5. From the test results we can find that the collision detection algorithm library can detect collision accurately. Our test hardware platform is DELL Vostro1400, CPU is Intel(R)Core™2Duo and 1GB of physical memory. The collision detection algorithm is relatively the most time-consuming when pipe fitting or machine tool is about to collide or has already collided. The specific test results of case c in Fig.3 are as follows: Pipe bending time duration 12.3s Fig. 2 system status update mechanism Table I. Test results of collision detection algorithm Number of Total time Single Maximum detection consuming detection single of algorithm time detection time 300 0.492s 1.6ms 16ms (a) pipe bending process 1 G-code compiler handles G instruction set inputted into it and output specific motion control commands to drive each related axis to produce movement, and then mechanism starts to move. A timer is defined in simulation system, and every time slice (such as 0.0010.01s) it would perform a subroutine to update model status, as shown in Fig. 2. III. RESULTS We built general collision detection simulation platform with VC6.0, OpenGL graphics package and (b) pipe bending process 2 (c) collision of pipe itself (d) collision between pipe and machine tool Fig. 3 collision detection IV. CONCLUSION This paper presents the general simulation platform architecture with kinematic constraints based on assembly model, and implements CAD model import, G-code parsing and system simulation control mechanism. Collision detection of the system based on accurate collision detection algorithm has also been implemented. Take 3D CNC pipe bending machine as example, we verified the practicality of the simulation system. To further improve the general simulation system and apply it to assembly and simulation field, the follow-up work is mainly in three aspects. The first one is to support more model definition file format, such as the wildly used VRML file format, as well as lightweight CAD model JT and 3DXML file format offered by UG and CATIA. The second one is to integrate the platform with simulation software, and realize Working Model 3D or ADAMS data interface. The third one is to optimize the collision detection algorithm library, and implement accurate calculation of interference amount (interference depth). REFERENCES [1]. Qu Xuejun, Xi Ping. A Method for Automatically Picking up Process Technical Information of Bend Pipe Part in an Emulator System [J]. Computer Simulation, 2002, 19(5):78-80(in Chinese) [2]. Li Bohu, Cai Xudong. The New Trends of Modern Simulation Technology [C] // Proceedings of the 21th Chinese Control Conference, Hangzhou, 2002:1-4(in Chinese) [3]. Zhou Silei. NC Simulation Technology Based on Virtual NC [J]. Mechanical Engineering & Automation, 2008, 4:24-28(in Chinese) [4]. Duan Chunhui, Ding Guofu, Zhang Jihui, Gao Zhaoxue. Design and Implementation of Tube Bending CAD/CAM System [J]. Application Research of Computers, 2007, 24(5) : 204-209(in Chinese) [5]. Li Feng. Study on Motion Simulation and Working Procedure Planning for NC Tube Bending [D]. Xian: Northwestern Polytechnical University, 2007(in Chinese) [6]. Chen Chengjun, Zhou Yiqi, Yang Hongjuan. Study on an approach of transformation and representation based on the SolidWorks model to the virtual assembly model [J]. Journal of Shandong University (Engineering Science), 2008, 38(1): 61-65(in Chinese) [7]. MathWorks. SimMechanics Reference. www.mathworks.com, 2009 [8]. Yang Hongjun, Ning Ruxin, Zheng Yi . Data exchange from CAD to virtual assembly system based on XML [J]. Machinery Design & Manufacture, 2006, 11: 46-48(in Chinese) [9]. Ali Akgunduz. Collision detection in fast moving objects [D]. PhD dissertation of Illinois Institute of Technology, 1996 [10]. Zheng Yi, Ning Ruxin, Liu Jianhua, Yao Jun. Research on Fast Collision Detection Method in Virtual Assembly Environment [J]. Journal of System Simulation, 2005, 17(9):2167-2170(in Chinese) [11]. Miguel A. Otaduy, etc. CLODs: Dual Hierarchies for Multiresolution Collision Detection [C] // Proceedings of the 2003 Eurographics/ACM SIGGRAPH symposium on Geometry processing, Aachen, 2003:94-101 [12]. S. Gottschalk, etc. OBB Tree: A Hierarchical Structure for Rapid Interference Detection [C] // Proceedings of the 23rd Annual Conference on Computer Graphics, August 4-9, New Orleans, 1996:171-180 [13]. Wei Yingmei, Shi Jiaoying, Wu Quanyuan. Collision Detection Methods for Virtual Environment[J]. Computer Engineering & Science, 2001, 23(2):44-47(in Chinese) [14]. Yang Jing, Zheng Guolei. Digital Human Model and the Simulation of Worker's Working Posture in Aircraft Assembly Simulation [J]. Mechanical Engineering & Automation, 2005, 4:15-18(in Chinese) [15]. Wan Bile, Liu Jianhua, Ning Ruxin, Zheng Ye. Research and Realization on CAD Model Transformation Interface for Virtual Assembly [J]. Journal of System Simulation, 2006, 18(2):391-394(in Chinese) [16]. Tang Rongxi. The Principle of CAD/CAM Technology [M]. Beijing: The Press of Beihang University, 1994 [17]. Sun Jiaguang. Computer Graphics [M]. Beijing: The Press of Tsinghua University, 2007(in Chinese) [18]. Russell Smith. Open Dynamics engine V0.5 User guide. www.ode.org, 2006.