I. INTRODUCTION
An inverted pendulum is a system whereby the centre of mass of the pendulum is located above the point of pivot of the pendulum [1]. It is often described as a typical fast speed system, with many variables, nonlinear and entirely unstable. The inverted pendulum system is one the most difficult systems while being at the same time a standard problem in the field of control systems due to it being really unstable [2]. A proper force balance must be maintained in order for the system to be kept stable, which eventually lead to the need of a proper control theory [3].
The required force balance is achieved, either by a specific torque applied at the point of pivot; horizontally moving the pivot point in the feedback system; changing the speed at which the mass mounted of the pendulum parallel to the axis of pivot rotates, producing a net torque on the pendulum or by oscillation of the pivotal point vertically. There are so far two kinds of inverted pendulum that have been studied extensively: the simple inverted pendulum and the double inverted pendulum. Other orders of the inverted are deemed really unstable and therefore more difficult to study. There is a wide range of applications of the inverted pendulum. It serves as an excellent model idea for the automatic landing system and stabilisation for aircrafts in turbulent air-flow, stabilization of the cabin in a ship and so on . The process of stabilizing an inverted pendulum is a non-linear one which is unstable with one input signal and several output signals.
II. LITERATURE REVIEW ON THE DOUBLE INVERTED PENDULUM
A double inverted pendulum is a combination of the inverted pendulum and the double pendulum. The double inverted pendulum is said to be a multivariate nonlinear system which has fast reaction as well as being an unstable one. This eventually results in the formation complex equations when finding a stabilized position. Stabilization of a double inverted pendulum system is not only a problem which is challenging but also a valuable way in showing the power of the control method.
Since the double inverted pendulum system has strong nonlinearity and inherent instability, sometimes the mathematical model of the object near upright position of the pendulum has to be made linear by the inconsistent structure control system . Control of a double inverted pendulum is a quite a challenge due to it being nonlinear. It is sometimes used as a tool to test linear and nonlinear laws . There are two main problems which are concentrated when working on pendulum control: the control design of the pendulum swing up and stabilising of the inverted pendulums.
Much research has been done on the control of the double inverted pendulum by using different techniques such as the fuzzy control systems, control strategies such as the PID controller, neural network and gravity compensator. Experiments using the fuzzy control theory, which contains fuzzy interference, have shown that is difficult to design a fuzzy controller for the double inverted pendulum. Fuzzy control theory was used by Qing-Rui Li et. al. [8] to stabilise the double inverted pendulum. The results show that the controller had great precision, with rapid convergence speed and greater precision. It was concluded that the control results can be extended for controlling multiple order of inverted pendulum and a proven way to control other unstable system has been obtained.
Alexander Bogdanov[9] studied and compared many algorithms for the ideal control of a double inverted pendulum on a cart (DIPC). He tested many different methods. The results of the simulations showed that the state-dependent Riccati equation (SDRE) had a better performance than other methods he used. Linearization technique to balance a double inverted pendulum on a cart was attempted by Mandar R.
Nalvadeet. al [10]. The Jacobian method was used to obtain the linearization form with the proper cost function and modelling was done with the help of Euler-Lagrangian equation. The simulation results were obtained by MATLAB which showed that the linearization technique is good for stabilisation around an equilibrium point.
In nature many living things follow the concept of the inverted pendulum such as humans and animals when standing on their feet. They need a proper force balance for stabilisation when carrying specific activities so that they don't fall. A bird is an animal of nature. As it is known the bird's leg consists of four parts[11]; femur, tibia and fibula, tarsus and finally the claw. It is said to be underactuated. The main focus of this paper are the the femur, tibia and fibula and the tarsus. They are among the important structures in a bird's leg which help it to carry out its activities. The aim of this paper is to model the leg of a bird as a double inverted pendulum and thentry to stabilise it using LQR control method.
III. STRUCTURE OF THE BIRD'S LEG AND THE RELATIONSHIP WITH THE INVERTED PENDULUM
a) Structure of the bird's leg
Fig. 1 below shows the skeletal structure of a bird, with the femur, tibia and fibula, tarsus and the claw.
They are all connected with each other by joints, with the femurin the end connected to the ilium, which is a part of the skeletal structure of the bird as shown.

When a bird stands on its legs, its knees are flexed at the same time putting the knee joints near the centre of gravity and the feet are positioned approximately under the centre of gravity and the tail acts as a counter-balance. All these actions lead to stabilize the balance of the body when the bird is standing. The tail also acts as a means of balancing when the bird walks/hops on the ground or perches. Birds like woodpeckers have stiffened tail feathers, which they use as a prop, helping them in perching and climbing on vertical tree trunks.
b) The
A close look at the leg of the bird, it can be seen that its shape resembles to that of an inverted pendulum, with the body of the bird on the top and the foot the ground. The bird changes the angle of the ankle and knee joints to balance it self with the help of ligaments behind the ankle and knee joints which help them to flex within the required angle when perching, standing or hopping, thus forming an imaginary system of an inverted pendulum. Inverted pendulums are among the basics for body balance such as the human leg and in this case, of a bird's leg. In Fig. 2 below, the relationship of the bird's leg to the inverted has been shown, with a schematic diagram to simplify representation of the bird body and its leg.

IV. MODELLING THE BIRD'S LEG AS A DOUBLE INVERTED PENDULUM
a) The
The bird's leg is geometrically a three order inverted pendulum, also known as the triple inverted pendulum. But a triple inverted pendulum is practically really unstable. In practice, some of the triple inverted pendulum parameters may not be known precisely, which has a big impact on the system dynamics [12]. By ignoring the femur which is usually inside the body of the bird, the inverted pendulum can be considered as double inverted one. Fig. 3 below shows the bird in schematic diagrams as it would be if considered as a double inverted pendulum from the triple inverted pendulum. The claw has been represented as the "Foot" of the bird in the diagrams due to its complex shape and the body of the bird is represented as "Body".

b) Modelling
As being a living thing, the bird legs follow certain the rules of which cannot be mimicked here. Fig. 4 below shows a schematic representation of the bird's leg as a double inverted pendulum where the mass M represents the body of the bird, the rods of length and and masses and respectively represent the tibia and fibula and tarsus and finally the base which is fixed, represents the foot of the bird. The rod sare attached to a pivot in the base which are allowed free rotation within certain degrees; and .

The double inverted is restricted to linear motion and with the base connected to a fixed place. The movement of the mass M, to and thro, causes the system to be unstable. If the mass is tilted to the right,
They can be derived using the Lagrange's equations:
the pendulum moves to the right and vice-versa. The equations of motion of inverted pendulums depend on the constraints that are placed on the movement of the pendulum.
Where L = T - U is the Lagrangian; T and U are the total kinetic energy and potential energy respectively. Q is a vector of the generalized forces or moments that is acting in the direction of the generalized coordinates and is not taken into consideration in forming the Total Kinetic Energy, equations of kinetic energy and potential energy and is usually considered as Q = 0 for a stabilized system.
Derivation of the total kinetic energy and potential energy:
where v is the speed at the time and l is the moment of inertia of the rods
Kinetic energy of rod :
Kinetic energy of rod :
Kinetic energy of Mass:
Total kinetic energy, T:
Total Potential Energy,
Potential energy of :
Potential energy of :
Potential energy of Mass:
Total Potential energy, U:
The Lagrange equation is given by:
And therefore the equations of motion are:
Substituting L in these equations and simplifying leads to the equations that illustrate the motion of the inverted pendulum:
Therefore the equations are:
The equations of motion of Lagrange can be rewritten to a compact matrix form [9]:
Assumption: The centers of mass of each pendulums and the mass, M, are at the geometrical center of each component. Therefore and . Then for the element of become:
V. CONTROL DESIGN
a) Linearization
It can be seen clearly by the system's equation that the model belongs to a nonlinear system. Normal differential equations can be created by the conversion of the system into state space model format. When a control law is designed, Lagrange equations of motion (9) are reformatted. To be able to carry this out, a state vector is introduced which is as follows.
To be able to apply the LQR technique on the system, linearization is important. Therefore the nonlinear model of the system turns into:
After putting the variables of the system matrices in the above generalisation and their derivatives, the system equation is as follows:
Where I and 0 are identity and zero matrices respectively.
The system equation can be rewritten as:
Where
b) Linear Quadratic Regulator Controller
The Jacobian matrix is used to do an approximated linearization of the above system equation to reduce the nonlinear system equation to a standard linear system one in the form:
The cost function is given by:
Where Q is a positive semi-definite matrix and R is a positive definite matrix as well as constant. The control value u is called the optimal control which is:
Where is the solution of the standard Riccati equation and K is the linear optimal feedback matrix. The Riccati equation is as follows:
VI. EXPERIMENT ANDRESULTS
(24)
| Symbol | Parameter | Value | Unit |
| M | Mass of bird's body | 0.912 | kg |
| Mass of tarsus | kg | ||
| Mass of tibia and fibula | kg | ||
| Length of tarsus | 0.07378 | m | |
| Length of tibia and fibula | 0.09942 | m | |
| Moment inertia of | kgm2 | ||
| Moment inertia of | kgm2 | ||
| G | Acceleration of gravity | 9.81 |
Table 1 shows the data of a leg of a bird [13] and and are the angles of and respectively. is negative because it is moving in the opposite direction to which is to the left.
Using equation (20) and (21), the matrices of A and B can be obtained:
a) Simulation of the double inverted pendulum
When LQR method is used, the selection of weighting matrices Q and Rare important have an effect on the optimal control whereby if they are not selected properly the actual system performance requirements will not be met. They are called the priority matrices. Q and R are usually obtained through simulation of trial. According to [14] where Q changes most of the times compared to R which is fixed at most times.
Using Matlab the values are input into the formula for LQR where , where A, B, Q and R are matrices from calculations.
VII. RESULTS
Using Matlab command, the calculations results; K = [-1.0000 -60.1690 -1.2099 -6.2206]. The following step response graph was obtained for
Step Response: LQR

It can be seen from the results in Fig. 5, the pendulum at first is really unstable from 0s as it started to move, causing the overshoot. Then it started to find the stability as it can be described by the graph as it starts to flatten. It can also be seen that the settling time and rise time are large.
To minimize the rise time and the settling time, many other simulations can be done using different values of Q and R.

The graph above shows another simulation with different values of Q and R. It can be seen that the rising time and settling time are lower than that of the first simulation with .
VIII. CONCLUSION
The above results show that a double inverted pendulum can be stabilised using the LQR method. Different values of the priority matrices Q and R, gives different results, with smaller rising and settling time. Therefore it can be deduced that the stability of the double inverted pendulum is directly related to the priority matrices, Q and R.
There are other better ways which can be used to determine the stability of the double inverted pendulum more accurately than the LQR, such as the Neural Network and state-dependent Riccati equation (SDRE). They can be used independently or in combination with the LQR method to have precise data. The aim of this paper was to design an LQR based controller to show how the leg of a bird can stabilised if considered as a double inverted, which was met with success.
IX. DISCUSSION
As state before, a bird is a living thing; therefore in real it may not really follow the modelling. A bird has two legs, with 2 tibias and fibula and 2 tarsi. In order to maintain a stable body, both legs works together to achieve the required stability. In real when a bird perches, the tarsus moves with more visible change via the angle whereas the angle , of the tibia and fibula, has very little change almost negligible where it can be said that the tibia and fibula is static. The changes in the angles allow the body to maintain stability while perching, standing or hopping.
While the angle of the tarsus and the fibula and tibia plays an important role to maintain stability in a bird, there are other factors that come into play. The size of bird's body is one such factor. In this modelling, the body of the bird was considered as a static mass M above the pendulum. But in real, the body of the bird moves, within certain angles and directions such that if the pendulum goes to the left, it goes to the right and vice-versa to help maintain balance, while shifting its centre of mass at the same time.
The equations for the modelling have been described and formulated as that of a double inverted pendulum where the femur was excluded. If the femur is taken into consideration, this leads the system of the leg to be a triple inverted pendulum, which is even more unstable than the double inverted pendulum. For the bird's leg, considering a triple inverted pendulum can be quite complicated due to the high instability of the triple inverted pendulum. The high instability means more complicated and longer equations are needed to be resolved in order to find a better control. This is mostly done through a computerised system.
With promising results on the double inverted pendulum, the control of stability theorem can be useful in the balancing of UAVs where the UAV is fitted with landing devices resembling the bird's leg. They UAV will represent the bird's body while the landing devices will represent the legs of the bird. The control will help the UAV to maintain its stability, for e.g., when it is perching on a cable wire or a branch or while it is on a flat surface after landing. This can be useful for the UAV in situations where it flies to places where people cannot go and lands for collection of data.
In addition to perching, the UAV can use the photovoltaic effect to recharge its batteries. In order to perch-and stare, the UAV will be able to land on numerous types of different surfaces. Birds' feet show a specific and interesting behaviour which makes them adaptable to most surfaces. The future aim is to design a landing device that can help the UAV to perform the perch-and-stare manoeuvre and at the same time be able to take-off and land normally, just a bird would do.
X. ACKNOWLEDGEMENT
We present our sincere gratitude to those friends for providing us their support and advices while writing this paper.
Conflict of Interest
I, Ramdhun Vyas, together with my supervisor Jianbin Xue, hereby states that this manuscript has not been published elsewhere, everything written in this manuscript is our own research work and we have no conflicts of interest to disclose. I hope this manuscript is appropriate for journal and meets the proper standards.