Model of Inverted Pendelum
Model of Inverted Pendelum
Model of Inverted Pendelum
Modelling
The two wheeled self balancing vehicle is modelled as an inverted pendulum with a moving bottom.
1.1
Nonlinear model
In the nonlinear model air drag and rolling resistance are taken in account. And another external force
is also applied which should simulate a person standing and pushing forward on the vehicle. A Figure
of the model which is used, see Figure 1.
Figure 1: Model of the Segway with air resistance FD , rolling resistance Fr and the force (a moment)
applied by a person on the rod FB .
List of all variables
g := Gravity
m1 := Mass of wheels
m2 := Mass of pendulum
Iw := Moment of inertia of the wheels
Ip := Moment of inertia of the pendulum
r := Radius of wheels
l := Distance to center of gravity for the pendulum
kD := Constant for air resistance
b := Constant for rolling resistance
F := Force applied by the vehicle
FD := Air resistance
Fr := Rolling resistance
FB := Body force
N := Normal force
Fr = sign(x)
FD
where sign is a function which gives the sign of a number, in this case the velocity. This is used
because the air-and rolling resistance are applied in the opposite direction in which the vehicle is moving.
The Lagrangain L = T V of the system is given by
L=
1
1
1
1
2
Ip p2 + Iw w
+ m1 v1 + m2 v2 m2 gl cos()
2
2
2
2
where
p =
x
w =
r
v12 = x 2
2
2
1
1
x
+ (m1 + m2 )x 2 + m2 lx cos() + m2 2 l2 m2 gl cos().
r
2
2
= F FD Fr
dt x
x
d L L
= FB l FD l cos()
dt
which lead to the final equations of motions for the nonlinear model
x
+ (m1 + m2 )
x + m2 l cos() m2 l2 sin() = F FD Fr
r2
Ip + m2 l
x cos() + m2 l2 m2 glsin() = FB l FD l cos().
Iw
1.2
(1)
(2)
Linear model
The main goal of using a linear model instead of the nonlinear is to find the state space of the system
therefore is now the air drag and rolling resistance replaced by an new friction force Ff which is proportional to the velocity and therefore is always acting in the right direction. This is because before the
function sign was used to determine the direction of both air drag and rolling resistance but since there
is now easy way of determine the Laplace of the function sign this change was done. The before applied
body force is now removed but is later going to be added as an disturbance. To clarify the new model
an the acting forces, see Figure 2.
1 2 1
Ip + Iw
2
2
2
1
1
x
+ (m1 + m2 )x 2 + m2 lx cos() + m2 2 l2 m2 gl cos().
r
2
2
= F Ff
dt x
x
d L L
=0
dt
+ (m1 + m2 )
x + m2 l cos() m2 l2 sin() = F Ff
r2
Ip + m2 l
x cos() + m2 l2 m2 glsin() = 0.
As one can see there are still nonlinear terms in the above equations. To get rid of these the assumption
is made that the angle is small since the goal is to balance the vehicle around zero degrees. Which means
that following approximation can be made
cos() = 1
sin() =
2 0.
+ (m1 + m2 )
x + m2 l = u kf x
r2
(3)
Ip + m2 l
x + m2 l2 m2 gl = 0.
(4)
Note that F (the input) has been replace with u and Ff with kf x.
1.3
Transfer function
In order to find the transfer functions for linear system it is first necessary to Laplace transform 3 and
4. After that the equations can be rewritten so that the transfer functions can be found.
1.4
State Space
To rewrite the linear system on state space form it is first necessary to rewrite 3 and 4 so that the two
equations only contain one variable and there respective derivatives. Which with some algebra leads to
these equations
x
=
=.
The linear system is represented in state space form as following
x
x
0
0 1 0 0
x
0 0 0 0 x 1
=
0 0 0 1 + 0 u
1
0 0 0 0
(5)
(6)
(7)
y1
1
=
y2
0
0
0
0
1
1.5
PID controller
1.6
LQR
x
0
x + 0 u
0
0
(8)