Adaptive Swarm Fuzzy Logic Controller of Multi-Joint Lower Limb Assistive Robot

: The idea of developing a multi-joint rehabilitation robot is to satisfy the demands for recovery of lower limb functionality in hemiplegic impairments and assist the physiotherapists with their therapy plans. This work aims at to implement the Lyapunov Adaptive and Swarm-Fuzzy Logic Control (LASFC) strategy of 4-degree of freedom (4-DoF) Lower Limb Assistive Robot (LLAR) application, in which the control law is an integration of swarm-fuzzy logic control (SFLC) and Lyapunov adaptive control (LAC) with particle swarm optimization (PSO). The controller is established based on the sliding ﬁltered steady-state error for SFLC. Its parameters are tuned by using PSO for the mathematical model of LLAR. The fuzzy defuzziﬁcation membership is set based on the tuned parameters for the real-time control system. LAC strategy is determined using stability analysis of the system to choose the controller’s parameters by observation of the system’s output and reference. The control law implemented in LLAR is the integration of SFLC and LAC to adjust the input voltage of joints. The parameters tuned by PSO are compared with the genetic algorithm (GA) statistically. In addition, the real-time trajectory tracking of the proposed controller for each joint is compared with LAC and SFLC separately. The experiment revealed that the LASFC has superior performance to the other two methods in trajectory tracking. For example, the average error for left hip by LASFC is 53.57% and 68% lower than SFLC and LAC, respectively. By the statistical analysis, it can be ascertained that the LASFC strategy performed efﬁciently for real-time control of the joint trajectory tracking.


Introduction
The occurrence of neurological diseases such as spinal cord injuries and stroke have increased and have become one of the main reasons for mobility impairments and vestibular dysfunction in many countries [1][2][3]. Adequate rehabilitation training is essential to slow down the disabling effects of chronic health conditions [4]. Recent clinical investigations on neurological rehabilitation have revealed the positive influence of repetitive motor activities on obtaining movement functionality. Traditional rehabilitation methods are physically demanding work, in which physiotherapists are required to deliver manual treatment based on their experiences. Practicing conventional manual therapy is often difficult and needs considerable exertion by practitioners to provide care for large patients [5]. Therefore, the application of robot-assisted rehabilitation devices has increased recently due to their potential in providing repetitive rehabilitation training to avoid muscle atrophy for disabled patients and lessen the physical efforts of the physiotherapists [6]. Integration of robotic technology and clinical rehabilitation treatments provides affordable and efficient long-endurance treatments as an alternative to high-intensity repetitive manual rehabilitation therapy. According to previous work, robot-assisted systems have been investigated in the implementation of a rehabilitation program to assist practitioners and mobility impaired individuals [7,8]. For instance, Franceschini et al. [9] investigated long-term effects of robot-assisted therapy for upper limbs compared with traditional physical therapy on stroked subjects for six months.
The control strategies in rehabilitation robots play a crucial role in retrieving satisfactory performance for various rehabilitation treatments [10]. Several training programs, such as repetitive motion tasks, require predetermined multi-joint trajectories. This type of practice demands precise trajectory control strategies. Numerous control techniques have been used in existing literature [11][12][13]. For instance, Tu et al. [14] presented a control strategy using the adaptive sliding mode method for the 4-degree of freedom (4-DoF) lower limb exoskeleton. Their strategy consisted of two outer loops with admittance parameters for estimating wearer active muscle strength and the inner loop of an adaptive sliding mode controller. Guo et al. [15] investigated model parametric identification for the lower exoskeleton to determine the unknown parameters of the mathematical model by using biogeography-based learning particle swarm optimization (PSO). They also used the active admittance controller for angular trajectory tracking. Yang et al. [16] developed a control scheme based on repetitive learning control and neural network (NN) for the lower limb exoskeleton, and they proved the stability of their control strategy with the Lyapunov approach.
Many researchers focused on combining fuzzy logic and control systems [17][18][19]. Sharma et al. [20] presented a control system that was the integration of a fuzzy logic controller (FLC) and dragon fly optimization algorithm for 4-DoF lower limb exoskeleton. In other work, Wu et al. [21] proposed a novel control strategy for a rehabilitation upper limb exoskeleton based on a neural-fuzzy adaptive control scheme. The output of their controller is a combination of the adaptive neural network, fuzzy logic, and force feedback compensation. It was developed based on sliding filtered steady-state trajectory error and fuzzy inference to determine controller parameters in a real-time control system. Sun et al. [22] studied reduced adaptive fuzzy decoupling control for a lower limb exoskeleton. Their fuzzy inference was developed based on the steady-state of the control system. They validated the control strategy in a multi-input-multi-output uncertain nonlinear system model. Premkumar et al. [23] presented a fuzzy proportional derivative controller and fuzzy proportional derivative integral controller, in which the ranges of defuzzification membership function are determined by a bat optimization algorithm.
From literature [17][18][19][20][21][22][23], there are various types of controller strategies to increase the performance of fuzzy logic on nonlinear systems. Developing a simpler controller strategy with more efficient tracking performance has attracted much attention from researchers. The aim of using fuzzy logic as a control strategy is to minimize the complexity of the control system and reduce processing time and computational burden. This paper presents a new PSO-based initialization for fuzzy logic and adaptive controller in a lower limb assistive robot (LLAR) for passive mode rehabilitation exercise, which is a new approach compared to the previous fuzzy logic and adaptive control strategy.
The novelty of this paper is to implement the Lyapunov Adaptive and swarm-fuzzy logic control (LASFC) strategy on the 4-degree of freedom (4-DoF) LLAR, in which the control law is an integration of swarm-fuzzy logic control (SFLC) and Lyapunov adaptive control (LAC) that are improved by particle swarm optimization (PSO). In summary, the contributions of the paper are: • A novel LASFC, which integrates SFLC and LAC strategies, is presented for each joint of the LLAR to achieve the predetermined angular trajectories. • A SFLC is developed to tune the parameters of the controller based on sliding filtered steady-state error. Its defuzzification subsets are determined by PSO. • A LAC strategy is initialized by PSO to adjust the controller parameters in real-time.

•
The novel LASFC is implemented in the actual 4-DoF LLAR.
The rest of this paper is organized as follows: In Section 2, the structure of the LLAR, the dynamic model, and actuator formulation are given. Section 3 addresses the devel-opment of LASFC and the integration of PSO with SFLC and LAC. Section 4 represents the performance and result of the proposed LASFC strategy in real-time control of LLAR. The conclusion is in Section 5.

Overview of the LLAR Structure
The mechanical structure, the electrical components, and the mathematical model of LLAR are described herein.

Mechanical Design and Structure
The LLAR is worn by a human subject in parallel to their lower limb. It has a 4-DoF linkage that consists of two active joints, such as the hip and knee, in each leg. The hip and knee are flexion/extension rotation joints. The structure of the LLAR is shown in Figure 1. Each joint is operated by a 12 V brushed DC motor and a worm gearbox. The generated torque is transmitted to the worm gearbox with gear ratio of 32. A quadrature encoder is located at the motor shaft to record the angle of each joint with a resolution of 200 pulses per rotation. An Arduino Mega 2560 is used to control and capture the data from the encoder and regulate the input voltage and direction of actuators based on the determined data from the control system. Figure 2 illustrates the structure of hardware of the LLAR. As can be seen in Figure 2, four DC motor drivers are used to convert the direction and pulse-width modulation (PWM) received from the Arduino to the actuators of each joint. An embedded PC using Raspberry Pi4 8 GB is employed to communicate with the Arduino and the base station. The connection between the Raspberry Pi and the base station is a master PC employed to monitor and command the LLAR through a WiFi hotspot. Robot Operating System (ROS) is used as the master and client for this communication.
The control system is programmed in Python and run in the base station, which is a PC with an Intel Core i3 CPU 16 GB RAM.

Mathematical Analysis of Dynamic Model
The dynamic model of a multi-joint serial-link robot can be determined by a Lagrangian equation. The dynamic equation is expressed as follows: where M(θ) ∈ 4×4 is the inertia matrix; V(θ,θ) ∈ 4 is centripetal and Coriolis vector; G(θ) ∈ 4 introduces the gravitational force; τ ∈ 4 represents the torques generated by actuators; F(t) ∈ 4 is vector of interactions between human subject and exoskeleton; and D ∈ 4 denotes uncertainties, including external disturbances, modelling errors, and frictional forces. In general, the following properties hold for the exoskeleton dynamic system: [16] Property 1. The inertia matrix M ∈ 4×4 is positive-definite and symmetric inertia, which is further bounded, where α 1 and α 2 are the positive constants and . is the standard Eulidean norm.

Property 2.
The centripetal and Coriolis vector V(θ,θ) ∈ 4 and the time derivative of the inertia matrix M(θ) ∈ 4×4 satisfy the following equation: Property 3. The uncertain term D ∈ 4 is limited by positive constant δ as follows:

Actuator Model
The joints of the exoskeleton are actuated by DC motors to provide the required torque. The input voltage is determined as follows: where L and i represent the electric inductance and current, respectively; R and u are resistance and the input voltage of the DC motor, respectively. The generated torque is proportional to the current as follows: where K m is the torque sensitivity. In addition, the generated torque by the DC motor applied to the joints is the summation of link torque τ l and rotary torque τ r , given as follows: where τ r is the torque of the rotary shaft, which is given as follows: where J and C f represent the inertia of the rotary shaft and friction coefficient. The mathematical model of the LLAR in continuous time is written as follows: where G i (s) denotes the mathematical model of the hip and knee; b i and a j i , j = 1, 2, 3, 4 are the parameters. The mathematical model was determined previously in [24] by system identification determined by genetic algorithm (GA) to estimate the parameters of the mathematical model. As the LLAR has symmetric parallel legs, we consider one leg for developing the control strategy. Table 1 expresses the mathematical model parameters for hip and knee joints.

Overview of Control Strategy
To design the LASFC strategy, the control law is composed of two terms: LAC and SFLC. The overall block diagram of the LASFC control strategy is shown in Figure 3.
Therefore, the output of LASFC u is expressed as follows: where u f and u a are the output of LAC and SFLC, which are developed by the Lyapunov approach and if-and-then linguistic rules. The control task for LLAR is to bound the controller output u that the output trajectory track x the desired trajectory r as minimally as possible despite uncertainties and disturbances.
In the LASFC strategy, the parameters of the fuzzy control law are pre-tuned by PSO. The tuned parameters determine the defuzzification subsets ranges. The control law is defined based on the observation of the input and output of the system. The tuned parameters are employed as the initial value for control law determined by the Lyapunov approach. Algorithm 1 shows the implementation method of LASFC.

Swarm-Fuzzy Logic Control Strategy
SFLC adjusts the controller parameters according to the actual situation detected and signal processed by the control system. In this control strategy, the conditions are implemented into fuzzy logic rules that process the data captured by the sensor. Fuzzy inference is then applied, and the actual control parameters can be obtained. The fuzzy logic rules for the inference are captured by PSO, which is used to tune the controller parameters and distinguish fuzzy membership subsets. The PSO is an iterative optimization method based on the population that took its inspiration from observation of biological societies such as a flock of birds, swarms of bees, and schools of fish [25]. Moreover, PSO has a simple concept and is easy to implement in different optimization problems. In addition, it is possible to control the robustness of its parameters. PSO has few parameters to adjust, and it has a high probability of and efficiency in finding the global optimum. The PSO has a chance of finding the global optimum by providing a wide exploration area in the initial iterations to find the neighbor of the global optima and narrowing the searching space to find the best result [26,27]. It causes fast convergence and prevents it from being trapped to the local optimum, which makes it superior to various metaheuristic optimization methods, such as the grey wolf optimizer, whale optimization algorithm, and Jaya algorithm [28].
Fuzzy logic is divided into three main parts: fuzzification, fuzzy inference machine, and defuzzification. Fuzzification is the input of the fuzzy control system, which produces the fuzzy quantity from the transformation of membership sets for fuzzy inference. Let us define A as a fuzzy set, with the membership function characterized as follows: where Y is the universal base set. α is the subset of set A, represented as follows: There are several common types of membership functions, including triangular, trapezoidal, and Gaussian, and their graphs have different shapes.
The fuzzy inference machine synthesizes the obtained data from fuzzification and the defined linguistic if-and-then rules. The fuzzy inference is the kernel of fuzzy logic that processes the antecedent as the input by linguistic rules and concludes the consequent output.
Defuzzification is the process of converting the linguistic results of fuzzy inference to the actual quantitative and reasonable crisp values as the output of the fuzzy logic control. This can be achieved by various methods, such as the center of gravity, weighted average, the center of the largest area, and centroid methods. The control law for SLFC controller is given as follows: where K f is the controller parameter and s represents the sliding filtered steady-state error as follows: where Λ ∈ 4 is the symmetric positive constant gain matrix; e andė are steady-state error and its derivative as follows: where r and x are the desired and actual angular trajectories. The tuning of controller parameters K f and Λ are defined as the optimization problem and solved by PSO. The objective function of the optimization problem is integral time absolute error (ITAE) for the closedloop control system, in which the controller is shown in Equation (13) and the plant is the hip and knee mathematical models. The objective function is expressed as follows: where t is elapsed time. Each particle of the PSO consists of design variables of controller parameters K f and Λ. The initial particles are filled by random values between zero and one.
where j and µ are the number and maximum quantity of particles. The objective function is determined for each particle for evaluation. The minimum one is selected as the best particle, denoted as p. The particles of the next generations are created by the summation of the current particle and the velocity of each particle, expressed as follows: where i is the number of iterations; υ i,j carries the velocity and direction of each particle toward the particles of the next iteration [29]. The value of υ i,j is given as follows: where ω is positive constant of inertial weight, and c 1 and c 2 are self and social recognition positive constants; g represents the best global particle determined after evaluation of particles in each iteration in comparison with the best particle p; ζ is a random value between 0 and 1. The particles captured as global best g of the last iteration are the optimal output of the algorithm.
The parameters of the PSO is expressed in Table 2. To tune the controller parameters K f and Λ, the noted optimum problem is solved by PSO and compared by GA and beetle antennae search (BAS). The elapsed time is 10 s and the time step is 0.1 s. The population and generation numbers for GA and BAS are 20 and 200, respectively. Table 3 compares numerical analysis of PSO and GA in the unit step response closed-loop control system for an LLAR hip joint.
The average of ITAE driven by PSO for ten different runs are 34.8% and 63.13% less than GA for hip and knee, respectively. Moreover, this value for PSO is 18% and 56% lower than BAS for hip and knee, respectively. Therefore, the controller parameters tuned by PSO are selected. The p-value comes from the ANOVA test for the ITAE of ten different running by PSO and GA. The p-value is lower than 0.005, which shows the ITEA for ten different runs is not repetitive.
Therefore, in the real-time control of the LLAR, the controller parameters K f and Λ are chosen as follows: • Λ is the constant value tuned by PSO. Its average values in Table 3 are selected for hip and knee, which are 0.88 and 0.76, respectively. • K f is the output of the fuzzy inference. It is determined by the linguistic rules of the fuzzy controller based on its maximum and minimum obtained by PSO in Table 3, which are 6.82 and 1.32 for hip and 6.95 and 2.64 for knee.
The parameter K f is the output of the fuzzy inference by the linguistic rules and fuzzy sets. Five subsets are defined for K f defuzzification membership function such as ZE, PS, PM, PB, and PL, in which their ranges are determined based on minimum and maximum of K f driven by PSO, given as follows: where T represents the defuzzification subsets; n denotes the number of defuzzification subsets; andḰ f is the defuzzification subsets range step, expressed as follows: The linguistic fuzzy logic rules are defined based on sliding filtered error s and its derivative, as expressed in Table 4  The fuzzy logic rules are defined as follows: where L i and H i are the input fuzzy subsets labels; and T i represents output fuzzy subsets. Particularly, there are two examples of the fuzzy logic rules, written as follows: The center of gravity technique and Zadeh fuzzy synthesis method are employed for fuzzy defuzzification [30]. Pseudo code of SLFC is illustrated in Algorithm 2. 5: Start; 6: Initialize particles by random values; 7: Evaluate initial population; 8: Select the initial p; 9: while (Number of iteration less than µ) do; 10: Create new iteration; 11: Update velocity and position; 12: Select the p; 13: if p less than the previous g then; 14: Store it as g; 15: end if 16: end while 17: Select the particle of g as the result; 18: Determine Λ for control law; 19: Set fuzzification and defuzzification linguistic rules; 20: Set fuzzification membership function for s andṡ; 21: DetermineḰ f based on the results of PSO; 22: Implement the defuzzification membership function for K f ; 23: End.

Lyapunov Adaptive Control Strategy
LAC is defined to guarantee the stability of the non-linear dynamic system by the Lyapunov approach. It is mainly used in the control system to improve robustness in the presence of external forces. To clarify, consider the case that the LLAR is worn by the human object, hence the desired torque should be generated to minimize the steady-state-error e thus the auxiliary variable x converges to zero [31,32]. Theorem 1. Consider a non-linear dynamic system, where f is a Lipschitz function. Consider a function V : n → [0, ∞), which is a positive definite function and V x is a Lipschitz gradient. The Lyapunov function for a system is considered as follows [33]: Such a system is stable if the Lyapunov function V exists and its derivative is negative definite.
Proof. By considering Equation (9), the state-space variables are assumed as follows: Therefore, the time-invariant vector differential of LLAR mathematical model is given as follows: the control law is selected to observe the reference and output of the control system given as follows: Here, the candidate Lyapunov function is chosen as follows: where P is a positive definite matrix used to simplify algebra without any loss of generality; X T is the transpose of Equation (31); and Γ is the adaptation gain matrix, which is positive definite. Differentiating Equation (33) over time, it can be obtained, whereK = K −K andL = L −L, in whichK andL are the estimation of controller parameters. Therefore,˙K from Equation (31), Substituting Equation (31) into Equation (34), we can get, Substituting Equation (32) into Equation (38) and simplifying, it can be giveṅ It is assumed for a given positive-definite matrix Q, there is a positive-definite solution P such that PA + A T P = −Q. Thus, if the expressions −BXPX − X T PBX + 2˙K T Γ −1 and B T rPX + X T Br + 2˙L T Γ −1 converge to zero, the differential of Lyapunov function will bė V = −X T QX, which is the negative, and Theorem 1 is satisfied.
Therefore, the parameters of controller are given as follows: By applying the time domain integral of Equations (41) and (40), the parameters of the adaptive control system are represented as follows: where c k and c l are the unknown parameters, which are determined by optimal tuning by PSO. The objective function of the PSO is ITAE, which is determined in the closedloop control system by the control law given in Equation (32). The design variables are the two control parameters. The parameters of PSO are shown in Table 2. Table 5 compares the optimal results for c k and c l determined by PSO, GA, and BAS. The population and generation numbers for GA and BAS are 20 and 200, respectively. The average of ITAE determined by PSO for ten different runs is 32.14% and 69.4% less than GA for hip and knee, respectively. This value for PSO is 50% and 71.1% lower than BAS. Hence the optimal results that have the lowest ITAE established by PSO for hip and knee are selected as c k and c l .

Results and Discussion
The performance of the proposed LASFC is validated for LLAR joints. In addition, its efficiency is compared with LAC and SFLC separately. The angular trajectory tracking test is suggested to evaluate the performances of the proposed LAC, SFLC, and LASFC. The desired trajectories are developed for the rehabilitation gait training exercise inspired by the stand and swing phases of healthy human walking [34]. The desired trajectories equations for left hip, left knee, right hip, and right knee, respectively, are given as follows: y rk (t) = min(0, 30sin( f t)), where t and f are the elapsed time and frequency. Figure 6 compares the angular trajectories LAC, SFLC, and LASFC for four joints of LLAR. As can be seen in Figure 6, LASFC converged to the desired trajectory more efficiently than LAC and SFLC, due to the parameters adjustment and initialization by PSO. In all joints, the error of LASFC has the lowest peak. The parameter's range for defuzzification of SFLC is adjusted by PSO tuning technique, despite the fact that the LAC parameters are initialized by the PSO and it should adjust the parameters based on the observation of output and input of the control system. Therefore, SFLC performed better than LAC. Figure 7 represents the changes of fuzzy parameter for LASFC strategy for the left hip and knee. In Figure 7, K f changes periodically based on the swing and stand phases of left hip and knee trajectories. It raises with fluctuation while the trajectory is in the swing phase to converge the trajectory error. In addition, it levels off while the angular trajectory is stable in the standing phase for the hip and knee. Figure 8 shows K f changes over s andṡ for four joints determined by LASFC strategy.
In Figure 8, it can be observed how the fuzzy logic rules are followed by LASFC. For instance, s andṡ are in the NL and NM fuzzy subset ranges, whereas K f is in its highest range, which are PL and PB fuzzy subsets. In addition, while s andṡ increase, the K f moves to its lower subsets. Figure 9 illustrates the changes of L and K parameters of the adaptive controller strategy of LASFC for the left hip and knee.
In Figure 9, the parameters of L and K reached their peak when the angular trajectories are in the swing phase of gait training. They remain constant in the initialized value tuned by PSO for LAC. Table 6 represents a statistical analysis of angular trajectory error determined by LAC, SFLC, and LASFC.  In Table 6, E max , E ave , and RMS denote maximum, average, and root mean square steady-state error, respectively. The E max , E ave , and RMS for LASFC are significantly lower than for LAC and SFLC. For example, the E ave for the left hip by LASFC is lower than than SFLC and LAC by 0.013 (rad) and 0.028 (rad), respectively. In addition, E max for the right knee determined by LASFC is 0.012 (rad) and 0.066 (rad) lower than SFLC and LAC. Generally, E max , E ave , and RMS calculated by LASFC did not exceed 0.05 (rad) , which is the acceptable value [35]. Table 7 compares the performance of LASFC with three other controllers for exoskeletons.  Figure 9. Changes of L and K parameters for left hip, left knee, right hip, and right knee: (a) L for left hip, (b) K for left hip, (c) L for left knee, (d) K for left knee, (e) L for right hip, (f) K for right hip, (g) L for right knee, (h) K for right knee.
For the current study, IAE is lower than the NN-based controller demonstrated in [37] and FLC presented in [30] by 85% and 62% for the hip joint, respectively. It should be considered that the exoskeleton model demonstrated in [30] was developed in Matlab/Simulink as the benchmark and was not validated in the experimental prototype. In addition, the RMSE in this work is 28% lower than PSO-PID represented in [36] for the knee. The actuator used in [36] is BLCD Maxon, which has higher quality and power than the motor used in the present work.

Conclusions
This paper presented a novel LASFC strategy based on the integration of the LAC and SFLC for LLAR. In FSLC, the defuzzification membership function for parameters of the controller was determined based on the PSO. Similarly, the parameters of the LAC controller were initialized by PSO. The results comparison of LAC, SFLC, and LASFC showed satisfactory performance for the three control strategies, despite the LASFC performing more accurately with lower steady-state error. For instance, the E ave for the left hip by LASFC is 53.57% and 68% less than SFLC and LAC, respectively. In addition, E ave for the right knee determined by LASFC is 45% and 70% lower than SFLC and LAC.
The proposed LASFC strategy can be implemented in multi-joint exoskeleton robots for assisting physiotherapists in rehabilitation training. However, this method is validated in the fixed frame of LLAR for specific average height subjects. In addition, human-inloop effects for various rehabilitation exercises have not been considered in this paper. By considering these limitations in future work, the effect of the wearer's forces will be added to the controller strategies and it will be tested in a variety of rehabilitation exercises.