FACTA UNIVERSITATIS Series: Mechanical Engineering Vol. 16, N o 2, 2018, pp. 139 - 155 https://doi.org/10.22190/FUME180420016M © 2018 by University of Niš, Serbia | Creative Commons License: CC BY-NC-ND Original scientific paper1 A CLOUD-BASED EXPERT SYSTEM FOR SYNTHESIS AND EVOLUTIONARY OPTIMIZATION OF PLANAR LINKAGES UDC 621.7 Rosen Mitrev 1 , Boris Tudjarov 2 , Todor Todorov 3 1 Technical University, Mechanical Engineering Faculty, Sofia, Bulgaria 2 Technical University, Faculty of Computer Systems and Technologies, Sofia, Bulgaria 3 Technical University, Faculty of Industrial Technology, Sofia, Bulgaria Abstract. The present paper introduces a cloud-based expert system for synthesis and evolutionary optimization of planar linkages. The kinematic structure of the linkage is composed by the modular approach based on Assur’s groups. The dyads are represented as functional blocks with input and output variables. The applied approach for obtaining the geometrical relationships between the input and the output variables of the dyads is based on the use of homogeneous transformation matrices. The developed software system allows a dimensional synthesis of planar linkages by using genetic optimization algorithms. One feature is remote creation of the models of genetic algorithms as well as the receiving of the results by means of a user-friendly interface. By exploiting the application, the user can produce and edit the initial information about the synthesized or optimized linkage; thus he can receive the calculation results as a web page and/or as MS Excel file. An additional mutation of the best chromosome genes by scanning of every gene within its searching space improves the optimal solution. The analyzed numerical case studies show the applicability of the developed software system for mechanism analysis, synthesis and optimization. Because the number of genes is not limited, the linkages with a very big number of design variables can be synthesized by exploiting the developed approach. Key Words: Planar Linkage, Assur’s Groups, Genetic Algorithms, Expert System 1. INTRODUCTION In the past two decades, along with the classical graphical and analytical techniques [1, 2], there has been an increasing interest in the use of computer technologies for Received April 20, 2018 / Accepted May 28, 2018 Corresponding author: Rosen Mitrev Technical University, Mechanical Engineering faculty, Kliment Ohridski 8 blvd., Sofia, Bulgaria E-mail: rosenm@tu-sofia.bg 140 R. MITREV, B. TUDJAROV, T.TODOROV modeling and simulation of machines and mechanisms in education and engineering practice [3,4]. An easy applied and widely used approach is the modeling by way of special or general-purpose mechanical dynamics and kinematics software with different functionality realized on different platforms. Some programs are fully interactive, offering an easy-to-use environment [5-7] and possessing modules for preprocessing, numerical analysis and results post-processing. Simultaneously with undeniable advantages in its use, this type of software has some significant drawbacks: it is usually high-priced, the obtained results are limited to the software capabilities, equations of motion are embedded in the program and cannot be previewed by the user, and, finally yet importantly - it does not allow further development of algorithms by the user. Software systems where an active involvement of the user in the mechanism simulation model development is required are becoming increasingly popular. This type of software is based primarily on the algorithmic programming languages. For example, the C/C++ compatible object-oriented software [8] provides for a possibility of realizing independent applications in a Web environment and capabilities for performing a kinematic and dynamic analysis of a variety of mechanisms as well as synthesizing mechanisms with predefined properties. Other applications [9-11] are entirely Web-based and platform independent client-server systems, exploiting the advantages of the network computing. Typically, in this case, standard feature rich libraries for mechanism visualization, animation and results plotting are available. In some cases, the software systems are equipped with modules for mechanism type or dimensional synthesis, based on analytical or numerical methods [12]. A widely used approach, considerably facilitating the mechanisms creation, analysis and synthesis, is the modular approach [13, 14], which uses predefined blocks and subroutines for composing mechanisms with arbitrary complexity. During the realization of the modular kinematics it is possible to use different modeling approaches and philosophies. Such systems as OpenModelica [15] use graphical blocks to compose the mechanism kinematical structure while others use a collection of software subroutines for kinematic simulation, written in general-purpose [16] or computer algebra programming languages [17]. Despite the presence of a vast number of software systems, the capabilities of the modular approach combined with optimization for the purpose of mechanism synthesis in the Web environment are not used enough. The paper presents an open cloud-based expert system for dimensional synthesis and optimization of planar linkages based on the theory of Assur’s groups and genetic algorithms. The modular approach applied to the building of the linkages allows for their fast creation, modification, analysis, synthesis and optimization in a user-friendly cloud-based Internet environment, fully exploiting the benefits of the network computing. This paper is organized as follows: In Section 1 papers dealing with mechanisms different modeling approaches and philosophies are analyzed. Section 2 is devoted to the derivation of the Assur’s groups position, velocity and acceleration kinematic equations. Section 3 gives the structure of the developed cloud-based expert system for synthesis and optimization of planar linkages. Section 4 presents the description and discussion of the synthesis of four-bar and six-bar planar linkages. Section 5 represents a short conclusion. Cloud-Based Expert System for Synthesis and Evolutionary Optimization of Planar Linkages 141 2. ASSUR’S GROUPS KINEMATIC EQUATIONS The idea of decomposition of the mechanisms into Assur’s groups is not new. At the beginning of the 20 th century, the Russian scientist Leonid Assur developed a method of composing planar mechanisms of any complexity by the sequential appending of fundamental kinematic chains, which were later named Assur’s groups. The number of links n and the number of the fifth class pairs p5 in the Assur’s groups are related by the following equation: 5 3 2 p n Because n and p5 must be integer numbers, the first possible solution of the above equation is n = 2 and p5 = 3, i.e. the simplest fundamental kinematical chain consists of two links and three fifth class kinematical pairs. Internal kinematical pair of the group connects the two group links to each other and two external pairs connect the group to a driver link, to the other groups or to the ground. This simplest type of group is often called a binary group or dyad. Each of the dyads has zero mobility and their appending to the mechanism does not change the DOF (degree of freedom) of the whole mechanism. One can distinguish the following types of dyads: RRR, RRT, RTR, TRT, RTT, where R denotes rotational one DOF pair and T – translational one DOF pair. The RRR dyad is called Assur’s group of the first type. The rest of the dyads are created by replacement of the rotational with the translational pairs. The vast majority of the industrial linkages can be created by the combination of one or more dyads with the addition of one or more rotational or translational driving links. A substantial advantage of using dyads is the possibility to perform an independent kinematical analysis of each group and then compose a solution for the whole mechanism as a combination of partial solutions for different dyads. The primary goal of the solution is to describe the motion of the dyad according to the referential coordinate frame. Let us demonstrate the derivation and analytical solution of the kinematic equations for RRR dyad by using rotation and homogeneous transformation matrices, widely used in robotics. In order to specify the position of the dyad pairs, it is necessary to define their Cartesian coordinates in the fixed space reference coordinate system {x0y0}. To each rigid link of the dyad is attached a fixed coordinate frame {xkyk}, k = 1,2. The pose of the link is described by the position of its frame origin and the orientation of its x-axis according to the reference coordinate system. Fig.1 shows the geometrical relationships between the global and local representations of the dyad specific points. The orientation of link k is specified by the angle of rotation φk of link xk axis relative to x0 axis of the reference coordinate system. Angle φk is considered as positive if the rotation of xk axis according to positive x0 axis is counterclockwise. To point O3 is attached a local coordinate system {xeye} parallel to the reference frame. As the input for the position analysis of the RRR dyad are used coordinates (x1,y1) and (x3,y3) of two external rotational pairs and lengths L1 and L2 of the links. As the output are received coordinates (x2,y2) of the internal pair and angles φ1 and φ2. Thus, a dyad can be considered as а functional block which has input and output variables, related by known kinematical relationships. This type of dyad representation allows creating subprograms or modules for each dyad type and utilizing them as building blocks when creating linkages. 142 R. MITREV, B. TUDJAROV, T.TODOROV 2.1. Formulation of the position equations Formulation of the position equations constitutes the most difficult part of the kinematical analysis. Over the years, various approaches for formulation and analytical or numerical solution of the position equations are used [18-22]. A method to establish the geometrical relationships between coordinates of the group external pairs O1 and O3 is by using homogeneous transformation matrices. They represent a mapping from one frame to another: 2 2 2 1 3 3 1 2 ( ) ( , ) ( , , ) 1 B B B A A A x y x y              R P Т 0 (1) where by ( ) B A R is denoted the rotation matrix between two arbitrary coordinate systems A and B:   cos sin sin cos B A             R (2) φ – the angle of rotation between x-axes of A and B coordinate systems. By ( , ) B A x yP is denoted the vector that represents coordinates of the origin of frame B according to the origin of frame A. x0 y0 O0 φ1 L1 L2 x1 y1 O1 φ12 φ2 x2y2 O2 O3 x1 y1 x2 y2 x3 y3 φ2 xe ye Pk Fig.1 Schematics of RRR dyad The transformation matrix between {x0y0} and {xeye} coordinate frames is obtained by a sequential multiplication of a number of transformation matrices between the adjacent frames: 1 2 0 0 1 1 1 1 12 1 2 2 2 ( , , ) ( , , 0) ( , , 0) e e x y L L   T T T T (3) Cloud-Based Expert System for Synthesis and Evolutionary Optimization of Planar Linkages 143 After the expansion and simplification of Eq. (3) we get: 3 1 1 1 2 2 3 1 1 1 2 2 1 0 1 0 cos cos 0 1 0 1 sin sin 0 0 1 0 0 1 x x L L y y L L                            (4) Equating the elements (1,3) and (2,3) of the left matrix to the corresponding elements of the right matrix leads to the following position equations: 1 1 2 2 1 3 1 1 2 2 cos cos sin sin L L L L               r r (5) where by 1 r and 3 r are denoted the position vectors in the global frame of points O1 and O3, 1 1 1[ ] T x yr , 3 3 3 [ ] T x yr . In Eq. (3) we also had in mind that 12 2 1     (6) Eqs. (5) constitutes a nonlinear system of transcendental equations with unknown variables φ1 and φ2. After elaborate algebraic manipulations are obtained equations for the unknown angles in an explicit form:     1 2 acos atan2 , p C D E F        (7) where the following notations are used: 1 1 3 2 ( )A L x x  , 1 1 3 2 ( )B L y y  , 2 2 1 2 C L L   2 2 1 3 1 3 ( ) ( )x x y y    , 2 2D A B  , atan2( , )B D A D  , 1 3 1 1 2( ( ) sin ) /E y y L L    , 1 3 1 1 2 ( ( ) cos ) /F x x L L    . Parameter p specifies the assembly mode of the RRR group and accepts values +1 and 1. In addition, the coordinates of inner rotational pair O2 are computed as: 2 1 1 1 cosx x L   (8) 2 1 1 1 siny y L   (9) 2.2 Formulation of the velocity and acceleration equations Once the position equations are established, the corresponding velocity and acceleration equations are obtained by a straightforward differentiation with respect to the time. The linear velocities of joints O1 and O3 and the angular velocities of links 1 and 2 are related by Jacobian matrix J: V = JΩ (10) where 1 2 [ ] T  Ω is the vector of the unknown angular velocities of the links and 1 3 [ ] V r r is the vector of the difference of the known linear velocities of the external rotational pairs. The Jacobian for the considered RRR dyad has the following form: 144 R. MITREV, B. TUDJAROV, T.TODOROV 1 1 2 2 1 1 2 2 sin sin cos cos L L L L             J (11) The singular configuration for the dyad is determined from the Eq. (12). For L1, L2 ≠ 0 it is easy to find that the determinant (12) vanishes when φ1 = φ2 and singularities exist in this particular configuration. 1 2 1 2 det( ) sin( )L L    J (12) The unknown angular velocities are determined from the equation 1 Ω = J V (13) where by J -1 is denoted the inverse of the Jacobian: 2 1 2 11 1 2 1 21 2 cos sin1 cos sinsin( ) L L L L                J (14) The time differentiation of Eq. (10) leads to  A JΩ JΩ (15) which provides the relationship between the accelerations of external pairs 1 3[ ] A r r and the angular accelerations of links 1 2 [ ] T  Ω . From Eq. (15) we obtain the equations for the angular accelerations of the links: 1 ( )  Ω = J A JΩ (16) When we use Eq. (16), we have in mind that 1 1 1 2 2 2 1 1 1 2 2 2 cos cos sin sin L L L L                J (17) The Cartesian coordinates, velocity and acceleration of internal joint O2 are calculated by the Eqs. (18), (19) and (20): 2 1 1 1 1 [cos sin ] T L   r r (18) 2 1 1 1 1 1 [ sin cos ] T L     r r (19) 2 2 2 1 1 1 1 1 1 1 1 1 1 ( sin cos ) ( cos sin ) T L              r r (20) Once the unknown coordinates and angles are obtained, the displacement, velocity and acceleration of every point of the links can be determined. A fixed point Pk on body k is located from the origin of local frame {xkyk} by vector P k u and from the origin of global frame {x0y0} by vector , 1, 2 P k k r (see Fig.1). Position P k r , velocity P k r and acceleration P k r of the point are computed by the following relations: Cloud-Based Expert System for Synthesis and Evolutionary Optimization of Planar Linkages 145 0 ( ) P k P k k k k  r r R u (21) 0 ( ) P k P k k k k k  r r R u (22) 2 0 0 ( ) ( ) P k P k P k k k k k k k k     r r R u R u (23) where 0 sin cos ( ) cos sin k kk k k k               R and 0 cos sin ( ) sin cos k kk k k k             R . In a similar manner, the kinematic equations for the other four types of dyads are derived. In Figs.2-5 are shown the schematics and closed-form solutions for the rest of the Assur’s groups, derived in a similar manner as for the RRR group. For the Assur’s groups, containing slider pairs in their kinematic structure, one must take into account that the line of the sliding pair motion is defined by the coordinates of a point and angle, for example, for RRT dyad (see Fig.3) are used coordinates (x3,y3) and angle φ3, measured from horizontal x0-axis. The velocities and accelerations of the dyad output parameters are calculated according to the following kinematical equations: -1 out in q = J q (24) ( ) -1 out in out q = J q Jq (25) whose quantities are shown in Table 1, where the following short notations are used: c1 = cosφ1, s1 = sinφ1, c3 = cosφ3, s3 = sinφ3, cα = cosα, cα1 = cos(α+φ1), sα1 = sin(α+φ1), c4 = cosφ4, s4 = sinφ4, 13 1 3x x x   , 13 1 3y y y   , 13 1 3x x x   , 13 1 3y y y   , 14 1 4 x x x   , 14 1 4 y y y   , 14 1 4 x x x   , 14 1 4 y y y   . Fig. 2 Schematics and equations for TRT dyad 146 R. MITREV, B. TUDJAROV, T.TODOROV Fig. 3 Schematics and equations for RRT dyad Fig. 4 Schematics and equations for RTR dyad Fig. 5 Schematics and equations for RTT dyad Cloud-Based Expert System for Synthesis and Evolutionary Optimization of Planar Linkages 147 Table 1 Velocities and accelerations of the dyads output parameters Dyad Input/Output Singularities Jacobian RRR 13 13 x y        in q , 13 13 x y        in q 1 2          out q , 1 2          out q 1 2 2 k      1 2 2 k    k  1 1 2 2 1 1 2 2 L s L s L c L c         J , 1 1 1 2 2 2 1 1 1 2 2 2 L c L c L s L s            J 2 2 1 1 1 11 2 2 2 1 sin( ) c s L L c s L L                 -1 J RRT 13 13 x y        in q , 13 13 x y        in q 1 s        out q , 1 s        out q 1 3 2 2 k       1 3 2 2 k       k  1 1 3 1 1 3 L s c L c s         J , 1 1 1 3 3 1 1 1 3 3 L c s L s c            J 3 3 1 1 1 3 1 1 1 cos( ) s c L L c s              -1 J RTR 13 13 x y        in q , 13 13 x y        in q 1 s        out q , 1 s        out q 1 coss L   1 1 1 1 1 1 1 1 1 1 L s ss rc c L c sc rs s                   J 1 11 1 21 1 s c n ns L c             J 1 1 1 1 1 n sc rs L c       2 1 1 1 1 n ss rc L s       1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ( ) ( ) ss L c sc rs s sc L s ss rc c                          J TRT 13 13 x y        in q , 13 13 x y        in q 1 2 s s        out q , 1 2 s s        out q 3 4 2 k      3 4 2 k    k  4 3 4 3 c c s s        J , 4 4 3 3 4 4 3 3 s s c c             J , 3 31 4 43 4 1 sin( ) s c s c           J RTT 14 14 x y        in q , 14 14 x y        in q 1 2 s        out q , 1 2 s        out q 2 2 k     2 2 k      k      2 3 3 2 3 3 sin cos c s              J 3 31 2 3 2 32 1 cos( ) sin( )cos s c               J 2 3 3 3 2 3 3 cos( ) sin( ) s c               J 148 R. MITREV, B. TUDJAROV, T.TODOROV 3. DEVELOPMENT OF AN EXPERIMENTAL CLOUD-BASED EXPERT SYSTEM In order to combine the modular approach and the optimization synthesis in a common software environment, an experimental cloud-based expert system for synthesis and evolutionary optimization of planar linkages based on the derived in Section 2 Assur’s groups equations has been developed and tested. The system consists of the following software modules: 1) A module for linkage synthesis and optimization using evolutionary optimization methods, and, 2) A module with a user interface for linkage visualization, results plotting and animation. Among the available evolutionary algorithms [23,24] the genetic optimization algorithms (GA) are chosen and implemented in the developed cloud-based expert system [25]. It allows remote creation of the models of genetic algorithms and the receiving of the results by means of a user-friendly interface. By exploiting the application, the user can produce and edit the initial information about the synthesized or optimized linkage; thus he can receive the calculation results as a web page and/or as MS Excel file. The GA framework used technologies and realized functions are shown in Fig.6a). The sequence of the work with the experimental application is as follows: a) the user creates a description of the specific problem (model of genetic algorithm) that is transported and saved as XML file - Fig. 6b), where the explanation of the purpose of the elements is given by italic letters); b) PHP file reads stored XML and automatically generates a new PHP file for the considered case and the execution is redirected to the generated file; and c) generated PHP file performs the calculations and transmits a report back to the user according to the user requirements. a) b) Fig. 6 a) The GA framework; b) Contents of the XML transport file Cloud-Based Expert System for Synthesis and Evolutionary Optimization of Planar Linkages 149 The sequence of the steps of genetic algorithms is: a) An initial random population of n chromosomes (solutions) is generated; b) The viability f(x) of each chromosome in the population n (target function - called "fitness function") is calculated; c) The chromosomes are sorted according to their viability (calculated values of the fitness function) and priority for the next population is given to the best m of them (m