Professional Documents
Culture Documents
This project, aims at monitoring the real time environment with help of Unmanned Aerial
Vehicle (UAV), like surveillance of banks, highly crowded areas, aerial traffic and security
watch etc. This project is intended to design and fabricate low cost, light weight surveillance
UAV. A drone in structure of quad rotor that houses a camera with a wireless transmission
system was designed. This provides a live feed from camera to the ground station via telemetry.
It is also intended to carry a payload for future developments. GPS is used to predict the location
of UAV and inertial measurement unit (IMU) sensors will be used to predict proper acceleration
and detection of changes in rotational attributes roll, pitch and yaw. IMU consists of 3-axis
accelerometer, 3- axis gyroscope and 3-axis digital compass. PID control system is used to
maintain the stability of flight.
iii
TABLE OF CONTENTS
Chapter No.
Description
Page No.
LIST OF TABLES
vii
LIST OF FIGURES
viii
LIST OF ABBREVIATIONS
xi
INTRODUCTION
1.1
Objective
1.2
Motivation
1.3
Background
TECHNICAL SPECIFICATIONS
10
3.1.3 Propellers
12
3.1.4 Battery
13
16
17
17
18
19
20
21
21
23
iv
Chapter No.
Description
Page No.
3.3.3 ESC
24
25
26
26
26
27
28
29
29
30
30
33
35
36
38
38
38
38
38
38
39
39
39
40
40
4.3.2 Alternatives
41
Chapter No.
Description
4.3.3 Tradeoff
Page No.
41
41
41
41
42
6 PROJECT DEMONSTRATION
43
43
49
50
51
53
58
58
7.1.1.1 DJI
59
7.1.1.2 3D Robotics
59
7.1.1.3 FireBox
59
59
8 SUMMARY
61
REFERENCES
62
APPENDIX A
1. Binding of RF Transceiver
63
63
63
64
APPENDIX B
65
65
76
vi
LIST OF TABLES
Table No.
Description
Page No.
3.1
Engineering Module
3.2
10
3.3
Battery Comparison
14
3.4
15
3.5
16
3.6
22
3.7
23
4.1
32
vii
LIST OF FIGURES
Figure No.
Description
Page No.
1.1
ARES
1.2
Global Hawk
1.3
Parrot AR Drone
1.4
Amazons PrimeAir
1.5
SWARM MAV
1.6
Quadcopter rotation
3.1
Quadcopter Frame
3.2
Brushless DC Motor
11
3.3
11
3.4
Propellers
13
3.5
14
3.6
15
3.7
17
3.8
Camera
19
3.9
20
3.10
Ardiuno board
22
3.11
Raspberry pi
24
3.12
24
3.13
25
3.14
26
3.15
27
3.16
27
viii
Figure No.
Description
Page No.
4.1
Flow Diagram
29
4.2
Quadcopter Design
30
4.3
Quadcopter Architecture
31
4.4
33
4.5
36
4.6
37
4.7
Improper throttle
40
5.1
42
6.1
43
6.2
44
6.3
45
6.4
46
6.5
46
6.6
47
6.7
47
6.8
48
6.9
Quadcopter as in flight.
48
6.10
49
6.11
50
6.12
51
6.13
NMEA Format
52
6.14
GPS Output
52
ix
Figure No.
Description
Page No.
6.15
53
6.16
53
55
6.18
55
6.19
56
6.20
56
6.21
57
LIST OF ABBREVIATIONS
API
APM
ArduPilot Mega
BEC
DARPA
DARO
ESC
FPS
GPS
GUI
HD
High Definition
I/O
Input/Output
IR
Infrared
Kv
MSP
MW
MultiWii
NMEA
PCB
PID
Proportional-Integral-Derivative
PPFS
PPS
PWM
OS
Operating System
RAM
RC
Radio Controlled
UAV
USB
VDC
xi
CHAPTER 1
INTRODUCTION
A quadcopter is an aerial vehicle that uses four rotors for lift, steering, and stabilization.
Unlike other aerial vehicles, the quadcopter can achieve vertical flight in a more stable condition.
Furthermore, due to the quadcopters cyclic design, it is easier to construct and maintain. As the
technology becomes more advanced and more accessible to the public, many engineers and
researchers have started designing and implementing quadcopter for different uses. One of the
main use is surveillance. Surveillance is critical for security operations. In the past, helicopters
were used for these types of missions. Recently, Unmanned Aerial Vehicles (UAVs) are (have
grown in popularity and are an excellent resource that can be) utilized for surveillance missions.
The unmanned aerial vehicles are helpful to observe, analyze and get information and transfer it
to base station. UAVs are able to perform missions with high level of complexity and at the same
time, they require less human operator involvement due to their autonomous behavior. The
additional advantage is, they are agile in nature and can have degree of freedom up to 10.
The goal of this project is to build an UAV in in structure of x shaped quad rotor that
houses a camera with a wireless transmission system. This unmanned aerial vehicle will be used
for campus surveillance. Aerial surveillance will be done by monitoring the real time
environment with help of UAV. Surveillance of banks, highly crowded areas, aerial traffic and
security watch can be easily done with the help of this UAV.
1.1
Objective
The objective of this project is to build an UAV in structure of quad rotor which can
maintain safe and stable flight and houses a camera with a wireless transmission system to
provide surveillance of real time environment. These are the following objective
a) Design and implementation of UAV in structure of X shaped quadcopter.
b) Development of flight controller by proper interfacing of sensor and tuning of PID
control values.
1
c) Apart from the stable flight, a camera is interfaced with quadcopters processor to record
the aerial view for surveillance.
d) A wireless transmission system developed to telemeter the video and GPS data to ground
station.
1.2
Motivation
From observation of prior art in UAV, one can say that future is full of unlimited
potential and possibilities of UAV. Now days, UAVs are everywhere. It is not only used for civil
and commercial but also in scientific research as well. Fig. 1.2 shows the UAV Global Hawk
High-Altitude Endurance Unmanned Aerial Vehicle from Defense Advanced Research Projects
Agency (DARPA) and Defense Airborne Reconnaissance Office (DARO) is used for NASA's
airborne Hurricane and Severe Storm Sentinel or HS3 mission. NASA is redoubling its efforts to
probe the inner workings of hurricanes and tropical storms with two unmanned Global Hawk
aircraft flying over storms and two new space-based missions. UAVs are also considered as a
potential unmanned candidate for future mars mission over rover and landers. A mission named
ARES (Aerial Regional Scale Survey of Mars) was under evaluated mission, developed by
Langley Research Center to build a powered aircraft that would fly on Mars as shown in Fig. 1.1.
Although some UAVs like General Atomics MQ-1 Predator, General Atomics MQ-9 Reaper
were also considered as Human killing machine, yet there are several UAVs used for benefit and
improvement of society. For example, S.W.A.R.M. (Search with Aerial RC Multi-Rotor) is a
worldwide volunteer search and rescue network of over 1,100 SAR Drone Pilots dedicated to
searching for missing persons. Not only in the serious situation, but for entertainment UAVs are
used. Commercial available Parrot AR Drone [14] and DJI Phantom are best quadcopters for
aerial photography and videos. A drone from DJI Global have recently used in Golden Globe
Event.
Several attempts were also made in logistic and transport like delivery of Amazons product by
Amazons PrimeAir as shown in Fig 1.4 or pizza delivery in Mumbai. On the other hand, small
drone also known as micro and nano-copter are small, lightweight, spontaneous and very agile in
nature gives them advantage in flight. According to Vijay Kumar, GRASP Lab, University of
Pennsylvania micro drones are capable of 1850 /sec roll and pitch, performs a 360 flip in 0.4
seconds and exhibits a lateral step response of 1 body length in 1 second [1].
1.3
Background
Quadcopter, also known as quadrotor, is a helicopter with four rotors. The rotors are
directed upwards and they are placed in a square formation with equal distance from the center
of mass of the quadcopter. The quadcopter is controlled by adjusting the angular velocities of the
rotors which are spun by electric motors. Quadcopter is a typical design for small UAV because
of the simple structure. Quadcopter are used in surveillance, search and rescue, construction
inspections and several other applications.
Each rotor produces both a thrust and torque about its centre of rotation, as well as a drag
force opposite to the vehicle's direction of flight. Quad-copter achieves lift, yaw, roll and pitch
simply via a manipulation of the thrusts of four motors relative to each other as shown in Fig.1.6.
This way, fixed rotor blades can be made to manoeuvre the quad rotor vehicle in all dimensions.
Similar to other flying objects, a quadrotor has a group of forces and torques acting on it while it
flies. There are four main forces acting on the drone: drag, lift, weight, and thrust. In order for
the drone to fly, these different forces need to be balanced. This can be seen by utilizing
Newtons Second Law.
(1)
For constant velocity acceleration is zero (a=0). Thus the sum of the forces is equal to zero. So
for steady, constant velocity flight, completing a force balance in the horizontal direction on the
diagram obtains:
= 0
(2)
(3)
Since this is for a constant velocity, the aircraft is either moving or at rest. An analysis in the
vertical direction will produce similar results.
= 0
=
(4)
(5)
CHAPTER 2
PROJECT DESCRIPTION AND GOALS
The goal of this project is to build an UAV in structure of quad rotor that houses a camera
with a wireless transmission system. This unmanned aerial vehicle will be used for campus
surveillance.
Quad rotor must hover in place, take off and land vertically, maintain stable flight and perform
flight attributes (like roll, pitch and yaw). These attributes are essential for surveillance. To do
these above mentioned flight traits, PID control system was utilized. The tuning of the PID
control system is very crucial because three different PID control systems for pitch, roll, and yaw
had to be tuned carefully for proper stabilization. Inertial measurement unit (IMU) sensors will
be used to collect data of 3-axis accelerometer, 3- axis gyroscope which can be exploited by PID
control algorithm to maintain the auto stable flight.
Wireless transmission system provides a live feed from camera to the ground station. Wireless
transmission system will help monitoring the real time environment like surveillance of banks,
highly crowded areas, aerial traffic and Security watch etc. A GPS module will be used to
determine the current position of UAV. Telemetry will be used as a wireless transmission system
(XBee Radio Modules works on RF 2.4 GHz frequency under the zigbee protocol, IEEE
802.15.4). Data from camera and GPS will be wirelessly transferred from uav to base station via
telemetry. Flight of quad rotor will be also controlled wirelessly through RF Transceiver working
at 2.4 GHz. Finally, this project intended to design and fabricate a low cost, light weight
surveillance UAV. The project has been divided into b following broad areas to achieve the
targeted functionality:
Maintain the stable flight and perform flight attributes (like roll, pitch and yaw).
Develop a wireless transmission system provides a live feed from camera to the ground
station.
CHAPTER 3
TECHNICAL SPECIFICATIONS
While the overall goals, strategies and objectives have been stated, the specifications of
the components will be determined as they are identified for their applicability in the project. The
technical specifications are divided in the following in engineering module on the basis of
application and engineering involved. The modules are represented in Table 3.1.
Landing Stand
4 x Electrical Motor
4 x Propellers
On board camera
GPS
Telemetry
System
&
other
Electronics
Software Module
Module
Python
3.1
These are the following main mechanical and electrical module whose specification are
described.
a) Quad rotor Frame
b) Electrical Motor
c) Propellers
d) LiPo Battery & Charger
e) Power Distribution Board
3.1.1 Quad Rotor Frame:
Quad copter is a novel appearance, superior performance VTOL aircraft, which has a simple
structure, flexible operation, high load capacity and other characteristics, have important civilian
and military value. According to our design, we have select the necessary materials and
structures that meet the strength and stiffness the system needs. They are designed to be strong
and lightweight.
To decide the appropriate frame for the copter three main factors, i.e. weight, size and materials
have taken in consideration. The frame should be flexible enough to minimize the vibrations
from the motors. Our frame is consisting of these following fragments:
1) The center plate where the electronics are mounted.
2) Four arms mounted to the center plate.
3) Four motor brackets connecting the motors to the end of the arms.
Strong, light and sensible configuration including suspension system that allows for a clean and
easy build is highly recommended. Parts and accessories that are 100% compatible and
interchangeable are always preferred.
Frames are usually made of:
a) Carbon Fiber: Carbon fiber is the most rigid and vibration absorbent but it is the most
expensive too.
b) Aluminum: Hollow aluminum square rails are the most popular for the arms due to its
light weight, rigidness and affordability. However aluminum can suffer from motor
8
vibrations, as the damping effect is not as good as carbon fiber. In cases of severe
vibration problem, it could mess up sensor readings.
c) Wood: Wood/ Plywood could be used for the arms as they are better at absorbing the
vibrations than aluminum and carbon fiber. Unfortunately the wood is not a very rigid
material and can break easily if the quad copter crashes. For the center plate, plywood is
most commonly used because of its light weight, easy to work factor and good vibration
absorbing features. As for arm length, motor-to-motor distance is sometimes used,
meaning the distance between the 12 centers of one motor to that of another motor of the
same arm. The motor to motor distance usually depends on the diameter of the propellers
in order to have enough space between the propellers.
d) Glass Fiber: Fig. 3.1 shows the Quadcopter Frame is made of glass fiber. The glass fiber
is the most flexible and vibration absorbent very less expensive compared to carbon fiber.
An individual structural glass fiber is both stiff and strong in tension and compression
that is, along its axis. The main frame is glass fiber while the arms are constructed from
ultra-durable polyamide nylon [2].
Fiber type
Tensile strength
(MPa)
Compressive
strength
(MPa)
Density
Softening T
Price
(g/cm )
(C)
($/kg)
E-glass
3445
1080
2.58
846
S-2 glass
4890
1600
2.46
1056
20
10
quadcopter block diagram in Figure 3.2 and accompanying Table for more information.
Figure 3.3 below shows the direction of the motors on prototype.
The motors were tested to lift the quadcopter and its components successfully.
Above that, the motors were able to lift an additional 0.149 kg. The proposed design was
able to fly over 15 km/hour meeting the prototype requirement, but the maximum speed was
not tested out of concern for a crash that could occur during this test.
3.1.3 Propellers
Requirements
The propellers shall be large enough to provide adequate lift for the quadcopter, but
small enough to fit on the chosen frame. Propellers are also specific to the direction of
rotation, making it necessary to match propellers with motors.
Alternatives
Carbon fiber or plastic propellers both fit project needs. There are propellers that
range in length from 4 to 22 inches and with pitches ranging from 2 to 12 degrees.
Decision Criteria
The choice between plastic or carbon fiber propellers depended on multiple factors.
The blades needed to be robust enough to handle moderate collisions, balanced enough to
limit vibrations, and have appropriate length and pitch values. Motors driving the propellers
are rated for specific propeller sizes, so this was taken into effect as well. Larger propellers
(and those with a higher pitch) can provide more lift because they move more air, but they
also require more power. Cost was another factor, as multiple crashes were anticipated with
a new quad copter design.
Decision
The team chooses to continue using plastic propellers. Carbon fiber propellers are
more expensive and much stronger, making them even more dangerous if they were to
contact an object or a person. Due to the nature of the project with many new components of
hardware and software coming together, the team anticipated multiple crashes. Keeping this
in mind, the team chose plastic propellers to help stay under budget while providing a safer
product for the user. The team specifically selected APC propellers for their build quality
which is shown in Fig. 3.4. The length chosen 8 inch with a pitch of 4.5 degrees as this
provided the best balance of lift without sacrificing stability.
12
Propellers were not tested in a specific way other than during test flights of the
quadcopter. The team observed that propellers of 10 inch and with a pitch equal to 4.5
degrees made the quadcopter too sensitive to user input. However, the larger the propeller,
the more lift the quadcopter experienced. As such, the team settled on 8 inch, 4.5 degree
propellers because they have good lift while leaving the quadcopter stable.
13
Decision Criteria
Cost was a portion of the decision for the battery chosen, but voltage output,
discharge rate, capacity, and weight were major criteria as well. The battery needed to
operate at a voltage of 11.1 V and have a discharge rate of at least 30 C. Batteries with
larger capacities weigh more, creating a need for more power, and eventually diminishing
the advantages of having a high capacity battery. Table 3.3 shows the capacity, weight, cost,
and charge time of several batteries that were considered. All of the listed batteries had the
required voltage and discharge rates needed.
Table3.3 Battery Comparison
Capacity
(mAh)
Charge
(min)
Cost
Weight (g)
2450
Rs. 1176
218
29.4
3000
Rs.1307
269
36.0
3600
Rs.1482
321
43.2
5000
Rs.2400
414
60.0
11,975
Rs.5400
1050
143.7
Time
14
Prototype Decision
The prototype decision was to use originally use a 2300 mAh battery as shown in
Fig. 3.5 which was available on website (RC Hyderabad) and meet the design specification
of the project. The team was able to reach the prototype flight time requirement of six
minutes, so this battery was the final team decision.
2450
6.5
3000
7.55
3300
8.78
5000
10.50
11,975
30.00
15
Raspberry
Pi
ESCs
4.5-5.5
4.5-6.5
4.75 - 5.25
12
Not Available
Not Available
0.7
25
Alternatives
There were two main alternatives for this section: a custom printed circuit board or
a power distribution board.
Decision Criteria
The decision was based on cost, size, weight, and ability to scale for more
components. With the expandable nature of the project, the power distribution system
needed to be able to handle extra components necessary for the project.
After replacing the malfunctioning UBECs with a Simon EMAX ESC, the power
distribution system was able to power all quad copter components successfully.
On board camera
GPS
Telemetry
16
a) MPU 6050:
MPU-6050 sensor contains a MEMS accelerometer and a MEMS gyro in a single chip. It
is very accurate, as it contains 16-bits analog to digital conversion hardware for each
channel. Therefor it captures the x, y, and z channel at the same time. The sensor uses
the I2C-bus to interface with the Arduino.
b) HMC5883L:
HMC5883L, a 3-axis digital magnetometer designed for low-field magnetic sensing. The
sensor has a full-scale range of 8 Guass and a resolution of up to 5 milli-Gauss.
Supplied voltage should be between 2.16 and 3.6VDC. Communication with the
HMC5883L is simple and all done through an I2C interface. All registers and operating
modes are well described in the datasheet below. Comes in a low-height, LCC surface
mount package. For a breakout board, see below.
17
c) BMP180:
This precision sensor from Bosch is the best low-cost sensing solution for measuring
barometric pressure and temperature. Because pressure changes with altitude you can
also use it as an altimeter! The sensor is soldered onto a PCB with a 3.3V regulator, I2C
level shifter and pull-up resistors on the I2C pins. This board is 5V compliant - a 3.3V
regulator and an i2c level shifter circuit is included so you can use this sensor safely with
5V logic and power. Arduino, simply connect the VIN pin to the 5V voltage pin, GND to
ground, SCL to I2C Clock (Analog 5) and SDA to I2C Data (Analog 4).
communicate over a TTL serial connection, including the wireless telemetry module we are
using. The ability to integrate the video over the serial connection seamlessly was the main
reason that we chose this camera. Other reasons included the fact that it operated from a 5 V
power supply, just like the rest of our sensors, and that the power consumption was low at
less than 100 mA.
The camera has the ability to capture VGA, QVGA, and QQVGA picture formats as well as
allow the image to be compressed with various degrees of compression. This allowed us to
shrink the image file size to under 30 kb per image frame which is small enough to allow us
to reach a frame rate of about 2.5 fps while transmitting at 115200 bps. This frame rate
should be sufficient to guide navigation or to perform surveillance. The camera module is
shown in Fig. 3.8. The camera is controlled by the Arduino processor board. A series of hex
commands are sent to the camera from the Arduino to initialize and then start a series of
image collects. The images are sent from the camera serially in hex format to the Arduino
and then transmitted via the XBee-PRO telemetry modules to the ground-based computer for
processing.
18
stuff using the Digi XBee tool. The pins on an XBee are 2mm spacing, not 0.1" so they will not
fit into a breadboard.
Key Feature
Outdoor line-of-sight: up to 1 mile (1600 m), 2500' (750 m) for International variant
Each direct sequence channels has over 65,000 unique network addresses available
Source/Destination Addressing
positions. A GPS device typically receives a signal from a satellite to calculate these
positions. Depending on the GPS device chosen, some devices give the internal clock and
standard deviations of its positions. The GPS section of code interfaces directly with the
GPS module. The first major choice was where to interface with the GPS module. It could
either be connected to the flight controller, or connected directly onto the RASPBERRY PI.
Initially, data is received in NMEA format. The NMEA 0183 standard defines an electrical
interface and data protocol for communications between marine instrumentation. NMEA
0183 devices are designated as either talkers or listeners (with some devices being both),
employing an asynchronous serial interface with the following parameter:
code to the Arduino from the PC. The gyros are for sensing rotational motion around the three
axes (x y z) and the accelerometers are for sensing linear acceleration about those same axes.
ATmega328
Operating Voltage
5V
7-12V
6-20V
40 mA
50 mA
Flash Memory
32 KB (ATmega328)
SRAM
2 KB (ATmega328)
EEPROM
1 KB (ATmega328)
Clock Speed
16 MHz
Length
68.6 mm
Width
53.4 mm
Weight
25 g
22
Raspberry Pi B Arduino
(Rs.)
(Rs.)
Price
I/O (Pins)
Adafruit
Compatible
Uno Arduino
Due(Rs.)
Arduino
(Rs.)
Mega BeagleBone
Black(Rs.)
2400
1400
2400
2400
2600
20
20
66
70
92
Yes
Yes
Yes
Yes
Yes
Pin Output
50 mA at 3.3 V
or 5 V
USB Type
2 ports A
50 mA at
800 mA at
3.3 V
3.3 V or 5 V
Micro B
50 mA at 3.3 V
B
3.3 V, 5 V
A
Price was a factor, as well as the number and capabilities of Input/output pins to
ensure that all communication could be received from the laptop and sent to the remote
control transmitter. This includes serial ports and pulse width modulation (PWM) analog
outputs. Although not a requirement, it would be ideal if developers of the flight controller
and the RC interface module could use the same communication cable (USB micro Type B)
for fast interchangeability with computers used for programming. The power consumption
was not considered for this section, as all boards were reasonably small (less than 5 watts).
The chosen Raspberry pi board is shown in Fig. 3.11.
23
ESC supplies power from battery but not constant, it varies according to input signal.
ESC also has BEC (Battery Eliminated Circuit). BEC is nothing but 5V output from ESC that
can power up receiver, servo motor (for camera gimbal) and FC. But how to select ESC for our
multirotor? Well it's really simple. One only need to keep in mind that Ampere rating of ESC
should be higher than max amp rating of motor. For example the motor we selected draws
maximum 15Amp so your ESC rating should be higher than 15amp. Say 18-20Amp. One can
select ESC between ranges of 18A to 22A. 20 Amps was selected as our designed requirement.
Fritzing
Matlab/Simulink
Linux/ Python
3.4.1 Fritzing
Fritzing is an open-source hardware initiative that makes electronics accessible as a
creative material for anyone. Software community offer services in the spirit of Processing
and Arduino,
fostering
creative
ecosystem
that
allows
users
to document their
prototypes, share them with others, teach electronics in a classroom, and layout and
manufacture professional pcbs. This software module is used to design the circuit diagram and
interfacing of sensor with Arduino board [7].
3.4.2 Matlab/ Simulink
PID Tuner tool box is used to tune the values of PID as shown in Fig. 3.14.
Fig. 3.14 PID Tuner tool box for tuning the value of PID
26
3.4.3 MultiWii
Fig. 3.15 shows the MultiWii which is a general purpose software to control a multirotor RC
model. It can now use various sensors but was initially developed to support Nintendo Wii
console gyroscopes and accelerometers. Multiwii software module is used here as flight
simulator and to get the visualization and plotting of flight data. It also used to calibrate the ESC,
tuning the flight, sensor graph, video capture etc.
27
28
CHAPTER 4
DESIGN APPROACH AND DETAILS
4.1
Design Approach
Fig. 4.1 demonstrates the design approach which has been considered for the project. The
first and most important factor is the identification of problem which is identified as the need of
aerial surveillance. The next step is research and background which have been discussed in
section 1.3. The best solution is identified as unmanned aerial vehicle in form X shaped
quadcopter structure. After that design of the prototype have been done on several stage which
involved static thrust calculation, total weight, flight time and power consumption calculation.
Next step are also implemented and evaluated.
31
Sl.No.
Communication Type
1.
ESC Control
Protocol
PWM
Description
The flight controller sends a pulse width modulated
signal between one millisecond and two milliseconds
to the ESC for each motor to control the movements of
the quadcopter.31
2.
MSP
3.
4.
Motor Controls
Video Stream
Three-
Phase
Power
H.264
Video
5.
GPS Data
6.
Arduino Power
DC
8.
Sensor Interface
I2C
32
(1)
The origin of the body frame is in the center of mass of the quadcopter. In the body frame, the
linear velocities are determined by VB and the angular velocities by v
33
(2)
The rotation matrix from the body frame to the inertial frame is
in which Sx = sin(x) and Cx = cos(x). The rotation matrix R is orthogonal thus R1 = RT which
is the rotation matrix from the inertial frame to the body frame. The transformation matrix for
angular velocities from the inertial frame to the bodyframe is W_, and from the body frame to
the inertial frame is W1 _ , as shown in Fig 4.4.
(5)
The angular velocity of rotor i, denoted with !i, creates force fi in the direction of the rotor axis.
The angular velocity and acceleration of the rotor also create torque_Mi around the rotor axis
34
in which the lift constant is k, the drag constant is b and the inertia moment of the rotor is IM.
Usually the effect of (i) is considered small and thus it is omitted. The combined forces of rotors
create thrust T in the direction of the body z-axis. Torque B consists of the torques in the
direction of the corresponding body frame angles
in which l is the distance between the rotor and the center of mass of the quadcopter. Thus, the
roll movement is acquired by decreasing the 2nd rotor velocity and increasing the 4th rotor
velocity. Similarly, the pitch movement is acquired by decreasing the 1st rotor velocity and
increasing the 3th rotor velocity. Yaw movement is acquired by increasing the the angular
velocities of two opposite rotors and decreasing the velocities of the other two [10].
4.1.4 Wireless Transmission System
There will be a wireless transmitter mounted on quadcopter and interfaced with Arduion
board. There will also be wireless receiver interfaced to a computer that will receive the GPS and
video data. They are several wireless transmission can be exploited which work on RF
communication at 2.4 GHz which is ISM Band allotted for public application.
Telemetry is one of the brightest option for wireless communication in this situation. XBee Pro
radio module can be used as they provide long range of communication with high signal
strength. XBee is a microcontroller made by digi which uses the Zigbee protocol
35
(IEEE802.15.4). The other possible option for wireless communication is WiFi as it is provided
in our campus and easy to use.
4.1.5 PID Control theory and algorithm
PD controllers are nice in their simplicity and ease of implementation, but they are
often inadequate for controlling mechanical systems. Especially in the presence of noise and
disturbances, PD controllers will often lead to steady state error[3]. A PID control is a PD control
with another term added, which is proportional to the integral of the process variable. Adding an
integral term causes any remaining steady-state error to build up and enact a change, so a PID
controller should be able to track our trajectory (and stabilize the quadcopter) with a significantly
smaller steady-state error. The equations remain identical to the ones presented in the PD case,
but with an additional term in the error:
(9)
(10)
(11)
However, Fig 4.5 shows the PID controls come with their own shortcomings. One problem that
commonly occurs with a PID control is known as integral windup.
37
4.2
GPS modules typically put out a series of standard strings of information, under something
called the National Marine Electronics Association (NMEA) protocol.
Zigbee protocol is used by RF 2.4 GHz XBee radio modules to setup the wireless
transmission system to telemeter the video and GPS data.
The ZigBee standard operates on the IEEE 802.15.4 physical radio specification and
operates in unlicensed bands including 2.4 GHz, 900 MHz and 868 MHz.
38
4.3
4.3.1 Constraints
The real time constraints involved during the flight would be external factors like air
drag, wind, birds, tower, transmission lines, wall and trees. Apart from this there are also some
legal constrains to fly the drones and quadcopters. Other constrain during the flight would be
flight time and flight range due to power restraint and communication restraint. Power
optimization is crucial in this situation. The range of flight will limited to 2 to 2.4 Km due to
wireless communication through RC controller. At the time of construction, structure of frame
should be perfect in terms of orientation, weight and size. The selection of motors and propellers
would be such that quad could maintain stable flight with proper tuning of PID.
4.3.1.1
Legal Constrains
One do not need a license to operate a UAV/Drone. Although, the FAA (Federal Aviation
Administration) has rules one needs to follow. Two of the most important rules are: 1) one
should never fly around or above people and should always keep it within sight. 2) FAA has a
complete list of safety guidelines for model aircraft that one should check before you decide to
take off. There are also restrictions on where one can and cannot fly. For example, one cannot fly
within 5 kms of any airport. The Map box provides a great map which lists all the areas which
are no fly zone areas. Also, the local Remote Control (RC) aircraft clubs may list the areas one
can and cannot use. The FAA has partnered with several industry associations to promote Know
before You Fly, a campaign to educate the public about using unmanned aircraft safely and
responsibly. Individuals flying for hobby or recreation are strongly encouraged to follow safety
guidelines, which include: Fly below 400 feet and remain clear of surrounding obstacles
[15].
4.3.1.2
Don't be careless or reckless with your unmanned aircraft you could be fined for
endangering people or other aircraft.
Power shortage and flight duration
One of the main constrained faced during the implementation is power shortage due to higher
need of power consumption by motors and ESC. To degrade this fact, higher capacity battery is
required, but as capacity of battery increase, size & weight will also increase. We have chosen
the 2300 mah battery to operate our system. The flight time is also limited due to capacity of
battery which is 6 to 8 min.
4.3.1.3
Improper weight distribution have occurred in the system due to small size of frame. At the time
of first flight test, throttle observed was improper which leads to unbalanced flight as shown Fig.
4.7. The result of these circumstances was tilt flight. Further increase in throttle will lead to crash
of UAV. To avoid the situation, proper weight distribution is necessary can be achieved by either
increase the frame size or multipoint to single point weight distribution technique. The first one
is easy to implement that is the reason, we decided to adopt it [5].
4.3.2 Alternatives
These are the following alternative should have consider
For establishing the wireless communication from quadcopter to ground station, WiFi
technique can be exploited in spite of Zigbee Protocol (IEEE 802.15.4). GPS and Video
data can be transmitted through WiFi modem instead of XBee Pro Radio telemetries
which will be interfaced to Raspberry Pi.
To operating the flight of UAV, 2.4 GHz RF transceiver have used. We can use
Bluetooth module and control the flight of UAV on the android device with GUI. APM
mission planner, Multiwii, 3DR robotics provide the android app to operate UAVs.
Material of Frame have been chosen as a glass fiber. It could also be wood, aluminum
and carbon fiber as mentioned in section 3.1.1.
Flight controller can also be bought instead of making it from scratches by interfacing of
sensor to Arduino board.
4.3.3 Tradeoff
Tradeoff have explained in the following portions4.3.3.1
Development Cost
It is planned to design a flight controller using accessible microcontroller, sensor and other
required electronic components rather than purchasing directly a quadcopter kit.
4.3.3.2
Weight
To make system more agile, it is necessary to lesser weight that can be done choosing right
frames structure, size and material. The payload carrying capacity will be sacrificed to make
system more agile in nature.
4.3.3.3
Power System
2300 mAh, LiPo battery is used which gives 5 to 6 min of flight time. Flight time can be
increased by increasing the power of battery but it will lead to more volume and mass and
unnecessarily increase weight of the system.
41
CHAPTER 5
SCHEDULE, TASKS AND MILESTONES
The Schedule to complete the required task, in order to achieve the aim of the project is
described in the tabular graph format in Fig. 5.1 which consist of procurement of component,
literature study, development, testing, integration, validation and operation manual preparation.
Developing and Implementing of PID control algorithm and tuning the PID values.
To achieve the above mentioned milestones few crucial tasks are need to be done which were
mentioned in the whole section 4.3.
42
CHAPTER 6
PROJECT DEMONSTRATION
6.1
4.1.2 where the entire component are connected as per setup explained in chapter 3. In every
integral part of the project indicated in Fig. 6.2 and in Fig 6.3, each electrical and mechanical
components of quadcopter have shown. The sponge balls are also shown which works as both
suspension and quadcopter stand as mentioned in section 3.1.2.
There are mainly four integral parts are necessary in this project as mentioned also in the
figure in red block which are complete quadcopter with embedded electronics, Base Station GUI,
Base station telemetry receiver and 2.4 GHZ RF Transceiver. In order to fly, one have do first
binding of 2.4 GHZ RF transmitter and receiver is mentioned in Appendix A. After then
Calibration of ESCs are also necessary (is mentioned in Appendix A). Then arming of motor
43
should be done. Now setup is ready to fly. Now one have to go in open environment. Connect
the battery with power distribution board to power up the whole system. Switch on the 2.4 GHZ
RF Transceiver; A constant blink of 2.4 GHZ RF receiver is gone. Now, one should increase the
throttle by moving the throttle stick up. RF transmitter will send PWM signal to reviver and
ESCs will act accordingly to rotate the propellers. When throttle is enough that quadcopter can
lift up, the data of MPU 6050 will be sent to Arduino board through I2C communication and PID
control algorithm will be applied to maintain the stable flight as shown in Fig. 6.5. One should
tune the PID value properly to maintain the stable flight. These PID values can be easily
observed in GUI as shown in Fig. 6.6. The GPS and video data will sent to base station vai XBee
pro radio module.
44
45
46
47
48
6.2
gyroscope MEMS sensor as shown in Fig. 6.10a and Fig. 6.10b. In addition, it also contain
temperature sensor. It is very accurate, as it contains 16-bits analog to digital conversion
hardware for each channel. Therefor it captures the x, y, and z channel at the same time. The
sensor uses the I2C-bus to interface with the Arduino. The MPU-6050 always acts as a slave to
the Arduino with the SDA and SCL pins connected to the I2C-bus.The output representation of
accelerometer, gyro and temperature is shown in Fig. 6.11.
6.3
The Bluetooth module has been used for controlling and operating the quadcopter as
mentioned in section 4.3.2. The module used here is HC05 as shown in Fig. 6.12.
50
6.4
GPS modules typically put out a series of standard strings of information, under the National
Marine Electronics Association (NMEA) protocol. $GPRMC strings have been used for our
project. The NMEA 0183 standard defines an electrical interface and data protocol for
communications between marine instrumentation. NMEA 0183 devices are designated as either
talkers or listeners (with some devices being both), employing an asynchronous serial interface
with the following parameters:
Baud rate: 4800
Number of data bits: 8 (bit 7 is 0)
Stop bits: 1 (or more)
Parity: none
The NMEA 0183 standard uses a simple ASCII, serial communications protocol that defines
how data are transmitted in a "sentence" from one "talker" to multiple "listeners" at a time.
Through the use of intermediate expanders, a talker can have a unidirectional conversation with a
51
nearly unlimited number of listeners, and using multiplexers, multiple sensors can talk to a single
computer port. Output will be in NMEA format and GPS format is shown in Fig. 6.13 and Fig.
6.14 respectively.
$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76
$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A
$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70
$GPGSV,3,2,11,02,39,223,19,13,28,070,17,26,23,252,,04,14,186,14*79
$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76
$GPRMC,092750.000,A,5321.6802,N,00630.3372,W,0.02,31.66,280511,,,A*43
$GPGGA,092751.000,5321.6802,N,00630.3371,W,1,8,1.03,61.7,M,55.3,M,,*75
$GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38*0A
$GPGSV,3,1,11,10,63,137,17,07,61,098,15,05,59,290,20,08,54,157,30*70
$GPGSV,3,2,11,02,39,223,16,13,28,070,17,26,23,252,,04,14,186,15*77
$GPGSV,3,3,11,29,09,301,24,16,09,020,,36,,,*76
$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45
6.5
The XBee can communicate with other XBee in two modes. One is API mode and another one is
AT mode. Here in the project API mode communication has been chosen. The communication
will be unicast communication. The XBee RF Modules interface to a host device through a logiclevel asynchronous serial port. Through its serial port, the module can communicate with any
logic and voltage compatible UART; or through a level translator to any serial device (for
example: through a RS-232 or USB interface board).
UART Data Flow
Devices that have a UART interface can connect directly to the pins of the RF module as shown
in Fig. 6.15.
Fig 6.16 UART data packet 0x1F (decimal number 31) as transmitted through the RF
module
53
Serial-to-RF Packetization
Data is buffered in the DI buffer until one of the following causes the data to be packetized and
transmitted:
1. No serial characters are received for the amount of time determined by the RO
(Packetiza-tion Timeout) parameter. If RO = 0, packetization begins when a character is
received.
2. The maximum number of characters that will fit in an RF packet (100) is received.
3. The Command Mode Sequence (GT + CC + GT) is received. Any character buffered in
the DI buffer before the sequence is transmitted.
API Operation
API (Application Programming Interface) Operation is an alternative to the default Transparent
Operation. The frame-based API extends the level to which a host application can interact with
the networking capabilities of the module. When in API mode, all data entering and leaving the
module is contained in frames that define operations or events within the module.
Transmit Data Frames (received through the DI pin (pin 3)) include:
RF Transmit Data Frame
Command Frame (equivalent to AT commands)
Receive Data Frames (sent out the DO pin (pin 2)) include:
RF-received data frame
Command response
Event notifications such as reset, associate, disassociate, etc.
The following figures from Fig. 6.17 to Fig. 21 shows the configuration of 2 XBee,
communication AT Mode and API mode has been done in X-CTU Software environment.
54
Fig. 6.17 complete setup of XBee module in X-CTU software, you can see the MAC NO.and
port of device
55
57
CHAPTER 7
MARKETING AND COST ANALYSIS
7.1
Marketing Analysis
This project has been designed for airborne campus surveillance. There is no prior art has been
implemented for this application. Our team has focused on the application and have tried to make
campus surveillance UAV commercially by providing easy design and cost effectiveness. Apart
from this the scope of market will also fall under the other civilian and military application. The
current market for military spending on UAVs is about 10.6 billion and for non-military
spending is near 6.6 billion. This equates to a total market of around 17.2 billion dollars for both
the military and non-military spending on UAVs. Our quadcopter target market also consists
primarily of military and security companies which need constant surveillance. Although
military services mostly prefer to have some UAV and drone by their own. Our quadcopter
attempts to fill a need that is not currently met by existing UAVs due to their higher cost and
complexity to operate.
The proposed UAV can be used for several applications like crop monitoring, aerial surveillance,
aerial photography and search operations. A huge amount of money can be saved by using UAV
for inspections. Wind turbines, power lines, pipelines, etc. can be inspected using a quadcopter.
The focus of the project to make aerial surveillance task easy, less expensive and more efficient.
A lot of money and manpower can be saved by performing the aerial inspection wind turbines,
power lines, pipelines etc. By adding additional sensor technology, 3D mapping of environment
can be done and it will exploit for several uses.
58
$250-$300. They are also not very handy and need trained pilot to operate. Apart from this, they
are very complex to understand and take lot of time to be a pro pilot.
7.1.1.1 DJI
Drones from DJI are very popular these days and comes with lot of feature yet they
comes under the very high cost and maintenance. DJI is an active competitor in the small UAV
market, offering four different copters between $110 and $15000. The closest which comes to
fulfilling those demands is the DJI Phantom 2 for about $1,100. Mostly, DJI Phantom series are
used for aerial photography and known as flying camera. While it does offer a flight time of 25
minutes but you will have to shell out a whopping $800 more than what we are spending on ours.
You may find a cheaper one in Air Hogs RC Helix X4 at $75 but it doesn't come close to the
number of functions our quadcopter will be performing [13].
7.1.1.2 3D Robotics
Another quadcopter, cost of $1000 in market is IRIS+ from company 3D Robotics. It has
advantage in flight time. The total flight time is 20 min for this quadcopter. IRIS+ comes with
an integrated GoPro camera mount with a vibration dampener for aerial photography and video,
but still costly.
7.1.1.3 FireBox
Firebox designs and supplies various electronic products; one of these is the Micro Drone
quadcopter for $120. The Micro Drone quadcopter is marketed towards enthusiast as a toy for
primarily indoor use. Our proposed model will respond to this competitor by focusing on the
features that Firebox failed to include, such as video capturing and GPS navigation.
59
Serial No.
Components
Total Cost
1.
Quadrotor Frame
1200
1200
2.
ESC
1000
4000
3.
Propellers
300
600
4.
Battery
1200
1200
5.
Arduino UNO
1500
1500
6.
1000
4000
7.
Transceiver
3100
3100
8.
Telemetry
2300
4600
9.
Camera
1500
1500
10.
IMU Sensors
1500
1500
11.
GPS Receiver
1800
1800
Total
25000
60
CHAPTER 8
SUMMARY
The Aerial Surveillance System is designed to monitor the real time environment like
surveillance of banks, highly crowded areas, aerial traffic and security watch etc. on a
quadcopter platform using marginal sensor input. The project consists of wireless
communication system, Camera, GPS and a quadcopter aerial platform. The quadcopter is
controlled by a 2.4 GHz RF transceiver system wirelessly. PID control technique will be
exploited to perform the flight stabilization. This project intended to design and fabricate low
cost, light weight surveillance UAV in structure of quad rotor. It is also intended to be able to
carry a payload for future developments.
61
REFERENCES
[1] Towards A Swarm of Agile Micro Quadrotors, Alex Kushleyev, Daniel Mellinger, Vijay
Kumar GRASP Lab, University of Pennsylvania.
[2] Design considerations of a small UAV platform carrying medium payloads, Juan Alberto
Benito, Guillermo Glez-de-Rivera, Javier Garrido Human Computer Technology Laboratory
(HCTLab) Univ. Autonoma de Madrid, Spain guillermo.gdrivera@uam.es
[3] Jun Li, YunTang Li (2011). Dynamic Analysis and PID Control for a
Quadrotor 2011 International Conference on Mechatronics and Automation.
[4] Atheer L. Salih, M. Moghavvemil, Haider A. F. Mohamed and Khalaf Sallom
Gaeid (2010). Flight PID controller design for a UAV Quadcopter. Scientific
Research and Essays Vol. 5(23), pp. 3660-3667, 2010.
[5] A multi-point Metropolis scheme with generic weight functions Luca Martino, Victor
Pascual Del Olmo, Jesse Read Department of Signal Theory and Communications, Universidad
Carlos III de Madrid. Avenida de la Universidad 30, 28911, Leganes, Madrid, Spain.
[6] Simple GUI Wireless Controller of Quadcopter Dirman Hanafi1 , Mongkhun Qetkeaw1 ,
Rozaimi Ghazali1 , Mohd Nor Mohd Than1 , Wahyu Mulyo Utomo2 , Rosli Omar1 1
Department of Mechatronic and Robotic Engineering, Faculty of Electrical and Electronic
Engineering, University Tun Hussein Onn Malaysia, Batu Pahat, Malaysia 2 Department of
Power Engineering, Faculty of Electrical and Electronic Engineering, University Tun Hussein
Onn Malaysia, Batu Pahat, Malaysia
[7] http://fritzing.org/home/
[8] http://arxiv.org/pdf/1112.4048.pdf
[9] https://cma.tcd.ie/misc/Surface_area_and_porosity.pdf
[10] http://sal.aalto.fi/publications/pdf-files/eluu11_public.pdf
[11] http://www.gpsinformation.org/dale/nmea.htm
[12] http://dx.doi.org/10.4236/ijcns.2013.61006
[13] http://www.dji.com/product/phantom-2
[14] http://ardrone2.parrot.com/
[15] https://www.faa.gov/uas/
62
APPENDIX A
Binding of RF Transceiver
Procedure:
Switch the Transmitter in pairing mode and switch the receiver in pairing mode.
Move the throttle to idle and turn the transmitter power on.
Press the ENTER for 5 second.
Press the ENTER key 5 times to select the BIND Function.
Press the up. The screen will display the dotted line scrolling from left to right.
Binding Procedure is done.
the motor depending on the ratio of high to low signals. Calibration involves programming the
ESC to understand the PWM waves corresponding to the stop and maximum speeds of the
motor.
The default signal range for most servo motors and ESCs is a high signal width between 1000
and 2000 microseconds over a repetition period of 20 milliseconds (assuming a 50 Hz PWM
signal). For the quad copter, however, we want the range to be as wide as possible to allow for
greater incremental control of the motor. To this end, we calibrated the ESCs to read a signal
width from 700 to 2000 microseconds with 700 being the stop speed and 2000 being the max
speed.
First flight test for throttle
RC Radios have several outputs, one for each channel/stick/switch/knob. Each radio
output transmits a pulse at 50Hz with the width of the pulse determining where the stick is on the
RC transmitter. Typically, the pulse is between 1000us and 2000us long with a 18000us to
19000us pause before the next - so a throttle of 0 would produce a pulse of 1000us and full
throttle would be 2000us. Sadly, most radios are not this precise so we normally have to measure
the min/max pulse widths for each stick (which we'll do in a minute). Throttle test for flight is
shown in Fig. A.2.
64
APPENDIX B
#include "MPU6050_6Axis_MotionApps20.h"
//#include "MPU6050.h" // not necessary if using MotionApps include file
65
66
uint16_t packetSize;
uint16_t fifoCount;
// orientation/motion vars
Quaternion q;
// [w, x, y, z]
quaternion container
VectorInt16 aa;
// [x, y, z]
VectorInt16 aaReal;
VectorInt16 aaWorld;
VectorFloat gravity;
// [x, y, z]
// [x, y, z]
// [x, y, z]
float euler[3];
float ypr[3];
67
void dmpDataReady() {
mpuInterrupt = true;
}
void setup() {
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
// NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
// Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
// the baud timing being too misaligned with processor ticks. You must use
68
// initialize device
Serial.println(F("Initializing I2C devices..."));
mpu.initialize();
// verify connection
Serial.println(F("Testing device connections..."));
Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050
connection failed"));
// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
69
// set our DMP Ready flag so the main loop() function knows it's okay to use it
Serial.println(F("DMP ready! Waiting for first interrupt..."));
dmpReady = true;
Serial.println(F(")"))
}
// configure LED for output
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// if programming failed, don't try to do anything
if (!dmpReady) return;
71
// check for overflow (this should never happen unless our code is too inefficient)
if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
// reset so we can continue cleanly
mpu.resetFIFO();
Serial.println(F("FIFO overflow!"));
// otherwise, check for DMP data ready interrupt (this should happen frequently)
} else if (mpuIntStatus & 0x02) {
// wait for correct available data length, should be a VERY short wait
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
#ifdef OUTPUT_READABLE_QUATERNION
// display quaternion values in easy matrix form: w x y z
mpu.dmpGetQuaternion(&q, fifoBuffer);
Serial.print("quat\t");
Serial.print(q.w);
72
Serial.print("\t");
Serial.print(q.x);
Serial.print("\t");
Serial.print(q.y);
Serial.print("\t");
Serial.println(q.z);
#endif
#ifdef OUTPUT_READABLE_EULER
// display Euler angles in degrees
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetEuler(euler, &q);
Serial.print("euler\t");
Serial.print(euler[0] * 180/M_PI);
Serial.print("\t");
Serial.print(euler[1] * 180/M_PI);
Serial.print("\t");
Serial.println(euler[2] * 180/M_PI);
#endif
#ifdef OUTPUT_READABLE_YAWPITCHROLL
// display Euler angles in degrees
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
Serial.print("ypr\t");
Serial.print(ypr[0] * 180/M_PI);
73
Serial.print("\t");
Serial.print(ypr[1] * 180/M_PI);
Serial.print("\t");
Serial.println(ypr[2] * 180/M_PI);
#endif
#ifdef OUTPUT_READABLE_REALACCEL
// display real acceleration, adjusted to remove gravity
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetAccel(&aa, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
Serial.print("areal\t");
Serial.print(aaReal.x);
Serial.print("\t");
Serial.print(aaReal.y);
Serial.print("\t");
Serial.println(aaReal.z);
#endif
#ifdef OUTPUT_READABLE_WORLDACCEL
// display initial world-frame acceleration, adjusted to remove gravity
// and rotated based on known orientation from quaternion
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetAccel(&aa, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
74
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
Serial.println(F("FullExample.ino"));
Serial.println(F("An extensive example of many interesting TinyGPS++ features"));
Serial.print(F("Testing
TinyGPS++
library
v.
"));
Serial.println(TinyGPSPlus::libraryVersion());
76
Time
Date Alt
Course
(deg)
RX
(deg)
Age
Age (m)
Fail"));
Serial.println(F("--------------------------------------------------------------------------------------------------------------------------------------"));
}
void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
(unsigned long)TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON) / 1000;
printInt(distanceKmToLondon, gps.location.isValid(), 9);
double courseToLondon =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);
smartDelay(1000);
78
static void printFloat(float val, bool valid, int len, int prec)
{
if (!valid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
79
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(' ');
}
smartDelay(0);
}
{
if (!d.isValid())
{
Serial.print(F("********** "));
}
else
{
char sz[32];
sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
Serial.print(sz);
}
if (!t.isValid())
{
Serial.print(F("******** "));
}
else
{
char sz[32];
sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
Serial.print(sz);
}
82