You are on page 1of 63

AUTONOMOUS QUADCOPTER NAVIGATION

A Project

Presented to the faculty of the Department of Electrical & Electronic Engineering

California State University, Sacramento

Submitted in partial satisfaction of


the requirements for the degree of

MASTER OF SCIENCE

in

Electrical & Electronic Engineering

by

Justin Sticksel

FALL
2014
AUTONOMOUS QUADCOPTER NAVIGATION

A Project

by

Justin Sticksel

Approved by:

__________________________________, Committee Chair


Professor Fethi Belkhouche

__________________________________, Second Reader


Professor Russell Tatro

____________________________
Date

ii
Student: Justin Sticksel

I certify that this student has met the requirements for format contained in the University format

manual, and that this project is suitable for shelving in the Library and credit is to be awarded for

the project.

__________________________, Graduate Coordinator ___________________


Prof. Preetham B. Kumar Date

Department of Electrical & Electronic Engineering

iii
Abstract

of

AUTONOMOUS QUADCOPTER NAVIGATION

by

Justin Sticksel

UAV's have become more versatile and prevalent in recent years. Due to their relatively

low cost, and ability to operate without endangering a human pilot they are becoming more

attractive for the civilian market as well as military applications. For this project an autonomous

control system will be created for a RC quadcopter. The system will utilize multiple sensors to

track the vehicle's movement, and use this information in a control system to enable the vehicle to

fly without human intervention. The systems will be simulated, and a working prototype will be

constructed to test their effectiveness.

_______________________, Committee Chair


Professor Fethi Belkhouche

_______________________
Date

iv
TABLE OF CONTENTS
Page

List of Tables ......................................................................................................................... vii

List of Figures ....................................................................................................................... viii

Chapter

1. INTRODUCTION ............................................................................................................. 1

2. HARDWARE ..................................................................................................................... 5

2.1 Overview................................................................................................................ 5

2.2 Project Vehicle & Control Board........................................................................... 5

2.3 Sensors ................................................................................................................... 7

2.4 Analog Signal Conditioning .................................................................................. 9

2.5 Inertial Measurement Unit .................................................................................. 10

2.6 Serial Peripheral Interface.................................................................................... 11

2.7 Cyclic Redundancy Check ................................................................................... 12

2.8 Inter-Intergraded Circuit Interface ....................................................................... 13

2.9 Navigation Control PIC ....................................................................................... 14

2.10 Pulse Width Modulation Motor Driver Control................................................. 14

2.11 Ultrasound Measurement Unit ........................................................................... 15

2.12 Circuit Board...................................................................................................... 15

3. INERTIAL MEASUREMENT UNIT SOFTWARE ........................................................ 17

3.1 Overview.............................................................................................................. 17

3.2 Data Representation ............................................................................................. 17

v
3.3 Rotation Equations ............................................................................................... 19

3.4 Butterworth Filtering ........................................................................................... 23

4. DISCRETE KALMAN FILTER ...................................................................................... 26

4.1 Simulation ............................................................................................................ 30

5. NAVIGATION CONTROL PROCESSOR...................................................................... 34

5.1 Overview.............................................................................................................. 34

5.2 Vehicle Modeling ................................................................................................ 34

5.3 PD/PID Controller ............................................................................................... 37

5.4 Simulation ............................................................................................................ 40

5.5 Flight Control....................................................................................................... 44

6. IMPLEMENTATION & TESTING RESULTS ............................................................... 46

7. CONCLUSION .................................................................................................................. 50

Bibliography ........................................................................................................................... 52

vi
LIST OF TABLES
Tables Page

1. Butterworth Filter RMSE Improvements .......................................................................... 24

2. Data Gathering Test Flight Sequence ................................................................................ 31

vii
LIST OF FIGURES
Figures Page

1. Control Board Connection Diagram.................................................................................... 6

2. Quadcopter Platform With Control Circuit ......................................................................... 7

3. Analog Filtering Layout .................................................................................................... 10

4. Body Frame Axis Orientation ........................................................................................... 18

5. Static Gyroscope Measurements ....................................................................................... 21

6. Static Accelerometer Measurements ................................................................................. 22

7. Magnetometer Static Measurements ................................................................................. 22

8. Static Accelerometer Measurements After Butterworth Filtering...................................... 25

9. Gyroscope Based Vehicle Tracking .................................................................................. 32

10. Accelerometer Based Vehicle Tracking ............................................................................ 32

11. Kalman Filter Vs. Gyroscope Vehicle Tracking ............................................................... 33

12. Hand Tuning Control Equations Without Noise ............................................................... 41

13. Hand Tuning Control Equations With Noise .................................................................... 42

14. PD/PID Weight RMS Error Calculations ...................................................................... … 43

15. Flight Testing ..................................................................................................................... 49

viii
1

CHAPTER 1 - INTRODUCTION

The goal of this project is to create an autonomous control system for a small

aerial vehicle. For this project a quadcopter is used as the platform. An onboard control

system is developed and tested for the vehicle. The control system is to be a self

contained unit, which will allow the quadcopter to maintain stable flight in an outdoor

environment without human intervention.

With advancements in research and development allowing unmanned aerial

vehicles (UAVs) to become more versatile, they are becoming more commonplace.

UAVs such as the military's Predator drone are capable of performing many roles, more

efficiently, and cheaper than traditional aircraft. Due to this the United State's

government is beginning to expand their use. With this in mind, developing a small,

cheap, electrically powered platform that can provide reliable information has the

possibility of fulfilling current roles such as security, surveillance, and search and rescue.

Currently UAVs have been in use for almost two decades with the Predator drone

first being flown in 1994 ("Predator UAS"). UAVs have been used for many different

applications since, but the military still has the largest variety of UAV applications.

Currently the Predator drone fulfills multiple roles for the U.S. military such as

"intelligence, surveillance, reconnaissance, close air support, combat search and rescue,

precision strike, buddy-lase, convoy/raid overwatch, route clearance, target development,

and terminal air guidance" (MQ-1B Predator).

With their flexibility, UAVs are making their way into the civilian world. The

U.S. government used a Predator drone in the 2013 California Rim Fire in Yosemite
2

National Park (Skoloff). During the fire the drone was used to provide "data directly back

to the incident commander, allowing him to make quick decisions about which resources

to deploy and where" (Skoloff). NASA has also begun to use drones for scientific

purposes. Using a Northrop Grumman Global Hawk platform, NASA is able to

"support... science customers and other customers who need access to a high-altitude,

long endurance (HALE) system" ("NASA Global Hawk"). Currently the drone has been

used to "examine... hurricanes, their formation process, and... other weather phenomena"

("NASA Global Hawk"). NASA is not alone in their drive to monitor natural events

using drone technology. The University of Colorado currently uses drones with onboard

sensors to track weather phenomenon (Detwiler). The government has also begun to use

the Predator drone for border control. Currently "Eight Predators fly for the Customs and

Border Protection agency." These drones "patrol most of the southern boundary, from

Yuma, Ariz., to Brownsville, Tex." (Booth). While not watching for illegal border

crossing, these drones are sometimes also loaned to police forces and other local

agencies. In 2012 the drones were loaned out 250 times in order to "investigate fishing

violations, search for missing persons and inspect levees along the Mississippi River,

among other things" (Sengupta).

While an airplane platform is currently more commonplace, they are not the only

type of platform that is being utilized. The U.S. Navy is currently working with Northrop

Grumman to develop a helicopter based UAV called the Fire Scout. The helicopter

platform for this model provides the advantage having interchangeable parts with current

aircraft as well as of being able to "take off and land on any aviation-capable warship and
3

at prepared and unprepared landing zones in proximity to the soldier in contact" ("Fire

Scout").

As usage of UAVs expands, new developments are constantly in progress in order

to meet evolving requirements. One new ability in development is the capability to land

on an aircraft carrier. Not only does the type of landing put more stress on the airframe,

requiring a different platform design, but it also requires a very accurate control system in

order to land on a moving object. This project recently had a successful test, which

marked the first time a "tailless, unmanned autonomous aircraft landed on a modern

aircraft carrier" (Vinson). Another project by Northrop Grumman is developing an

advanced aerial target system. This project allows the military to "simulate tactical threats

by enemy aircraft and missiles for defense readiness training, air-to-air combat training

and the development and evaluation of weapons systems" ("BQM-34 Firebee..."). While

some of these goals seem achievable by current drones, the ability to perform air-to-air

combat training is a major leap ahead in terms of drone capability. The drones goal of

being able to fly 10 ft above sea level also provides a level of training ability that would

not normally be risked with a human pilot on board the aircraft. Research is also being

done to allow drones to navigate in urban like environments. UC Berkeley has tested real

time obstacle avoidance methods, as well as methods to prevent airborne collisions with

trajectory reevaluation algorithms. ("Obstacle Avoidance..."). Although large progress is

being made with traditional vehicle platforms, new possibilities are being opened as new,

innovative platform designs are being tested. Harvard's Microrobotics laboratory has

developed an aerial drone small enough to fit on the end of one's finger. The hope is that
4

the new technology can be used to pollinate crops in farmers fields and monitor traffic, in

addition to more common drone applications ("Robobees").

With this project there are two main challenges to overcome. The first is creating

a reliable navigation system that can quickly monitor the vehicle's state over extended

periods of time. The second is making a control system that utilizes this information, and

accurately controls the vehicle's movements to perform a pre-defined course. The

challenge in creating a navigation system that is reliable over extended time periods is

creating a system that can minimize the effects of errors from sources such as

mathematical integration, and electrical motor noise. While performing these navigation

tasks the system also must operate fast enough to provide data to the control system in

time to make necessary corrections. The control system must be tuned specifically for the

vehicle and the type of maneuvering desired. The system must respond fast enough in

order to keep the vehicle's orientation in a limited safe range, however overcompensating

can create a situation where the system fights itself until the aircraft loses control. These

requirements also change based on the required maneuverability of the aircraft, which is

not high in this research project's case.


5

CHAPTER 2 - HARDWARE

2.1 Overview

In order to control the vehicle used in this project a circuit board was

created. This chapter will discuss the hardware used on the board. The components used

on this board will be reviewed, as well as the benefits that led to their selection. The

hardware interfaces used to connect the board's components, as well as the process used

to create the board will also be discussed.

2.2 Project Vehicle & Control Board

For this project an Aerosky model H100 quadcopter platform is used. This

platform was selected due to its design's natural stability, payload capacity, and relatively

low noise generation. The platform included the frame, four motors, motor drivers, and a

radio control circuit. The radio control circuit was removed, and a custom made control

board was installed to control the airframe. Two Microchip PIC 32-bit microcontrollers

are used to control the platform during operation. One microcontroller is tasked with

performing the duties of an inertial measurement unit (IMU), using angular velocity,

acceleration, and compass direction, to determine heading. The other microcontroller

performs the navigation controls for the vehicle. A connection diagram for the control

circuit board is shown in Figure 1.


6

Figure 1 - Control Board Connection Diagram

The IMU processor uses two gyroscopes to measure angular velocity. Integrating

the angular velocity measurement directly allows for faster measurement response time.

This integration also causes the accumulation of errors over time, which becomes

extremely detrimental. To counter this error accumulation, an accelerometer is used as a

back up sensor for the IMU. An accelerometer provides a measurement of the

accelerations acting on the vehicle frame. If the vehicle is not exposed to a net force, then

the accelerometer can provide a fixed orientation measurement, in the direction of the

earth's gravitational pull. These readings are used to augment the gyroscope heading

measurement via a Kalman filter. This provides a heading that is much more stable over

long periods. This also gives the IMU greater accuracy and noise resistance over long

operation intervals. The second microcontroller receives the heading information from

the IMU via a serial peripheral interface (SPI) module. It then uses that information to

control each motor's speed through a series of pulse width modulation (PWM) signals,
7

which in turn govern the movement of the platform. The platform is powered from a

single 11.1V three cell 3300mAh lithium polymer battery. The assembled quadcopter and

control circuitry is shown in Figure 2.

Figure 2 - Quadcopter Platform With Control Circuit

2.3 Sensors

In order for the IMU to accurately track the platform's heading over time, two

dual axis gyroscopes are used. The gyroscopes used are manufactured by ST

Microelectronics, part number LPY503AL. These micro-electro-mechanical system

(MEMS) gyroscopes were selected for various reasons. Since the gyroscopes measure

two axes, mounting the second module rotated ninety degrees offset with respect to the

first allows measurement of roll, pitch, and yaw. Using the same sensors also provides

closely matched inputs in terms of type, offsets, and scaling. This simplifies development

and provides easier comparison between inputs. The sensors provide their measurement
8

via an analog output with a sensitivity of 8.3 mV deg/s (LPY503AL 5). Although the

analog sensors come with the risk of greater noise influence in the sensor output, they

also allow for more flexibility in terms of hardware filtering, measurement resolution,

and measurement update frequency. Another feature that made this device attractive was

the built in self test function. This ensures the device is responding before operation. Low

power consumption, basic integrated output filtering, and optional amplification of the

output signal are also benefits to this sensor.

The IMU also requires acceleration measurements in order to reliably track

orientation over extended time periods. A single tri axis accelerometer is used for this

purpose. The accelerometer used is also manufactured by ST Microelectronics, part

number LIS352AX. This sensor is also a MEMS type, with analog outputs. One

advantage of using this chip is that all three required measurements are built into the

same chip. The sensor also offers a self test mode similar to the gyroscopes. This sensor

has a sensitivity of 0.363 V/g, with an accuracy of +/- 5% (LIS352AX 5). Other features

of this sensor such as a multiplexed analog output were not used in the final design, but

considered as possible benefits during the selection process. Both the accelerometer and

gyroscopes were also offered in small, surface mount packages. This allowed for more

compact, and lighter printed circuit board (PCB) design. Although the accelerometer is

well suited for backing up the roll and pitch measurements from the gyroscopes, it is

unable to back up the yaw measurement. In order to keep the yaw measurement reliable,

a magnetometer is used as a back up sensor. The sensor used for this project is a

Honeywell HMC5883L three axis digital compass. This device is used due to its small
9

layout, 1- 2° accuracy, and digital interface (HMC5883L... 1). The interface for this

sensor is I2C communication, which the IMU processor has a specific peripheral to allow

for faster interfacing with less required processing.

2.4 Analog Signal Conditioning

In order to improve signal quality, all sensors inputs were filtered. The analog

filtering layout is shown in Figure 3. In this setup the sensor signal is first fed through a

low pass filter, and then a unity gain buffer. Since the input signal is multiplexed through

the analog to digital converter (ADC), the time constants of the analog filtering network

are of a concern. In order to provide accurate measurements, the voltage rise time

between multiplexed signal switching must be accounted for. The initial filtering stage

provides the lowest cutoff frequency for the configuration. A unity gain buffer is used to

prevent the relatively large time constant of this phase of the filter from affecting the

multiplexed signal switching speed. After the low pass filter, the inputs are fed into the

ADC multiplexer. The multiplexer output is then fed into an instrumentation operational

amplifier (IOA). The IOA provides several benefits to the circuit. Firstly it removes some

of the sensor offset bias voltage. It also provides a small gain so the sensor output voltage

matches the full voltage input range of the ADC. The input and output of the IOA also

have low pass filters to help reduce noise. The cutoff frequencies for these filters are

much higher to reduce the multiplexing switching delay. A small delay is important

since, as a rule of thumb, an operating frequency of at least 100 Hz is required for

effective control of this type of system. With input sensor averaging considered, the
10

component values used in the analog system provided a theoretical maximum operating

frequency of 234 Hz (Walsh).

Figure 3 - Analog Filtering Layout

2.5 Inertial Measurement Unit

The IMU circuit for this project uses a PIC32MX575F512H microcontroller. The

IMU portion occupies the left hand side of the PCB in Figure 2. The PIC 32 line of

microcontrollers allows for faster data manipulation than other series PICs, due to its 32-

bit architecture. This is important due to intensive 32-bit floating point variable use in

this application. The increased calculation speed, as well as the fast processor speed of

80MHz allows the IMU operating program to run at 183 Hz, which increased

performance over previously tested processors (PIC32MX5XX ... 1). Another benefit of

the PIC 32 is that it can be coded using mostly ANSI C, rather than a platform specific

code. This allows for faster and easier programming. For this project Microchip's XC32

version of C is used. The PIC 32 also offers a wide variety of peripherals, which are built
11

in hardware modules that perform tasks separate from the main program flow. Using

these modules, a much greater number of operations can be performed with fewer

interrupts, less overhead, and minimal coding. The IMU uses three serial peripheral

interface (SPI) modules for communicating with the external AD7091 ADC, SD Card,

and the navigation control processor. The IMU also uses a single I2C peripheral to

communicate with the magnetometer.

2.6 Serial Peripheral Interface

SPI is a synchronous full duplex serial communication protocol provided as a

peripheral on the PIC32 microprocessors used for this project. The SD card and AD7091

ADC interfaces are both hard wired to use SPI. SPI was also used for communication

between the IMU and navigation control processors. In a SPI communication system one

device is designated master, and the other slave. In this application the IMU is designated

the slave device, and the navigation control microprocessor the master. SPI has a four

line communication interface configuration. Two of the lines are data lines, one in each

direction. The third line is a clock signal to synchronize the modules together. The last

line is used as a frame synch pulse in this application (Serial Peripheral Interface... 18).

In order to quickly transmit the 32-bit floating point data, a 32-bit transmission length

was selected with a transmission baud rate of 1 MHz. In order to synchronize the data

transmission timing, the frame synch line signals the start of a transmission by sending an

active low signal one clock cycle before data transmission begins. After the frame synch

signal, data is transmitted most significant bit first on both data transmission lines (Serial

Peripheral Interface... 17). Despite the synchronization built into the system, it was
12

determined through testing that a cyclic redundancy check (CRC) was needed in order to

ensure data accuracy.

Despite SPI providing full duplex communication, data transmission between

microcontrollers is coded as half duplex. The data transmission process begins with the

master requesting the required variable from the slave, following with the CRC value for

the request. The slave then processes the request and checks the CRC value sent. If the

value matches the CRC calculated by the slave, the required variable and its CRC are

transmitted. An error signal is sent instead when (or if) the CRC values don't match. The

master then processes the received data and CRC to ensure the correct value has been

captured. The values are then either used or discarded based upon the results. Data

transmission then repeats in this manner for the duration of the program.

2.7 Cyclic Redundancy Check

In order to reduce data transmission errors in the SPI process, a CRC algorithm is

implemented. For this implementation a table driven 16 bit algorithm is used. This

method provides high error detection rates, while still allowing for fast processing times.

The generator polynomial 0x8005 and an initial value of zero is used from the CRC-16

standard. A commonly used generator polynomial was selected, as the value has a

significant influence on the algorithms ability to detect errors (Koopman 1). For faster

processing time a CRC table is generated by both master and slave devices on start up.

Several commonly used values such as data requests and their respective CRC values are

also pre-defined and stored in memory to save on computation time. Once initialized the
13

algorithm checks the data transmissions and greatly reduces the probability that any

corrupted data is used by the navigation control microprocessor.

2.8 Inter-Intergraded Circuit Interface

The HMC5883L magnetometer used for this project requires the use of an Inter-

Integrated Circuit (I2C) communication protocol. I2C is a serial half duplex protocol

designed to interface multiple components using only two data lines. I2C communication

is formatted into component blocks. A normal transmission begins with a start block,

followed by a destination device address transmission with a read or write indication. The

transmission initiator then waits for an acknowledge signal from the target device. If the

signal is received, data is transmitted with a pause for a acknowledge signal from the

target device after each 8th bit. Finally the transmission is either ended with a stop block,

or restart block is sent to begin communications again. The HMC5883L conforms to this

standard for configuring internal registers in the device. For data retrieval the device has

a more efficient method of communication. Once the device is configured, the user is

only required to set the HMC5883L to the first data register address, and then may send 6

read requests to retrieve all measurement data. The HMC5883L automatically increments

the register pointer after each read, eliminating the need to send the device address and

desired register before each data retrieval. This results in the data retrieval requiring one

third the amount of time it would take with a standard block organization, which vastly

reduces the amount of time dedicated to retrieving data from the device.
14

2.9 Navigation Control PIC

The navigation control microprocessor selected for this project is also a

Microchip PIC32MX575F512H. Along with a SPI peripheral used to communicate to the

IMU, the navigation control microcontroller also utilizes a built in 10 bit ADC peripheral.

The controller also uses peripherals for generating four PWM signals. These peripherals

are used to interface to the ultrasound detector and the motor drivers respectively. The

control portion of the project board occupies the right half of Figure 2.

2.10 Pulse Width Modulation Motor Driver Control

The motor drivers provided with the platform were Hobbywing Skywalker part

number 40A units. A PWM signal is used to interface to the drivers. Each signal is

separately generated and controlled via an Output Compare peripheral provided with the

navigation control microprocessor. The peripherals operate off the 80MHz internal clock

signal from the microcontroller, and allow for a duty cycle resolution of over 17 bits

(Output Compare 16). The signal generated operates at 485 Hz, with inputs ranging from

50-100% duty cycle. The motor drivers also come equipped with a built in lock out

function to prevent the user from injuring themselves upon accidental start-up. In order to

control the motor drivers, a 50% duty cycle signal must be applied to each driver for

approximately 1s. A 50% duty cycle also corresponds to an off signal, which keeps the

motors stationary once unlocked. After this the motors are linearly controlled by

adjusting the duty cycle between 55-100%, with 100% corresponding with the maximum

motor speed.
15

2.11 Ultrasound Measurement Unit

In order to measure the platform's altitude an ultrasound range finding device is

used. The ultrasound unit selected for this application is manufactured by MaxBotix Inc.

This unit is capable of measuring from 0-254", with a 1" resolution (LV-MaxSonar... 1).

It also uses the same ultrasound transceiver for emission and reception, and therefore is

half the size of other units examined. This made the unit lighter, at only 4.3g, and easier

to mount (LV-MaxSonar... 1). The unit also has multiple output types, which provide

greater flexibility in the design. A analog output format was selected for the final design

since the navigation control unit can use an ADC peripheral to monitor the measurement,

and it is consistently available. In this mode the output voltage is calibrated to be

Vcc / 512 per inch (LV-MaxSonar... 2). This signal is read using a simple 10 bit ADC

peripheral. Due to the required accuracy of the ultrasound measurement being less than

the IMU inputs, and only a single input, a separate higher accuracy ADC is not used for

this interface. The peripheral ADC also reduces the number of processor cycles required

to retrieve the data from the sensor.

2.12 Circuit Board

For this project, a two layer PCB was created. The top layer contains most of the

power and signal traces, while the bottom layer is a ground plane with minimal signal

traces to reduce EMI as much as possible. The board is segmented into three parts for the

design. The IMU portion of the PCB which mainly consists of the microprocessor,

sensors, and active filtering, is grouped to the left side of the board. The analog sensors,

as well as their conditioning hardware, are grouped to the lower left of the PCB to keep
16

them as far away from the power supply and digital communications as possible. The

navigation control portion of the PCB is located on its right half. It consists of the

navigation control processor, external digital communications, as well as an interface to

the ultrasound sensor. The top of the board is saved for the power regulation circuitry, as

well as the SD card storage for easy access. Pins were also added to the board as test

points and programming interfaces for the microcontrollers. The PCB was designed using

EAGLE from CadSoft. This software allows for both the wiring diagram and circuit

board design to be created in one program. The circuit is designed with trace sizes

ranging from 12 to 32 thousands of an inch. The top and bottom circuit layouts are shown

in Figures 3 and 4, respectively. After the circuit board designs were finished, each layer

was printed onto photo paper using a LaserJet printer. The ink was then transferred to a

circuit board blank using an iron to provide heat and pressure. Once applied, the ink acts

as a protective layer to the copper beneath, and a ferric chloride solution is used to

dissolve the excess copper layer. Once the copper is dissolved, the board is then cleaned

using a solution of acetone. This is repeated for the bottom layer of the board, and it is

then treated with a liquid tin solution to prevent corrosion and promote easier soldering.

Finally the board is drilled, vias are installed, and the board is populated with the required

components.
17

CHAPTER 3 - INETIAL MEASUREMENT UNIT SOFTWARE

3.1 Overview

In order to control the vehicle its orientation must be tracked during operation. To

do this, one PIC microcontroller is dedicated to perform the tasks of an IMU. The

microcontroller uses the gyroscope, accelerometer, and magnetometer sensors to

calculate the vehicle orientation and acceleration. This information is then transmitted to

the navigation controller in order to control the vehicle's movements. This chapter will

explain the methods used in these processes.

3.2 Data Representation

Tracking the vehicle's orientation requires the selection of methods for

representing both the vehicle's orientation, and physical movement. The selection of these

representations also determines the methods for transferring values between the different

frames of reference that these representations create. Euler angles are used to represent

the vehicle's rotational orientation. Euler angles represent the plane rotations roll, pitch,

and yaw about the Cartesian axis along the vehicle's body (Farrell 46). This frame of

reference will be referred to the body frame. Figure 4 shows the body frame orientation

layout for this project. The symbols ϕ , θ , and ψ will be used to represent roll, pitch, and

yaw respectively, with the arrows representing rotation in a positive direction.


18

Figure 4 - Body Frame Axis Orientation

Although Euler angles are fairly intuitive to understand, they do have a major drawback.

An error known as gimbal lock occurs depending on the rotation order selected. In

physical gimbals, this error comes from the vehicle reaching an orientation that reduces

the rotational freedom of the gimbal, from three degrees to two. In electronic orientation

tracking the error causes the tracking equations used to break down. This can cause the

tracking program to fail, or produce divide by zero type errors. In order to avoid this, the

ZYX rotation order is used. This rotation order causes the gimbal lock condition to occur

at an orientation of θ = ± π 2 . Since the quadcopter produces no downward thrust at

these orientations, the control algorithm will prevent the vehicle from reaching either

position. This allows the ZYX rotation sequence to be safely used.


19

3.3 Rotation Equations

Since the vehicle's frame of reference moves along with the vehicle's body, a

static reference frame must be established to track the vehicle's position. The tangent

plane representation is used for this purpose (Farrell 25). The tangent plane of reference

projects a plane tangent to the earth at some point. For this project, the vehicle's initial

orientation is used as this point. From there, the x-axis is defined as pointing north, the y-

axis points east, and the z-axis points down.

With the body and navigation frames defined, the vehicle must be able to transfer

data between the two in order to correctly determine its position and orientation. In order

to track the Euler angle orientation of the vehicle, the measurements taken with respect to

the body frame must be related back to the navigation frame. Defining the orientation

state as x = [φ θ ψ ] , the change in orientation can be tracked using


T

 
 φ  1 tan θ sin φ tan θ cos φ 
dx   
= θ = Bu = 0 cos φ − sin φ u 3.1
dt    sin φ cos φ 
ψ  0 
 
 cos θ cos θ 

where u = [wr w y ] represents the rotational velocity measured in the body frame
T
wp

(De Marina 2). Given this relation, the vehicle's body frame orientation can be tracked

with respect to the navigation frame using equation 3.2.

dx
x = x+t 3.2
dt

It is also useful to be able to transfer measurements such as accelerometer

readings between both frames. In order to do this a direction cosine matrix (DCM) is
20

used. The DCM formation is different for each rotation order used. The individual axis

rotations are shown in equations 3.3 through 3.5 (Ardakani 1-3).

1 0 0 
roll = 0 cos φ sin φ 
 3.3
 
0 − sin φ cos φ 

cos θ 0 − sin θ 
pitch =  0 1 0  3.4
 
 sin θ 0 cos θ 

 cosψ sinψ 0
yaw = − sinψ cosψ 0 3.5
 
 0 0 1

For the ZYX rotation order used in this project, the DCM is calculated as shown

in equation 3.6 and 3.7. For these equations, Rnb represents the rotation from the

navigation frame to the body frame. The transpose of Rnb also provides us with the

rotation from the body frame to the navigation frame Rbn .

 cosψ sinψ 0 cos θ 0 − sin θ  1 0 0 


Rnb = ZYX = − sinψ cosψ 0  0 1 0  0 cos φ sin φ  3.6
   
 0 0 1  sin θ 0 cos θ  0 − sin φ cos φ 

 cos θ cosψ cos θ sinψ − sin θ 



R = − cos φ sinψ + sin φ sin θ cosψ
b
cos φ cosψ + sin φ sin θ sinψ sin φ cos θ  3.7
n  
 sin φ sinψ + cos φ sin θ cosψ − sin φ cosψ + cos φ sin θ sinψ cos φ cos θ 

Although the sensor filtering implemented in hardware reduced the input noise

significantly, the raw sensor inputs were still distorted when they reached the IMU. Input
21

data plots for the gyroscopes, accelerometer, and magnetometer are shown in Figures 5,

6, and 7 respectively. This data was generated with the vehicle stationary, so ideally there

should be no fluctuation in the measured values.

Figure 5 - Static Gyroscope Measurements


22

Figure 6 - Static Accelerometer Measurements

Figure 7 - Magnetometer Static Measurements


23

3.4 Butterworth Filtering

In order to improve the error of the input sensors, the values received were placed

through a Butterworth filter. The most significant sources of noise are the motors on the

vehicle, which generate a high frequency interference. For this reason a second order low

pass Butterworth filter is used. The transfer function for the filter is shown in equation

3.8 (Rangayyan 118).

az 2 + bz + c
H (z )wc = 3.8
dz 2 + ez + f

Where

a = wc 2T 2
b = 2 wc 2T 2
c = wc 2T 2
3.9
d = 4 + 2 2 wcT + wc 2T 2
e = 2 wc 2T 2 − 8
f = 4 − 2 2 wcT + wc 2T 2

For these equations, T is the sampling period, f c is the filter cutoff frequency,

and wc = 2πf c . When the filter is transformed to the z domain, its cutoff frequency is

distorted. In order to correct this, the cutoff frequency must be warped using equation

3.10 (Rangayyan 119).

2  T
wa = tan  wc  3.10
T  2

After transforming the transfer function equation in 3.8 to the z domain, the filter

equation shown in 3.11 is obtained. In this equation Vo represents a filter output, while
24

Vi represents a filter input value. The coefficients also use the prewarped cutoff

frequency wa in place of the standard cutoff frequency wc for equation 3.11.

aVi (z ) + bVi (z − 1) + cVi (z − 2 ) − eVo(z − 1) − fVo(z − 2 )


Vo(z ) = 3.11
d

The Butterworth filter provides smoother input values. Using a motionless data sample,

the input root mean square error (RMSE) values were calculated. Table 1 shows the

RMSE values for the accelerometer and gyroscope before and after filtering.

Table 1 - Butterworth Filter RMSE Improvements


RMSE Comparison

Direct Input Filtered Input Improvement

Gyro Roll 1.121 0.864 22.93%

Gyro Pitch 0.838 0.506 39.62%

Gyro Yaw 0.642 0.408 36.45%

Acc X 0.149 0.051 65.77%

Acc Y 0.147 0.064 56.46%

Acc Z 0.236 0.2 15.25%

Figure 8 also provides an example of the Butterworth filtering improvement on the

accelerometer measurements. Since the accelerometer and magnetometer measurements

have a slower response to the vehicle's movement, the cutoff frequency selected was

lower for their filtering. The benefit of the Butterworth filtering is therefore more obvious

with the measurements from these sensors.


25

Figure 8 - Static Accelerometer Measurements After Butterworth Filtering


26

CHAPTER 4 - DISCRETE KALMAN FILTER

After filtering, the input data from each sensor needs to be fused into a single

representation of the vehicle's orientation. For this project a Discrete Kalman filter is

used to accomplish this. A Kalman filter is a method to "estimate the state of a process, in

a way that minimizes the mean of the squared error" (Welch 1). The advantage of using

the Kalman filter goes beyond fusing all three sensor measurements. In doing so, it

combines the strong points of each sensor, while reducing the negative effects that can be

caused by them. For the sensors used in this project, the gyroscopes provide a fast

measurement response. In order to do this the gyroscope's measurements must be

integrated every time step. Due to this, they suffer greatly from the accumulation of

errors, and noise, over longer durations. The accelerometer provides roll and pitch

measurements that do not suffer from integration errors. The vehicle's movement

influences the accelerometers accuracy however, so the measurements cannot always be

used. The magnetometer provides reliable yaw measurements. Unfortunately the sensor

measurement rate is almost half of the operating frequency of the IMU and Navigation

controllers. Due to this, it cannot be used for every update. The Discrete Kalman filter

equations are split up into two groups, time update equations...

x k− = Ax k −1 + Bk uk −1 3.12

Pk− = APk+−1 AT + Q 3.13

and measurement update equations (Welch 4).

K k = Pk− H T (HPk− H T + R )
−1
3.13
27

xk+ = xk− + K (z k − Hx k− ) 3.14

Pk+ = (I − K k H )Pk− 3.15

The superscript + and - represent the estimates before (-) and after (+) the measurement

has been taken into account. For the Discrete Kalman filter in place, the gyroscope

measurements represent the control input uk (Terejanu 1). The system state is

xk = [φ θ ψ ] . With these definitions, Bk is as defined in equation 3.1, A becomes the


T

identity matrix, and Pk represents the covariance matrix for the filter. The initial value for

the covariance matrix can be calculated using equation 3.16 (Terejanu 1).

[
P0+ = E ( x0 − µ 0 )( x0 − µ 0 )
T
] 3.16

In 3.16 E represents the statistical expectation operator (Rangayyan 75). However, Pk

changes based on the measurements provided to the filter. Therefore if a small, nonzero

number is used for the covariance it will automatically seek out its own value. Using this

fact, the covariance matrix was initialized as the identity matrix in a simulation using data

from the vehicle. Once the simulation was complete, the final value of the covariance

matrix was used as the initial value for a new simulation. In a very short amount of time,

stable values were reached. These values were used as the initial covariance matrix for

the vehicle during testing. The values calculated are shown in 3.17.

0.0032 0 0 
P =+ 0 0.0031 0  3.17
0  
 0 0 0.0018
28

The Q matrix represents the process noise covariance. This matrix is more complex to

calculate and will be discusses later. The time measurement equations are consistently

updated throughout the IMU's operation. This provides a fairly accurate measurement

during periods where the accelerometer cannot be used for data fusion. It also provides a

covariance estimate that increases with time as the accelerometer aiding is not used,

which reflects the integration error accumulation in the gyroscope measurements.

When the body is not undergoing significant acceleration, the accelerometer

measurements can be used, and the measurement update equations are preformed. The

measurement update equations require the calculation of the measurement noise

covariance matrix R. The R matrix is a representation of the error in the accelerometer

measurements (Terejanu 2). Using measurements taken from the vehicle, the R matrix

was calculated as...

0.0053 0 0 
[
R = E vk v k
T
] = 

0 0.0050 0 

3.18
 0 0 0.0021

In a normal Discrete Kalman filter the H matrix relates the state to the measurement

value as in equation 3.19.

z k = Hx k + vk 3.19

For this implementation a different approach was pursued. When the vehicle has

experienced no rotation, and is not experiencing any acceleration from its motors or

external sources the accelerometer measurement should equal the gravity vector. The

gravity vector is known to be ge = [0 0 g earth ] . Using the DCM matrix Rnb the known
T
29

gravity measurement can be transfered to any body frame orientation as shown in

equation 3.19.

 − sin θ 
y c = R ge =  sin φ cos θ  g earth
b
3.19
n  
cos φ cos θ 

The error between the calculated gravity vector in the body frame y c and the

accelerometer measurement y m can be found using a simple subtraction as follows.

z = ym − yc 3.20

For small errors, the difference between the two vectors can be represented as an angular

velocity using equation 3.21 ("DCM Tutorial..."). It is important to mention that this is

accurate only for small time steps, so the filter has to update relatively quickly. In this

equation × represents the cross product between the two vectors.

dx = ge × (z − ge ) 3.21

With the angular velocity calculated, the state can be updated using equation 3.22 instead

of the standard Kalman filter equation given in 3.14. The covariance matrix is then

updated using equation 3.15, which completes the Kalman filter algorithm.

x k+ = x k− − Kdxk dt 3.22

The process noise covariance matrix Q is more difficult to calculate than other

matrices used in the Kalman filter. Rather than estimating the noise directly from

measurements, the values were calculated using a gradient decent method. A set of data

was used from the vehicle while it was stationary, with the motors running. Since the

vehicle was not moving, the total root mean square error (RMSE) for the IMU program
30

could be calculated. An initial guess was entered in for Q, and simulations were then

performed with a value of Q increased and decreased by a small value δ . Using the error

values, the error function gradient J was calculated from equation 3.23. The Q matrix was

then updated using the gradient and a gain control G as shown in equation 3.24. All of the

values of Q were adjusted once, and then the entire process was repeated until the matrix

reached a stable value. In order to reduce the chance that the values calculated settled on

a local minimum, the process was then repeated with different initial guess values for Q.

The adjusted Q values for each set of initial guesses were averaged, then used in the

Kalman filter simulation, and later IMU implementation.

J (Q + δ ) − J (Q − δ )
∇J (Q ) ≈ 3.23

Qn +1 = Qn − G∇J 3.24

4.1 Simulation

In order to test the IMU system, a simulation was created to test the effectiveness

of the tracking algorithms and validate the results. In order to make the simulation

effective, a simulated flight was performed to gather sensor data. The vehicle was put

through a series of evenly spaced rotations shown in Table 2. The vehicle was

maneuvered by hand to create these rotations. After each new orientation was reached,

the vehicle was held stationary for approximately two seconds before being moved to the

next orientation. In order to simulate the motor interference created during flight, the

propellers were removed and the motors were operated with continuous changes in speed.
31

Although this did provide some interference, without propeller resistance the motor

interference was reduced.

Table 2 - Data Gathering Test Flight Sequence

Step Number Roll Pitch Yaw


1 0 0 0

2 0 45 0

3 0 -45 0

4 0 0 0

5 90 0 0

6 -90 0 0

7 0 0 0

8 0 0 -90

9 0 0 0

10 -45 45 0

11 45 -45 0

The sensor data was used in a Matlab simulation to test the filter's effects and

check for errors. Figure 9 shows the vehicle's orientation calculated by only the

gyroscope values. Figure 10 shows the orientation estimated using only the accelerometer

values. Figure 11 shows the Kalman filter orientation tracking vs. the gyroscope tracking

from Figure 9.
32

Figure 9 - Gyroscope Based Vehicle Tracking

Figure 10 - Accelerometer Based Vehicle Tracking


33

Figure 11 - Kalman Filter Vs. Gyroscope Vehicle Tracking

From the plots it can be seen that the Kalman filter output merges the two sensor

outputs, and also significantly reduces the effects of the gyroscope's integration errors.

The IMU saves these values and transfers them to the Navigation processor to be used in

the vehicle control calculations.


34

CHAPTER 5 - NAVIGATION CONTROL PROCESSOR

5.1 Overview

The navigation control processor is responsible for retrieving data from the IMU

unit, and using it to control the vehicle's movement. To do this mathematical models of

the vehicle were created. Using these models, and the control algorithm selected,

simulations were run to tune the vehicle's response. The tuned control system was then

tested within a flight control program loaded onto the navigation control processor. These

methods will be discussed in this chapter.

5.2 Vehicle Modeling

In order to control and simulate the vehicle a mathematical representational model

is required. To begin, a simple inertial model of the vehicle was calculated. For the

inertial calculation, the vehicle is split into two sections. The first section is composed of

the quadcopter arms, which are estimated as solid cylinders located parallel (4.1) and

perpendicular (4.2) to the axis of rotation (Halliday 253). In these equations M represents

the mass of the shape, R the cylinder's radius, and L its length.

1
I cylinder − parallel = MR 2 4.1
2

1 1
I cylinder −⊥ = MR 2 + ML2 4.2
4 12

The second section comprises the motors, which are represented as point masses (4.3).

For this equation, M again represents the mass of the object, while L represents the

distance the mass is located from the axis of rotation.

I po int = ML2 4.3


35

Due to the vehicle's construction, its rotational inertia is the same with respect to the X

and Y axes. Therefore, the vehicle's inertia can be calculated using equation 4.4. In this

equation, the motor mass lengths are separated between the co-axis and cross-axis

motors. The co-axis motors are mounted slightly above the axis of rotation, while the

cross-axis motors are the full quadcopter arm's length away from the axis of rotation.

I x = I y = I cylinder − parallel + I cylinder − ⊥ + 2 ML2far + 2 ML2near 4.4

I Z = 2 I cylinder − ⊥ + 4 ML2far 4.5

A mathematical model of the forces applied by the vehicle motors is also required

in order to create a complete model for the control system. Each motor creates a thrust,

which is used to control the roll, pitch, height, and movement of the body. The thrust can

be modeled using the equation 4.6 (Gibiansky 3). In this equation the thrust is

proportional to many constants related to the physical design of the motors and propellers

used (Gibiansky 3). In this equation Kτ is a constant determined by the propeller blade

shape, KV is a motor proportionality constant, K t is a torque proportionality constant

related to motor input current, ρ is the air density, A is the area swept out by the

propeller, and ωm is the motor's angular velocity. Although this equation is useful in

giving insight into what effects the motor's thrust, it was much more important to see that

the thrust was directly proportional to the square of the motor's angular velocity. Rather

than attempt to calculate or determine each constant in equation 4.6, a simpler method

was used. The propeller angular velocity was calculated by directly driving the motors

over their input range. The control system calculated in the following sections was placed
36

into the control board, and the vehicle was put through fight testing at a level orientation.

If the value of kT was correct, the vehicle would hover in place. If not the vehicle would

either attempt to gain, or lose altitude. In this way kT was quickly estimated without the

need for additional testing equipment.

2
 K K 2 ρA 
T = V τ ω  = kT ωm2 4.6
 K
m 
 t 

Each motor also creates a rotational torque from drag forces. This torque is based

on the motor's angular velocity, and the propellers shape. The equation for the generated

torque from each motor is given in 4.7 (Gibiansky 4). In this equation, R is the propellers

radius, A is the area of the propeller cross section, C D is a dimensionless constant based

on the shape of the propeller, and ωm is the motor's angular velocity.

RρC D A(ωm R ) = k bω m2
1
τ Drag = 2
4.7
2

With the motor effects modeled, the net torques acting on the body can be calculated

using equation 4.8 as follows (Gibiansky 5).

 Lk t (ωm2 1 − ωm2 3 ) 
Lk t (ωm 2 − ωm 4 )
 
τ Body = 2 2
 4.8
k b (ωm1 − ωm 2 + ωm 3 − ωm 4 )
2 2 2 2
 

Using Euler's equations vehicle's angular velocity ωv can be related to the net body torque

created by the motors. Equation 4.9 and 4.10 show these relations (Gibiansky 5).

Iω v + ωv × (Iωv ) = τ 4.9

ω = I −1 (τ − ω × (Iω )) 4.10
37

Since the vehicle's inertial model is symmetrical, the inertial matrix I becomes a diagonal

matrix shown in equation 4.11 (Gibiansky 5).

I x 0 0
I = 0 Iy 0 4.11
 
 0 0 I z 

Equation 4.10 can be simplified using the diagonal inertial matrix, which provides the

final vehicle angular acceleration in equation 4.12 (Gibiansky 5). This equation models

the vehicle's movement through simulations in order to design a control system in a much

faster and more effective manner.

 I y − Iz 
 ω yω z 
τ φ I x−1   I x 
 −1   I z − I z 
ω v = τ θ I y  −  ω xω z  4.12
Iy
τ ψ I z−1   
  Ix − Iy
 I ω xω y 
 z 

5.3 PD/PID Controller

In order to control the vehicle's responses, a combined PD/PID controller was

created. A PID controller is a lag-lead controller that uses integrator and differentiator

transfer functions (Phillips 254). The advantage to using a PID controller is that it

considers not only the error, but also the error sum and change in error in its calculations.

Due to this PID controllers are widely used. PID controller performance depends heavily

on its gain selection however, and tuning them can be difficult. Although PID controllers

are very flexible, the integral term can lead to a problem known as integral windup. This
38

problem occurs when the integral summation becomes very large over time, and

overpowers the other control terms causing oscillations in the system response. In order

to prevent this problem, a PD controller is used for large errors. When the vehicle's

orientation becomes close to its target value, the controller switches to a PID system in

order to remove any steady state errors. In order to implement a PD/PID controller, it

must be related to the physical system it will be controlling. The vehicle body torque is

related to its angular acceleration as shown in 4.13. If the controller output u (t ) is set

proportional to the body torque as in 4.14, the controller output can be related to the

motor torque generation equation (4.8) as shown in 4.16 (Gibiansky 8).

τ Body = Iω v 4.13

τ Body = Iu (t ) 4.14

  T

 − I x  K d ϕ + K pφ + K i ∫ φdt  

  0 
  T

τ B =  − I y  K d θ + K pθ + K i ∫ θdt   4.15
  0 
  T

− I z  K dψ + K pψ + K i ∫ ψdt 
 
  0 

  T

 − I x  K d ϕ + K pφ + K i ∫ φdt  
 
 Lk t (ωm2 1 − ωm2 3 )    0 
  
Lk t (ωm2 2 − ωm2 4 )
 
T
τB =  =  − I  K d θ + K pθ + K i ∫ θdt   4.16
 y  
b(ωm2 1 − ωm2 2 + ωm2 3 − ωm2 4 )   0 
    T

 − I z  K dψ + K pψ + K i ∫ ψdt 
 
  0 
39

This decision provides three constraining equations for four motor control variables. In

order to solve for the motor angular speed variables, one more constraining equation is

required. For the final equation the total vehicle downward thrust is set equal to the

gravitational force acting on the body. This provides a constraint that will force the

vehicle to attempt to maintain a stable hovering position. Equation 4.18 shows this

relation (Gibiansky 8). For this equation the denominator compensates the total thrust

generated by the vehicle for changes in roll and pitch. This is necessary due to the fact

that the motors are in a fixed position on the vehicle, and therefore any change in roll or

pitch reduces the amount of thrust used to keep the vehicle aloft. A compensation

variable, H, was also added to the equation in order to account for times when a change

of altitude is desired.

mg + H
T= 4.17
cos θ cos φ

[ ]
kT ωm2 1 + ωm2 2 + ωm2 3 + ωm2 4 =
mg + H
cos θ cos φ
4.18

Given the four constraining equations, it is now possible to solve for the angular velocity

of each vehicle motor individually. Equations 4.19 through 4.26 provide the following

results.

X + U + 2Z
ω12 = 4.19
4

X + U − 2Z
ω22 = 4.20
4

X − U − 2Z
ω32 = 4.21
4
40

X − U + 2Z
ω42 = 4.22
4

where

mg + H
X = 4.23
kT cos θ cos φ

 T

− I x  K d ϕ + K pφ + K i ∫ φdt 
Y =  0  4.24
LkT

 T

− I y  K d θ + K pθ + K i ∫ θdt 
 
Z=  0  4.25
LkT

 T

− I z  K dψ + K pψ + K i ∫ ψdt 
U=  0  4.26
kb

5.4 Simulation

Although the PD/PID controller is very versatile, it can be very difficult, time

consuming, and in the case of crashes costly to tune the controller with trial and error

methods using the actual vehicle. In order to circumvent this problem, a simulation was

created to test different controller values. Figure 12 shows a result of the simulation. In

order to test different gains a single initial angle offset was tested, and the controller's

reaction was plotted. Simulation provides an insight into aspects such as the response

time, overshoot, and any oscillations that occur with the specified values. Based on the

plotted output, the controller gains were adjusted to obtain a more desirable response.

This method provided a simple way to tune the controller, however it has several
41

weaknesses. This method made it difficult to analyze the controller's response to errors in

multiple angles, and also from different initial error magnitudes. Also, when attempting

to determine the controller's response to a noisy environment the simulated vehicle's

orientation measurements were corrupted. During this testing it became very difficult to

determine if changes to the controller gains were improvements, as each provided

random results as shown in Figure 13.

Figure 12 - Hand Tuning Control Equations Without Noise


42

Figure 13 - Hand Tuning Control Equations With Noise

Due to the shortcomings of hand tuning the controller based on simulations, a

different method of controller gain selection was implemented. Rather than estimating the

controller performance based upon response graphs, a root mean square error calculation

was used to estimate the quality of the controller's response. The benefit to this method

was that a program loop could analyze multiple simulations and determine the best

response without user intervention. Another benefit is that control gains can be simulated

multiple times with random noise. Using this method an averaged RMSE value for all the

runs provides a more accurate representation of the controller response, compared to

plotting results individually. With these advantages in mind, a gradient decent method

was again used to estimate optimal gains for the control system (Gibiansky 15). In order

to calculate the gradient, equation 3.23 was modified so that the controller gains, and

switch point between PD and PID controllers, are the input values for the function as

shown in 4.27. The calculation method was then the same with the exception that
43

multiple simulations were performed for the same gain equations. The resulting averaged

RMSE was used for reasons previously discussed. Figure 14 shows the RMSE for each

parameter set during simulation. From the figure, it can be seen that the method does

produce an improved set of controller gains. The nonlinearities in the plot represent a

change in the initial conditions of the simulation in order to minimize the chance of

finding a local minimum. This also shows that a particular gain set is only optimal for

specific disturbances. Due to this fact the final gain values calculated were the average of

the optimal gains arrived at for each different initial condition set.

J (K + δ ) − J (K − δ )
∇J (K ) ≈ 4.27

Figure 14 - PD/PID Weight RMS Error Calculations

With the quadcopter's design if the PD/PID system restrained the orientation to

strictly level flight, very little vehicle movement would be observed. In the real world this
44

is nearly impossible, so a vehicle position tracking system is required in order to keep the

vehicle's position consistent during flight. The onboard accelerometer was used for this

purpose as well. In order to track position the net acceleration in the navigation frame

was integrated twice. This provided not only a measurement for position, but a vehicle

velocity calculation as well. In order to determine the net acceleration in the navigation

frame, the measured body acceleration was referenced to the navigation frame using a

DCM as shown in 4.28. An average of the earth's gravitational measurement was then

removed from the calculated value, with the resulting acceleration components

contributing to the vehicle's movement.

Anet = Rbn Abody − Aearth 4.28

5.5 Flight Control

During flight the vehicle was set to hover at a desired height of 60". In order to

control the height of the vehicle, ultrasound sensor's measurements were used in a

proportional controller. The output of the proportional controller was then used as the

compensation variable H in equation 4.18. This provided a means of accounting for

errors in the control systems operation with a direct height measurement. Using direct

measurements aids in eliminating errors in the accelerometer tracking, which suffers from

integration errors over time. Once the desired flight time had been reached, the vehicle

was programmed to land. In order to do this the desired height value was reduced by 10%

every half second. This provided a decent method for the vehicle that became more

gradual as the vehicle approached the ground, reducing the risk of damage. In order to

prevent the vehicle from being damaged during landing the motors are completely turned
45

off if the vehicle is below a set height. To do this the number of height measurements

below a threshold value were stored. Once this value was reached the motors were turned

off, and the vehicle would drop to the ground. This method put more stress on the frame

during landing, however since the vehicle was tested on soft ground it did not cause a

problem.

In order to keep the vehicle at its starting location during flight, the calculated

position and velocities in the X and Y axes of the navigation controller was used in a PD

controller. A PD controller was selected to avoid integral windup, especially during

longer flights where the accelerometer integration errors could affect the accuracy of the

position and velocity measurements. The controller set the desired flight orientation

variables, within limits, and therefore controlled the PD/PID algorithm that governs the

vehicle's motors.
46

CHAPTER 6 - IMPLEMENTATION & TESTING RESULTS

In order to test the IMU tracking system the propellers were first removed from

the vehicle for safety reasons. Since testing equipment that can accurately adjust the

vehicle's orientation was not available, the vehicle was started in a marked location, and

then maneuvered by hand. After maneuvering the vehicle to multiple orientations, the

vehicle was returned to its starting position and the orientation variables were checked.

This testing method was used due to the fact that it provided a fixed orientation. After the

vehicle's maneuvers the roll and pitch measurements should return to zero, and the yaw

would return to its initial reading. During this test the motors were set to run at different

speeds to generate noise. After two minutes of testing the orientation tracking system's

errors ranged from 0.31 to 1.64 degrees. During testing it was determined that there was a

problem with the magnetometer's readings. The z axis reading of the magnetometer was

much larger than expected, and did not seem to be effected by vehicle orientation. Figure

7 provides an example of this. It can be seen that at level flight the z-axis of the

magnetometer is over four times greater in strength than the other measurements. At a

level orientation the z-axis should display a very small reading. One possible cause of

this error is that the ground plane was not removed under the sensor location. This was

recommended by the device datasheet, but was forgotten in the circuit layout. Another

possible cause for this is that the sensor is mounted above the vehicle's battery. The

sensor was located closer to the center of the board in the hopes that it would reduce the

effects of the motor's interference. Unfortunately this position places the sensor directly

over the battery. Due to the compact design of the board the sensor could not be more
47

that a few inches away from the battery at any possible mounting location directly to the

board. A possible solution for this problem would be to mount the sensor remotely on one

of the vehicle's arms, though the effects of the motor interference on the sensors would

have to be examined. This problem made the z axis readings from the magnetometer

unreliable. Since the z axis was unusable, the magnetometer aiding can only be utilized

when the vehicle's orientation is approximately level. As the vehicle is in testing phases,

it is programmed to always attempt to be at, or very close to, a level orientation. This

provides enough time for the magnetometer to aid the yaw reading, however if this was

not the case the gyroscope integration error would become a large problem.

After testing the IMU, the control system response was tested. Initially the

vehicle's thrust was reduced, and the vehicle was tested in hand to determine how the

control system reacted to different orientation errors. While this allowed for thrust tuning

and revealed if the systems response was far too strong or weak, the vehicle reacts very

differently while completely under its own power. Initial tests for the vehicle were

performed with a flight time of only 5 seconds, with the landing program kicking in after

that duration. Initial tests showed that the accelerometer position tracking suffered from

large integration errors, and therefore the vehicle attempted to travel rather than stay at its

initial location. Attempts to reduce this error by increasing the number of measurements

averaged for the reference vector calculation were unsuccessful. Due to this problem the

position tracking for the vehicle was disabled for the majority of the test flights. Once the

position tracking was removed, the vehicle's reaction was more stable during test flights.

During these flights it was observed that the vehicle always drifted to the right. This was
48

also the side that the ultrasound module is mounted on. It is assumed that the difference

between the symmetric vehicle inertial model and the actual vehicle's weight distribution

caused this effect. Since the ultrasound module is mounted far from the center of mass on

the right arm, it prevents the vehicle's inertia from being symmetric.

The vehicle controller gains where tested over multiple flights. The vehicle's

response is still inconsistent over multiple runs with the same gains, but trends have been

observed. From these tests the vehicle was most stable with the gains calculated from the

simulations. The vehicle's roll and pitch controls work well at the smaller errors where

the simulations were taking place, however as the errors increase the vehicle tends to

overcompensate. More testing is required to determine if this is caused from the gains

being too low at mid level errors, allowing larger errors to occur, or if the gains are too

high at larger error levels. A possible solution for this problem is to have the vehicle

switch between different gains depending on the magnitude of the error it is reacting to.

These gains can be tuned using the same simulation as before to hopefully produce

favorable results.

Although the roll and pitch controls worked well, the vehicle was unable to keep a

consistent yaw heading during test flights. Further testing is required to determine if this

is caused by a error in the IMU tracking and aiding, but it is currently believed that this is

caused due to an inaccurate torque coefficient k b . Since testing proved that the

calculations for the motor thrust coefficient kT were inaccurate, it is very likely that k b is

also incorrect. Further test fights can examine this using a guess and check method. A
49

more accurate and less time consuming method would be preferable however, and

therefore requires research.

Figure 15 - Flight Testing


50

CHAPTER 7 - CONCLUSION

During the course of this project, an autonomous control system was developed

for a quadcopter type aircraft. The circuit board that implements the control system

contains both an IMU and navigation control processor, which are interlinked. The IMU

processor utilizes gyroscopes, an accelerometer, and a magnetometer to gather orientation

data for the vehicle. These values are then processed using both a Butterworth and

Kalman filter. The Butterworth filter reduces the RMS error in the measurement data by

at least 15%. The Kalman filter improves data integrity, and fuses the data into a single

orientation measurement. Figure 11 shows the Kalman filter's improvement on

measurement noise and integration error accumulation. The IMU system was simulated

using Matlab in order to determine its effectiveness and to tune it. After the simulation,

the system was tested by manually manipulating the vehicle. The IMU was able to track

vehicle orientation with a maximum error of 1.64 degrees after two minutes of testing.

Orientation data from the IMU is used by the navigation control processor to

control the vehicles movements. The orientation data is used by a PD/PID control system.

The control system acts as a PD control system for large errors, and switches to a PID

configuration for smaller errors. It is based upon vehicle inertial, motor thrust, and motor

torque generation models. The control system was also simulated in Matlab. The

simulations modeled the vehicle's movements, and allowed for tuning of the control

system. Final tuning of the control system was obtained using a gradient decent method

to calculate both optimal gains, and switching points between PD and PID control

configurations. The gradient decent method uses a RMS error calculation to adjust the
51

values. The vehicle's position was tracked by integrating the net acceleration on the

vehicle, and use of an ultrasound distance detection sensor for an additional height

measurement. The vehicle's position was controlled using a PD control system, with the

exception of the vehicle's height control being strictly a proportional controller. In order

to test all systems on the vehicle multiple flight tests were conducted. Early in testing it

became clear that the position tracking system was not accurate, and was disabled for the

rest of the tests. After doing so, the vehicle became much more stable. During testing the

control system responded to changes in the vehicle's orientation was able to keep the

vehicle in flight. The system's response does vary over multiple tests, and requires further

tuning to make it more consistent. In the testing performed the PD/PID controller gains

calculated through simulation provided the most successful flights.


52

Bibliography

Ardakani, H. Alemi, and T. J. Bridges. Review of the 3-2-1 Euler Angles: A Yaw–pitch–

roll Sequence. N.p.: U of Surrey, Guildford, 2010. PDF.

Booth, William. "More Predator Drones Fly U.S.-Mexico Border." Washingtonpost.com.

The Washington Post, 21 Dec. 2011. Web. 17 Oct. 2013.

<http://articles.washingtonpost.com/2011-12-21/world/35285176_1_drone-

caucus-predator-drone-domestic-drones>.

"BQM-34 Firebee High Performance Aerial Target System." Northrop Grumman. N.p.,

n.d. Web. 17 Oct. 2013. <http://www.northropgrumman.com/Capabilities

/BQM34Firebee/Pages/default.aspx>.

"DCM Tutorial – An Introduction to Orientation Kinematics." Starlino. N.p., 27 May

2011. Web. <http://www.starlino.com/dcm_tutorial.html>.

De Marina, Hector, Fernando J. Pereda,, Jose M. Giron-Sierra, and Felipe Espinosa,.

UAV Attitude Estimation Using Unscented Kalman Filter and TRIAD. 11th ed.

Vol. 59. N.p.: IEEE TRANSACTIONS, 2012. INDUSTRIAL ELECTRONICS.

PDF.

Detwiler, Andrew G. "Tornado Chaser: Unmanned Aircraft for Severe Storms."

Unmanned Aircraft System for In-Situ Sensing Along Atmospheric Airmass

Boundaries. N.p., n.d. Web. 23 Nov. 2014.

Farrell, Jay A. Aided Navigation: GPS with High Rate Sensors. New York: McGraw-Hill,

2008. Print.
53

"Fire Scout." northropgrumman.com. Northrop Grumman, n.d. Web. 17 Oct. 2013.

<http://www.northropgrumman.com/Capabilities/FireScout/Pages/default.aspx>.

Gibiansky, Andrew. "Quadcopter Dynamics, Simulation, and Control." N.p., 23rd Nov.

2012. Web. <http://andrew.gibiansky.com/blog/physics/quadcopter-dynamics/>.

Halliday, David, Robert Resnick, and Jearl Walker. Fundamentals of Physics. Vol. 1.

Hoboken, NJ: Wiley, 2005. Print.

HMC5883L 3-Axis Digital Compass IC. N.p.: Honeywell, 2013. Datasheet. PDF.

Koopman, Philip, and Tridib Chakravarty. "Cyclic Redundancy Code (CRC) Polynomial

Selection For Embedded Networks." The International Conference on

Dependable Systems and Networks (2004): n. pag. Web.

LIS352AX. N.p.: STMicroelectronics, 2010. PDF.

LPY503AL. N.p.: STMicroelectronics, 2009. Datasheet. PDF.

LV-MaxSonar®-EZ4™ High Performance Sonar Range Finder. N.p.: MaxBotix®, 2007.

Datasheet. PDF.

"MQ-1B Predator." Af.mil. US Air Force, 20 July 2010. Web. 23 Oct. 2013.

<http://www.af.mil/AboutUs/FactSheets/Display/tabid/224/Article/104469/mq-

1b-predator.aspx>.

"NASA Global Hawk." northropgrumman.com. Northrop Grumman, n.d. Web. 16 Oct.

2013. <http://www.northropgrumman.com/Capabilities/NASAGlobalHawk/

Pages/default.aspx>.

"Obstacle Avoidance in Urban Environment." BEAR: Berkeley Aerobot Research. N.p.,

n.d. Web. 23 Nov. 2014.


54

Output Compare. Vol. 16. N.p.: Microchip Technology, 2011. PIC32 Family Reference.

PDF.

Phillips, Charles L., and H. Troy Nagle. Digital Control System Analysis and Design.

Englewood Cliffs, NJ: Prentice-Hall, 1984. Print.

PIC32MX5XX/6XX/7XX Family Data Sheet. N.p.: Microchip Technology, 2011.

Datasheet. PDF.

"Predator® UAS." ga.com. General Atomics Aeronautical, n.d. Web. 16 Oct. 2013.

<http://www.ga-asi.com/products/aircraft/predator.php>.

Rangayyan, Rangaraj M. Biomedical Signal Analysis: A Case-study Approach.

Piscataway, NJ: IEEE, 2002. Print.

"Robobees." Robobees. N.p., n.d. Web. 21 Nov. 2014.

<http://robobees.seas.harvard.edu/>.

Sengupta, Somini. "U.S. Border Agency Allows Others to Use Its Drones." New York

Times. N.p., 3 July 2013. Web. 16 Oct. 2013.

Serial Peripheral Interface (SPI). Vol. 23. N.p.: Microchip Technology, 2011. PIC32

Family Reference. PDF.

Skoloff, Brian, and Tracie Cone. "Predator Drone Now Part of Battle against Rim Fire

near Yosemite." MercuryNews.com. San Jose Mercury News, 29 Aug. 2013.

Web. 16 Oct. 2013. <http://www.mercurynews.com/ci_23971789/predator-drone-

now-part-battle-against-wildfire-near>.
55

Terejanu, Gabriel. "Discrete Kalman Filter Tutorial." N.p., n.d. Web. 15 Apr. 2012.

<http://users.ices.utexas.edu/~terejanu/files/tutorialKF.pdf>.

Vinson, Brandon. "X-47B Makes First Arrested Landing at Sea." Navy.mil. US Navy, 10

July 2013. Web. 17 Oct. 2013. <http://www.navy.mil/submit/display

.asp?story_id=75298>.

Walsh, Alan. Front-End Amplifier and RC Filter Design for a Precision SAR Analog-to-

Digital Converter. Vol. 46-12. N.p.: Analog Devices, 2012. Analog Dialogue.

PDF.

Welch, Greg, and Gary Bishop. An Introduction to the Kalman Filter. N.p.: UNC-Chapel

Hill, 2006. PDF.

You might also like