1 Introduction

The inverted pendulum (IP) is an inherently unstable system with highly nonlinear dynamics. This is a system which belongs to the class of under-actuated mechanical systems having fewer control inputs than the degree of freedom. This renders the control task more challenging, making the inverted pendulum system a classical benchmark for the design, testing, evaluating and comparing of different classical and contemporary control techniques. Being an inherently unstable system, the inverted pendulum is among the most difficult systems, and is one of the most important classical problems. The control of inverted pendulum has been a research interest in the field of control engineering. Due to its importance, this is a choice of dynamic system to analyze its dynamic model and propose a control law. The aim of this case study is to stabilize the inverted pendulum such that the position of the cart on the track is controlled quickly and accurately so that the pendulum is always erected in its inverted position during such movements. Realistically, this simple mechanical system is representative of a class of attitude control problems whose goal is to maintain the desired vertically oriented position at all times[14].

In general, the control problem consists of obtaining dynamic models of systems, and using these models to determine control laws or strategies to achieve the desired system response and performance. The simplicity of control algorithm as well as guaranteeing the stability and robustness in the closed-loop system is a challenging task in real situations. Most of the dynamical systems such as power systems, missile systems, robotic systems, inverted pendulum, industrial processes, chaotic circuits, etc., are highly nonlinear in nature. The control of such systems is a challenging task.

The proportional-integral-derivative (PID) control gives the simplest and yet the most efficient solution to various real-world control problems. Both the transient and steady state responses are taken care of with its three-term (i.e., P, I, and D) functionality. Since its invention, the popularity of PID control has grown tremendously. The advances in digital technology have made the control system automatic. Even though, the automatic control system offers a wide spectrum of choices for control schemes, more than 90% of industrial controllers are still implemented based on the PID algorithms, particularly at the lowest level, as no other controllers can match the simplicity, clear functionality, applicability, and ease of use offered by the PID controllers.

The performance of the dynamical systems being controlled is desired to be optimal. There are many optimization and optimal control techniques which are present in the literature for linear and nonlinear dynamical systems[57]. The recent development in the area of artificial intelligence (AI), such as artificial neural network (ANN), fuzzy logic theory (FL), and evolutionary computational techniques such as genetic algorithm (GA), and particle swarm optimization (PSO), etc., commonly all these are known as intelligent computational techniques which have given novel solutions to various control system problems[820]. The intelligent optimal control has emerged as a viable approach by the application of these intelligent computational techniques[10].

There are many papers presented which have taken the inverted pendulum-cart dynamical system for implementing the various control schemes[1823]. A Lyapunov function based control of inverted pendulum cart system is presented in [23]. Quad-rotor, another example of under actuated strongly coupled nonlinear system is presented in [24] in which the adaptive backstepping sliding mode approach is used for the trajectory tracking control. The optimal control design method of linear quadratic Gaussian (LQG), which is a combination of a linear quadratic estimator (LQE) (i.e., Kalman filter) and a linear quadratic regulator (LQR), has been used for optimal control of pneumatic Stewart-Gough platform in [25]. In recent trends even the various advance control approaches[820, 24] are developing and being tried for many dynamical systems control, the simplicity of control algorithms along with the fulfillment of control objectives is further desired. The neural network based control design requires a large data set collected from experiments for networks training and testing; the fuzzy control requires framing of rules, which becomes complex for higher order systems; and the evolutionary computational techniques are slow in computation. These drawbacks put limits to their implementations even they provide automation and intelligent features to the controlled systems. Also the algorithms of several adaptive, sliding mode and robust control approaches are comparatively complex even they have certain merits. The objective and contribution of this paper is to present a simple approach to control nonlinear dynamical systems. The simple control algorithms of LQR and PID control which are generally used for control of the linear dynamical systems are used in this paper to control the nonlinear inverted pendulum-cart dynamical system as presented by us partly in [3, 4]. In this paper, the performance analysis for both cases of this system without and with disturbance input have been presented comprehensively. The comprehensive performance investigation shows that the proposed control method is simple, effective, and robust.

This paper is organized in 5 sections. Section 1 presents the relevance and the general introduction of the paper. Section 2 describes the mathematical model of the inverted pendulum-cart system without and with disturbance input. In Section 3, the control methods of PID control and optimal control using LQR are discussed briefly. Section 4 presents Matlab-Simulink modeling, and simulation results for both cases of without and with disturbance input. Section 5 presents conclusions. At the end, a brief list of references is given.

2 Mathematical modeling

2.1 Inverted pendulum system equations

The free body diagram of an inverted pendulum mounted on a motor driven cart is shown in Fig. 1[14]. The system equations of this nonlinear dynamic system can be derived as follows. It is assumed here that the pendulum rod is mass-less, and the hinge is frictionless. In such assumption, the whole pendulum mass is concentrated in the centre of gravity (COG) located at the center of the pendulum ball. The cart mass and the ball point mass at the upper end of the inverted pendulum are denoted as M and m, respectively. There is an externally x-directed force on the cart, u(t), and a gravity force acts on the point mass at all times. The coordinate system considered is shown in Fig. 1, where x(t) represents the cart position, and θ(t) is the tilt angle referenced to the vertically upward direction.

Fig. 1
figure 1

Motor driven inverted pendulum-cart system

A force balance on the system in the x-direction can be written as

$$M{{{{\rm{d}}^2}x} \over {{\rm{d}}{t^2}}} + m{{{{\rm{d}}^2}{x_G}} \over {{\rm{d}}{t^2}}} = u$$
(1)

where the time-dependent centre of gravity (COG) of the point mass is given by coordinates (X G , Y G ). For the point mass assumed here, the location of the center of gravity of the pendulum mass is

$${x_G} = x + l\sin \theta, \,\,\, {y_G} = l\cos \theta $$
(2)

where l is the pendulum rod length. Substituting (2) into (1), we have

$$(M + m)\ddot x - ml\sin \theta {\dot \theta ^2} + ml\cos \theta \ddot \theta = u.$$
(3)

In a similar way, a torque balance on the system is performed. Fig. 2 shows the force components acting on the system. The resultant torque balance can be written as

$$({F_x}\cos \theta)l - ({F_y}\sin \theta)l = (mg\sin \theta)l$$
(4)

where \({F_x} = m{{{{\rm{d}}^2}} \over {{\rm{d}}{t^2}}}{x_G}\), and \({F_y} = m{{{{\rm{d}}^2}} \over {{\rm{d}}{t^2}}}{y_G}\) are the force components in the x and y directions, respectively.

Fig. 2
figure 2

Vector diagram for force components in torque balance

After manipulation, (4) is written as

$$m\ddot x\cos \theta + ml\ddot \theta = mg\sin \theta.$$
(5)

Equations (3) and (5) are the equations defining this system. These two equations are manipulated algebraically to have only a single second derivative term in each equation. Finally, we may derive the system equations describing the cart position dynamics and the pendulum angle dynamics, respectively. Thus we have

$$\ddot x = {{u + ml(\sin \theta){{\dot \theta }^2} - mg\cos \theta \sin \theta } \over {M + m - m{{\cos }^2}\theta }}$$
(6)
$$\ddot \theta = {{u\cos \theta - (M + m)g\sin \theta + ml(\cos \theta \sin \theta){{\dot \theta }^2}} \over {ml{{\cos }^2}\theta - (M + m)l}}.$$
(7)

Equations (6) and (7) represent a nonlinear system which is relatively complicated from a mathematical point of view. The following subsection presents the standard state space form of these two nonlinear equations.

2.2 Nonlinear system state space equations of inverted pendulum

For numerical simulation of the nonlinear model for the inverted pendulum-cart dynamic system, it is required to represent the nonlinear equations (6) and (7) into the standard state space form:

$${{{\rm{d}}x} \over {{\rm{d}}t}} = f(x,u,t).$$
(8)

Consider the state variables:

$${x_1} = \theta, \,\, {x_2} = \dot \theta = {\dot x_1},\,\,{x_3} = x,\,\,{x_4} = \dot x = {\dot x_3}.$$
(9)

The final state space equation for the inverted pendulum system may be written as

$${{{\rm{d}}x} \over {{\rm{d}}t}} = {{\rm{d}} \over {{\rm{d}}t}}\left[ {\matrix{{{x_1}} \cr {{x_2}} \cr {{x_3}} \cr {{x_4}} \cr } } \right] = {{\rm{d}} \over {{\rm{d}}t}}\left[ {\matrix{\theta \cr {\dot \theta } \cr x \cr {\dot x} \cr } } \right] = \left[ {\matrix{{{f_1}} \cr {{f_2}} \cr {{f_3}} \cr {{f_4}} \cr } } \right]$$
(10)

where

$${f_1} = {x_2}$$
(11)
$${f_2} = {{u\cos {x_1} - (M + m)g\sin {x_1} + ml(\cos {x_1}\sin {x_1})x_2^2} \over {ml{{\cos }^2}{x_1} - (M + m)l}}$$
(12)
$${f_3} = {x_4}$$
(13)
$${f_4} = {{u + ml(\sin {x_1})x_2^2 - mg\cos {x_1}\sin {x_1}} \over {M + m - m{{\cos }^2}{x_1}}}.$$
(14)

If both the pendulum angle θ and the cart position x are the variables of interest, then the output equation may be written as

$$y = Cx{\rm{or}}y = \left[ {\matrix{\theta \cr x \cr } } \right] = Cx = \left[ {\matrix{1 & 0 & 0 & 0 \cr 0 & 0 & 1 & 0 \cr } } \right]\left[ {\matrix{\theta \cr {\dot \theta } \cr x \cr {\dot x} \cr } } \right].$$
(15)

Equations (10) and (15) give a complete state space representation of the nonlinear inverted pendulum-cart dynamic system.

2.3 Linear system state space equations of inverted pendulum

Since the goal of this particular system is to keep the inverted pendulum in the upright position around θ = 0, the linearization might be considered about this upright equilibrium point. The linear model for the system around the upright stationary point is derived by simply linearization of the nonlinear system given in (10). Since the usual A and B matrices are zero for this case, and so every term is put into the nonlinear vector function f (x, u, t), the linearized form for the system becomes

$${{{\rm{d}}\delta x} \over {{\rm{d}}t}} = {J_x}({x_0},{u_0})\delta x + {J_u}({x_0},{u_0})\delta u$$
(16)

where the reference state is defined by the pendulum in stationary and upright position with no input force. Under these conditions, x 0 = 0, and u 0 = 0.

Since the nonlinear vector function is rather complicated, the components of the Jacobian matrices are determined systemically term by term. The elements of the first, second, third, and fourth columns of J x (x 0, u 0) are given by \({\left. {{{\partial {f_i}} \over {\partial {x_1}}}} \right|_{{x_0},{u_0}}},\,{\left. {{{\partial {f_i}} \over {\partial {x_2}}}} \right|_{{x_0},{u_0}}},\,{\left. {{{\partial {f_i}} \over {\partial {x_3}}}} \right|_{{x_0},{u_0}}}\) and \({\left. {{{\partial {f_i}} \over {\partial {x_4}}}} \right|_{{x_0},{u_0}}}\) respectively. Thus, combining all these separate terms gives

$${J_x}({x_0},{u_0}) = \left[ {\matrix{0 \hfill & 1 \hfill & 0 \hfill & 0 \hfill \cr {{{(M + m)g} \over {Ml}}} \hfill & 0 \hfill & 0 \hfill & 0 \hfill \cr 0 \hfill & 0 \hfill & 0 \hfill & 1 \hfill \cr { - {{{m_g}} \over M}} \hfill & 0 \hfill & 0 \hfill & 0 \hfill \cr } } \right].$$
(17)

For the derivative of the nonlinear terms with respect to u, we have

(18)

Finally, after all these manipulations, (16) may be written explicitly as

$${{{\rm{d}}\delta x} \over {{\rm{d}}t}} = \left[ {\matrix{0 & 1 & 0 & 0 \cr {{{(M + m)g} \over {Ml}}} & 0 & 0 & 0 \cr 0 & 0 & 0 & 1 \cr { - {{mg} \over M}} & 0 & 0 & 0 \cr } } \right]\delta x + \left[ {\matrix{0 \cr { - {1 \over {Ml}}} \cr 0 \cr {{1 \over M}} \cr } } \right]\delta u.$$
(19)

This is the open loop linearized model for the inverted pendulum with a cart force δu(t), written in the perturbation form. Thus, the linear time-invariant (LTI) system is in the standard state space form. Equation (19) may be written in general as

$${{{\rm{d}}\delta x} \over {{\rm{d}}t}} = A\delta x + B\delta u.$$
(20)

Equation (20) along with the output equation (15) represents the final linear model of the inverted pendulum-cart system. This is the simplified model which is used to study the system behavior in general and to design LQR.

2.4 Inverted pendulum system equations with disturbance input

The system equations of this nonlinear dynamic system with disturbance input can be derived as follows. Consider a disturbance input due to wind effects acting on the inverted pendulum in addition to the force on the cart, u(t). Let F w represent the horizontal wind force on the pendulum point mass. With this additional force component, the force balance equation (1) becomes

$$M{{{{\rm{d}}^2}x} \over {{\rm{d}}{t^2}}} + m{{{{\rm{d}}^2}{x_G}} \over {{\rm{d}}{t^2}}} = u + {F_w}$$
(21)

which can be manipulated to give

$$(M + m)\ddot x - ml\sin \theta {\dot \theta ^2} + ml\cos \theta \ddot \theta = u + {F_w}.$$
(22)

Similarly, the torque in the clockwise direction caused by the horizontal wind disturbance is (F w cos θ)l. Adding the torque contribution of this term the torque balance equation (4) becomes

$$({F_x}\cos \theta)l - ({F_y}\sin \theta)l = (mg\sin \theta)l + ({F_w}\cos \theta)l$$
(23)

which can be modified to give

$$m\ddot x\cos \theta + ml\ddot \theta = mg\sin \theta + {F_w}\cos \theta.$$
(24)

Equations (22) and (24) are the defining equations for this system with a disturbance input.

The state space equation for the inverted pendulum system with disturbance input is derived as the same as (10) with following modifications:

$${f_2} = $$
(25)
$${{\matrix{{u\cos {x_1} - (M + m)g\sin {x_1} + ml(\cos {x_1}\sin {x_1})x_2^2 - } \cr {{M \over m}{F_w}\cos {x_1}} \cr } } \over {ml{{\cos }^2}{x_1} - (M + m)l}}$$
(26)
$${f_4} = {{u + ml(\sin {x_1})x_2^2 - mg\cos {x_1}\sin {x_1} + {F_w}{{\sin }^2}{x_1}} \over {M + m - m{{\cos }^2}{x_1}}}.$$
(27)

The output equation of the nonlinear inverted pendulum system with disturbance input remains the same as (15).

The linearized model can also be developed as

(28)

This is the open loop linearized model for the inverted pendulum with a cart force δu(t), and a horizontal wind disturbance δF w (t). The two inputs have been separated for convenience, thus the LTI system can be written as

$${{{\rm{d}}\delta x} \over {{\rm{d}}t}} = A\delta x + {b_1}\delta u + {b_2}\delta {F_w}.$$
(29)

3 Control methods

The following control methods are presented here to control the nonlinear inverted pendulum-cart dynamic system[3, 4].

3.1 PID control

To stabilize the inverted pendulum in the upright position and to control the cart at the desired position using the PID control approach, two PID controllers: Angle PID controller and cart PID controller have been designed for the two control loops of the system. The equations of the PID control are given as

$${u_p} = {K_{pp}}{e_\theta }(t) + {K_{ip}}\int {{e_\theta }} (t){\rm{d}}t + {K_{dp}}{{{\rm{d}}{e_\theta }(t)} \over {{\rm{d}}t}}$$
(30)
$${u_c} = {K_{pc}}{e_x}(t) + {K_{ic}}\int {{e_x}(t){\rm{d}}t + {K_{dc}}} {{{\rm{d}}{e_x}(t)} \over {{\rm{d}}t}}$$
(31)

where e θ (t) and e x (t) are angle error and cart position error, respectively. Since the pendulum angle dynamics and cart position dynamics are coupled to each other, the change in any controller parameters affects both the pendulum angle and cart position, which makes the tuning tedious. The tuning of controller parameters is done by using trial and error methods and observing the responses of Simulink model to be optimal.

3.2 Optimal control using LQR

Optimal control refers to a class of methods that can be used to synthesize a control policy which results in the best possible behavior with respect to the prescribed criterion (i.e., control policy which leads to maximization of performance). The main objective of optimal control is to determine control signals that will cause a process (plant) to satisfy some physical constraints and at the same time extremize (maximize or minimize) a chosen performance criterion (performance index (PI) or cost function). The optimal control problem is to find a control which causes the dynamical system to reach a target or follow a state variable (or trajectory) and at the same time extremize a PI which may take several forms[17].

Linear quadratic regulator (LQR) is one of the optimal control techniques, which takes into account the states of the dynamical system and control input to make the optimal control decisions. This is simple as well as robust[17].

After linearization of nonlinear system equations about the upright (unstable) equilibrium position having initial conditions as x 0 = [0, 0, 0, 0]T, the linear state-space equation is obtained as

$$\dot x = Ax + Bu$$
(32)

where \(x = {\left[ {\theta, \dot \theta, x,\dot x} \right]^{\rm{T}}}\)

The state feedback control u = −Kx leads to

$$\dot x = (A - BK)x$$
(33)

where K is derived from minimization of the cost function

$$J = \int {\left({{x^{\rm{T}}}Qx + {u^{\rm{T}}}Ru} \right)} {\rm{d}}t$$
(34)

where Q and R are positive semi-definite and positive definite symmetric constant matrices, respectively.

The LQR gain vector K is given by

$$K = {R^{ - 1}}{B^{\rm{T}}}P$$
(35)

where P is a positive definite symmetric constant matrix obtained from the solution of matrix algebraic Riccati equation (ARE)

$${A^{\rm{T}}}P + PA - PB{R^{ - 1}}{B^{\rm{T}}}P + Q = 0.$$
(36)

In the optimal control of nonlinear inverted pendulum dynamical system using PID controller and LQR approach, all the instantaneous states of the nonlinear system, pendulum angle θ, angular velocity \({\dot \theta }\), cart position x, and cart velocity \({\dot x}\) are considered available for measurement, which are directly fed to the LQR. The LQR is designed using the linear state-space model of the system. The optimal control value of LQR is added negatively to the PID control value to have a resultant optimal control. The tuning of the PID controllers which are used here either as PID control method or PID+LQR control methods is done by using trial and error method and observing the responses achieved to be optimal.

4 Simulation and results

The Matlab-Simulink models for the simulation of modeling, analysis, and control of nonlinear inverted pendulum cart dynamical system without and with disturbance input are developed. The typical parameters of inverted pendulum-cart system setup are selected as [3, 4, 18, 22]: mass of the cart (M): 2.4 kg; mass of the pendulum (m): 0.23 kg; length of the pendulum (l): 0.36 m; length of the cart track (L): ± 0.5 m; the friction coefficient of the cart and pole rotation is assumed negligible. The disturbance input parameters taken in the simulation are[3]: band limited white noise power = 0.001, sampling time = 0.01, seed = 23341.

After linearization, the system matrices used to design LQR are computed as

With the choice of

$$Q = \left[ {\matrix{1 \hfill & 0 \hfill & 0 \hfill & 0 \hfill \cr 0 \hfill & 1 \hfill & 0 \hfill & 0 \hfill \cr 0 \hfill & 0 \hfill & {500} \hfill & 0 \hfill \cr 0 \hfill & 0 \hfill & 0 \hfill & {250} \hfill \cr } } \right]\,{\rm{and}}\,R = 1$$

the LQR gain vector is obtained as

$$K = \left[ {\matrix{{ - 137.7896} \hfill & { - 25.9783} \hfill & { - 22.3607} \hfill & { - 27.5768} \hfill \cr } } \right].$$

Here, three control schemes have been implemented for the optimal control of nonlinear inverted pendulum-cart dynamical system:

  1. 1)

    PID control method having two PIDs, i.e., angle PID and cart PID;

  2. 2)

    Two PIDs (i.e., angle PID and cart PID) with LQR control method;

  3. 3)

    One PID (i.e., cart PID) with LQR control method.

The tuned PID controller parameters of these control schemes for cases of without and with disturbance input are given as in Tables 1 and 2, respectively.

Table 1 PID controller parameters of control schemes for without disturbance input case
Table 2 PID controller parameters of control schemes for with disturbance input case

The Simulink models for control of nonlinear inverted pendulum system using PID control method for both cases of without and with disturbance input are shown in Figs. 3 and 5, respectively. The band limited white noise is added as the disturbance input to the system. Here only pendulum angle θ and cart position x are considered for the measurement. The reference angle is set to 0 rad, and reference cart position is set to 0.1 m. The simulation results for both cases are shown in Figs. 4 and 6, respectively. It is observed that the pendulum stabilizes in the vertically upright position after two small overshoots for the case of without disturbance input, and it also stabilizes upright with minor oscillations for the case of with continuous disturbance input. The cart position x reaches the desired position of 0.1 m quickly and smoothly for the case of without disturbance input, and quickly with minor oscillations for the case of with continuous disturbance input. The control input u is bounded for both cases in ranges [−0.1 0.1] and [−1 1], respectively. Thus simulation results justify the effectiveness and robustness of the PID control.

Fig. 3
figure 3

PID control of nonlinear inverted pendulum system

Fig. 4
figure 4

Responses of pendulum angle θ, cart position x, and control force u of nonlinear inverted pendulum system with PID control

Fig. 5
figure 5

PID control of nonlinear inverted pendulum system with disturbance input

Fig. 6
figure 6

Responses of pendulum angle θ, cart position x, and control force u of nonlinear inverted pendulum system with PID control with disturbance input

The Simulink models for the optimal control of the nonlinear inverted pendulum-cart system using two PID controllers (angle PID and cart PID) with LQR control method for both cases of without and with disturbance input are shown in Figs. 7 and 9, respectively. In this approach, all the states of the system θ, \({\dot \theta }\), x and \({\dot x}\) are fed to LQR, which is designed using the linear state-space model of the system. Here also the angle θ and cart position x are taken as variables of interest for control, and the band limited white x noise is added as the disturbance input to the system. The reference angle is set to 0 rad, and the reference cart position is set to 0.1 m. The simulation results for both cases are shown in Figs. 8 and 10, respectively. The responses of angle θ, angular velocity \({\dot \theta }\), cart position x, cart velocity \({\dot x}\), and control u are plotted. It is observed that the pendulum stabilizes in the vertically upright position quickly and smoothly after two minor undershoots and a minor overshoot for the case of without disturbance input, and it also stabilizes in the vertically upright position with minute oscillations for the case of with continuous disturbance input. The angular velocity approaches 0 rad/s quickly for the case of without disturbance input, and it oscillates by approximately +/−0.01 rad/s remaining at most in the range approximately +/−0.02 rad/s for the case of with continuous disturbance input. The cart position x reaches smoothly the desired position of 0.1 m quickly in approximately 6 s, and the cart velocity reaches zero for both cases. The control input u is bounded for both cases in ranges [−0.1 0.1] and [−1 1], respectively. The simulation results justify the effectiveness and robustness of the 2PID+LQR control.

Fig. 7
figure 7

Cart PID, Angle PID and LQR control of nonlinear inverted pendulum system

Fig. 8
figure 8

Responses of pendulum angle θ(solid line), angular velocity \({\dot \theta }\) (dashed line), cart position x (solid line), cart velocity \({\dot x}\) (dashed line), and control force u of nonlinear inverted pendulum system with cart PID, angle PID and LQR control

Fig. 9
figure 9

Cart PID, Angle PID and LQR control of nonlinear inverted pendulum system with disturbance input

Fig. 10
figure 10

Responses of pendulum angle θ (solid line), angular velocity \({\dot \theta }\) (dashed line), cart position x (solid line), cart velocity \({\dot x}\) (dashed line), and control force u of nonlinear inverted pendulum system with disturbance input using cart PID, angle PID and LQR control

The Simulink models for the optimal control of the nonlinear inverted pendulum-cart system using one PID controller (cart PID) with LQR control method for both cases of without and with disturbance input are shown in Figs. 11 and 13, respectively. This control method is similar to 2PID+LQR control method in all respects of control techniques but differs only in the number of PID controllers used. Here only cart PID controller is used, and angle PID controller is not used. Here only cart position x is taken as variable of interest for control. The reference cart position is set to 0.1 m. The desired angle to be zero is directly taken care of by state feedback control of LQR which is designed using the linear state-space model of the system with vertically upright position as the reference. The band limited white noise is added as the disturbance input to the system. The simulation results for both cases are shown in Figs. 12 and 14, respectively. The responses of angle θ, angular velocity \({\dot \theta }\), cart position x, cart velocity \({\dot x}\), and control u are plotted. It is observed that the pendulum stabilizes in the vertically upright position quickly and smoothly after two minor undershoots and a minor overshoot for the case of without disturbance input, and it also stabilizes in the vertically upright position with minute oscillations for the case of with continuous disturbance input. The angular velocity approaches 0 rad/s quickly for the case of without disturbance input, and it oscillates by approximately +/−0.01 rad/s remaining at most in the range approximately +/−0.02 rad/s for the case of with continuous disturbance input. The cart position x reaches the desired position of 0.1 m quickly and smoothly in approximately 6 s for both cases. The cart velocity reaches zero for the case of without disturbance input, and it oscillates very near to zero for the case of with continuous disturbance input. The control input u is bounded for both cases in ranges [−0.1 0.1] and [−1 1], respectively. The simulation results justify the effectiveness and robustness of the cart PID+LQR control.

Fig. 11
figure 11

Cart PID and LQR control of nonlinear inverted pendulum system

Fig. 12
figure 12

Responses of pendulum angle θ (solid line), angular velocity \({\dot \theta }\) (dashed line), cart position x (solid line), cart velocity \({\dot x}\) (dashed line), and control force u of nonlinear inverted pendulum system using cart PID and LQR control

Fig. 13
figure 13

Cart PID and LQR control of nonlinear inverted pendulum system with disturbance input

Fig. 14
figure 14

Responses of pendulum angle θ (solid line), angular velocity \({\dot \theta }\) (dashed line), cart position x (solid line), cart velocity \({\dot x}\) (dashed line), and control force u of nonlinear inverted pendulum system with disturbance input using cart PID and LQR control

The maximum absolute values of system states and control showing maximum absolute variations with respect to desired nominal values in simulation for both cases of without and with disturbance input are shown in Tables 3 and 4, respectively.

Table 3 Maximum absolute values of system states and control for without disturbance input case
Table 4 Maximum absolute values of system states and control for with disturbance input case

By comparing the results, it is observed that the responses of both alternatives of the PID+LQR control method are better than the PID control, which are also smooth and fast. It is also observed that the responses of 2PID+LQR control and cart PID+LQR control are similar. Just the cart position response of 2PID+LQR control is smoother than cart PID+LQR control and so it is slightly better, which is due to the additional degree of freedom of control added by the angle PID controller. But the cart PID+LQR control has structural simplicity in its credit. The analysis of the performances of the control schemes of PID control, 2PID+LQR control, and cart PID+LQR control for the nonlinear inverted pendulum-cart dynamical system without and with disturbance input gives that these control schemes are effective and robust. The advantage of this simulation study is that, it demonstrates that, the proposed PID+LQR control approach is a simple, effective and robust technique for the optimal control of nonlinear dynamical systems.

5 Conclusions

PID control and LQR, an optimal control technique to make the optimal control decisions have been implemented to control the nonlinear inverted pendulum-cart system without and with continuous disturbance input. To compare the results of proposed PID+LQR control method, the PID control method has been implemented. In the optimal control of nonlinear inverted pendulum dynamical system using PID controller and LQR approach, all the instantaneous states of the nonlinear system are considered available for measurement, which are directly fed to the LQR. The LQR is designed using the linear state-space model of the system. The optimal control value of LQR is added negatively to the PID control value to have a resultant optimal control. The Matlab-Simulink models have been developed for simulation and performance analysis of the control schemes. The tuning of the PID controllers which are used her either as PID control method or PID+LQR control methods is done by using trial and error method and observing the responses achieved to be optimal. The simulation results justify the comparative advantage of the optimal control using LQR method. The pendulum stabilizes in the upright position and the cart reaches the desired position quickly and smoothly even under the continuous disturbance input such as wind force justify that the control schemes are effective and robust. The analysis of the responses of control schemes gives that the performance of proposed PID+LQR control method is better than PID control. This comparative performance investigation for this benchmark system shows that the proposed PID+LQR control approach is a simple, effective and robust control scheme for the optimal control of nonlinear dynamical systems. The performance investigation of this control approach with tuning of PID controller parameters using GA and PSO instead of trial and error method may be done as a future work.