Quadcopter Simulation: Jose Carlos Lopez
Quadcopter Simulation: Jose Carlos Lopez
Ű̇ = (Ű̇ , ű̇ , Ų̇ )T. The roll, pitch and yaw angles are in the
quadcopter kinematics and dynamics. Aerodynamic defined in the inertial frame as x = (x,y,z)T and
Ÿ = Ɩ0 śŹ śŴŢŹ ̇ ƘŴ
I. INTRODUCTION 1 0 −ŢŴ
A quadrotor helicopter (quadcopter) is a helicopter (1) 0 −ŢŹ śŴśŹ
Ť = ŝšƆ + Ş Ɖ Ÿ (4) Ž
ţż
Š =
ƞ2ŵŚ
(10)
(Ŷ + Şƈ ŝź )(Şƈ źŝ šƆ + ŶšƆ + Şƈ Ş Ɖ Ÿ)
angular velocity of the motor as shown in (11).
Š = ŝŤ = ż
Şƈż ŪƉƎŞƞ2ŵŚ
ţ =ƨ ŸƩ = ŪŸż
(5)
Ūƈ
(11)
To simplify the model, the motor resistance in (6) is
neglected. If all the motors are summed, the total thrust on
(Ŷ + Ūƈŝ ź )Ş Ɖ Ÿ
Š=
the quadcopter in the body frame is given by (12).
Şƈ
(6)
ţƀ = Ū ƪ ƫ
0
ơ Ÿƅż
0
assumed to be much smaller than Ŷ which is reasonable
In simplifying the model even further, the term k tI0 is (12)
ŞƉ
proportional to the linear velocity is modeled. (13) is a
Š= ŶŸ
Şƈ
simplified model of fluid friction, but will be good
(7)
enough for the model.
Š = ţŤƄ
torque is the torque required to keep the propeller
(8) spinning while providing thrust. The drag equation
form fluid dynamics is used in (14).
Assuming vehicle speeds are low, so Vh is the air
Ŝƃ = ŵśƁ Śů ż
velocity when the quadcopter is hovering. The 1
(14)
free stream velocity is also assumed to be zero. 2
Momentum theory gives the equation for hover Where ŵ is the surrounding fluid density, A is the
velocity as a function of thrust. propeller cross section and CD is a dimensionless
ŸƊ̇
Ÿ̇ = ƪ Ƌ̇ ƫ = ŝſŻ ƚŶ − Ÿ × (ŝŸ)Ɯ
Ÿ
constant. Then the torque due to the drag is given by
Ÿƌ̇
(15) . (20)
ŝƊƊ
(16)
ŝ =ƪ 0 ŝƋƋ 0ƫ
0 0
ŝƌƌ
The roll and pitch torques are taken from standard (21)
mechanics. The pitch torque is given by (17). 0 0
ŶƐ = şŞ(ŸŻż − ŸŽż ) (17) The final equation for the rotations in the body frame
are found in (22).
ŝƋƋ − ŝƌƌ
ŸƋ Ÿƌ ⎤
Where L is the distance from the center of the
ŶƐ ŝƊƊ ŝ
quadcopter to any of the propellers. Adding all of these
ƊƊ
⎡
⎢(ŝƌƌ − ŝƊƊ )
ſŻ
Ÿ̇ = ƗŶƍ ŝƋƋ
ſŻ ƙ − ⎢ ŸƊ Ÿƌ ⎥
together gives (18), total torques in the body frame. ⎢ ⎥
ŶƏ ŝƌƌ
(22)
Ŷƀ = ƪ şŞ(Ÿżż − Ÿžż ) ƫ ſŻ
⎢ ƊƊ − ŝƋƋ Ÿ Ÿ ⎥
ŝ
⎢ ⎥
ť(ŸŻ − Ÿż + ŸŽ − Ÿž )
ż ż ż ż
ŝƌƌ
(18)
Ɗ Ƌ
⎣ ⎦
This model that has been derived is a highly simplified III. CONTROL
model. Many advanced effects are ignored that make
the model highly nonlinear. Rotational drag forces, The purpose of getting a mathematical model of a
blade flapping, wind, etc. are ignored. quadcopter is to help develop controllers for real
quadcopters. The inputs of the system are the four
F. Equations of Motion angular velocities of the rotors. The system can be
written as a first order differential equation in state
The acceleration of the quadcopter in the inertial
space form as shown in (23).
frame is due to thrust, gravity, and linear friction. So
Ű̇Ż = Űż
the linear motion can be expressed by (19).
Ű̇ż = Ɩ 0 Ƙ + šţƀ + ŜƁ
0
ūŰ̈ = Ɩ 0 Ƙ +šţ +Ŝ ū−ũ ū
0 1 1
ƀ Ɓ(19)
−ŢŴ ſŻ
śŹ śŴŢŹ
−ūũ
Ű̇Ž = Ɩ Ƙ Űž
1 0
0 −ŢŹ śŴśŹ
0 (23)
Where x is the position of the quadcopter, g is the
ŝƋƋ − ŝƌƌ Ÿ
ŸƋ ƌ ⎤
acceleration from gravity, F D is the drag force, and T B
ŝƊƊ
ŶƐ ŝƊƊ
is the thrust vector in the body frame. ⎡
⎢(ŝƌƌ − ŝƊƊ ) Ÿ ⎥
ſŻ
ŝ
Űž̇ = Ɨ Ŷƍ ƋƋ ŸƊ ƌ ⎥
⎢ ⎥
ſŻ ƙ −
It is helpful to have the linear equations of motion in
ŝƋƋ
ŝ
ŶƏ ƌƌ
the inertial frame, but the rotational equations of
⎢ ŝƊƊ − ŝƋƋ ŸƊ ŸƋ ⎥
⎢
motion are more easily written in the body frame, so ſŻ ⎢ ⎥
ŝƌƌ
that rotations can be expressed about the center of the
⎣ ⎦
quadcopter. The rotational equations of motion are
found in (20) which are derived from Euler's equations
for rigid body dynamics.
where x1 is the quadcopter position, x2 is the linear Where ųƅ is the angular velocity of each motor squared,
velocity, x3 is the roll, pitch and yaw angles, and x4 is and e is the error. The errors are calculated in (28).
Ƃ Ƃ Ƃ
the angular velocity vector. All of these are vectors
ŨƐ = Ū ƃŹ ̇ + Ū ƇƠ Ź ̇ ŧŮ + Ūƅ Ơ Ơ Ź̇ ŧŮŧŮ
with three elements.
ź ź ź
Ƃ Ƃ Ƃ
In order to control the quadcopter, a PID controller
Ũƍ = Ū ƃŴ+
̇ Ū ƇƠ ŴŧŮ̇ + Ūƅ Ơ Ơ Ŵ̇ ŧŮŧŮ
will be used, with a component proportional to the
(28)
ź ź ź
error between the desired trajectory and the observed
Ƃ Ƃ Ƃ
ŨƏ = Ū ƃŷ ̇ + Ū Ƈ Ơ ŷ ̇ ŧŮ + Ūƅ Ơ Ơ ŷ̇ ŧŮŧŮ
trajectory, and a component proportional to the
ź ź ź
derivative of the error. The quadcopter will be
stabilized in a horizontal position, so the desired
velocities and angles will all be zero. The torques will IV. SIMULATION
be set proportional to the output of the controller as
shown in (24). With the complete equations of motion and the
controller in place, a simulation was built using
Ƃ
⎡−ŝƊƊ(Ū ƃŹ ̇ + ŪƇ Ơ Ź ̇ ŧŮ⎤
simulink as shown in Fig. 1 and Fig. 2.
ŶƐ
ź
Ƃ
⎢ ⎥
Ɩ Ŷƍ Ƙ = ⎢−ŝ ƋƋ (ŪƃŴ+̇ ŪƇ Ơ Ŵ̇ ŧŮ
⎢ ⎥
ŶƏ
(24)
ź
⎥
Ƃ
⎢ −ŝ (Ū ŷ ̇ + Ū Ơ ŷ ̇ ŧŮ⎥
⎢ ⎥
ƌƌ ƃ Ƈ
⎣ ź ⎦
şŞ(ŸŻż − ŸŽż )
ź
Ƃ
⎢ ⎥
Ŷƀ = ƪ şŞ(Ÿż − Ÿž )
ż ż ƫ = ⎢ −ŝƋƋ(Ū ƃŴ+̇ ŪƇ Ơ Ŵ̇ ŧŮ ⎥(25)
⎢ ⎥
ť(Ÿ
Ż −Ÿ + ż Ÿ − Ž Ÿž
ż ż ż ż ź
Ƃ
⎢ −ŝƌƌ(Ū ƃŷ̇ + ŪƇ Ơ ŷ ̇ ŧŮ⎥
) ⎢ ⎥
⎣ ź ⎦
ūũ
ţ=
ŦŬŭŴŦŬŭŹ
(26)
ųŻ = −
ūũ Ũ ŝ ŨŝƋƋ
4ŪŦŬŭŴŦŬŭŹ 4ťŪş
ųż =
Ə ƌƌ ƍ
+ −
ūũ −2ťŨƐŝ ƊƊ + ŨƏŝ ƌƌŪş
4ŪŦŬŭŴŦŬŭŹ 4ť 2Ūş
ųŽ = − (27)
ūũ ƏŨŝƌƌ ƍŨŝƋƋ
4ŪŦŬŭŴŦŬŭŹ 4ťŪş
ųž = + +
4ŪŦŬŭŴŦŬŭŹ 4ť 2Ūş