Open access peer-reviewed chapter

Design and Simulation of Anfis Controller for Virtual-Reality-Built Manipulator

By Yousif I. Al Mashhadany

Submitted: November 24th 2011Reviewed: May 15th 2012Published: September 27th 2012

DOI: 10.5772/48383

Downloaded: 3817

1. Introduction

Fuzzy logic (FL) and artificial neural networks (ANNs), despite their successful use in many challenging control situations, still have drawbacks that limit them to only some applications. Their combined advantages have thus become the subject of much research into ways of overcoming their disadvantages. Neuro-fuzziness is one resulting rapidly emerging field. ANFIS network, proposed by Jang, is one popular neuro-fuzzy system [1-4].

For specific-problem training of an ANFIS network, [1] proposes use of hybrid learning rule, which combines gradient descent technique and least-square estimator (LSE). Being a method of supervised learning, it needs a teaching signal, which can be difficult to provide when the ANFIS network is to be a feedback controller, as the desired control actions that the teaching signal represents are unknown. Literatures have proposed several ANFIS learning methods in which ANFIS is applied as a MIMO controller. Djukanović et al., for example, uses a special ANFIS learning technique called temporal back propagation (TBP); control of a nonlinear MIMO system is by considering both the controller and the plant as a single unit each time step. The method, however, is complex and distinctly computation-heavy [5-9].

Another training approach for ANFIS-controller of nonlinear MIMO systems is inverse learning; the ANFIS network is trained to learn the inverse dynamics of the plant it controls. Its success, however, is crucial on three elements: accurate modeling of the original system (a problem when the system is complex), availability of the system’s inverse dynamics (they do not always exist), and appropriate distribution of the training data (could be impossible, given the constraints of the system’s dynamics). [10-13] has another training approach besides the ones already mentioned.

Present robot navigation systems demand controllers that can solve complex problems under uncertain and dynamic environments. ANFIS garners interest because it offers the benefits of both neural network (NN) and FL, and removes their individual disadvantages by combining them on their common features. ANN is a new motivation for studies into FL. It can be used as a universal learning paradigm in any smooth parameterized models, including fuzzy inference systems [14-15].

Traditional robot control methods rely on strong mathematical modeling, analysis, and synthesis. Existing approaches suit control of mobile robots operating in unknown environments and performing tasks that require movement in dynamic environments. Operational tasks in unstructured environments such as remote planets and hazardous waste sites, however, are more complex, yet the analytical modeling is inadequate. Many researchers and engineers have tried to solve the navigational problems of mobile robot systems [16-18]. Though fuzzy systems can use knowledge expressed in linguistic rules (and thus could implement expert human knowledge and experience), fuzzy controller lacks a systematic design method. Tuning of membership-function parameters takes time. NN learning techniques can automate the process so development can be hastened and performance improved. The combination of NN and FL has produced neuro-fuzzy controllers and created their present popularity. In real-time autonomous navigation, a robot must be able to sense its environment, interpret the sensed information to obtain knowledge of its position and environment, and plan a route that gets it to the target position from an initial position and with obstacle avoidance and control of its direction and velocity. Ng et al. [19-23] propose a neural-integrated fuzzy controller that integrates FL representation of human knowledge with NN learning to solve nonlinear dynamic control problems. Pham et al. focus on developing intelligent multi-agent robot teams capable of both autonomous action and dynamic-environment collaboration in achieving team objectives. They also propose a neuro-fuzzy adaptive action selection architecture that enables a team of robot agents to achieve adaptive cooperative control of cooperative tasks, track dynamic targets, and push boxes. Crestani et al. defines autonomous navigation in mobile robots as a search process within a navigation environment that contains obstacles and targets, and propose a fuzzy-NN controller that considers navigation direction and navigation velocity as controllable. Rutkowski et al. derived a flexible neuro-fuzzy inference system; their approach increases structural and design flexibility in neuro-fuzzy systems. Hui et al. and Rusu et al. discuss neuro-fuzzy controllers for sensor-based mobile robot navigation. Garbi et al. implemented an adaptive neuro-fuzzy inference system in robotic vehicle navigation [24-26].

Robots are one way to improve industrial automation productivity. Robotic manipulators have been used in routine and dangerous-environment manufacturing jobs. They are highly nonlinear dynamic systems subject to uncertainties. Obtaining accurate dynamic equations for their control laws is thus difficult. Uncertainties in their dynamic models include unknown grasped payloads and unknown frictional coefficients. Adaptive control or model-free intelligent control has been much proposed as able to compensate for those uncertainties [26-28].

Virtual reality (VR) has become important to applications in engineering, medicine, statistics, and other areas where 3D images can aid understanding of system complexity. The interactability of a virtual system can in many applications be enhanced by touch sensing. Haptic feedback can convey to a human user, virtual environment forces. It has become useful in tele-surgery, where a master manipulator guides robotic surgical tools while providing realistic-force feedback to the surgeon. It is already available in many systems under development but these often still are specifically developed research prototypes (i.e., providing specific-force feedbacks and for specific problems) [29, 30].

Kinematics analysis is key to motion control of humanoid manipulators. Its main problems are forward kinematics and inverse kinematics. The inverse kinematics of a 7-DOF manipulator has multiple solutions; obtaining anthropomorphic solutions is thus a problem. Detailed research in it has yet to be found, though works on design, control, and obstacle avoidance in humanoid manipulator exist. In serial manipulators, between forward kinematics and inverse kinematics, solution of the latter is a lot more difficult. Solution methods of inverse kinematics generally are numerical, analytical, or geometric. Numerical method is most widely used, but it cannot obtain all possible solutions. Analytical method can derive all possible solutions but is much more difficult. Geometric method is simple and easy to understand but suits only a few types of manipulators [31, 32].

A human-manipulator skeleton has 7-DOF mechanism; other degrees of freedom of the arm are performed by the tendon. A 7-DOF anthropomorphic arm has been developed; it has the manipulability criterion and uses 3-DOF planar manipulator theory (i.e., the mechanism of the human limb can be modeled by three moving links). 3-DOF planar mechanism is fundamental to an anthropomorphic arm; its evaluation criteria can be used to analyze the arm’s operational performance. 3-DOF planar manipulator theory is a supposition that the three link lengths are of the upper arm, the forearm, and the hand, and the three joints are 3-DOF shoulder joint, 1-DOF elbow joint, and 3-DOF wrist joint [33].

This chapter presents the design of an ANFIS controller of a VR manipulator model and simulation of the ANFIS-controlled system’s command execution. Simulation results of the 7-DOF human-manipulator show an improved control system. Section II presents the manipulator’s kinematic model whereas Section III the structure of the ANFIS controller and its learning methods. Section IV presents the manipulator’s VR model, whereas Section V, the simulation of the case study, the system design, and the conclusions.

2. Kinematics of the 7-DOF manipulator

Forward kinematics was used to calculate the racket’s posture according to the joint angles. It is quite useful for analysis of the manipulator’s workspace and verification of the inverse kinematics. Denoting the shoulder width as D, the upper arm length as L1, and the lower arm length as L2, the position of the shoulder is thus P1(0, -D, 0) and the position of the elbow is P2 (xp2, yp2, zp2 ). Denoting the joint angles as q1q7, the posture of joint i relative to joint i-1 can thus be described by a 4×4 homogeneous matrix i-1Ti [34]:


Where: sqi ≡sin(qi); cqi ≡cos(qi)

Assuming the position of Joint-7 in the fixed coordinate is P3 (xp3, yp3, zp3 ) and its pose as described by RPY (Roll Pitch Yaw) angles is (φ, θ, ψ), the posture of Joint-7 can thus be described by a homogenous matrix 0T7:


Matrix 0T7 also stands for the racket’s posture and can be derived also as:


From (1) and (2), the racket’s posture can be calculated as:


with atan2( ) being the four-quadrant inverse tangent function and (3) the manipulator’s forward kinematics. All the commands (e.g., the racket’s hitting position and hitting speed) are given by the visual system, in the operation space. They must be transformed into joint space values. Jacobian matrix is used to calculate the joint space speed according to the operation space speed. The mapping relationship between them is [35]:


with V being the racket’s speed in the operation space and q.the joint space speed. J is the 6×7 Jacobian matrix and can be derived by differential transformation method. The ith item of J is:


Where ni(nix, niy, niz), oi(oix, oiy, oiz), ai(aix, aiy, aiz) and pi(pix, piy,piz) are the items of matrix i1Ti


The parameter k stands for the rotational axis of joint i. For example, if the joint rotates around the x-axis, then k is x. Racket speed V can be calculated by (4) whereas joint space speed q.cannot be uniquely determined because J is not a square matrix. This problem can be solved by Moore-Penrose method:


with J+=(JTJ)1JTbeing the Moore-Penrose pseudo inverse matrix of J.

The inverse kinematics is used to calculate the joint angles according to the racket’s posture. The manipulator is redundant, so the elbow’s position is not uniquely determined when the racket’s posture is given. The motion characteristics of a human arm show the mapping relationships between elbow position and racket posture. In a general configuration of the manipulator (see Fig. 2), any three points on the manipulator’s neck, shoulder, elbow, and wrist are not collinear. The position of elbow P2, whose axis is P1P3, is in circleO'. The position of the center point O'=(xO',yO',zO')and the radius r of the circle are determined by positions P1 and P3, and arm length parameters L1 and L2. Ω1 denotes the plane constructed by points P1, P2, and P3, and Ω2 the plane constructed by points O, P1, and P2. α denotes the separation angle between Ω1 and Ω2. Once the position of P3 is known, α can uniquely determine P2 elbow position. If the points O, P1, P3 are collinear whereas P1, P2, P3 are not, the plane Ω2 does not exist. Angle α can be defined as the separation angle between Ω1 and the horizontal plane. Also, if the points P1, P2, P3 are collinear, the plane Ω1 does not exist and P2 position can be calculated according to positions P1 and P3 and arm length parameters L1 and L2. Considering the general configuration of the manipulator (see Fig. 2), the inverse kinematics can be solved if angle α and the racket’s posture are given. According to the motion characteristics of human arms, the mapping relationship between α and the racket posture can be built offline. Denoting with i (i1, i2, i3) the unit vector pointing from P3 to P1, and assuming the angle α to have been calculated by a well-trained ANN model, the circle O'can thus be expressed as [34-36]:


Figure 1.

General configuration of the manipulator

The plane Ω2 and the circle O'intersect at two points. One point near the neck is Pw (xw, yw, zw) and angle ∠P2O׳ Pw is the separation angle α between Ω1 and Ω2. Denoting Ω2 norm vector as n and position as Pw should satisfy this equation:


Pw position can be calculated from (8) and (9). P2 position (xp2, yp2, zp2) satisfies this equation:


P2 position can be calculated from (8) and (10). With P1, P2, P3 positions and the cosine theorem, Joint-4 angle can be calculated as:


With P2 position, this can be obtained:


The angles of Joints 1 and 2 can thus be derived as:


With P3 position, this can be obtained:


Joint-3 angle can thus be derived as:


From (2),


The angles of Joints 5-7 can thus be derived as:


with Tij*being the ith row and jij the column item of T

3. General structures of ANFIS

ANFIS integrates ANN with FIS. The ANFIS analyzed here was a first-order Takagi Sugeno Fuzzy Model. The analysis has four inputs: front obstacle distance (x1), right obstacle distance (x2), left obstacle distance (x3), and target angle (x4). The output is steering angle. The ‘if-then’ rules are [26, 37]:




A, B, C, and D are the fuzzy membership sets defined for input variables x1, x2, x3, and x4. q1, q2, q3, and q4 are the number of membership functions, respectively for the fuzzy systems of inputs x1, x2, x3 and x4. fi is the linear consequent functions defined in terms of inputs x1, x2, x3, and x4. qi, ri, si, ti, and ui are consequent parameters of an ANFIS fuzzy model. Same-layer nodes of an ANFIS model have similar functions. Output signals from the nodes of a preceding layer are input signals to a present layer. The output obtained through the node function will be input signals to the next layer (see Figure 2) [38, 39].

Layer 1: This is the input layer, which defines obstacles as either static or moving and also the tracker robot’s target position. It receives signals from x1, x2, x3, and x4.

Figure 2.

Structure of a six-layer ANFIS

Layer 2: Every node in this layer is an adaptive node (square node) with a particular fuzzy membership function (node function) specifying the degrees to which the inputs satisfy the quantifier. For four inputs, the node outputs are:


The membership functions considered here for A, B, C, and D are bell-shaped functions and defined as:


with ag, bg, and cg being the parameters for fuzzy membership function. The bell-shaped function changes its pattern with changes to the parameters. This change will give various contours of the bell-shaped function, as needed and in accordance with the data set for the problem considered.

Layer 3: Every node in this layer is a fixed node (circular) labeled ‘π’. L2i output is the product of all incoming signals.


Each of the second layer’s node output represents the firing strength (degree of fulfillment) of the associated rule. The T-norm operator algebraic product {Tap(a,b) = ab} was used to obtain the firing strength (Wi).

Layer 4: Every node in this layer is a fixed node (circular) labeled “N”. The output of the ith node is the ratio of the firing strength of the ith rule (Wi) to the sum of the firing strength of all the rules [40].


This output gives a normalized firing strength.

Layer 5: Every node in this layer is an adaptive node (square node) with a node function.


with Wi¯being the normalized firing strength form (output) from Layer-3 and {pi, ri, si, ti, ui} the steering-angle parameter set. Parameters in this layer are consequent.

Layer 6: The single node in this layer is a fixed node (circular) labeled “Σ”. It computes the overall output as the summation of all incoming signals.


This work’s ANFIS development has six-dimensional space partitions and q1, q2, q3, and q4 regions. Each region is governed by a fuzzy if-then rule. The first layer is the input layer. The second contains premise or antecedent parameters of the ANFIS and is dedicated to fuzzy sub-space. Consequent parameters of the fifth layer were used to optimize the network. During the forward pass of the hybrid learning algorithm, node outputs go forward until Layer-5 and the consequent parameters are identified by least-square method. In the backward pass, error signals propagate backwards and the premise parameters are updated by gradient descent method [40, 41].

4. VR Modeling of the 7-DOF manipulator

Design requirements for Virtual Reality Modeling Language (VRML) are described in finite processing allocations, autonomy, consistent self-registration, and calculability. VRML design procedure will be presented. Design in VRML depends on the information available to the designer and his imaging of the object. There are two choices for VR design: one is standard configuration such as sphere, cone, cylinder, etc., another is free design by selecting indexed face set button to get many configurations with free rearrangement of points; every real-form design is thus considered to be the latter [42-45], which starts with building parts one by one and comparing the shape’s similarity against that of the real manipulator part. Manipulator parts cannot be simulated in VR when the VR library’s standard shapes (they are not uniform) are used. Designing thus uses indexed face set in VR. The second choice to be made in design work is very important as it is about connecting all parts to get the final object, and limiting the object’s original point. This is the starting point of the design work. The first shape (e.g., the shoulder) is first set, and then the next shape (forearm) is connected to the “children” button. The same procedure is repeated for other parts. Figure 3 presents the full design of the 7-DOF human arm manipulator [46-50].

Figure 3.

The VR-modeled 7-DOF human-arm manipulator

5. Design of the ANFIS controller for the 7-DOF manipulator

The design work considered many parameters related to the system’s real values (see Table 1 for real limits of the joints of a human arm). The joints motor is considered a real DC-motor with a transfer function similar with that in Equation (1).


Figure 4 is a block diagram of the control system. The inputs to the system design have two sets of targets: orientation (θT1, θT2, θT3) and position (Tx, Ty, Tz). In the proposed technique, each joint has its own controller, so in all, seven identical (same structure, same training algorithm) ANFIS controllers were used. Inputs of the training algorithm were the desired joint angle and the actual angle. The desired values were calculated by using analytical solution of the IKP algorithm shown previously. Actual values of the joint angle were obtained by feedback from the virtual model.

Figure 4.

ANFIS control of the 7-DOF human-arm manipulator

The structure of the ANFIS controller was built in Matlab software Ver.2011b, with two inputs, an error signal, and change in the error. The fuzzy inference method used was Mamdani's, because it is intuitive, widely accepted, and well-suited to human input, and, for the proposed control structure, it gives better results than does Sugeno inference method. In designing the controller, types of membership functions were tried before selecting the best: triangular built-in membership function (trimf). The trial-and-error design approach for the ANFIS controller, i.e., selecting the interference type, the membership function type, and the number of this membership function in the hidden layer, gave optimal results: minimum number of rules and simple simulation. The design uses seven parallel-connected ANFIS to compute the optimal deflection of the joints and get the desired angle. Figures (5-7) show the procedure of the Matlab-fuzzy-toolbox-based design.

Figure 5.

Mamdani's fuzzy inference and the set of rules for training of the ANFIS controller

Figure 6.

The surface error and the set of rules for training of the ANFIS controller

Figure 7.

The triangular built-in memberships function with error signal and change in error signal

Figure 8 shows in Matlab Simulink GUI window the internal structure of the ANFIS controller and the training output for the input signal, with the various steps used in instructing the manipulator’s movement. The ANFIS training used hybrid training algorithm, with the input nodes (3, 3) to the membership functions each having nine rules (see Figure 5). Epoch length was used in training eighty iterations for each sample, with 0.01s Simulink sampling time.

Figure 8.

The ANFIS structure in Matlab-Simulink GUI and its training response

6. Simulation results

Figure 9(a) is a block diagram of the simulation done for the ANFIS-controlled manipulator. Seven ANFIS controllers were used, one each for each degree of freedom of the three joints (3 for the shoulder, 1 for the elbow, and 3 for the wrist). The seven were effective in tracking the trajectory desired for the 7-DOF manipulator. The controller’s rules base has 9 rules, each determined by fuzzy neural network (FNN). The desired position and orientation were, in simulation entered as input signal, whereas actual positions for the joints were given as feedback from the output signal. Figure 9(b) shows the results of using both ANFIS and PID controllers on the joints and for the ANFIS controller’s implementation into the virtual model. Performance of the ANFIS-controlled joint was better than that of the PID-controlled one. The ANFIS controller effected fast response in the manipulator and reduced errors, for various complex trajectories of the manipulator.

Figure 9.

a, b, c). Simulation of the ANFIS controller for the VR-implemented 7-DOF manipulator

The manipulator’s movements used the link between Matlab-Simulink and VR environment. Computation for the order of movement was done in Matlab-Simulink. The order was then sent to the VR model to implement, with considerations for the axes between Matlab’s and VR’s to get the real movement (i.e., for general motion: elbow flexion/extension, elbow rotation (supination/pronation), shoulder adduction/abduction, shoulder flexion/extension, shoulder interior/exterior rotation, wrist flexion/extension, wrist ulnar/radial deviation, shoulder horizontal flexion/extension; for special motion: arm reaching towards the head, arm reaching to the right and the head, arm reaching to the left and the head, and arm reaching to the right) (see Figure 10 for examples).

Figure 10.

Postures of the ANFIS-controlled 7-DOF manipulator

7. Conclusion

This work aimed to design an ANFIS-based controller that overcomes the general problems of FL and NN in a dynamic system. To obtain excellent manipulator postures, training of the ANFIS controller for all the elements (fuzzy interference, membership function, number of neurons, number of rules) was by trial and error. The controller was compared with classical PID controller, in tracking the speed and the joint angle’s accuracy. The simulation results allowed these conclusions to be drawn:

  • For any speed, the ANFIS controller has the better transient response and the steadier state response than does a PID controller; even the best-tuned PID controller is unable to perform well in both slow-speed and high-speed ranges.

  • With only 9 neurons, 4 layers, and 9 rules, the proposed ANFIS controller is simpler than other adaptive neuro-fuzzy controllers reported by many other researches.

  • The ANFIS controller does not require an accurate model of the plant. Its relative simplicity makes it fairly easy to construct and implement. High-level knowledge of system is not needed to build a set of rules for a fuzzy controller or for the identification needed in an NN controller.

  • The ANFIS controller was used in both simulation and experiment in trajectory tracking of multiple manipulators. Kinematic analysis of the 7-DOF manipulator produced the calculation for the envelope of similar manipulators.

  • VR implementation of the manipulator was able to show the latter’s accuracy. The manipulator can be depended on for many high-accuracy applications such as collecting of minute/fragile items.

© 2012 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Yousif I. Al Mashhadany (September 27th 2012). Design and Simulation of Anfis Controller for Virtual-Reality-Built Manipulator, Fuzzy Controllers - Recent Advances in Theory and Applications, Sohail Iqbal, Nora Boumella and Juan Carlos Figueroa Garcia, IntechOpen, DOI: 10.5772/48383. Available from:

chapter statistics

3817total chapter downloads

1Crossref citations

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

Related Content

This Book

Next chapter

Hierarchical Fuzzy Control

By Carlos André Guerra Fonseca, Fábio Meneghetti Ugulino de Araújo and Marconi Câmara Rodrigues

Related Book

First chapter

New Strategy to Approach the Inverse Kinematics Model for Manipulators with Rotational Joints

By José-Emilio Vargas-Soto, Efren Gorrostieta-Hurtado, Saúl Tovar- Arriaga, Jesús-Carlos Pedraza-Ortega and Juan-Manuel Ramos- Arreguín

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us