FULLTEXT01
FULLTEXT01
Handledare:
Mrten Svanfeldt
Intuitive Aerial
Manon Kok
isy, Linkpings universitet
Examinator:
David Trnqvist
isy, Linkpings universitet
Avdelning, Institution
Division, Department
Datum
Date
Institutionen fr systemteknik
Department of Electrical Engineering
SE-581 83 Linkping
2012-11-27
Sprk
Language
Rapporttyp
Report category
ISBN
Svenska/Swedish
Licentiatavhandling
ISRN
Engelska/English
Examensarbete
C-uppsats
D-uppsats
LiTH-ISY-EX--12/4644--SE
Serietitel och serienummer
Title of series, numbering
vrig rapport
ISSN
Titel
Title
Frfattare
Author
Jakob Johansson
Sammanfattning
Abstract
This thesis is about the modelling and control of three axis camera pan-roll-tilt unit (gimbal)
which was meant to be attached to a multi rotor platform for aerial photography. The goal
of the thesis was to develop a control structure for steering and active gyro stabilization of
the gimbal, with aid from a mathematical model of the gimbal. Lagrange equations, together
with kinematic equations and data from CAD drawings, were used to calculate a dynamics
model of the gimbal. This model was set up as a Simulink simulation environment. Code for
sensor reading and actuator control was written to the gimbals microprocessor and the code
for the control structure in the gimbal was developed in parallel with a control structure in
the simulation environment. The thesis resulted in a method for mathematical modelling of
the gimbal and a control structure, for steering and active gyro stabilization of the gimbal,
implemented in its control unit as well as in the simulation environment.
Nyckelord
Keywords
Abstract
This thesis is about the modelling and control of three axis camera pan-roll-tilt
unit (gimbal) which was meant to be attached to a multi rotor platform for aerial
photography. The goal of the thesis was to develop a control structure for steering
and active gyro stabilization of the gimbal, with aid from a mathematical model
of the gimbal. Lagrange equations, together with kinematic equations and data
from CAD drawings, were used to calculate a dynamics model of the gimbal.
This model was set up as a Simulink simulation environment. Code for sensor
reading and actuator control was written to the gimbals microprocessor and the
code for the control structure in the gimbal was developed in parallel with a
control structure in the simulation environment. The thesis resulted in a method
for mathematical modelling of the gimbal and a control structure, for steering
and active gyro stabilization of the gimbal, implemented in its control unit as
well as in the simulation environment.
iii
Sammanfattning
Detta examensarbete handlar om modellering och styrning av av en 3-axlig s.k.
pan-roll-tilt-enhet (gimbal) till en kamera fr flygfotografering frn en multikopter. Mlet med examensarbetet var att utveckla en struktur fr styrning och aktiv
gyrostabilisering av gimbalen med hjlp av en matematisk modell av den. Lagrangeekvationer, tillsammans med kinematiska ekvationer och data frn
CAD-ritningar, anvndes till att rkna fram en modell av gimbalens dynamik.
Denna modell sattes upp som en simuleringsmilj i Simulink. Programmeringskod fr sensoravlsning och aktuatorstyrning skrevs till gimbalens egna mikroprocessor och koden fr styrstrukturen till gimbalen utveckades parallellt med
en styrstruktur i simuleringsmiljn. Examensarbetet resulterade i en metod fr
matematisk modellering av en gimbal och en struktur fr styrning och aktiv gyrostabilisering implementerad i gimbalens styrenhet samt i en simuleringsmilj.
Acknowledgments
First of all, I would like to thank Intuitive Aerial for the opportunity to do this
thesis and the valuable experience of a young company in a very exciting phase.
My thanks goes to my supervisor Manon Kok and examiner David Trnqvist at
ISY, for their great patience valuable input on the report, and Per Skoglar at ISY,
for his input early in the thesis. Last by not least I would like to thank my parents
and the rest of the family for their everlasting love and support.
Linkping, November 2012
Jakob Johansson
vii
Contents
Notation
xi
1 Introduction
1.1 General introduction . . . . . . . .
1.1.1 Background . . . . . . . . .
1.1.2 The camera gimbal . . . . .
1.1.3 Outline of the thesis . . . .
1.2 Purpose of the thesis . . . . . . . .
1.2.1 Goals . . . . . . . . . . . . .
1.2.2 Limitations . . . . . . . . . .
1.2.3 Changes from original goals
1.3 Earlier work . . . . . . . . . . . . .
1.3.1 Mechanical modelling . . .
1.3.2 Gimbal control . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
1
1
2
2
2
3
4
4
4
5
2 Modelling
2.1 Gimbal Properties . . . . . . . .
2.1.1 Mechanics . . . . . . . .
2.1.2 Sensors . . . . . . . . . .
2.1.3 User Input . . . . . . . .
2.2 Kinematics . . . . . . . . . . . .
2.2.1 Forward Kinematics . .
2.2.2 Inverse Kinematics . . .
2.3 Dynamics . . . . . . . . . . . . .
2.3.1 Lagrange Dynamics . . .
2.3.2 Dynamics of the gimbal
2.4 Identification . . . . . . . . . . .
2.4.1 Friction tuning . . . . .
2.4.2 Sensor noise . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
7
7
9
10
11
12
16
19
19
22
25
25
32
35
35
35
ix
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
36
42
46
46
46
49
57
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
63
63
64
64
64
65
65
67
Bibliography
69
Notation
X
1n
I
Br
P
r i
GT
B
Ti T
i
B
G B
i
Meaning
The time derivative of X
An identity matrix of size n.
Mass moment of inertia
The coordinate P expressed in coordinate frame B.
The skew-symmetric matrix form of vector ri
Rotational (R), translational (d) or homogeneous (T)
transformation from coordinate frame B to frame G.
Transpose of matrix Ti
Joint angular position vector.
Component i of vector (joint parameter).
Joint angular velocity vector of coordinate frame B
with respect to frame G, expressed in frame B.
Component i of vector .
Attitude of the IMU relative the ground.
Angular velocity of the IMU around its own axes.
Component i of vector .
Cartesian acceleration of the IMU.
xi
xii
Notation
Abbreviations
Abbreviation
CAD
IA
DOF
IMU
MBS
UAV
CM
PWM
rad
Meaning
Computer Aided Design
Intuitive Aerial
Degrees of Freedom
Inertial Measurement Unit
Multi body System
Unmanned Aerial Vehicle
Center of mass
Pulse-width modulation
radians
Introduction
This chapter covers the background of this thesis as well as its original purposes,
goals and limitations. A survey of earlier work in scientific literature is also included in this chapter.
1.1
1.1.1
General introduction
Background
Intuitive Aerial AB, henceforth referred to as IA, develops a UAV system for aerial
photography comprising a multi-rotor aerial vehicle, ground station and a remote
control system. The vehicle, hereafter referred to as the platform, is made out of
carbon fiber composites and ABS plastics and is controlled by a built in electronic control system that keeps the platform balanced as well as on course to
an intended target. An important part of the UAV system, and the basis for this
thesis, is a three axis camera mount, henceforth called the gimbal attached to the
platform.
1.1.2
The basis for this thesis is a prototype three axis (yaw, roll, pitch) camera gimbal designed by IA parallel to the thesis work for mounting of different types
of cameras. Each of the three axes is independently driven by motors and gears
with encoder feedback which gives angular position and velocity feedback. The
gimbal is also equipped with an Inertial Measurement Unit (IMU), consisting of
gyroscopes and accelerometers and is placed at the camera mounting point.
1
1.1.3
Introduction
1.2
This thesis aims to design, implement and evaluate a stabilization and control
system for a three axis camera gimbal attached to a multi-rotor helicopter. The
control system should compute an optimal set of control outputs to aim the camera under given constraints such as maximal possible velocities, accelerations,
angles etc. The control system should also keep the camera stable in reference to
the ground. The system design must also consider implementation limitations including processing power requirements and limitations in accuracy of available
sensor data.
To aid the control design, a model of the gimbal should be developed based on
mechanical equations and experiments.
1.2.1
Goals
1.2
Gyro stabilization
The gimbal should be able to switch targets as quickly and smoothly as possible.
Dynamic targeting
The gimbal should be able to aim at a dynamic point, e.g. a continuous function of coordinates, given motion constraints such as maximal possible velocities,
accelerations, angles etc.
Other challenges
The control system should be robust enough to cope with various types of
cameras, with different moments of inertia, without the need to manually
change parameters. It should also show some robustness to when the mass
center of the camera is not in the gimbals rotational center.
The control system should be able to function under the constraints imposed by the limited processing power of the control unit and the angular
limitations of the gimbal.
1.2.2
Limitations
Aiming of the camera is a complex interaction between the gimbal and the platform. Turning the gimbal will, due to its size, create large disturbances, consisting of inertial forces on the platform. This will lead to a motion of the platform
that will disturb the aiming of the gimbal that has to be compensated by the platform control system. However, the platform control system is considered to be a
subject outside of this thesis so the platform will be assumed to be able to handle
these disturbances. A simple test on the actual platform should however be made
to get some knowledge of which motions that can be used without creating too
much disturbance on the platform. Control strategies where the platform itself
is used to gain better performance, e.g. faster pan motion over ground, will not
be considered due to this simplification. A feed-forward signal from the gimbal
to the platform may be discussed to be used in later development of the platform
control system.
Another simplification is that the gimbal is viewed as a system of rigid bodies.
1.2.3
Introduction
When the initial research and modelling was done (chapter 2) it was time to implement a control structure in a simulation environment (chapter 3), together
with the mathematical model of the gimbal (chapter 2). It was also time to create a similar control structure in the real gimbals control unit. However, it took
some time before all parts of the gimbal were delivered, including the actuators.
This delayed the code development as well as the development of the simulation
environment due to missing friction data. When the actuators finally arrived it
became clear that they were much too weak and could not produce the power
needed for a good control performance of the gimbal. It was however decided
that the project would continue but without the weight from a camera. The next
big delay in the project came when the Pulse-Width Modulation (PWM) ports of
the control unit failed. As these were not functional again until several weeks
later, this resulted in a loss of time and momentum in the project.
The thesis was initially meant to focus on the control of the gimbal and the model
was not intended for use outside of simulation of control in joint space. Due to
the problems mentioned above, the entire control structure had to be developed
in the simulation environment, rather than directly on the gimbal control unit.
Thus, the goal of the control structure became to get a good active gyro stabilization around = (0, 0, 0), whereas the steering was much less prioritized and
the targeting goal was abandoned. Also, there was no longer any focus on more
advanced control structures such as LQR control or linearization.
1.3
Earlier work
There is not much written about modelling and control of three-axis gimbals.
Most development of gimbal control is for military applications and is guarded
by secrecy. It is also hard to find any useful information from the commercial
uses of gimbals such as mobile camera platforms at big sporting events. Most
public papers in this field are about two-axis gimbals.
1.3.1
Mechanical modelling
1.3
Earlier work
1.3.2
Gimbal control
The most common control designs are based on PID (proportional, integral,
derivative) controllers. An interesting implementation is presented in Kwon
et al. [2007] where a PI2 controller, combined with a lead compensator, is used:
(s+1 )(s+2 ) (s+3 )
Gs (s) = Kp
a (s+ ) where the extra I-parameter enables a high opens2
4
loop gain in the low frequency region.
Good stabilization results are achieved in Seong et al. [2006] where a LQG/LTR
(Linear Quadratic Gaussian control with Loop Transfer Recovery) controller is
used. The results are compared to results obtained using a Lead-PI controller
which shows that their LQG/LTR controller is better, especially in terms of decoupling. The same writers have in Seong et al. [2007] modified the controller to
handle windup, due to input saturation, with good results.
In this work, it may be necessary to handle unknown or ill-defined disturbances
and parameters, as mentioned in first paragraph of section 1.2.1. In Smith et al.
[1999] and Shtessel [1999] a sliding mode control (SMC) technique is used where
the differential equations that describe the system are forced into special manifolds (sliding surfaces) and handled by high speed switching control functions.
It can be noted that Shtessel [1999] is an article on a three-axis platform.
Modelling
2.1
Gimbal Properties
This section is a presentation of the gimbal properties without going into much
details.
2.1.1
Mechanics
The gimbal was mainly made of aluminium profiles and consisted of four bodies
(body (0)-(3) in Figure 2.1 and 2.2) connected by three revolute joints. Each joint
was driven by a dc-motor (not shown in the figures below) via a gearbox. The
mounting point of the camera on body (3) in the 2 direction. The box on body
(1) containded the electronics including the control card.
7
Modelling
Body (0) was supposed to be attached to the platform via a dampening joint
which was supposed to cancel out some of the disturbances, e.g. from wind and
motor vibrations. However, the gimbal was not attached to a platform during
this thesis so body (0) became the part of the gimbal which was held by hand or
fixed during tests.
The dimensions (l1 , h1 , b2 and h3 ) in Figure 2.1 and 2.2, and the mass, mass moment of inertia and center of mass for each body were given by the CAD models
of the gimbal.
Figure 2.1: The gimbal in configuration = (0, 0, 0) viewed from the side
with coordinate axes and distances between them. The direction of the joints
is indicated by the double arrows.
2.1
Gimbal Properties
Figure 2.2: The gimbal in configuration = (0, 0, 0) viewed from the front
with coordinate axes and distances between them. The direction of the joints
is indicated by the double arrows.
2.1.2
Sensors
The gimbal was equipped with different sensors to aid the control:
Encoders
Rotary encoders were used to measure the angular position of the gimbal joints
from the actuators. These were placed in the transmission between the dc-motors
and the gimbal. The joint velocities were approximated using two angular positions and the time between the samples.
10
Modelling
IMU
The gimbal was equipped with an Inertial Measurement Unit (IMU) close to the
camera mounting point (origin of coordinate frame (3) in Figure 2.1). An IMU
consists of gyroscopes (gyros) and accelerometers measuring accelerations and
changes in attitude such as roll, pitch and yaw. The unit can with this information calculate the angular velocity of the device it is mounted on. The gyros
(gyroscopes) were used to measure the angular velocities of the camera and these
velocities were integrated to calculate the cameras angular position relative to
the ground (attitude). However, a simple integration of the calculated velocities
("dead reckoning") also leads to accumulation of the errors present in them. The
accumulated errors creates an ever-increasing difference between the calculated
attitude and the actual attitude (drift). The drift is usually corrected using other
sensors such as a GPS, which not available. A filter solution from IA using accelerometer data was used to get more correct attitudes (section 3.2.2).
2.1.3
User Input
User input to the gimbal consisted of two modes with either the desired angular
velocities, or the desired attitude.
The first of these control modes was supposed to be used when the photographer
uses a hand controller to control the yaw, pitch and roll of the camera in reference
to its image output, i.e. the velocities are first defined in the cameras coordinate
frame. The input from the hand controller consists three values that are interpreted as desired angular velocities of the camera. The gimbal control unit then
calculates new reference velocities of the gimbal joints. When input ceases, so
does the change in attitude.
The second input mode was a desired angular position relative to the ground
(attitude). These angles are transformed to the gimbals reference frames using
the information from the IMU and new reference joint angles are given to the
control.
2.2
2.2
11
Kinematics
Kinematics
The kinematics of a mechanical system is, according to Jazar [2007], the description of the systems translational and angular position and their time derivatives
taking only geometry into account. The forces that cause the motion of the system
are not taken into consideration but the kinematics can be used in the derivation
of the dynamics of the system (section 2.3) which take into account all forces acting upon it. The basics of the kinematics of a rigid multi body system (MBS) is to
describe the motion of a body in a coordinate frame attached in another body (e.g.
a global fixed reference frame) using matrix algebra. The approach to do this is
to combine a series of individual transformations between the body-attached coordinate systems. These transformations are a description of the relative rotation
and distance between the bodies and consist of variable parameters according to
the degrees of freedom (DOF) between the bodies. The gimbal in this thesis (see
Figures 2.1 and 2.2) consists only of three revolute joints (R-joints) that individually have only one DOF (see Figure 2.3). This gives the whole MBS a total of
three DOF, yaw, roll and pitch (1 , 2 , 3 ). These are the joint parameters that
henceforth will be used to describe the system. The kinematics can be divided
into forward and inverse kinematics.
B
(B)
(A)
Figure 2.3: Principal sketch of a revolute joint (R-joint) with index [B] where
body (B) is rotated an angle indicated by the joint parameter B . It has in
this case its zero value on the axis orthogonal to the length of body (A). B
indicates the direction of the joint (the thumb in the right-hand-rule). A Rjoint has only one degree of freedom and therefore only one joint parameter.
12
2.2.1
Modelling
Forward Kinematics
In Figures 2.1 and 2.2 there are two types of axes: the coordinate axes (xi , yi , zi ),
indicated by an one-headed arrow, and the joint parameter axes (1 , 2 , 3 ), indicated by the double-headed arrows. The joint parameters describe the angular
position of the three joints in the gimbal, according to Figure 2.3. For the whole
gimbal, motions in these joints are called yaw (1 ), roll (2 ) and pitch (3 ). According to a common flight convention (Jazar [2007][p. 41]) yaw, roll, and pitch
are defined such that yaw is a motion around a bodys z-axis, roll around its xaxis and pitch around its y-axis. Each body can only move in one DOF so the joint
parameters are defined in the following way: 1 as body (1)s motion around the
z0 -axis (yaw), 2 as body (2)s motion around the x1 -axis (roll) and 3 as body
(3)s motion around the y2 -axis (pitch). The coordinate systems in the bodies of
the gimbal (Figures 2.1 and 2.2) are placed in a way that they are parallel to each
other in the configuration (1 , 2 , 3 ) = (0, 0, 0). The forward kinematic matrices
derived in this section are used in the dynamic modelling in section 2.3 as well
as in the inverse kinematics described in section 2.2.2.
Homogeneous Transformations
rP =
RB B rP +G dB ,
(2.1)
where in a 3D environment
B
xP
B
rP = B yP .
B
zP
(2.2)
The expression (2.1) is called the transformation of the coordinate P from frame
B to frame G.
2.2
13
Kinematics
r = 0 R2 2 r + 0 d2 ,
(2.3)
R2 = 0 R1 1 R2
(2.4)
d2 = R1 d2 + d1 .
(2.5)
The expressions for the transformations get very messy even if with relatively
few intermediate frames. A convenient way to describe a transformation is to use
homogeneous transformation matrices G TB , where for a 3D environment
"
G
TB =
Gd
013
GR
#
B
(2.6)
= 0 T2 2h r,
(2.8)
where
0
hr
" #
0r
=
,
1
2
hr
" #
2r
=
1
(2.9)
and
0
T2 = 0 T1 1 T2 .
(2.10)
14
Modelling
With the design parameters l1 , h1 , h3 and b2 in Figures 2.1 and 2.2 the transformations between the bodies are as follows.
The rotation matrix between the base frame (0) and the frame of body (1) is
cos(1 ) sin(1 ) 0
sin( ) cos( ) 0
0
R1 =
(2.11)
1
1
0
0
1
and distance between the coordinate origins is
l1 cos(1 )
l sin( )
0
d1 = 1
1
.
h1
(2.12)
The matrices (2.11) and (2.12) together create the homogeneous transformation
matrix
#
"0
R1 0 d1
0
(2.13)
T1 =
0
1
or
0
1
1
1
1
.
(2.14)
T1 =
0
1
h1
0
0
0
0
1
The transformation between the frames of body (1) and body (2):
0
0
1
0 cos( ) sin( )
1
R2 =
2
2
0 sin(2 ) cos(2 )
l2
1
d2 = 21 b2 cos(2 )
1
2 b2 sin(2 )
0
1
0 cos( )
1
2
T2 =
0 sin(2 )
0
0
0
l2
sin(2 ) 12 b2 cos(2 )
.
cos(2 ) 12 b2 sin(2 )
0
1
The transformation between the frames of body (2) and body (3):
cos(3 ) 0 sin(3 )
2
0
1
0
R3 =
sin(3 ) 0 cos(3 )
(2.15)
(2.16)
(2.17)
(2.18)
2.2
15
Kinematics
h3 sin(3 )
2
d3 = 21 b2
h3 cos(3 )
cos(3 ) 0
0
1
2
T3 =
sin(3 ) 0
0
0
sin(3 )
0
cos(3 )
0
(2.19)
h3 sin(3 )
2 b2
.
h3 cos(3 )
c1 c3 s1 s2 s3 c2 s1 c1 s3 + c3 s1 s2
c s + c s s
0
c1 c2 s1 s3 c1 c3 s2
R3 = 3 1
1 2 3
c2 s3
s2
c2 c3
(2.20)
(2.21)
(2.22)
and
0
c1 l2 c1 l1 + c1 h3 s3 + c3 h3 s1 s2
l s l s + h s s c c h s
d3 = 2 1 1 1
3 1 3
1 3 3 2
.
h1 + c2 c3 h3
(2.23)
0R
3
c1 c3 s1 s2 s3 c2 s1 c1 s3 + c3 s1 s2
g
R3 = c3 s1 + c1 s2 s3 c1 c2 s1 s3 c1 c3 s2 ,
(2.24)
c2 s3
s2
c2 c3
where si and ci are short for sin(i ) and cos(i ) and 1 = yaw, 2 = roll and
3 = pitch derived using the information from the IMU. There exist a total of
12 possible independent orientation representation of this type, but this one was
chosen due to its similarity to matrix (2.22).
16
2.2.2
Modelling
Inverse Kinematics
The opposite of forward kinematics is when the joint parameters are determined
from the translational and angular position of the end-effector. This is called inverse kinematics. In a common robotic application the goal is to move a tool to
a certain position and hold it in a certain orientation. This is often a difficult
problem because it leads to multiple solutions which are often avoided by letting
the robot "learn" the configuration of the joint parameters instead of computing
them. Inverse kinematics in the gimbal application is simpler, because in this
case it is only concerned with the orientation (in this thesis called angular position) of the camera. Thus multiple solutions of trigonometric functions can be
avoided. The inverse kinematics will be used to generate the reference signals to
the gimbal control.
Angular position
According to the second user input mode described in section 2.1.3 one goal is
to change the attitude of the camera relative to the ground. This will result in
a control error between the desired attitude and with gyros and accelerometers
derived current attitude described by (2.24). This can be presented as a new
rotation matrix in the cameras reference frame.
c1 c3 s1 s2 s3 c2 s1 c1 s3 + c3 s1 s2
3
Re = c3 s1 + c1 s2 s3 c1 c2 s1 s3 c1 c3 s2 ,
(2.25)
c2 s3
s2
c2 c3
where 1 , 2 and 3 are the errors ( = des ) of yaw, roll and pitch in the
cameras reference frame. e denotes an imagined error coordinate frame.
The total rotation matrix between the error frame (e) and the gimbal base frame
(0) is then
0
Re (, ) = 0 R3 () 3 Re (),
(2.26)
where are the current angles of the joints (1 , 2 , 3 ) (Figures 2.1, 2.2 and 2.3).
A new joint configuration new is chosen such that
0
R3 ( new ) = 0 Re (, ),
(2.27)
which means that coordinate frame (3) becomes in the same frame as (e), i.e the
desired attitude is reached.
2.2
17
Kinematics
R3 ( new =0 R3 () 3 Re .
r11 r12
0
R3 () 3 Re = r21 r22
r31 r32
r13
r23 ,
r31
(2.28)
(2.29)
(2.30a)
2new = arcsin(r32 ),
(2.30b)
(2.30c)
where arctan2(y,x) is a function that places the computed angle in the correct
quadrant of the unit circle.
These angles will be the angular position reference signals for the individual
joints.
Angular velocity
According to the first user input mode described in section 2.1.3, the input can
be a set of desired angular velocities of the camera in its own coordinate frame:
x roll
3
y = pitch .
(2.31)
3 =
yaw
z
The relationship between the local angular velocities in the joints and the camera angular velocity can be expressed using a Jacobian matrix J
3
3
= J,
(2.32)
where
= (1 , 2 , 3 )T = ( 1 , 2 , 3 )T .
(2.33)
18
Modelling
As in Jazar [2007][p. 351] the Jacobian J can be viewed as the angular velocity
directions of the joints presented in the cameras coordinate frame and because
the gimbal consists only of R-joints it can be written as
h
i
J = 3 1 3 2 3 3
h
i
= 3 R1 1 1 3 R2 2 2 3 3
T
= 1 R2 2 R3 1 1 2 R3T 2 2 3 3 ,
(2.34)
where
0
1
1 = 0 ,
1
1
2
2 = 0 ,
0
0
3
3 = 1 ,
0
(2.35)
which are the directions of the joints (Figures 2.1, 2.2 and 2.3).
(2.32) is then
roll cos(2 ) sin(3 )
sin(2 )
pitch =
yaw
cos(2 ) cos(3 )
cos(3 ) 0 1
0
1 2 ,
sin(3 ) 0 3
(2.36)
yaw cos(2 ) cos(3 )
roll = cos(2 ) sin(3 )
sin(2 )
pitch
sin(3 ) 0 1
cos(3 ) 0 2 .
0
1 3
(2.37)
yaw
1
= J pitch .
roll
(2.38)
of the end-effector
It is also possible to derive the current translational velocity X
with another Jacobian matrix Jd
h
i
= JD = 3 0 3 d1 3 1 3 d2 3 2 3 d3 .
X
(2.39)
This can be useful if the translational velocity is needed, e.g. in applications such
as positional tracking and sensor filtering. Translational Jacobians are used in the
dynamics in section 2.3.
2.3
19
Dynamics
2.3
Dynamics
The dynamics of an MBS is how its motion is affected by external forces such as
gravity and torque from the joint actuators. It is presented as a system of differential equations obtained using either Newton-Euler equations Jazar [2007][p. 447],
which use Newtons second law of motion, or Lagrange equations
Jazar [2007][p. 478], which uses the kinetic and potential energies of the MBS.
The method using Lagrange equations was chosen in this thesis. The reason for
this is mainly the writers desire to learn this method.
2.3.1
Lagrange Dynamics
dt i
i
L is the Lagrangian which is defined as the difference between the kinetic energy
K and potential energy V
L = K V.
(2.41)
i are the coordinates of the system (which in the gimbal application are the
current angles in joints i = 1, 2, 3). i is the time derivative i of the coordinates and Qi is the non-potential force driving i . Qi are external forces such as
torques from actuators while internal forces such as gravity and Coriolis effects
Jazar [2007][p. 451] are already a part of the left hand side of equation (2.40).
According to the proof in Jazar [2007][p. 529] the kinetic energy of the whole
robot can be expressed as
K=
1 T
Dj
2 j
j = 1, 2, . . . n,
(2.42)
(2.43)
j=1
which is called the inertial-type matrix. JDj and JRj are the Jacobians of body (j)
that transform the joint angular velocities into the translational and rotational
velocities of the bodys center of mass (CM) (similar to the jacobians in section
2.2.2). The component mj is the mass of body (j) and 0 Ij is the Mass moment of
inertia matrix about its CM and expressed in the base coordinate frame (0).
20
Modelling
The potential energy can according to the same proof [Jazar, 2007, p. 529] be
written as
n
n
X
X
V =
Vi =
mi 0 gT 0 ri ,
(2.44)
i=1
i=1
0g
where
is the gravitational acceleration vector in the base frame (0) and 0 ri are
the coordinates of the center of mass of each body expressed in the base frame
(0).
If equations (2.41) to (2.44) are inserted in (2.40) the result can with some rearrangement (done in Jazar [2007][p. 529]) and = (1 , 2 , 3 )T be presented in a
matrix form
+ H(, ) + G() = Q,
D()
(2.45)
or in summation form
n
X
Dij () j +
j=1
n X
n
X
Hikl k l + Gi = Qi .
(2.46)
k=1 l=1
n X
n
X
Hijk k l
k=1 l=1
(2.47)
(2.48)
where
Hijk =
n X
n
X
Dij
j=1 k=1
!
1 Djk
.
2 i
(2.49)
n
X
(i)
mj 0 gT JDj .
(2.50)
j=1
Equation (2.46) can in theory be viewed as how reaction torques Q in each joint
are affected. The n n inertial-type matrix D is how the reaction torques are
due to the inertias of the bodies and
affected by a given set of accelerations
every component outside the diagonal are coupling effects. The n 1 Velocity
coupling vector H contains the reactions due to a given set of angular velocities
and the bodies inertias and coupling effects. H can often be referred as a
Christoffel operator Jazar [2007][p. 533]. The n 1 Gravitational vector G contains
the reaction torques in the joints due to the gravitational pull 0 g.
2.3
21
Dynamics
Instead of deriving each Jacobian that is needed in the terms of (2.46) the Lagrange equations can be derived using the link transformation matrices 0 Tr derived in section 2.2.
It is proven in Jazar [2007][p. 535] that the terms in (2.46) can be rewritten such
that the Inertial-type matrix (2.43) becomes
!T
n
X
0 Tr r
0 Tr
tr
Ir
Dij =
(2.51)
,
i
j
r=max(i,j)
n
X
r=max(i,j,k)
2 0 Tr
tr
i
0 T r
Ir
i
!T
(2.52)
n
X
r=i
mr 0 gT
0 Tr r
rr .
i
(2.53)
The tr() indicates the trace function of the matrices and rr is the translational
position of the center of mass of body (r) expressed in frame (r).
Matrix r Ir is the pseudo inertia matrix of body r expressed in rs reference frame
which is compatible with the homogeneous transformation matrices, see Jazar
[2007][p. 467].
Ixx +Iyy +Izz
Ixy
Ixz
mxcm
2
Iyx
Iyz
mycm
2
I =
(2.54)
Izx
Izy
mz
cm
2
mxcm
mycm
mzcm
m
where xcm is the x-coordinate of the bodys center of mass. Iii are the elements of
the mass moment of inertia Ir of body (r), Jazar [2007][p. 466].
22
2.3.2
Modelling
One difference between the gimbal application and most robotic applications is
the gravitational vector 0 g. The direction of it is in most applications constant
straight down (along the global z-axis). The gimbal is however supposed to be in
flight which means that 0 g varies with the attitude of platform. The gravitational
vector (0, 0, g)T on the ground is therefore transformed to the base frame (0) via
gyro and accelerometer data from the IMU.
0
c2 s3
0
g = 0 R3 g R3T 0 = 0 R3 s2 g
(2.55)
g
c2 c3
where 0 R3 is (2.22), g R3T the inverse of (2.24) and g is the gravitational acceleration (9.81m/s2 ). This gives that G in (2.45) becomes a function of both the joint
parameters and the IMU attitude , G(, ).
With the aid of Matlab symbolic toolbox and Mathematica, the terms D(),
H(, ) and G(, ) were obtained using the kinematics in section 2.2. The design parameters described in section 2.1, such as masses, lengths and moments
of inertia I were taken from the CAD-models of the gimbal.
The Lagrange equations (2.45) were rearranged to
= D1 (Q H G)
= 3 .
x=
1
2
3
(2.56)
(2.57)
With (2.56) and one derivation of (2.57) the system of differential equations that
describes the dynamics of the gimbal were obtained
"
#
D(x4:6 )1 (Q H(x) G(x4:6 , ))
x =
.
(2.58)
x1:3
The IMU attitude could have been a set of states among (2.57) but is not directly
a part of the joint states and is therefore viewed as a separate set of states.
2.3
23
Dynamics
Camera mechanics
(2.59)
According to Jazar [2007][p. 449] the combined center of mass of a rigid body B
is defined as
Z
1
B
rcm =
r dm.
(2.60)
m
B
If the masses mi and the center of masses ri = (xcm , ycm , zcm )T are known for each
part of the body, equation (2.60) can be written as
1 X
B
rcm = P
ri mi ,
(2.61)
mi
where the summations are of each body (i) incuded in body B.
In the gimbal application the center of mass of body (3) with a camera attached
becomes
1
3
r3 =
(r
m
+ rc mc ).
(2.62)
m3 3org 3org
Vector r3org is the coordinate of the original bodys center of mass expressed in
the coordinate frame (3) (see Figure 2.2) and rc is the center of mass of the camera
expressed in coordinate frame (3).
The total mass moment of inertia of body (3) is obtained using the parallel-axes
theorem, also called Huygens-Steiners theorem (Jazar [2007][p. 473]).
T
+ Ic + mc r c r Tc ,
I3 = I3org + m3org r3org r3org
(2.63)
where
r i = zcm
ycm
zcm
0
xcm
ycm
xcm .
(2.64)
24
Modelling
The same theory can be applied if other parts of the gimbal are not included in
the original body. It can for instance be useful to treat the motors of the gimbal as separate bodies if simulation tests of different actuators (motors and gearboxes) are desired. Instead of generating a whole new model, with a different
set of actuators or a different camera, their mechanical properties are treated as
symbolic quantities, and given appropriate values in the simulation environment.
The model in this thesis allows for interchangeable cameras, but not actuators, as
these are included in the original gimbal bodies.
Friction
The torques Q on the gimbal are affected by friction which is assumed to be linear
Q = a f sgn()
(2.65)
where a are the torques from the actuators, f the static frictions in the joints
and is a diagonal matrix containing the kinetic friction coefficients of the joints.
The combined torques in a joint need in reality overcome the static friction f
in order to create a motion. The condition for the gimbal to behave according to
(2.58) from a standstill is therefore according to Algorithm 2.1.
Algorithm 2.1 Condition for motion in joint i due to static friction
h
i
H G) < f (i) && (i == 0) then
if a D
i
i = 0;
else
h
i
i = D1 (Q H G) ;
i
end if
Actuator dynamics
According to Mohan et al. [2003] dc-motor drives can be described using the
following equations:
m = Kt i,
(2.66)
where m is the output torque from the motors, Kt the torque constant and i the
current. The current is expressed in the differential equation
di
1
= (u Rm i e),
(2.67)
dt
L
where u is the input voltage, Rm the resistance of the motor circuit, e the back-emf
of the motor and L the motors inductance. e is produced by the angular velocity
m
e = Ke m ,
where Ke the back-emf constant.
(2.68)
2.4
25
Identification
a
m
a = Kt ai
(2.69)
1
di
= (u Rm i Ke a)
dt
L
(2.70)
and
The constants Kt , Ke L, Rm and a are taken from the data sheets of the motor and
the gearbox.
2.4
Identification
2.4.1
Friction tuning
In order to estimate the friction in each axis a series of voltage step response
tests were made. The results from these tests were compared to the results from
the same steps in the simulation environment. The static and dynamic friction
parameters in the model, f and mentioned in section 2.3.2, were then simply
tuned to get a simulation result that fitted the results from the real measurements.
All tests were done around = (0, 0, 0).
Figure 2.4 shows that the simulation results were quite close to the real measurements but the overall angular velocity was too high. The static friction parameter
f was tuned to reduce the overall angular velocity and the dynamic friction parameter was tuned to set a penalty on higher angular velocities. The result is
shown in Figure 2.5.
26
Modelling
Figure 2.4: Step response on the pitch axis with friction parameters set to
zero. Voltage step from 0 to 8.5 V. Thin lines are angular velocity in rad/s
and thick lines angular position in radians. Solid lines are real results and
dashed lines are simulation results.
Figure 2.5: Step response on the pitch axis with tuned friction parameters.
Voltage step from 0 to 8.5 V. Thin lines are angular velocity in rad/s and thick
lines angular position in radians. Solid lines are real results and dashed lines
are simulation results.
2.4
Identification
27
The behaviour was somewhat different when the voltage to the motors were reversed, as shown in Figure 2.6. Negative directions of the torque on the axes
needed separate sets of friction parameters. The results of friction tuning in the
negative direction on the pitch axis is shown in Figure 2.7.
Figure 2.6: Negative step response on the pitch axis with same friction parameters as the positive step. Voltage step from 0 to -8.5 V. Thin lines are
angular velocity in rad/s and thick lines angular position in radians. Solid
lines are real results and dashed lines are simulation results.
Figure 2.7: Negative step response on the pitch axis with tuned friction parameters. Voltage step from 0 to -8.5 V. Thin lines are angular velocity in
rad/s and thick lines angular position in radians. Solid lines are real results
and dashed lines are simulation results.
28
Modelling
The results from the roll and yaw axes are shown in Figure 2.8 to 2.13.
Figure 2.8: Step response on the roll axis with friction parameters set to
zero. Voltage step from 5.1 to 17 V. Thin lines are angular velocity in rad/s
and thick lines angular position in radians. Solid lines are real results and
dashed lines are simulation results.
Figure 2.9: Step response on the roll axis with with tuned friction parameters. Voltage step from 5.1 to 17 V. Thin lines are angular velocity in rad/s
and thick lines angular position in radians. Solid lines are real results and
dashed lines are simulation results.
2.4
Identification
29
Figure 2.10: Negative step response on the roll axis with with tuned friction
parameters. Voltage step from 5.1 to -17 V. Thin lines are angular velocity in
rad/s and thick lines angular position in radians. Solid lines are real results
and dashed lines are simulation results.
Figure 2.11: Step response on the yaw axis with friction parameters set to
zero. Voltage step from 0 to 13.6 V. Thin lines are angular velocity in rad/s
and thick lines angular position in radians. Solid lines are real results and
dashed lines are simulation results.
30
Modelling
Figure 2.12: Step response on the yaw axis with tuned friction parameters.
Voltage step from 0 to 13.6 V. Thin lines are angular velocity in rad/s and
thick lines angular position in radians. Solid lines are real results and dashed
lines are simulation results.
Figure 2.13: Negative step response on the yaw axis with tuned friction parameters. Voltage step from 0 to -13.6 V. Thin lines are angular velocity in
rad/s and thick lines angular position in radians. Solid lines are real results
and dashed lines are simulation results.
2.4
31
Identification
The results on the yaw axis and to some extent the other axes shows that the assumption in (2.65) was not sufficient to represent the friction in the joints. The
bearings in the yaw joint were too small to distribute the load from the gimbal
evenly witch results in a nonlinear behaviour and dependency on the joint angular position. The friction parameters in yaw were tuned to at least get an accurate
result around 1 = 0. Tests with a friction model where there was only dynamic
friction when the joint was in motion did not yield any better results. The friction
parameters are presented in Table 2.1.
Table 2.1: Friction in the gimbal joints. (+) indicates forward direction and
(-) negative direction.
Axis
f [N m] [N m/(rad/s)]
Yaw (+)
0.45
4.5e-2
Yaw (-)
0.47
4.5e-2
Roll (+)
0.28
3.5e-2
Roll (-)
0.12
2.5e-2
Pitch (+)
0.05
1.5e-2
Pitch (-)
0.05
3.0e-2
Alternative method
(2.71)
32
2.4.2
Modelling
Sensor noise
Sensor noise was added to the model as sets of variances taken from the measurements in Figures 2.14 to 2.17 there the gimbal was held in a fixed configuration.
Figure 2.14: Noise from an encoder measurement after filtering in the gimbal controller. The signal with small variance is the angular position of the
encoder and the signal with much bigger variance is the angular velocity
which is the filtered derivative of the angular position.
Figure 2.15: Measurement of the noise in the yaw magnetometer in the IMU
when the gimbal was held stationary.
2.4
Identification
33
Figure 2.16: Measurement of the noise in the gyro for the roll axis in the
IMU when the gimbal was held stationary.
Figure 2.17: Measurement of the noise in the gyro for the pitch axis in the
IMU when the gimbal was held stationary.
34
Modelling
It is shown in figure 2.14 that the angular position noise is mainly due to the last
sampled bit in in the signal from the encoder. The real value was somewhere
between the value when the least significant bit in the binary signal was 1 or the
value when the bit was 0 and the signal jumped between these values. The angular velocity was simply a derivative of the angular position. As a simplification
the noise was modelled as white noise with bias and variance according to table
2.2. The noise of the angular position and velocities was also simplified to be
viewed as independent.
The largest part of the angular velocity bias was compensated for using the measurements of the IMU. However, a small bias remains after compensation The
biases and variances are presented in table 2.2.
The noise on the sensor signals was relatively small due to filtering and bias compensations present in the gimbal controller and can in most cases be disregarded,
see section 3.1.
Table 2.2: Bias and variances of the noise in the encoders and the IMU.
Signal
Bias [rad(/s)] Variance [(rad(/s))2 ]
Encoder angular position
-5.5632e-04
1.2617e-06
Encoder angular velocity
-4.5697e-03
4.5971e-04
Magnetometer yaw
6.7044e-04
4.1017e-06
Gyro roll
-3.1824e-03
5.9804e-06
Gyro pitch
4.9598e-03
4.0390e-06
3.1
Simulation
The model obtained in section 2.3 was included as in Figure 3.1 in a control structure shown in appendix A. Due to the much too weak motors, the "camera" referred to below can be considered a weightless object mounted on body (3) in
Figure 2.1.
3.1.1
Dynamics in Simulink
The dynamic model of the gimbal is set up as a Simulink model (Figure 3.1)
35
36
The block called gimbalmod is an S-function which contains the differential equations (2.58) and the friction handling. The input is the current state vector x,
the generated attitude angles to the ground , the torque from the actuators m
and a check if the angular velocity has reached zero which is used in the friction
The differential
handling. The output of the function is the derivative state x.
equations are solved using an integrator and a solver such as ode45.
The motors block is set up according to Figure 3.2 and the differential equation of
the current i is solved with an integrator.
3.1.2
Control structure
The control structure shown in Figure A.1 in appendix A is a joint angular velocity and position controller in cascade with an output signal between -1 and 1.
The output signal is then multiplied with the battery voltage input to the gimbal
motors. This is to get the same behaviour as a by pulse-width modulation (pwm)
controlled voltage. There are also input signals for the desired angular positions
and velocities in the cameras coordinate frame which are transformed to the joint
frames. The last part of the structure in Figure A.1 is a model of how gyros close
to the camera would behave when the entire gimbal is disturbed. This structure
can be compared to the block diagram in Figure 3.14.
3.1
Simulation
37
Controllers
The angular position and velocity controllers consists of two ordinary PID algorithms for each axis written as S-functions of the form shown in Algorithm 3.1.
Algorithm 3.1 Pseudo code on the function of the angular velocity controllers.
The angular position controllers do not have limited output and does not have
any if-statements.
Sample(e);
v = a + b e;
if (v > 1) then
u = 1;
else if (v < 1) then
u = 1;
else
u = v;
end if
Out(u);
if |u| , 1 then
I = I + K TTs e;
i
end if
a = I K TTd e;
s
b = K + K TTd + K TTs ;
s
i
Wait;
The variable e in Algorithm 3.1 is the control error, u the output, K the proportional gain constant, I the integral term, Ti the integral time, Td the derivative
time and Ts the sampling interval. a is the additional term of the output which
does not depend on the last sample and is pre-calculated in the previous sample
and b is the proportional part of the output. This is done, according to [Industriell reglerteknik, ch. 6] to minimize computational delay in the control system.
The second if-statement is the condition for integration to avoid reset wind-up.
The angular position controllers do not have the if-statements because the output
signal is not limited.
The angular velocity controller takes the angular velocity error for each axis as
input and outputs three signals between -1 and 1 which is multiplied with the battery voltage. The angular position controller takes the positional error as input
and outputs a desired angular velocity to reduce the error. This angular velocity
is added to the input to the angular velocity controller.
38
IMU
In order to disturb the simulation with a motion on the zero frame a block was
required that transformed a given angular velocity in zero frame to how the gyroscopes on an IMU close to the camera would measure it. First the components
of the angular velocity 0 were transformed to the joints. This can be viewed as
if the joints themselves produce the motion and the zero frame is fixed.
=
where
joints J
0
is the Jacobian
joints
J0 = 0
sin(2 )
joints
J0 0 ,
0
0
sin(1 )
cos(1 )
.
(3.1)
(3.2)
Then, the angular velocities , which are actually produced by the joints, are
added to . These are then transformed to the camera frame using equation
(2.32). The angular velocity that the gyros on the IMU detects is then
3
3
= J( + ).
(3.3)
Equation (3.3) is then implemented in the imusim block in Figure A.1. The angular position is (as in the hardware implementation) the integral of the angular
velocity.
Input
There are a number of inputs to the controller system. The simplest ones are the
desired angular positions and velocities in joint space. These require no transformations and are sent directly to the controllers. The angular position control
output is, to avoid conflict, simply set to 0 when only angular velocity control
is desired. Steering the gimbal to a new angular position using angular velocity
control and setting this as the new desired angular position is not implemented
in the simulation environment due to the increase in simulation time this brings.
The other input signals are in the camera space according to the modes in section 2.1.3. The difference between the desired angular velocity d and the, by
gyro measured, angular velocity is calculated to determine the required velocity change e . e is then in the invvel block transformed to joint space using
equation (2.38) and added to the current joint angular velocities according to the
equation
d = J1 e + .
(3.4)
3.1
Simulation
39
Control tuning
The controllers were tuned manually. The nonlinear behaviour of the model
made it hard to perform tests (such as transient responses or stable limit cycle
tests) in order to determine parameters to be used in tuning methods such as
Ziegler-Nichols or strm-Hgglund [Glad and Ljung, 2006, p. 56]. The angular
velocity controller needed to be tuned first and required a proportional gain K
and an integral term I with an integral time Ti as input. The parameters were
also set differently depending on the sign of the desired angular velocity. The
imbalance in the roll axis made the tuning a little bit harder and resulted in an
overshoot that could not be reduced by a derivative part. The angular position
controllers only needed proportional gains to reach the target which means that
it was quite simple to tune a desired "smoothness" on the motion by only lowering
the gain K.
Figure 3.3: Step responses of the Yaw axis angular velocity control on steps
from 0 to /4 rad/s in both positive and negative direction. The desired
steps are shown as well as the curved responses.
40
Figure 3.4: Step responses of the Roll axis angular velocity control on steps
from 0 to /4 rad/s in both positive and negative direction. The desired
steps are shown as well as the curved responses.
Figure 3.5: Step responses of the Pitch angular velocity control on steps from
0 to /4 rad/s in both positive and negative direction. The desired steps are
shown as well as the curved responses.
3.1
Simulation
41
Figure 3.6: Step responses of the Yaw axis angular position control on a step
from 0 to /4 rad. The desired steps are shown as well as the curved responses.
Figure 3.7: Step responses of the Roll axis angular position control on a step
from 0 to /4 rad. The desired steps are shown as well as the curved responses.
42
Figure 3.8: Step responses of the Pitch axis angular position control on a
step from 0 to /4 rad. The desired steps are shown as well as the curved
responses.
3.1.3
Gyro stabilization
A cosine wave on each axis, representing a angular velocity in zero frame, was fed
into the imusim block described in 3.1.2. In order to counter this distortion the
control system had to subtract the, by the gyro, measured angular velocity and
position from the reference signals and then transform them to controller inputs.
Figures 3.9 to 3.12 show the results for gyro stabilization around the angular
positions = (0, 0, 0).
3.1
Simulation
43
44
3.1
Simulation
45
Figures 3.9 to 3.11 show distortion in frequencies when the gyro stabilization is
still "acceptable". The ability of gyro stabilization depends on the angular velocity
capability of the joints. The pitch axis has a good stabilization due to its high
speed whereas the other two axes have much lower stabilization ability at higher
frequencies. This is particularly evident in the unbalanced roll axis (Figure 3.10)
where the speed capability is greater when the desired angular velocity is in the
negative direction, see Figure 3.12 and Figure 3.4. These simulations show that
the motors are much too weak to obtain a good gimbal performance.
Influence by increased noise
The noise measured in section 2.4.2 is relatively small and does not have much
impact on the gyro stabilization simulations. If the variances of the noise in the
IMUs gyros are multiplied by a factor of 1e6 the results are as shown in Figure
3.13. The drift in the angular position is because the control system is entirely relying on the accuracy of the IMU gyro measurements and has no other reference.
Increased noise in the joint encoders does not have any significant impact on the
gyro stabilization. This is because the control system only uses the control error
from the IMU. This would not be the case if the IMU gyros and the encoders were
read at different sample rates or if the joints are controlled directly, for instance
during initiations and calibrations.
Figure 3.13: Gyro stabilization test on pitch where the variance of the measurement noise in the IMU gyros was multiplied by a factor of 1e6 (all axes).
The thin curve is the angular position, as integrated from the IMU signals,
and the bold curve is the angular position, as measured without any noise.
46
3.2
Hardware Implementation
3.2.1
Numerical representation
(3.5)
The IQ number can be treated as any integer or used by TI-special functions such
as correct multiplications and trigonometric functions. The scale 224 is a tradeoff
between numerical accuracy and the range of possible values, in this case range
128 and accuracy 6 108 . The scaling factor can vary between 21 and 230 where
a larger scaling factor means higher accuracy but a smaller range.
3.2.2
Code structure
Figure 3.14 shows a block diagram over the control structure in the hardware
implementation. It can be compared to Figure A.1. A flow chart of the program
code is shown in Figure 3.15. The program contains the following parts:
Input reading
The gimbal controller has the ability to read input data from a computer via serial communication (USB converted to UART). The input data consists of strings
which are interpreted by the controller. The data is usually a new desired angle
d or angular velocity d in the camera space but it has also been used for setting
desired joint positions d or joint angular velocities d and new PID controller
parameters.
Update of joint states
The rotary encoder on gimbal axis i measures its current angular position and
sends it as a 10 bit binary number to the control unit. The control unit scales the
number to an angle i in radians (in IQ24 presentation, section 3.2.1). i , which
originally lies in the range 0...2, is also converted to lie in the range .... This
means i = 0 on the gimbal is 180 degrees from angle 0 on the encoder.
3.2
Hardware Implementation
47
(3.6)
The angles i and the angular velocities i are filtered using a simple exponential
moving average:
1
1
i = i + i,raw
(3.7)
2
2
and
3
1
i = i + i,raw ,
(3.8)
4
4
where i,raw and i,raw are the unfiltered angular position and velocity in the
current sample. The smoothing factors a = 12 and a = 14 were only roughly tuned
until an acceptable balance between accuracy and smoothness was believed to be
found.
Update of IMU states
The gyros on the IMU close to the camera mounting point measures the current
iT
h
yaw, roll and pitch angular velocities = yaw , roll , pitch of body 3 around
its own axes. It is set to measure in the range of 0... 2000 /s and sends the
measured angular velocities to the control unit as 15 bit binary numbers which
are then scaled to radians in the IQ24 representation (section 3.2.1). The measurements are calibrated by subtracting a bias measured at the beginning of each
gimbal session.
is used to calculate the current angular position relative to the ground . As
mentioned in section 2.1.2 attitude calculations using the measured angular velocities suffer from angular drift due to accumulated measurement errors. A simple approximate integration of using the sample frequency Fs in this case also
caused problem with angular drift. This was however solved by the use of a complementary filter already written by IA. The details of this filter were not studied
enough to be presented in this thesis but basic function is to integrate the by gyro
measured angular velocity to an attitude which is filtered using the translational
acceleration . This acceleration is measured by accelerometers on the IMU and
are sent to the control unit in a similar way as the angular velocities.
Inverse kinematics
The desired camera angular position d or the desired camera angular velocity
d is transformed to reference signals to the joint controllers in the same way as
in section 3.1.2 using equations in section 2.2.2 and equation (3.4).
48
The code for the PID-controllers was written in according to Algorithm 3.1. The
accumulated integral term I, the additional term a and the proportional part p
are stored in a static structure to be used in the next sample. In total there are 6
structures, one for each joint state.
As in the simulation environment in section 3.1.2 the angular position controller
takes the desired angular positions from the inverse kinematics as reference signals and outputs the desired angular velocity for each axis. These angular velocities are added to the desired angular velocities d from the inverse kinematics
which become reference signals to the angular velocity controller. The output
from the angular velocity controller is a number between 0 and 1 in the IQ24
representation. This number is rescaled to an integer between 0 and 1000 which
is the permille () of the PWM signal to the motor output ports, or the permille
of the maximum voltage to the motors. The voltages create a torque on each
motor according to section 2.3.2, which sets the gimbal in motion.
Figure 3.14: Block diagram of the control structure in the gimbal hardware
implementation.
3.2
Hardware Implementation
49
Figure 3.15: Flow chart of one loop in the gimbal control code after initiation
and calibration.
3.2.3
Control tuning
The PID-controllers of the gimbal were tuned by first applying the PID parameters which were tuned in the simulations described in section 3.1.2. These were
then adjusted to attain acceptable performance in the real application.
Angular velocity
The PID-parameters from the simulations (section 3.1.2) yielded unstable results
when used in the real gimbal control. The approach to tune the controller parameters on each axis was to keep the proportional gains K from the simulations
and adjust the integral time Ti until performance was deemed acceptable. This
resulted in the responses in Figures 3.16 to 3.18 and the parameters in table 3.1.
Two of the gain parameters K were also slightly adjusted. The results of the
angular velocity control became somewhat oscillative but still but were still considered acceptable with a balance between rise time, oscillations and accuracy.
Worth mentioning is the difference in behaviour between the first and second
transients in Figure 3.16 where the angular velocity in yaw axis steps back 0
rad/s are much more oscillative than the first steps. A possible explanation is the
nonlinear behaviour in the Yaw axis. The gimbal turns to around 180 degrees
during both motions and stops in the same angular position where the behaviour
of the joint is different from the behaviour when the yaw axis is in angular position 0 degrees. Another set of controller parameters would be more appropriate
in this angular position. It is also worth to notice that the pitch signal in Figure
3.18 is much noisier when the gimbal is given a angular velocity than when the
50
angular velocity is zero. A possible explanation is that the motion itself induces
small vibrations in the joint and in the body.
Table 3.1: Angular velocity PI parameters in the real gimbal control, parameters from simulations in parentheses.
Axis (direction)
K
Ti
Yaw (+)
1.5(1.5)
0.05(0.007)
Yaw (-)
1.5(1.8)
0.05(0.008)
Roll (+)
0.8(0.8)
0.05(0.02)
Roll (-)
0.4(0.5)
0.05(0.02)
Pitch (+)
0.08(0.08) 0.01(0.005)
Pitch (-)
0.07(0.07) 0.01(0.005)
The relatively large difference between the Ti parameters from the real control
and from the simulations can be explained by looking at the angular velocity
rise times in the figures with the adjusted friction parameters in section (2.4.1).
The rise time of the simulation in Figure 2.5 is for instance relatively close to
zero whereas the actual rise time is longer. In tuning methods, such as ZieglerNichols or strm-Hgglund [Glad and Ljung, 2006, p. 56] where step responses
are used to get reasonable values of the control parameters, the integral time Ti
is proportional to the rise time which means that a longer rise time demands a
longer integral time. If Ti is too small, it will create a too large integral term in
the control (see Algorithm 3.1).
3.2
51
Hardware Implementation
Figure 3.16: Step responses of the angular velocity in the yaw axis with
tuned PID parmeters. Figure a) shows a step from 0 to /4 rad and b) a
step from 0 to /4 rad.
52
Figure 3.17: Step responses of the angular velocity in the roll axis with tuned
PID parmeters. Figure a) shows a step from 0 to /4 rad and b) a step from
0 to /4 rad.
3.2
53
Hardware Implementation
Figure 3.18: Step responses of the angular velocity in the pitch axis with
tuned PID parmeters. Figure a) shows a step from 0 to /4 rad and b) a step
from 0 to /4 rad.
54
Angular position
The gains K for the angular positions of the gimbals axes were adjusted from 50
to 40 in order to obtain smoother results. Figures 3.19 to 3.21 show the desired
angular position and with IMU estimated angular position of the camera. Figure
3.21b also shows the desired and measured angular position in the pitch joint to
illustrate the nature of the angular position estimates. The overshoots in Figure
3.21b occur because the complementary filter mentioned in 3.2.2. The filter uses
both integration of the angular velocities from the gyros and the direction of the
translational acceleration from the accelerometers. The angular velocity part is
very sensitive to changes but the acceleration part reacts much slower so it takes
a while before the estimates are adjusted. The positional control follows this
adjustment.
Figure 3.19: Step response of the angular position in the yaw axis with tuned
PID parmeters. Step from 0 to /4 rad.
3.2
55
Hardware Implementation
Figure 3.20: Step responses of the angular position in the roll axis with tuned
PID parameters. (a) shows a step from 0 to /4 rad and (b) a step in the
negative direction to illustrate the significant rise time difference between
the directions.
56
Figure 3.21: Step responses of the angular position in the pitch axis with
tuned PID parameters. (a) shows the angular position estimated in the complementary filter (Section 3.2.2). (b) Shows the angular position in joint
space (bold curve) and the desired joint angular position (solid, thin curve).
The dashed curve is the angular position in IMU space, same as in (a).
3.2
Hardware Implementation
3.2.4
57
Gyro stabilization
Tests were done to determine the gimbal controllers ability to perform active
stabilization of the camera. This was done by comparing a measured motion in
body frame (0) to the motion in body frame (3) (see Figures 2.1 and 2.2). The
measurements in frame (3) were done with the IMU connected to the gimbal
control unit and the measurements in frame (0) were done with a second IMU
connected to a separate control unit. The two control units were not synchronized
so the same disturbance motion was recorded at different times by the two units.
This time difference was about 1.5 seconds. There was also an angular drift in
the yaw axis of the IMU on body (0) but, as testing was mainly concerned with
the local amplitudes and frequencies and not the angular position, this did not
cause a problem.
Figures 3.22 to 3.24 show the results from tests where the entire gimbal was given
a motion in one axis at a time. The gimbal was held by hand in body (0) and was
turned in the yaw axis or rocked in the roll and pitch axis of that body. Figure
3.25 shows the results when the gimbal was moved in all three axes. All these
measurement started in the IMU angular position = (0, 0, 0)T .
58
Figure 3.22: The result from a test of the gyro stabilization in the yaw axis.
(a) shows the measurement of the motion of the entire gimbal measured with
a IMU attached to body (0) (Figure 2.1). (b) shows the motion of body (3)
measured with the IMU there. The measurements were not synchronized,
the upper measurement started about 1.5 s before the lower.
3.2
Hardware Implementation
59
Figure 3.23: The result from a test of the gyro stabilization in the roll axis. (a)
shows the measurement of the motion of the entire gimbal measured with
a IMU attached to body (0) (Figure 2.1). (b) shows the motion of body (3)
measured with the IMU there. The measurements were not synchronized,
the upper measurement started about 1.5 s before the lower.
60
Figure 3.24: The result from a test of the gyro stabilization in the pitch axis.
(a) shows the measurement of the motion of the entire gimbal measured with
a IMU attached to body (0) (Figure 2.1). (b) shows the motion of body (3)
measured with the IMU there. The measurements were not synchronized,
the upper measurement started about 1.5 s before the lower.
3.2
61
Hardware Implementation
Figure 3.25: The results from a test of the gyro stabilization in all three axes
where the gimbal was rocked in all three directions. The figures to the left
show the measurements of the motion of the entire gimbal measured with
a IMU attached to body (0) (Figure 2.1). The figures to the right show the
motion of body (3) measured with the IMU there. The measurements were
not synchronized, the measurements to the left started about 1.5 s before the
ones to the right.
62
The results are similar to the results from the simulations in section 3.1.3. The
ability to stabilize differs between the axes. The pitch axis has a very good stabilization while the ability in the roll and yaw axis is poorer when the frequency
is increased to somewhere around 1 to 2 Hz. This, again illustrates the need for
much stronger actuators to obtain the needed angular velocities.
This final chapter contains some conclusions drawn in this thesis, thoughts on
what could have been done differently, and suggestions for future work.
4.1
The model of the gimbal derived in chapter 2 in this thesis does not exactly match
the behaviour of the real gimbal but is, for instance, sufficient for development
of control structures. One of the hardest parts of this work was to verify that the
transformations between the different coordinate frames were correct. This was
done by moving the joints of a crude little physical model of the gimbal and performing the same motions in the simulation environment. It was important that
this was done before the hardware implementation in order to avoid damages to
the gimbal due to unexpected motions.
The method using Lagrange equations with link transformation matrices in section 2.3.1 provides a way to calculate the dynamic model using fairly simple programming in Matlab. However the calculation did take a lot of time, especially
if simplification algorithms were used in the process. The expressions did also
became very cumbersome. They was improved slightly by transferring them to
Mathematica and using the simplification algorithms included in the program.
The results would probably be even better, in terms of faster computations and
more compact expressions, if all calculations had been done using Mathematica
or other tools for symbolic calculations.
63
64
4.1.1
As mentioned in the end of section 2.3.2 the actuators could be treated as separate
bodies in the model, this to to allow testing of different motors and gearboxes
without the need to calculate an entirely new model. This would also have been
useful to find more powerful actuators and also test how the performance was
affected by their increased size and mass..
Parameters of the gimbal were taken from drawings in CAD software. The same
kind of software could be used to simulate a multi body systems and even develop control systems around them. However, this possibility was not studied in
this thesis. One argument for the mathematical modelling method used in this
thesis is that it is, in principle independent of expensive software (even tough the
dimensions and masses could be less accurate if measured by hand and the calculations would be tedious without proper linear algebra software). The accuracy of
the model would probably increase with more powerful tools for identification
of unknown parameters, mentioned in section 2.4. Simulations could also be
done in any programming language, provided differential equation solvers were
available.
4.1.2
As explained in section 2.4.1 model accuracy can be improved by more sophisticated identification methods. This would create a model accurate enough to be
used in model based control methods or as residuals in diagnostics systems. Implementing the model in hardware would probably require a more powerful processor and better simplification algorithms to get less complicated expressions.
Modelling methods where powerful mechanics software is used should also be
evaluated.
4.2
The control system of the gimbal was only developed to perform around one
point ( = (0, 0, 0)) and did not get more advanced controllers than a P-controller
for angular position and a PI-controller for angular velocity of each axis. One
big advantage of PI(D)-controllers is that they are relatively simple to work with
for someone with limited prior knowledge of control theory. The hardest part of
the control design, apart from the work of writing the code, was to derive and
verify the transformations between camera and joint frames. This needed to be
done with great care to avoid unexpected motions that could potentially damage
the gimbal. The implementation was successful and no unexpected motions were
observed.
4.2
4.2.1
65
The sample rate in the control system was set quite low (100 Hz). Higher sample
rates would probably give some performance improvement. The low sample rate
was mainly to avoid data loss in the serial communication between the gimbal
and a computer.
4.2.2
Figure A.1 shows the control structure in the Simulink environment. In broad
strokes, it can be interpreted in the following way: The blocks in the upper part
of the structure pertain to states in joint coordinate space; control of joint angular
position and velocity in interaction with the mathematical model of the gimbal.
The "invpos" and "invel" blocks in the middle of the structure are the transformations between IMU coordinate space and joint space. The blocks in the lower
right corner model the behaviour of the gyros (and the magnetometer) in the
IMU and external manipulation of the gimbal. More detailed descriptions of the
control structure can be found in section 3.1.2.
67
68
Bibliography
69
70
Bibliography
Upphovsrtt
Detta dokument hlls tillgngligt p Internet eller dess framtida ersttare
under 25 r frn publiceringsdatum under frutsttning att inga extraordinra
omstndigheter uppstr.
Tillgng till dokumentet innebr tillstnd fr var och en att lsa, ladda ner,
skriva ut enstaka kopior fr enskilt bruk och att anvnda det ofrndrat fr ickekommersiell forskning och fr undervisning. verfring av upphovsrtten vid
en senare tidpunkt kan inte upphva detta tillstnd. All annan anvndning av
dokumentet krver upphovsmannens medgivande. Fr att garantera ktheten,
skerheten och tillgngligheten finns det lsningar av teknisk och administrativ
art.
Upphovsmannens ideella rtt innefattar rtt att bli nmnd som upphovsman
i den omfattning som god sed krver vid anvndning av dokumentet p ovan
beskrivna stt samt skydd mot att dokumentet ndras eller presenteras i sdan
form eller i sdant sammanhang som r krnkande fr upphovsmannens litterra
eller konstnrliga anseende eller egenart.
Fr ytterligare information om Linkping University Electronic Press se frlagets hemsida http://www.ep.liu.se/
Copyright
The publishers will keep this document online on the Internet or its possible replacement for a period of 25 years from the date of publication barring
exceptional circumstances.
The online availability of the document implies a permanent permission for
anyone to read, to download, to print out single copies for his/her own use and
to use it unchanged for any non-commercial research and educational purpose.
Subsequent transfers of copyright cannot revoke this permission. All other uses
of the document are conditional on the consent of the copyright owner. The
publisher has taken technical and administrative measures to assure authenticity,
security and accessibility.
According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected
against infringement.
For additional information about the Linkping University Electronic Press
and its procedures for publication and for assurance of document integrity, please
refer to its www home page: http://www.ep.liu.se/
Jakob Johansson