1 Introduction

It is obvious that uncertainties in various types and forms are unavoidable in real control systems. Uncertainties can be classified into two categories: Disturbance signals and dynamic perturbations. A disturbance is a signal that tends to adversely affect the values of the output of the system. If a disturbance is generated within the system, it is called internal, while an external disturbance is generated outside the system and regarded as an input. Sensor and actuator noises or the changes of the environment are the examples of disturbance signals. Dynamic perturbations are the uncertainties which refer to differences and errors between the actual plant and its mathematical model. This type of uncertainties may be classified as un-structural uncertainties and structural uncertainties. Sources of un-structural uncertainties include high frequency un-modeled dynamics, neglected nonlinearities, the errors due to modelling linearization and so on. The structural or parametric uncertainties represent any parametric variation in the plant dynamics which may take place due to lack of precise knowledge of actual system parameters. Each of these uncertainties may be time-varying or time-invariant and could be handled by robust control methods appeared in the control world around 1980 and has been broadly developed [1,2,3,4,5,6,7,8].

To deal with uncertainties of the system model, Zeinali and Notash [9] used a new approach to estimate the perturbation from the dynamics of the sliding surface to compensate model uncertainties, unknown external disturbances and time varying parameters in a robot manipulator. Chaoui and Sicard [10] considered the control and stabilization of an inverted pendulum mechanism with unstructured uncertainties by an adaptive fuzzy system. The uncertainty model in their paper was related to unknown friction composed of Coulomb, viscous and static friction terms. Shojaei et al. [11] tried to use an adaptive feedback linearizing controller for a nonholonomic wheeled mobile robot in the presence of both parametric and nonparametric uncertainties. Ricardez-Sandoval [12] presents a new methodology for the design and control of systems under random realizations in the disturbances. The researcher claims that the key idea in his work is to perform a distribution analysis on the worst-case variability. Figueroa and Biagiola [13] considered the modelling and characterizing the uncertainties for robust control and gave simulation examples to illustrate the method. Li et al. [14], in an interesting research, reviewed different types of uncertainties and relevant theories to manage the uncertainties and their applications to the fields of economics, engineering, ecology and information sciences. Yoon et al. [15] discussed adaptive tracking control for the spacecraft relative motion with mass and thruster uncertainties. In Ref. [16], a novel control strategy was considered for trajectory tracking control of a class of multi-input multi-output nonlinear systems including matched uncertainties and input-state constrains. Petersen and Tempo [17] reviewed some of main achievements in the field of the robust control for the uncertain systems.

What is presented in the current work in both terms of adopted adaptive control and the type of exerted uncertainties is fully different from all above-mentioned papers. In more details, at first, the changing domains of the uncertain parameters are specified, and different values for these parameters are produced in these domains. After this stage, the optimum control gains are found by the multiple-crossover genetic algorithm based on the single-objective optimization theory. It is obvious that each of the obtained control gains is optimal only for a specific set of the parameters. Finally, an approximating function is designed by the multiple-crossover genetic algorithm which can produce the optimal control gains at any situation according to the changings of the parameters.

The rest of this paper is organized as follows. Section 2 recalls the dynamical equations of the cart-type inverted pendulum system. Section 3 combines the approximate feedback linearization and sliding mode control to benefit the advantages of the both methods. The multiple-crossover genetic algorithm optimization is presented in Sect. 4. Details of the proposed optimal feedback linearization based sliding mode control scheme are explained in Sect. 5. Simulations of the states of the cart-type inverted pendulum system including time-varying uncertainties are depicted in Sect. 6. Finally, Sect. 7 concludes the paper, briefly.

2 Dynamical modelling of the problem

Consider the cart-type inverted pendulum system illustrated in Fig. 1 composed of a cart which is able to move left and right on a horizontal rail and a pendulum pivoted on the cart that can rotate around a vertical axis. Ignoring any types of friction in the system and using Newton’s second law, the governing dynamical equations can be mentioned as follows:

$$ ml\,\ddot{z}\cos \left( \varphi \right) - \frac{4}{3}ml^{2} \ddot{\varphi } + mgl\sin \left( \varphi \right) = 0 $$
(1a)
$$ \left( {M + m} \right)\ddot{z} - ml\ddot{\varphi }\;\cos (\varphi ) \,+\,ml \dot{\varphi }^{2} \sin \left( \varphi \right) = F $$
(1b)

where, M and m denote the masses of the cart and pendulum, respectively. l is the length of the pendulum. z represents the lateral displacement of the cart, and \( \varphi \) denotes the angular displacement of the pendulum. Finally, F is the only input applied to the cart in order to control the system. It is obvious that the pendulum will start to swing when the input F makes the cart move back and front.

Fig. 1
figure 1

Mechanical configuration of the considered cart-type inverted pendulum system

3 Combination of approximate feedback linearization and sliding mode control

All physical systems as well as their governing differential equations are nonlinear in nature, and the superposition principle is not valid for them. In order to control the nonlinear systems, two strategies are commonly suggested. The first strategy is linearization of the nonlinear equations around the equilibrium point and stabilization of the system using one of linear control methods. The linearization procedure is done by expansion of nonlinear equations into the Taylor series around the operating point and neglecting the nonlinear terms in Taylor series expansion. But this strategy has a big limitation that it is to be valid only in the neighborhood of the operating point. The second strategy is to use nonlinear control approaches for the nonlinear systems. For the reason of the aforementioned limitation for linear controllers, in recent decades, researchers have tried to expand the nonlinear control methods and use such techniques to stabilize the nonlinear systems. Feedback linearization is one of these approaches that uses a change of coordinates and nonlinear state feedback to transform the nonlinear dynamics into a fully or partially linear one. It is important to notice the difference between Taylor linearization and feedback linearization. Taylor or Jacobean linearization is done on the basis of neglecting nonlinear terms but in feedback linearization, in general, we have no type of neglecting. In other words, the feedback linearization approach uses transformation of dynamics but the Jacobean linearization is achieved by approximation of dynamics [18,19,20].

On the other hand, feedback linearization is divided into two general forms; namely, exact feedback linearization and approximate feedback linearization. In the following, a general explanation about the approximate feedback linearization is represented. In some cases, the control input is appeared in the derivative of the output, but it is not possible to define a control law according to that because the coefficient behind the control input becomes zero at the equilibrium point. In these situations, the designed controller based on such a law will not be able to stabilize the system in the equilibrium point. A solution to overcome this issue is to remove this coefficient and differentiate from the relations until the control input appears once again. This type of feedback linearization is called approximate feedback linearization that has been investigated in details in [20, 21].

In the following of this section, for the considered inverted pendulum system, the dynamical modelling is simplified by the use of the approximate feedback linearization, and the desirable control law is extracted by the sliding mode control. Ref. [21] has considered this procedure in complete details, and here, only the main relations are presented. Regarding the state vector of the governing equations as \( x = \, [x_{1} , \, x_{2} , \, x_{3} , \, x_{4} ]^{\text{T}} = \, \left[ {z, \, \dot{z}, \, z, \, \dot{z}} \right]^{\text{T}} \). Where, \( x_{1} = z \) is the position of the cart and \( x_{2} = \dot{z} \) denotes the velocity of the cart. Moreover, \( x_{3} = \varphi \) and \( x_{4} = \dot{\varphi } \) represent the angle and angular velocity of the pendulum, respectively. Then, the state-space equations can be rewritten as follows:

$$ \dot{X} = \left( {\begin{array}{*{20}l} {\dot{x}_{1} } \hfill \\ {\dot{x}_{2} } \hfill \\ {\dot{x}_{3} } \hfill \\ {\dot{x}_{4} } \hfill \\ \end{array} } \right) = \left( {\begin{array}{*{20}c} {x_{2} } \\ {\frac{{mg\sin (\dot{x}_{3} )\cos (x_{3} ) - \frac{4}{3}ml\;x_{4} \sin (x_{3} )}}{{\frac{4}{3}(M + m) - m\cos^{3} (x_{3} )}}} \\ {x_{4} } \\ {\frac{{g(M + m)\sin (x_{2} ) - ml\;x_{4}^{2} \sin (x_{2} \cos (x_{3} )}}{{l\left( {\frac{4}{3}(M - m) - m\cos^{2} (x_{3} )} \right)}}} \\ \end{array} } \right) + \left( {\begin{array}{*{20}c} {\begin{array}{*{20}c} 0 \\ {\frac{{\frac{4}{3}}}{{\frac{4}{3}\left( {M + m} \right) - m\cos^{2} (x_{3} )}}} \\ \end{array} } \\ 0 \\ {\frac{{\cos (x_{3} )}}{{l\left( {\frac{4}{3}\left( {M + m} \right) - m\cos^{2} (x_{3} )} \right)}}} \\ \end{array} } \right)F $$
(2)

If F is selected as \( F = \left( {\left( {M + m} \right) - \frac{3m}{4}\cos^{2} (x_{3} )} \right)u + mlx_{4}^{2} \sin (x_{3} ) - \frac{3mg}{4}\sin (x_{3} )\cos (x_{3} ) \), then Eq. (2) can be expressed by:

$$ {\dot{\mathbf{x}}} = \left( {\begin{array}{*{20}c} {\begin{array}{*{20}c} {x_{2} } \\ 0 \\ \end{array} } \\ {x_{4} } \\ {\frac{3}{4l}{\text{g}}\sin (x_{3} )} \\ \end{array} } \right) + \left( {\begin{array}{*{20}c} {\begin{array}{*{20}c} 0 \\ 1 \\ \end{array} } \\ 0 \\ {\frac{3}{4l}\cos (x_{3} )} \\ \end{array} } \right){\text{u}} = {\text{f}} + {\text{gu}} $$
(3)

Calculating \( ad_{f}^{i} g , \quad i = 0,1,2,3 \), for this model illustrates that it is only linearly independent in its definition domain and doesn’t have the involutive condition [22]. This means that model (3) cannot be input-state linearizable, and it is not possible to find a function for the output so that the relative degree of the system becomes full [23]. The solution of the above system for the control effort u presented in [21] can be stated as:

$$ u = - \frac{a\left( x \right)}{b\left( x \right)} + K {\text{sat}}\left( {\frac{s}{\emptyset }} \right) $$
(4)

where,

$$ \left\{ {\begin{array}{*{20}l} {a\left( x \right) = \alpha \left( x \right) + 3\lambda \xi_{4} + 3\lambda^{2} \xi_{3} + \lambda^{3} \xi_{2} } \hfill \\ {b\left( x \right) = \beta \left( x \right),} \hfill \\ \end{array} } \right. $$

that,

$$ \left\{ {\begin{array}{*{20}l} {\alpha \left( x \right) = - \frac{4l}{3}\frac{{\sin \left( {x_{3} } \right)}}{{\cos^{2} (x_{3} )}}\left( {\frac{6}{{\cos^{2} (x_{3} )}} - 1} \right)x_{4}^{4} - \left( {\frac{{3g\sin \left( {x_{3} } \right)}}{{\cos (x_{3} )}}} \right)\left( {\frac{4}{{\cos^{2} (x_{3} )}} - 1} \right)x_{4}^{2} + \frac{3g}{4l}\sin \left( {x_{3} } \right)\left( {2g - \frac{3g}{{\cos^{2} (x_{3} )}}} \right)} \hfill \\ {\beta \left( x \right) = 3x_{4}^{2} - \frac{{6x_{4}^{2} }}{{\cos^{2} (x_{3} )}} - \frac{9g}{{4l\cos (x_{3} )}} + \frac{3g}{2l}\cos (x_{3} )} \hfill \\ \end{array} } \right. $$

and,

$$ \left\{ {\begin{array}{*{20}l} {\xi_{1} = x_{1} - \frac{4l}{3}\ln \left( {\frac{{1 + \sin \left( {x_{3} } \right)}}{{\cos (x_{3} )}}} \right) } \hfill \\ {\xi_{2} = x_{2} - \frac{4l}{3}\left( {\frac{{x_{4} }}{{\cos (x_{3} )}}} \right)} \hfill \\ {\xi_{3} = {-}\tan (x_{3} )\left( {{\text{g}} + \frac{{4lx_{4}^{2} }}{{3\cos (x_{3} )}}} \right)} \hfill \\ {\xi_{4} = - \frac{4l}{3}\left( {\frac{2}{{\cos^{3} (x_{3} )}} - \frac{1}{{\cos (x_{3} )}}} \right)x_{4}^{3} - \left( {\frac{{3{\text{g}}}}{{\cos^{2} (x_{3} )}} - 2{\text{g}}} \right)x_{4} } \hfill \\ \end{array} } \right. $$

where, saturation function sat is defined as follows.

$${\text{sat}}\left( {\frac{s}{\emptyset }} \right) = \left\{ {\begin{array}{*{20}l} { - 1} \hfill & {\frac{s}{\emptyset }} \hfill \\ {\frac{s}{\emptyset }} \hfill & { - 1 < \frac{s}{\emptyset } \le 1} \hfill \\ 1 \hfill & {\frac{s}{\emptyset } > 1} \hfill \\ \end{array} } \right. $$
(5)

\( s\left( {\text{t}} \right) \) indicates the sliding surface of the system obtained by the sliding mode theory [21]. Control parameters \( \lambda \), \( \emptyset \) and \( k \) are constants that would be found by the multiple-crossover genetic algorithm.

4 Genetic algorithm optimization

Optimization can be defined as the selection of the best among a given set of finite or infinite alternatives. The optimal solution of an optimization problem is the minimum or maximum point of the objective function. The concept of optimization may seem straightforward but its implementation can be quite complicated.

The objective functions could be single-variable or multi-variable. These variables called decision variables or optimization parameters must be founded and determined so that the objective functions can be optimized. The optimization problems can be expressed in different forms from the view point of the number of the objective functions, the characteristics of the objective functions, being constrained or non-constrained and other cases. A single-objective optimization problem includes only one objective function as many of engineering problems are so. But many others include two or more objective functions which must be optimized, simultaneously. In a multi-objective problem, often, the objective functions are in conflicting with each other. For instance, in transportation systems, minimizing both travel time and travel cost is desirable. It is clearly evident that the two objectives are completely conflict with each other because an increase in one of them will cause a decrease in the other. Moreover, an optimization problem can be constrained or non-constrained. Constrains allow the optimization parameters to take on certain values but exclude others.

To solve the optimization problems, numerous algorithms have been proposed. In this work, a multiple-crossover genetic algorithm is considered to find the control parameters with regarding of an objective function. In the following, the used operators in this algorithm are presented. Let \( \sigma_{i} \left( t \right) \), \( \sigma_{j} \left( t \right) \) and \( \sigma_{k} \left( t \right) \) represent three random selected chromosomes so that \( \sigma_{i} \left( t \right) \) has the smallest fitness value among them. The following formula is proposed for the multiple-crossover operator:

$$ \sigma_{i} \left( {t + 1} \right) = \sigma_{i} \left( t \right) + \rho_{1} \left( {2\sigma_{i} \left( t \right) - \sigma_{j} \left( t \right) - \sigma_{k} \left( t \right)} \right) $$
(6a)
$$ \sigma_{j} \left( {t + 1} \right) = \sigma_{j} \left( t \right) + \rho_{2} \left( {2\sigma_{i} \left( t \right) - \sigma_{j} \left( t \right) - \sigma_{k} \left( t \right)} \right) $$
(6b)
$$ \sigma_{k} \left( {t + 1} \right) = \sigma_{k} \left( t \right) + \rho_{3} \left( {2\sigma_{i} \left( t \right) - \sigma_{j} \left( t \right) - \sigma_{k} \left( t \right)} \right) $$
(6c)

where, \( \rho_{1} , \rho_{2} {\text{and }}\rho_{3} \in \left[ {0, 1} \right] \) are random values. If \( P_{c} \) is the multiple-crossover probability and \( N_{p} \) is the population size, then \( \frac{{{\text{P}}_{\text{c}} \times N_{p} }}{3} \) number of chromosomes are selected for enhancing. Besides, the mutation operator is presented as the following equations.

$$ \sigma_{i} \left( {t + 1} \right) = \sigma_{i} \left( t \right) + \rho \times c $$
(7)

where, \( \sigma_{i} \left( t \right) \) is a randomly selected chromosome, \( \rho \in \left[ { - 1, 1} \right] \) is a random value, and c is a constant parameter. Moreover, \( P_{m} \times N_{p} \) chromosome(s) are randomly mutated, that \( P_{m} \) and \( N_{p} \) are the mutation probability and the population size, respectively [24, 25].

5 Optimal robust control against time-varying uncertainties

In Eq. (4), a control law based on the approximate feedback linearization and sliding mode control was proposed for stabilizing the cart-type inverted pendulum system. In this section, the control law is modified so that an optimal performance is displayed at any time against the time-varying uncertainties.

At first, system parameters M and l are respectively varied in the regions as \( {\text{M}} \in \left[ { 0.1, 2} \right] \;{\text{kg}} \), \( l \in \left[ { 0.05,1} \right] m \) with the steps as 0.1 and 0.05, and 400 ordered pairs of \( \left( {{\text{M}}, l} \right) \) could be generated. Then, for each pair, the optimum values of the control parameters \( {\text{K}}, \lambda\,{\text{and}}\,\phi \) would be obtained via the optimization process. The following Objective Function (OF) is defined for the optimization process based on the multiple-crossover genetic algorithm.

$$ {\text{OF}} = {\text{normalized }}\left( {\smallint \left| z \right|dt} \right) + {\text{normalized }}\left( {\smallint \left| \varphi \right|dt} \right) + {\text{normalized }}\left( {\hbox{max} \left( F \right)} \right) $$
(8)

The setting values for the multiple-crossover genetic algorithm, i.e. the reproduction probability, multiple-crossover probability, mutation probability, population size, maximum number of iterations and mutation constant, are regarded as 0.45, 0.45, 0.1, 1000, 1000 and 1 × 10−7, respectively. The found optimum parameters for some values of the defined ordered pairs are represented in Table 1.

Table 1 Objective functions and optimal control parameters found by the multiple-crossover genetic algorithm for some system parameters

In the next stage, an approximating function is introduced to produce the optimal control gains at any time with the changing of the system parameters. The coefficients of the approximating function are identified via an optimization process based on the multiple-crossover genetic algorithm. The proposed structure for the approximating function to calculate the control parameters (\( K, \lambda \; {\text{and}}\; \phi \)) is as follows.

$$ C_{\text{approximating}} = {\text{w}}_{1} + {\text{w}}_{2} {\text{M}}^{{{\text{w}}_{3} }} + {\text{w}}_{4} l^{{w_{5} }} $$
(9)

where, \( w_{j} \) j = 1 to 5 are coefficients found by the optimization algorithm. Further, \( M \) and \( l \) respectively denote the mass of the cart and the length of the pendulum that vary over time. Root Mean Squared Error (RMSE) between the approximating function (\( C_{\text{approximating}} \)) and the actual optimum gains (\( C_{\text{actual}} \)) is considered as the objective function for this optimization process that should be minimized with respect to \( w_{j} \) j = 1 to 5 as the design variables.

$$ {\text{RMSE}} = \sqrt {\frac{{\sum\nolimits_{i = 1}^{n} {(C_{{{\text{actual}}\;i}} - C_{{{\text{approximating}}\;i}} )^{2} } }}{n}} $$
(10)

where, n is the number of the produced ordered pairs \( \left( {{\text{M}}, l} \right). \) Figs. 2, 3, and 4 respectively compare the actual control gains \( K, \lambda \; {\text{and}}\; \phi \) and the related estimated values obtained by the approximating function. Table 2 displays the values of \( w_{j} \)’s and RMSE found by the multiple-crossover genetic algorithm and corresponding control gains \( K, \lambda \; {\text{and}}\; \phi \). Figure 5 depicts the block diagram of this adaptive optimal controller in order to control and stabilize the system with time-varying parametric uncertainties. It is worth mentioning that the proposed adaptive optimal controller will be able to adapt itself to any new conditions imposed by uncertainties and then present not only a robust control but an optimal one.

Fig. 2
figure 2

Actual and estimated values for the control gain K

Fig. 3
figure 3

Actual and estimated values for the control gain \( \lambda \)

Fig. 4
figure 4

Actual and estimated values for the control gain \( \phi \)

Table 2 Obtained values of wj’s and \( {\text{RMSE}} \) for control parameters \( K, \lambda \;{\text{and}}\; \phi \)
Fig. 5
figure 5

Block diagram of the proposed adaptive optimal control

6 Result and discussions

In order to produce the time-varying parametric uncertainties, M and l would be timely changed as the step and trapezoidal functions as illustrated in Fig. 6. After simulation, Figs. 7, 8, 9, and 10 are shown to depict the responses of the state variables of the system against the time-varying parametric uncertainties. These diagrams display the obtained results in two cases; first, the control law (4) uses the approximating function (10) to obtain the optimal amounts for control gains \( K, \lambda \; {\text{and}}\; \phi \). Second, the control law 4 utilizes the optimal constants K = 109.9651, λ = 1.2849 and \( \phi \) = 100.0004 obtained by multiple-crossover optimization method for M = 1 kg, \( l \) = 0.5 m and m = 0.05 kg. The initial conditions are also fixed at \( z\left( 0 \right) = 0 \), \( \dot{z}\left( 0 \right) = 0 \),\( \varphi \left( 0 \right) = \frac{ - \pi }{3} \) and \( \dot{\varphi }\left( 0 \right) = 0 \) for all situations.

Fig. 6
figure 6

Step and trapezoidal changes of a M and b l with time

Fig. 7
figure 7

Response of state variables for both M and l change steply a cart position, b cart velocity, c pendulum angle and d pendulum angular velocity

Fig. 8
figure 8

Response of state variables for M changes steply and l changes trapezoidally (a) cart position, (b) cart velocity, (c) pendulum angle and (d) pendulum angular velocity

Fig. 9
figure 9

Response of state variables for M changes trapezoidally and l changes steply a cart position, b cart velocity, c pendulum angle and d pendulum angular velocity

Fig. 10
figure 10

Response of state variables for both M and l change trapezoidally a cart position, b cart velocity, c pendulum angle and d pendulum angular velocity

It is necessary to mention that the results are presented for the following cases of the uncertainties as:

  1. (a)

    Both \( M \) and \( l \) change steply over time (Fig. 7),

  2. (b)

    \( M \) changes steply but \( l \) changes trapezoidally over time (Fig. 8),

  3. (c)

    \( M \) changes trapezoidally but \( l \) changes steply over time (Fig. 9),

  4. (d)

    Both \( M \) and \( l \) change trapezoidally over time (Fig. 10).

As it is observable from these figures, the use of the adaptive optimal controller could substantially decrease the maximum overshoots and settling times of all responses. Besides, Table 3 illustrates the values of objective function (9) when M and l change over time for two cases, (1) the control law implements the optimum control gains produced by the approximating function, and (2) it utilizes the constant optimum control gains. The results show that the use of the suggested strategy significantly improves the objective function (9) for all cases.

Table 3 Improvement of objective function (9) when using the adaptive optimal control

Moreover, in order to challenge the performance of the proposed controller, an impulse disturbance having value D = −10 N at t = 10 s is implemented on the inverted pendulum system in the z direction. The time responses of the states of the system having the disturbance is depicted in Fig. 11. In these figures, the comparative simulations are conducted for the time-varying parametric uncertainties, M and l are timely changed as the step and trapezoidal functions. These results demonstrate the effectiveness and robustness of the approximate feedback linearization based optimal robust control strategy.

Fig. 11
figure 11

Response of state variables when the impulse disturbance is implemented on the system a cart position, b cart velocity, c pendulum angle and d pendulum angular velocity

7 Conclusions

The present paper considers the stabilization problem of a cart-type inverted pendulum system with time-varying uncertainties as a well-known benchmark in the control engineering. The work proposes an adaptive optimal controller in order to display a robust control against time-varying uncertainties at any moment of time. It means that the adaptive optimal controller tries to adapt itself to the current conditions of the system at any moment and present not only a robust control against the uncertainties but also an optimal control. The proposed algorithm is tested to control the state variables of the system including cart’s position and velocity as well as pendulum’s angular position and velocity when the system is exposed to various combination of cart’s mass and pendulum’s length variations. The simulations have demonstrated that the introduced strategy is able to handle the considered inverted pendulum system with the especial conditions and significantly modify the performance in comparison with a non-adaptive but optimal version of the controller.