Real-Time Implementation of a Dynamic Fuzzy Neural Controller for a SCARA Robot Meng Joo Er *, Nikos Mastorakis #, Moo Heng Lim * and Shee Yong Ng * * School of Electrical and Electronic Engineering Nanyang Technological University Nanyang Avenue, Singapore 639798. REPUBLIC OF SINGAPORE Tel : (65) 7904529, FAX : (65) 7912687 Email : emjer@ntu.edu.sg, mooheng@pmail.ntu.edu.sg and sheeyong@pmail.ntu.edu.sg, # Military Institutions of University Education Hellenic Naval Academy Terma Hatzikyriakou, 18539, Piraues, GREECE. E-mail : mastor@ieee.org Abstract This paper presents the design, development and implementation of a Dynamic Fuzzy Neural Networks (D-FNNs) Controller suitable for real-time industrial applications. The unique feature of the D-FNNs controller is that it has dynamic self-organising structure, fast learning speed, good generalisation and flexibility in learning. The approach of rapid prototyping is employed to implement the D-FNNs controller so as to control a Selectively Compliance Assembly Robot Arm (SCARA) Robot in real time. Simulink, an iterative software for simulating dynamic systems, is used for modelling, simulation and analysis of the dynamic system. The D-FNNs controller was implemented through Real-Time Workshop (RTW). Keywords: Algorithms for Real-time Control; Adaptive Control; Fuzzy Systems; Neural Network Systems; Manipulators. 1
1 INTRODUCTION The promise of robots being able to replace menial, tedious, or dangerous human tasks has motivated many engineers to design and develop more sophisticated and intelligent controllers for robotics. Numerous intelligent control methodologies have been devised to solve a number of complicated problems in robot manipulators, which are represented by a multivariable non-linear coupling dynamic system with uncertainties [1]-[5]. Due to uncertainties, it is difficult to obtain an accurate mathematical model for the robot manipulators. Conventional control methodologies find it difficult or impossible to handle unmodelled dynamics of a robot manipulator. To accommodate system uncertainties and variations, learning or adaptive techniques must be incorporated. Most conventional methods, e.g. PID controllers, are based on mathematical and statistical procedures for modelling the system and estimation of optimal controller parameters. In practice, the plant to be controlled is often highly non-linear and a mathematical model may be difficult to derive. As such, conventional techniques will not be able to handle modelling errors and are lack of robustness. Fuzzy logic, however, offers a promising approach to robot controller design. In contrast with conventional controller design techniques, fuzzy logic formulates control of a plant in terms of linguistic rules drawn from the behaviour of a "human operator" instead of an algorithm synthesised from a rigorous mathematical model of the plant. Due to the growing popularity of Neural Networks, much research effort has been put into the design of intelligent hybrid controllers using fuzzy logic and neural networks. Design of robust adaptive controllers suitable for real-time control of robot manipulators is one of the most challenging tasks for many control engineers. Robot manipulators are multivariable non-linear coupling systems and are frequently subjected to structured and/or unstructured uncertainties even in a well-structured setting for industrial use. The Dynamic Fuzzy Neural Networks (D-FNNs) algorithm used is a newly developed algorithm that has the following salient features: dynamic self-organising structure, fast learning speed, good generalisation and flexibility in learning. The D-FNNs controller is employed to compensate for environmental variations such as payload mass and disturbance torque during the operation process. It offers either 2
off-line learning or on-line learning of the plant. By virtue of on-line learning, it is able to learn the robot dynamics and makes control decisions simultaneously. In effect, it offers an exciting on-line estimation scheme of the plant. The approach of Rapid Prototyping process is used to implement the D-FNNs controller in real-time through Real-Time Workshop (RTW) using the Texas Instruments TMS320C31 floating-point processor, together with some supporting files. In addition, Simulink is used for modelling, simulation and analysis of the dynamic system. 2 OVERVIEW OF THE SEIKO TT-3000 SCARA ROBOT 2.1 Background on the TT-3000 SCARA Robot The SEIKO D-TRAN 3000 Series robot used in this work is a four-axis, closed-loop DC servo Selectively Compliance Assembly Robot Arm (SCARA) manipulator. Each of the four axes provides a different motion and contributes to one degree of freedom of the robot (see Figure 2-1). The main characteristics of the TT-3000 SCARA robot are its high precision, repeatability and speed. The basic SCARA geometry is realised by arranging two revolute joints (T1 and T2 Axes) and one prismatic joint (Z-Axis) in such a way that all axes of motion are parallel. The acronym SCARA characterises mechanical features of a structure offering high stiffness to vertical loads and compliance to horizontal loads. Motion control is implemented only for axes Z, T1 and T2 of the TT-3000 in this work, which are designated as Joint 1, 2 and 3 respectively. 3
Figure 2-1 : The SEIKO TT-3000 SCARA Robot Arm 2.2 The Robot Dynamic Model The dynamic equations of a rigid body robot are a set of highly non-linear coupled differential equations given by M ( θ) θ + C( θ, θ) θ + G( θ) + F V θ + F C = τ where M( θ ) is the n n inertia matrix of the manipulator, C ( θ, ) is the n n vector of centrifugal and Coriolis terms, G( θ ) is an n 1 vector of gravity terms, vector of viscous friction terms, θ F V is the n 1 F C is the n 1 vector of coulomb terms and τ is the n 1 vector of the input torque (generated by the joint motor). Each element of M( θ ) and G( θ ) is a complicated function which depends on angular positions of all joints of the manipulator, θ. Similarly, each element of C ( θ, ) is a complicated function of both θ and θ. The movement of the end-effector to track a desired trajectory, at a particular velocity, thus requires a complex set of torque functions to be applied to the actuating system of the robot at each joint. The dynamic model of the TT-3000 SCARA robot arm has been developed in [6], with most of its parameters determined and verified θ 4
through experiments. Based on this known mathematical model of the robot, training of the D-FNNs controller was carried out using MATLAB simulation tools. 2.3 Motion Control A two-joint control structure is used in this work where motion control of the T1-axis and T2-axis will be executed simultaneously. In this scheme, the Z-axis will not be controlled for simplicity. Motion control of the robot arm is shown in Figure 2-2. Figure 2-2: The SCARA Robot Joint-Motion Control Structure The control system of the two joints is considered a Multiple-Input Multiple-Output (MIMO) system. The degree of difficulty will increase if the number of joints to be controlled simultaneously increases together. The implementation of this control architecture on the target system is illustrated in Figure 2-3. D-FNNs * Position Error & Link Acceleraton Data input to D- FNNs D/A T2-Axis T1-Axis Angular Displacement (In Digital Counts) SEIKO TT- 3000 SCARA Robot Arm T1 & T2 Axis Encoder Output 1 2 DSP Compute Position Error & Link Velocity Encoder Encoder T1-Axis Angular Displacement T2-Axis Angular Displacement 5
Figure 2-3: Control Structure of the D-FNNs 3 DESIGN AND SIMULATION STUDIES OF D-FNNs 3.1 D-FNN Architecture The D-FNN architecture used, depicted in Figure 3-1 1, is constructed based on the Radial Basis Function (RBF) and functionally, it is equivalent to an TSK model-based fuzzy system. Layer 1 Layer 2 Layer 3 Layer 4 x i MF φ ij j w j y Figure 3-1: D-FNN Architecture In Figure 3-1, Layer 1 defines the input variables layer. This is the layer where the input signals first enter the neural network. Layer 2 represents the membership function associated with the input variables. The membership function is chosen as a Gaussian function of the following form: - (x i c ij ) MF ij(x i ) = exp 2 σ j 2 i = 1,2,3 K r j = 1,2,3 K u (3.1) where r is the number of input variables and u is the number of membership functions. Layer 3 is the rule layer. The number of RBF units in this layer indicates the number of fuzzy rules. The outputs are given by φ MF (3.2) = r j i = 1 ij 1 Please refer to [7] for assumptions made in using this notation. 6
Layer 4 defines the output variables. Each output variable is the weighted sum of incoming signals. Corresponding to a fuzzy system, this layer performs defuzzification that considers the effect of all membership functions of the input values on the output, i.e., j w j The weight is chosen as follows in the TSK model: w j u y = φ (3.3) j = 1 = α K+ 0 j + α1 j x 1 + α rj x r (3.4) where αi s are real-valued parameters. It is not difficult to see that Eq. (3.3) can be re-written as where y =WΦ (3.5) w = α α α 01 11 L L r 1 K K K α 0 α 1 α u u ru (3.6) Φ φ K 1 φ φ x K 1 1 φ = K K φ x r K 1 φ u u u x x 1 r T (3.7) The proposed adaptive fuzzy neural control scheme is depicted in the following figure. θ, θ d d, θ d FNN B - PD + τ FNNB τ Disturbances Robot θ, θ, θ τ PD - FNN A D-FNN Learning Algorithm 7
Figure 3-2: Adaptive Fuzzy Neural Control System The basic idea of this approach is to learn the manipulator s inverse characteristics and to use the inverse dynamic model to generate the compensated control signal. There are two FNNs used in this control system. FNN A is employed for weights training of the system whereas FNN B is used to generate the appropriate control signal with the trained weight structure from FNN A. The proposed control algorithm is given by τ = τ PD + τ FNNB (3.8) where τ is the required control torque, τ PD is the torque generated by the PD controller and τ FNNB is the torque generated by FNN B. The inverse robot model is obtained by FNN A, employing the D-FNN learning algorithm 2. There are two learning modes, namely offline and online learning. For offline learning, FNN A is trained using a nominal dynamic model, whereas for online learning, FNN A is trained during real-time control of the manipulator. This paper deals with offline learning only. FNN B is a duplicate copy of FNN A, but its weights will be further adjusted by the error signal τ PD as the controller is running. This is to compensate for modelling errors and unmodelled disturbances. The parallelconnected conventional PD controller also caters for faster and more accurate tracking performance. The control idea is to train FNN B such that the squared error between the desired torque and the actual torque is minimised, i.e. 1 E = 2 1 = 2 ( τ τ FNNB ) ( τ ) 2 PD 2 (3.9) To achieve fast weight adjustment, the gradient method is used to minimise E. The weight is adjusted as follows: where η > 0 is the learning rate. ( new ) W ( old ) W = W E (3.10) = η W 2 Please refer to [7] for further details on the D-FNN learning algorithm. 8
Using the chain rule, we have E = W From (3.5) and (3.9) E τ FNNB E τ = W FNNB τ FNNB τ W FNNB ( τ τ ) = Φ FNNB (3.11) (3.12) (3.13) Thus, (3.10) can be rewritten as W = η ( τ τ )Φ (3.14) FNNB 3.2 Simulation Studies The simulation program for the D-FNNs is written in MATLAB and Simulink to facilitate Rapid Prototyping, a process that allows one to conceptualise solutions using block diagram modelling environment and have a preview of system performance prior to laying out hardware, writing any production software, or committing to a fixed design. Figure 3-3 shows the rapid prototyping process in greater details. Identify system and/or algorithm requirements Build/edit model in Simulink Run simulations and analyze results using Simulink and MATLAB Are results OK? NO YES Invoke the Real-Time Workshop Build procedure,download and run your target hardware Analyze result and tune the D-FNNs using ControlDesk Are results OK? NO YES Use generated code in the production system Figure 3-3: Rapid Prototyping Process 3.3 Simulation Model of D-FNNs 9
The rapid prototyping process begins in Simulink. The first step in the design is to develop the SCARA robot model prior to algorithms development in Simulink. Once a simulation model which models the robot with sufficient accuracy has been developed, the rapid prototyping process for D-FNNs design continues by using Simulink to develop the algorithm and analyse the results. If the results are not satisfactory, the modelling/analysis process is iterated until satisfactory results are achieved. Figure 3-4 depicts a general control model for D-FNNs. Pos_T1 Pos_T1 T1 Pos_T2 Pos_T2 T1 T2 Accl_T1 Accl_T2 Accl_T1 Accl_T2 T2 D-FNNs Robot Model Figure 3-4: General Control Model for D-FNNs Figure 3-5 shows the simulation model of the D-FNNs system created in Simulink for Joint 2 (T1-Axis) and Joint 3 (T2-Axis) of the SCARA robot. M-functions to be converted to S-functions Dynamic model of 2-link robot Figure 3-5: Offline Training System with D-FNN Learning Algorithm Using this model, iterative tuning is performed on the input and parameters of the D- FNNs controller. The aim is to achieve zero overshoot within an acceptable steadystate error of less than 2%. To ensure compatibility with Simulink s Real-Time Workshop (RTW) and real-time implementation, DFNNs controller needs to be 10
written in C-MEX S-Functions. Offline training was done using the system model in Figure 3-5. After obtaining the required weight structure, the system model in Figure 3-6 was used to simulate and test the D-FNNs controller. Mux S-function for FNN B dotdot1 MATLAB Function MATLAB Function dotdot2 Mux FNNB_simulin Demux u(1)*6000 Fcn Mux S-Function u(1)*3000 Scope2 Demux1 Fcn1 Mux6 1 Constant Amplitude = 1.5 Amplitude = 0.7 1 90 Gain1 90 Gain2 0.5 Gain 0.5 Gain3 D2R Degrees to Radians D2R Degrees to Radians1 Sum1 Sum4 PID PD=35,7 PID PD1=35,7 Sum2 Sum3 Sine = 100 TwoLink Scope8 q1 q1 q1 q2 q1_dot q2_dot Scope16 Scope15 q1_dotdot XY Graph Scope1 Constant1 Sine = 50 q2_dotdot Scope18 Scope17 q2 Figure 3-6: Offline Training System without D-FNN Learning Algorithm 3.4 Simulation Results To evaluate the performance of the proposed D-FNNs controller, a series of simulation runs were performed. The joint trajectory responses are plotted against time. Figure 3-7a Position Trajectory of Joint2 (S-function with offline training) From Figure 3-7a to 3-7b, we can see that the D-FNNs controller was able to attain almost perfect tracking. The initial transient response seen in Figure 3-7b is due to the 11
initial difference between the desired position and the starting position of Joint 3. The input desired signal fed into Joint 3 is -90 out of phase with that of Joint 2. Figure 3-7b Position Trajectory of Joint 3 (S-function with offline training) Figure 3-8a Position Error of Joint 2 (S-function with offline training) Figure 3-8b Position Error of Joint 3 (S-function with offline training) Figures 3-8a and 3-8b depict position errors of Joint 2 and Joint 3 using offline training control model respectively. From the above figures, we can see that overshoots are kept almost zero and errors of less than 2% are recorded for both joints. 12
4 Implementation of the D-FNNs Controller 4.1 Software Implementation The D-FNNs software consists of primarily two modules: (1) The main control module, and (2) The GUI for signal monitoring and parameters tuning. Module (1) is written in Simulink whereas Module (2) is developed using ControlDesk. The overall Simulink graphical model for the D-FNNs controller is shown in Figure 4-1. Figure 4-1: Overall Simulink Graphical Models for the D-FNNs Controller 4.2 Main Control Module The main control module handles the sampling of the joint s count information and also computes the joint s position error and acceleration. The results are then passed to the D-FNNs controller to control the SCARA robot. This module also manages the set-up of the I/O hardware and data transfer to the interfacing board. 4.3 Tuning of GUI Parameters and Signal Monitoring The second module provides an efficient means for us to analyse and monitor the joints trajectory data during real-time operation of the robot arm. Implementation of parameters tuning and signal monitoring module will be presented in the sequel. 4.3.1 On-the-fly Parameters Tuning On-the-fly parameters tuning involves changing the Simulink block parameters in real-time when the model is currently executing the program. The amount of time saved is substantial especially when no rebuilding of codes is involved. 13
4.3.2 Signal Monitoring Signal monitoring involves viewing the signals in real time. The signals can be used for analysis and comparison with the simulation results. 4.4 Implementation of Parameters Tuning and Signal Monitoring There are two ways of changing model parameters while the model is running on the target processor: 1. Using Simulink s external mode. 2. Using dspace s ControlDesk software. In this work, dspace ControlDesk is used to implement parameters tuning, signal monitoring and Graphic User Interface (GUI). ControlDesk (dspace s experiment software) provides all the functions for controlling, monitoring and automation of real-time experiments and makes the development of controllers much more effective. Figure 4-2: Overall GUI Display Figure 4-2 shows the various signals of the SCARA robot being monitored in real time by GUI. During the RUN mode, the robot behaviour can be monitored via GUI. Values like desired position, actual position and errors of both Joint 2 and Joint 3 are shown both in graphical and numerical format. 14
5 TESTING AND EXPERIMENTAL RESULTS 5.1 Performance Evaluation of D-FNNs Controller The criterion used to evaluate the performance of our D-FNNs controller is the same as that used for the simulation study. The primary concern for real-time execution of this D-FNNs algorithm is the amount of data that can be performed by the DSP-based controller before the next input data sample arrives. In our simulation model, a sampling frequency of 1 khz was assumed. In the following section, the tests conducted are compared with the D-FNNs controller performance in the simulation run with the experimental data obtained. 5.2 Experimental and Simulation Results The D-FNNs controller is set to traverse a trajectory of 60 degrees for both Joint 2 and Joint 3. Simulation runs are performed at a sampling frequency of 1000 samples/second, identical to the sampling rate used in the experiment. This is to promote a common basis for comparisons and evaluations of the results. The test will investigate on position tracking accuracy and tracking error. The results show that both simulation and experimental trajectories response match quite favourably, taking into consideration the highly non-linear dynamics of the robot arm. The marginal difference between both results lies mainly in the use of predominantly linearised simulation models. 5.2.1 Response of Position Tracking Trajectories Figure 5-1a and Figure 5-1b show the experimental position tracking trajectories of Joint 2 and Joint 3 respectively. Comparing with Figure 3-7a and 3-7b, we can see that both the experimental and simulation trajectories response match quite favourably for both Joint 2 and Joint 3. The difference in the two responses is mainly due the difference between the dynamics of the simulated model used for offline training and the actual dynamics of the SCARA robot.. 15
Figure 5-1a: Experimental Response for T1-axis Figure 5-1b: Experimental Response for T2-axis 5.2.2 Response of Position Tracking Errors Figure 5-2a and Figure 5-2b show experimental position tracking errors of Joint 2 and Joint 3 respectively. Comparing with Figure 3-8a and Figure 3-8b, we can see that the errors for Joint 2 and Joint 3 are kept within ± 0.03 radians for experimental and simulation responses. 16
Figure 5-2a: Experimental Error Response for T1-axis Figure 5-2b: Experimental Error Response for T2-axis 6 Conclusions A Dynamic Fuzzy Neural Networks (D-FNNs) Controller suitable for real-time industrial applications has been successfully designed, developed and implemented in this paper. The approach of rapid prototyping process was adopted to shorten the development time, thus reducing the cost of development. Besides, users are allowed to modify parameters real time, which enables the user to experiment different input conditions. Results and conditions of the robot can be monitored on the GUI. Henceforth, the amount of time saved is substantial especially when no rebuilding of codes is involved. The performance of the D-FNNs controller was found to be very 17
good and it matches favourably with the simulation results. We are confident that the proposed D-FNNs controller will be very useful in many other real-time industrial applications. References [1] H. Takagi, Introduction to Japanese Consumer Products that apply Neural Networks and Fuzzy Systems, Personal Communication, 1992. [2] A. O. Esogbue and J. A. Murrell, Advances in Fuzzy Adaptive Control, Computers Math. Applic., Vol. 27, No. 9/10, pp. 29-35, 1994. [3] J. J. Slotine and W. Li, Applied Nonlinear Control, Prentice-Hall, Englewood Cliffs, 1991. [4] L. X. Wang, Adaptive Fuzzy Systems and Control, Prentice-Hall, Englewood Cliffs, 1994. [5] S. S. Neo and M. J. Er, Adaptive fuzzy controllers of a robot manipulator, International Journal of Systems Science, Vol. 27, No. 6, pp. 519-532, 1996. [6] Nianzu Zhang, Experimental Research on Robot Control, M.Eng. Thesis, Singapore, Nanyang Technological University, 1996. [7] Y. Gao and M.J. Er, Adaptive Fuzzy Neural Control of Multiple-Link Robot Manipulators, accepted for publication in the Special Issue on Computational Intelligence, International Journal of Robotics and Automation. 18