1 Introduction

The robot has been researched and applied in many decades; it can complete required tasks and follow the object with more effectiveness and a short time than the human. Robot manipulators have been extensively used in different fields of human life and industry to perform many tasks that are pernicious or too costly for humans such as underwater activities, in space, activities in nuclear power plants [1,2,3,4,5]. Robot manipulators have been also used to complete tasks that are difficult for humans to achieve the required precision or quality in repetitive works such as assembly, welding, spray painting, materials handling, and other applications with such repetitive works [6,7,8,9,10].

A robot manipulator is a coupled multi-input multi-output (MIMO) system with the possession of highly non-linear and uncertain dynamics, where the proliferation of links will be the system further complicated. Classical PID controllers have been researched and widely used in control applications for robot manipulators. In Ref. [11], a PID controller with particle swarm optimization algorithm is used to control the position of the flexible manipulator, in which the optimal PID parameters found with PSO control the position of the flexible manipulator and ensure low vibration. A PID control scheme based on modeling compensation techniques is presented in Ref. [12] to solve the tracking problem of robot manipulators with revolute joints. All nonlinearities were merged into a single function to generate the modeling error function and estimated via a reduced-order observer, which is used in the feedback loop to compensate for nonlinearities. In research [13], an adaptive PID control through the equivalence relationship between the two controls with simple structure, model-free, and robust against payload variations is implemented to control a WAM robot holding a baseball bat with the high levels of stability and performance using the adaptive time-delay control. But robot manipulators are complex nonlinear coupled systems; PID controllers are not really effective for control action which is shown in a review article by Kumar [14]. It means that the classical PID controllers are most effective for linear systems but not really suitable for nonlinear and complex systems.

To better match the complex nonlinear coupled properties of robot manipulators, several nonlinear control techniques are studied in many articles. A practical nonsingular terminal sliding mode control approach for robot manipulators using time-delay estimation is introduced in Ref. [15], in which the time-delay estimation is used to guarantee fast convergence and reduce computational complexity involving the robot dynamics. In research [16], the force/position hybrid control method is used to control the operation of the redundant actuated parallel robot where the cascade control strategy based on a combination of the proportional-integral control and model predictive control in the redundant branch of the robot to significantly improve the tracking ability of the system. Integrating adaptive backstepping control approach into fractional-order controller design for an n-degree of freedom (n-DOF) robotic manipulator is presented in Ref. [17] to resolve the problem of finite-time stabilization and control the operation of the robot under interfering factors such as model nonlinearity, uncertainties, and external disturbances. An adaptive backstepping nonsingular fast terminal sliding mode control is constructed in Ref. [18] based on an integration of integral nonsingular fast terminal sliding mode surface, a backstepping control strategy, and an adaptive technique that requires no prior knowledge of the bound value of the disturbance and uncertainties. In Ref. [19], a robust control technique is designed for robot manipulators with the fast and finite-time tracking capability of the torque signals along with the desired torque commands, and a fast nonsingular terminal sliding mode control algorithm is developed to guarantee the fast convergence of the joint positions to their desired values. The paper [20] introduced a theorem for robust finite-time stability and derived a finite-time \( H_\infty \) controller for robotic manipulators that achieves high-precision tracking performance without requiring the solution of a Hamilton-Jacobi equation or a Riccati equation is derived using the backstepping method.

To implement the nonlinear control techniques such as sliding mode control, model reference adaptive control, backstepping, etc. for robot manipulators, exact plant mathematical model are required. However, dynamics of robot manipulators are highly nonlinear and complicated, and exact models of the robot systems are not always obtainable.

Many researchers always tried to find out the solution for efficient control design of nonlinear systems based on intelligent control techniques like fuzzy control, neural network, genetic algorithm, etc. In intelligent control technologies, fuzzy control is a promising solution that is widely used to design intelligent controllers. Fuzzy control is implemented based on the concept of linguistic variables which can take actions on the basis of logics and rules investigated by expert knowledge, thus it can give a powerful tool to design intelligent controller. In the paper [21], an adaptive fuzzy control system is constructed for a dual-arm robot, where an approximate Jacobian matrix and a decentralized fuzzy logic controller are used in combination to address the uncertain kinematic control and compensate for uncertain dynamics of the control object. In Ref. [22], the control structure for a robot manipulator is designed and implemented by a fractional-order fuzzy PD+I controller (FOFPD+I) which uses fuzzy logic and non-dominated sorting genetic algorithm-II for its nonlinear gains to give an adaptive capability and preserves the linear structure of fractional order PD+I controller. The papers [23, 24] propose a fuzzy sliding mode control (FSMC) scheme using the complementary cooperation of the traditional sliding mode control (SMC) and the fuzzy logic control (FLC) for the trajectory tracking control of a two-link robot manipulator where a fuzzy tuning scheme is presented to improve the performance of the control system. In Ref. [25], a kind of adaptive sliding mode control system for tracking control of robot manipulator has structured uncertainties and unstructured uncertainties where MIMO fuzzy logical system is used as a compensator in the control law to compensate all the uncertainties. Although there have been many studies on fuzzy control applications for robot manipulators. However, fuzzy controllers are often used in combination or at a high level for adaptive control. Besides, the fuzzy controller design is based on experience and expert knowledge of the system. There have also been many optimization algorithms used for fuzzy controller optimization such as genetic algorithm, particle swarm optimization, cross-entropy, etc. but the fuzzy controller optimization problem is still a challenging problem [26,27,28].

Stochastic fractal search (SFS) is a new powerful optimization algorithm based on randomized fractals using the diffusion-limited aggregation (DLA) method which is developed with an effort to deal with the shortcomings such as premature convergence and poor solution quality in existing metaheuristics [29]. SFS algorithm carry out remarkable improvement in solution quality and convergence speed by finding a solution that has the minimal error within a number of small iteration in comparison with other optimal solutions. Enhancing the performance of the SFS optimization algorithm can be also implemented simply by tuning only the maximum diffusion number (MDN). The SFS method has been studied and employed in various applications in recent years. The SFS algorithm is presented in Ref. [30] to adjust the PID parameters for model identification and vibration control of a flexible beam system. In papers [31, 32], the hybrid version of the SFS algorithmf is used to optimize the controller parameters in an automatic generation control of power systems. In Ref. [33], the variant SFS is implemented for optimizing PID and fuzzy PD controller parameters to enhance the performance of a simple twin-rotor control system. In the study, a small MDN is also used for the variant SFS which makes its convergence rate better than the original SFS. In Ref. [34], the SFS method is used to tune controller gains in an automatic generation control of wind incorporated hydrothermal system. The parameters of the integral minus proportional derivative with first-order filter (I-PDF) controller are tuned by the SFS method and other population-based optimization techniques in comparison where the results affirm the supremacy of the SFS against other metaheuristics. The researches have shown that SFS algorithm is good at finding a solution with remarkable improvement in solution quality and convergence speed. However, the SFS algorithm is often employed for optimization of conventional controllers such as PID controllers. Application of the SFS algorithm for fuzzy control systems should be also reviewed and studied, especially for complexity nonlinear objects such as robot manipulators.

To improve responses and simplify the control structure for complex nonlinear objects such as robot manipulators, this paper proposes the use of the fuzzy PD control system. The fuzzy PD control system is designed based on the relational model and optimized by the stochastic fractal search algorithm to reduce the complexity, suitable for real-time applications [35,36,37]. The main contribution of the paper can be summarized as follows:

  1. 1.

    Design and implementation of the optimal fuzzy control system for a two-link robot manipulator based on relation models and Lyapunov stable analysis with a minimum number of membership functions (MFs).

  2. 2.

    Propose and improve the performance of the designed fuzzy control system based on an optimal algorithm using random fractals.

  3. 3.

    Carry out comparison and evaluation simulations to show the advantages of the proposed optimal fuzzy control system.

The rest of this paper is arranged as follows: After an introduction in Sect. 1, a brief of the fractal search algorithm is presented in Sect. 2. System description and mathematical model of a two-link robot manipulator are constructed in Sect. 3. The design and optimization of the proposed fuzzy control system are implemented in Sect. 4. In Sect. 5, simulation scenarios and discussion is used for validation of results. Finally, conclusions and next directions of the proposed work are drawn in Sect. 6.

2 Fractal search algorithm

Random fractals are generated through modifying the iteration process according to a stochastic rule using the Diffusion Limited Aggregation method which is the key operation used for the diffusion phase [38, 39].

The optimization algorithm based on random fractals is constructed by incorporation of fractal growths through the DLA method and potential theory where particles are generated according to the following rules [40]:

  1. 1.

    Each particle contains its own particular electrical potential energy.

  2. 2.

    Each particle is subject to the random diffusion process using the levy flight, Gaussian distribution, or incorporating the advantages of both of them to generate other random particles, where the energy of the seed particle is distributed among the generated particles.

  3. 3.

    In successive generations, many unsuccessful particles are dropped from the population, only a few of the best particles have the ability to survive and grow through successive generations.

Stochastic Fractal Search algorithm is an optimization algorithm with powerful capabilities and simple implementation which is constructed from two main processes of the diffusion process and the updating process [41]. In order to implement the SFS algorithm, the parameters such as the position of each particle (P), the lower bound (LB), and upper bound (UB) of search space, including the search space dimension (N), the amount of initial particle (\(M_i \)), maximum diffusion of each particle allowed (D), and maximum iteration (G) need to be defined and initialized. And then the cost function also is determined in advance to spread every initial particle in the search space using (1)

$$\begin{aligned} {P_j} = LB + \varepsilon \times (UB - LB),\quad j = 1,2,...,{M_i} \end{aligned}$$
(1)

The diffusion process is presented by mathematical equations (2) and (3) to produce new particles that conduct searches in defined search spaces. A Gaussian distribution is used in the SFS algorithm to carry out the diffusion process. This process is often called the Gaussian Walks (\( GW1 \& GW2 \)) that form a pattern of fractal growth.

$$\begin{aligned}&\begin{aligned} G{\mathrm{{W}}_1} = Gaussian({\mu _{BP}},\sigma ) + (\varepsilon \times BP - \varepsilon ' \times {P_i}), \\ \quad i = 1,2,...,N \end{aligned} \end{aligned}$$
(2)
$$\begin{aligned}&G{\mathrm{{W}}_2} = Gaussian({\mu _P},\sigma ) \end{aligned}$$
(3)

The average value (\( \mu \)) and standard deviation (\( \sigma \)) are defined:

$$\begin{aligned} \begin{array}{l} {\mu _{BP}} = \left| {BP} \right| \\ {\mu _P} = \left| {{P_i}} \right| \\ \sigma = \left| {\frac{{\log (g)}}{g} \times ({P_i} - BP)} \right| \end{array} \end{aligned}$$
(4)

where BP is the best particle obtained by using the cost function to test each particle; \( P_i \) is the ith particle which implements diffusion; and g g is the number of iterations that have been implemented when the particle is diffusing. The parameters \( \varepsilon \) and \( {\varepsilon '} \) are random numbers that are uniformly distributed in the range of values from 0 to 1.

A probability value to each particle based on its fitness value is used to begin the first updating process. This process is used for the purpose of providing the highest probability value to the particle with the best fitness value. Further, this process will increase the chance of the worst particle being replaced. The probability value to each particle (\( Pa_i \)) is denoted as follows:

$$\begin{aligned} P{a_i} = \frac{{rank\,({P_i})}}{N} \end{aligned}$$
(5)

where N is the total number of particles in a population

After being given a probability value, the particle that has a value of \( P{a_i} < \varepsilon \) will be updated as follows:

$$\begin{aligned} {P'_i}(j) = {{\mathop {\mathrm{P}}\nolimits } _r}(j) - \varepsilon \times ({P_t}(j) - {P_i}(j)) \end{aligned}$$
(6)

where \( P'_i \) is the particle in new population, \( P_i \) is the previous particle in old population, \( P_r \) and \( P_t \) are randomly selected particles among each population.

After the first updating process is completed, the second updating process will be continued for all particles in the population. Again, all particles are given by probabilities according to (5), and then an update is implemented by (7)

$$\begin{aligned} {P''_t} = \left\{ \begin{array}{l} {{P'}_i} - {\hat{\varepsilon }} \times ({{P'}_t} - BP),\quad if\,{\hat{\varepsilon }} \le 0.5\\ {{P'}_i} - {\hat{\varepsilon }} \times ({{P'}_t} - {{P'}_r}),\quad if\,{\hat{\varepsilon }} > 0.5 \end{array} \right. \end{aligned}$$
(7)

where \( P''_t \) is the particle in newest population, \( P'_r \) and \( P'_t \) are randomly selected particles based on the result of the first updating process. The complete SFS algorithm can be summarized and implemented by Algorithm 1.

figure a

3 Dynamic model of two-link manipulators

Consider a 2-DOF robot manipulator with two links as shown in Fig. 1.

Fig. 1
figure 1

The coordinate system for a simplified model of a two-link robot manipulator

Referring to Fig. 1 the kinematic relations for each mass of the robot can be written [42, 43]:

$$\begin{aligned} \left\{ \begin{array}{l} {x_1} = {L_1}\sin \theta \\ {y_1} = {L_1}\sin \theta \\ {x_2} = {L_1}\sin \theta + {L_2}\sin ({\theta _1} + {\theta _2})\\ {y_2} = {L_1}\cos \theta + {L_2}\cos ({\theta _1} + {\theta _2}) \end{array} \right. \end{aligned}$$
(8)

The kinetic and potential energies of the system can be given by:

$$\begin{aligned} \left\{ \begin{array}{l} T = \frac{1}{2}{m_1}(\dot{x}_1^2 + \dot{y}_1^2) + \frac{1}{2}{m_2}(\dot{x}_2^2 + \dot{y}_2^2)\\ V = {m_1}g{L_1}\cos \theta + {m_2}g{L_2}\cos ({\theta _1} + {\theta _2}) \end{array} \right. \end{aligned}$$
(9)

The definitions for kinetic energy and potential energy can be considered by Lagrange dynamics [44,45,46,47,48]:

$$\begin{aligned} \frac{d}{{dt}}\left( {\frac{{\partial T}}{{\partial {{\dot{q}}_j}}}} \right) - \frac{{\partial T}}{{\partial {q_j}}} + \frac{{\partial V}}{{\partial {q_j}}} = {Q_j} \end{aligned}$$
(10)

The dynamic modeling of a 2-DOF robot manipulator can be expressed as follows:

$$\begin{aligned} M(q)\ddot{q} + C(q,\dot{q})\dot{q} + g(q) = u \end{aligned}$$
(11)

where \( q = {\left[ {\begin{array}{*{20}{c}} {{\theta _1}}&{{\theta _2}} \end{array}} \right] ^T} \) is the state variable; \( u = {\left[ {\begin{array}{*{20}{c}} {{\tau _1}}&{{\tau _2}} \end{array}} \right] ^T} \) is torque exerted by actuators (servo motors) at each joint; M, C, g are the inertia matrix (symmetric positive definite), the Coriolis and centrifugal matrix, and the gravity vector, respectively, which are given by:

$$\begin{aligned}M= & {} \left[ {\begin{array}{*{20}{c}} {{M_{11}}}&{}{{M_{12}}}\\ {{M_{21}}}&{}{{M_{22}}} \end{array}} \right] \\ M_{11}= & {} {\left( {{m_1} + \mathrm{{ }}{m_2}} \right) L_1^2 + {m_2}L_2^2 + 2{m_2}{L_1}{L_2}\mathrm {cos}{\theta _2}};\\ M_{12}= & {} {{m_2}L_2^2 + {m_2}{L_1}{L_2}\mathrm {cos}{\theta _2}};\\ M_{21}= & {} {{m_2}L_2^2 + {m_2}{L_1}{L_2}\mathrm {cos}{\theta _2}};\;\;\; M_{22} = {{m_2}L_2^2}\\ C= & {} \left[ {\begin{array}{*{20}{c}} { - {m_2}{L_1}{L_2}2{{{\dot{\theta }} }_2}\mathrm {sin}{\theta _2}}&{}{ - {m_2}{L_1}{L_2}{{{\dot{\theta }} }_2}\mathrm {sin}{\theta _2}}\\ 0&{}{ - {m_2}{L_1}{L_2}2{{{\dot{\theta }} }_1}\mathrm {sin}{\theta _2}} \end{array}} \right] \\ g= & {} \left[ {\begin{array}{*{20}{c}} { - \left( {{m_1} + {m_2}} \right) g{L_1}\mathrm {sin}{\theta _1} - {m_2}g{L_2}\mathrm {sin}\left( {{\theta _1} + {\theta _2}} \right) }\\ { - {m_2}{L_2}g\mathrm{{ }}\mathrm {sin}\left( {{\theta _1} + {\theta _2}} \right) \mathrm{{ }}} \end{array}} \right] . \end{aligned}$$

4 Design and optimize the fuzzy system for a two-link manipulator

In this section, the design and optimization of the fuzzy control system for the two-link robot manipulator is implemented. The block diagram of the design control system is presented in Fig. 2 where two fuzzy controllers are used for controlling the movement of the joints in the separate loops to ensure the robot can reach the desired position. The design protocol and optimization of the proposed control system is divided into 2 steps as follows:

  • Step 1: Design of the fuzzy controllers based on relation models and the Lyapunov stability analysis. The rules and the parameters of the relation matrixes \( (R_1, R_2) \) of the fuzzy controllers are designed and selected to minimize the number of the input and output linguistic variables, and their membership functions.

  • Step 2: Optimize the designed fuzzy controllers using the SFS algorithm where the performance of the designed system can be implemented by adjusting the input scale factor of the fuzzy controllers and found the optimal parameters.

Fig. 2
figure 2

The proposed block diagram of the fuzzy control system for a two-link robot manipulator

4.1 Fuzzy controllers design

Fuzzy control systems are developed based on rule-based or knowledge-based. Fuzzy control systems are designed by fuzzy inferences using linguistic variables to depict the state of the system with given conditions. In fuzzy systems, linguistic variables use the MFs to dene the degree of measurement belong to a particular state of the linguistic variable. The fuzzy rule base is a set of fuzzy inferences “IF-THEN”, where the ith rule \((L_{i} )\) can be represented as follows [48]:

$$\begin{aligned}&\begin{aligned} {L_i}:\mathrm{{ }}If\;{X_1}\;is\;A_1^i,\;{X_2}\;is\;A_2^i\; \ldots and\;{X_n}\;is\;A_n^i \\ \;then\;Y\;is\;G_c^i \end{aligned}\nonumber \\&i=1,2,...,N\end{aligned}$$
(12)

where \( X = [X_{1},...,X_{n}]^{T} \) and Y are the input and output linguistic variables, \(A_{j}^{i} \) and \(G_{c}^{i} \) are fuzzy sets.

To design the fuzzy controllers, a single-input 2th-order nonlinear system for each joint of the robot is considered as the following form:

$$\begin{aligned} \dot{x} = f(x) + b(x)u \end{aligned}$$
(13)

where \( x = {[{x_1},\;{x_2}]^T} \) is state vector; \( f(x) = [{f_1}(x),{f_2}(x)]^T \), \( b(x) = {[{b_1}(x),\;{b_2}(x)]^T} \) are functions which present the dynamics of the plant; u is the control signal from the design fuzzy controller.

To ensure the stability of the control system, the Lyapunov stability theory will be used for designing the fuzzy controllers. Each fuzzy controller is designed with two inputs, and we assume that the control object may have really two degrees of freedom referred to as \( x_1 \) and \( x_2={\dot{x}}_1 \), respectively; the states \( x_1 \) and \( x_2 \), are the only measurable variables; the 2th-order derivation of error \( {\dot{x}}_2 \) is proportional to the control signal u (u increases when \( {\dot{x}}_2 \) increases, and vice versa); the initial conditions \( x(0) = {({x_1}(0),\;{x_2}(0))^T} \) belong to the set \( \aleph = \left\{ {x \in \mathfrak {R}:\left\| {x - {x_d}} \right\| \le \varepsilon } \right\} \), with \( x_d \) is the desired equilibrium point. The fuzzy controller is designed using the rule-based to generate the control signal which ensure the stability of the proposed system. The Lyapunov function is defined as follow:

$$\begin{aligned} V({x_1},{x_2}) = \frac{1}{2}\left( x_1^2 + x_2^2\right) \end{aligned}$$
(14)

The derivative of \( V({x_1},{x_2}) \) can be written:

$$\begin{aligned} {\dot{V}}({x_1},{x_2}) = x_1 {\dot{x}}_1 + x_2 {\dot{x}}_2 = x_1 x_2 + x_2 {\dot{x}}_2 \end{aligned}$$
(15)

The system must be guaranteed stabilization at the desired equilibrium point \( x_d = (x_1^d, x_2^d)^{T} \), so:

$$\begin{aligned} {\dot{V}}({x_1},{x_2}) = x_1 x_2 + x_2 {\dot{x}}_2 <0 \end{aligned}$$
(16)

The inequality (16) will be satisfied with sufficient conditions which can be written as: If \( x_{1} \) and \( x_{2} \) have opposite signs, then \( x_{1} x_{2} < 0 \) and (16) will hold if \( {\dot{x}}_2 = 0 \); if \( x_{1} \) and \( x_{2} \) are positive, then (16) will hold if \( {\dot{x}}_2 < -x_{1} \); if \( x_{1} \) and \( x_{2} \) are negative, then (16) will hold if \( {\dot{x}}_2 > -x_{1} \). On the other hand, we can notice that \( {\dot{x}}_2 \) is proportional to u, so these conditions can be translated into the following fuzzy rule-base for the stabilizing controller:

  1. 1.

    If \( x_1 \) is negative and \( x_2 \) is negative then u must be positive big;

  2. 2.

    If \( x_1 \) is negative and \( x_2 \) is zero then u must be zero;

  3. 3.

    If \( x_1 \) is negative and \( x_2 \) is positive then u must be negative;

  4. 4.

    If \( x_1 \) is zero and \( x_2 \) is negative then u must be positive;

  5. 5.

    If \( x_1 \) is zero and \( x_2 \) is zero then u must be zero;

  6. 6.

    If \( x_1 \) is zero and \( x_2 \) is positive then u must be negative;

  7. 7.

    If \( x_1 \) is positive and \( x_2 \) is negative then u must be positive;

  8. 8.

    If \( x_1 \) is positive and \( x_2 \) is zero then u must be zero;

  9. 9.

    If \( x_1 \) is positive and \( x_2 \) is positive then u must be negative big;

The fuzzy controller for the joints of the robot are designed by using relation models with two inputs and an output that are presented by error, rate of the error, and the control signal, respectively. The scale factors for the fuzzy controllers is designed by trial and error method using experimental. The MFs for the linguistic variables of the fuzzy controllers are presented in Figs. 3 and 4, respectively.

Fig. 3
figure 3

The MFs for the input linguistic variables (a), (b) and the output linguistic variables (c) of the fuzzy controller 1, respectively 1

Fig. 4
figure 4

The MFs for the input linguistic variables (a), (b) and the output linguistic variables (c) of the fuzzy controller 2, respectively

The control rule of the designed fuzzy controllers for the joints of the robot is presented by the relation matrix \(R_{1} \) and \(R_{2} \), respectively. The parameters of the relation matrix \(R_{1} \) and \(R_{2} \) are selected to satisfy the fuzzy rule-base with the stabilizing conditions which are shown above [49,50,51]:

$$\begin{aligned} \begin{array}{l} \;\quad \;\,\quad \quad \quad \quad N \quad \;\; Z \;\quad P\\ {R_1} = \begin{array}{*{20}{c}} {NN}\\ {NZ}\\ {NP}\\ {ZN}\\ {ZZ}\\ {ZP}\\ {PN}\\ {PZ}\\ {PP} \end{array}\left[ {\begin{array}{*{20}{c}} {0} &{} {0.1} &{} {0.9} \\ {0} &{} {1} &{} {0} \\ {0.65} &{} {0.35} &{} {0} \\ {0} &{} {0,15} &{} {0.85} \\ {0} &{} {1} &{} {0} \\ {0.85} &{} {0.15} &{} {0} \\ {0} &{} {0.35} &{} {0.65} \\ {0} &{} {1} &{} {0} \\ {0.9} &{} {0.1} &{} {0} \end{array}} \right] \; \end{array} \end{aligned}$$
(17)
$$\begin{aligned} \begin{array}{l} \;\quad \;\,\,\; \quad \quad \quad \quad N \quad \; Z \quad \; P\\ {R_2} = \begin{array}{*{20}{c}} {NN}\\ {NZ}\\ {NP}\\ {ZN}\\ {ZZ}\\ {ZP}\\ {PN}\\ {PZ}\\ {PP} \end{array}\left[ {\begin{array}{*{20}{c}} {0} &{} {0.02} &{} {0.98} \\ {0} &{} {1} &{} {0} \\ {0.7} &{} {0.3} &{} {0} \\ {0} &{} {0,18} &{} {0.82} \\ {0} &{} {1} &{} {0} \\ {0.82} &{} {0.18} &{} {0} \\ {0} &{} {0.7} &{} {0.3} \\ {0} &{} {1} &{} {0} \\ {0.98} &{} {0.02} &{} {0} \end{array}} \right] \; \end{array} \end{aligned}$$
(18)

4.2 SFS optimization

The proposed fuzzy controllers with two degrees of freedom will be optimized using SFS based on tuning the input scale factors. The optimization will be implemented and tested through simulation studies, to control the motion of the robot. The block diagram of the control system using SFS method is illustrated in Fig. 5.

Fig. 5
figure 5

The block diagram of the optimization process using the SFS method for the fuzzy controllers

The optimization process is similar for both fuzzy controllers. To use the SFS method, the input scale parameters of the fuzzy controllers are first encoded into a particle such that \( P_i = [K_{i1}, K_{i2}] \) \( (i=1,2) \) where each member is represented by a real number. Then, an objective function is defined, and through the SFS phases, the particles are optimized by minimizing the value of this objective function. The objective function is critical for optimization and selecting this objective function should be realized depending upon the problem nature to obtain the fuzzy controllers with their parameters optimized as desired. In this paper, the ITAE formula is adopted as objective function J which is given by:

$$\begin{aligned} J = ITAE = \int \limits _0^{{t_{sim}}} {t\left| {e(t)} \right| dt} \end{aligned}$$
(19)

In the proposed approach, a random population of 20 particles is selected for the initial population. By using digital simulation in Matlab environment with simulation time of \(t_{sim}=1(s)\), each particle is fed into the control system to obtain the response of the joints. Next, fitness values are calculated for each particle by using (19), and the particles are modified by optimization module using Algorithm 1 for the next iteration. The execution is repeated until a specified number of iterations are reached. After finishing the optimization process, the best particle that corresponds to a minimum value of ITAE will be received. The comprehensive flowchart of SFS implementation for optimizing the designed fuzzy control system is shown in Fig. 6.

Fig. 6
figure 6

SFS implementation applied for optimizing the designed fuzzy system

The SFS algorithm will be implemented to tune the input scale factor of the fuzzy controllers simultaneously. The SFS parameters used in the implementation are shown in Table 1.

Table 1 SFS parameters

5 Main results

To confirm the efficacy of the designed control system, the simulation will be implemented and the results discussed in conjunction with the GA-PID controller [52] and MNNA-PID controller [53], where the search space for the input scale factors and the system parameters are all assumed the same. The nominal parameters of the 2-DOF robot manipulator in the simulations are \( m_1 = m_2 = 0.1\) [kg], \( L_1 = 0.8\) [m], \( L_2 = 0.4\) [m], and \( g = 9.81 \,\,[\mathrm {m}/\mathrm {s}^2] \) [52, 53]. Various test scenarios are implemented to affirm the efficiency and robustness of the proposed optimal fuzzy system. These scenarios are arranged with the designed parameters which are shown in Table 2 to check with desired reference angles and trajectory experiments for the position of each joint.

Table 2 SFS parameters

In the first simulation, a reference angle is applied for each joint at system nominal parameters. The angular error of each joint of the robot manipulator to follow a reference angle is presented in Figs. 7 and 8. Torque for the joint of the robot manipulator is shown in Figs. 9 and 10. We can see that the designed optimal fuzzy system is more stable than other controllers.

In the second simulation, the performance of the control systems with a reference trajectory will be investigated. Straight-line from point A(0, 1.2) to B(0.3, 0.7) will be considered for the desired trajectory of the robot. A cubic position trajectory and a parabolic velocity will be applied for the motion on links of the robot which is clarified in Figs. 11 and 12.

Fig. 7
figure 7

The response curves of the position error for the angle \(\theta _1\)

Fig. 8
figure 8

The response curves of the position error for the angle \(\theta _2\)

Fig. 9
figure 9

Torque of the angle \(\theta _1\)

Fig. 10
figure 10

Torque of the angle \(\theta _2\)

Fig. 11
figure 11

Reference cubic position trajectory

Fig. 12
figure 12

Reference parabolic velocity

The output response of the links achieved by the different controllers in the situation of the cubic position trajectory test is shown in Figs. 13 and 14 where the efficiency of the optimal fuzzy control system is clearly demonstrated, the proposed algorithm can control links of the robot follow the cubic position trajectory more effectively.

Fig. 13
figure 13

The output response of link-1 for cubic position trajectory

Fig. 14
figure 14

The output response of link-2 for cubic position trajectory

The simulation scenarios showed that the optimal fuzzy controllers can offers better response curves in terms of minimum settling time, negligible overshoots and stability. The designed fuzzy control system can also follow the reference trajectory with fast response and negligible steady-state error compared with other techniques such as GA-PID or MNNA-PID.

6 Conclusion

In the paper, an intelligence system using fuzzy controllers based on relation model has been proposed for a two-link robot manipulator. Besides, the SFS method is introduced to optimize the input scale factors of the designed fuzzy controllers by minimizing integral of time-weighted absolute error in control signal. The optimal fuzzy control system is successfully tested in simulation environment to effectively control a non-linear, multi-input and multi-output, complex and coupled two-link robot manipulator. The performance of the proposed fuzzy control system is also compared with some previous researches such as GA-PID method or MNNA-PID method. The simulation scenarios have been verified the advantages of the proposed fuzzy control system in terms of minimum settling time, negligible overshoots and stability. The proposed fuzzy control system can control the two-link robot manipulator to follow the cubic position trajectory more effectively with fast response and negligible steady-state error.

In the future, received simulation results are proposed to be experimentally verified in real-time systems. Besides, the design of the fuzzy system is implemented based on experiences and knowledge of experts, not require a mathematical model of control plants. However, designing and optimizing several fuzzy controllers together increase the degree of nonlinearity and complexity in the optimization process, and selecting optimal parameters becomes challenging. These problems will be also our future research directions.