Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction in robotics, Cheat Sheet of Robotics

this books is for review only

Typology: Cheat Sheet

2022/2023

Uploaded on 11/06/2022

john-jeriel-galicia
john-jeriel-galicia 🇵🇭

1 document

1 / 222

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
McGriffy
Make: Drones
Teach an Arduino to Fly
Teach an Arduino to Fly
by David McGriffy
Technology & Engineering/Drones
US $29.99 CAN $34.99
ISBN: 978-1-6804-5171-9
Make: Drones
Inside Make: Drones, you'll find:
If you’re passionate about drones, get ready to take your skills and understanding
to new heights. Drones make a great platform for learning about the fascinating,
useful, and even beautiful world of control systems. With this guide, you will
learn how to harness the breakthroughs that make possible the remarkable flying
abilities of multirotor copters.
» Hands-on DIY projects for building your own drones using existing frames
» An in-depth examination of flight-control systems and programming
» Tips for upgrading and improving off-the-shelf systems
» A lucid explanation of multirotor aerodynamics
» Custom circuit board design with modular components
» Instructions for installing RC radio, telemetry, and GPS systems
» Fine-tuning and troubleshooting for flight stabilization
» And much more!
If you’re ready to get serious about drones and drone control systems,
this is the book for you. Teach your Arduino how to fly today!
The book covers three classes of drones. You’ll start by building a small drone using
the Hubsan frame and brushed motors. As you move up to a medium-sized drone,
you’ll use an Arduino Teensy as the core of a flight-control system and add modules
for power, sensors, and radios. Finally, you’ll build an autonomous drone using the
S500 frame kit, brushless motors, and an ArduCopter flight control system that
makes a great aerial photography platform.
Make:
Drones
7.5 x 9.25
190.5 mm x 234.95 mm 7.5 x 9.25
190.5 mm x 234.95 mm
.438
11.125 mm
15.438” x 12”
392.2 x 305 mm
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Introduction in robotics and more Cheat Sheet Robotics in PDF only on Docsity!

Teach an Arduino to Fly

by David McGriffy

Make:

Drones

Technology & Engineering/Drones

US $29.99 CAN $34. ISBN: 978-1-6804-5171-

Make: Drones

Inside Make: Drones, you'll find:

If you’re passionate about drones, get ready to take your skills and understanding

to new heights. Drones make a great platform for learning about the fascinating,

useful, and even beautiful world of control systems. With this guide, you will

learn how to harness the breakthroughs that make possible the remarkable flying

abilities of multirotor copters.

» Hands-on DIY projects for building your own drones using existing frames

» An in-depth examination of flight-control systems and programming

» Tips for upgrading and improving off-the-shelf systems

» A lucid explanation of multirotor aerodynamics

» Custom circuit board design with modular components

» Instructions for installing RC radio, telemetry, and GPS systems

» Fine-tuning and troubleshooting for flight stabilization

» And much more!

If you’re ready to get serious about drones and drone control systems, this is the book for you. Teach your Arduino how to fly today!

The book covers three classes of drones. You’ll start by building a small drone using
the Hubsan frame and brushed motors. As you move up to a medium-sized drone,
you’ll use an Arduino Teensy as the core of a flight-control system and add modules
for power, sensors, and radios. Finally, you’ll build an autonomous drone using the
S500 frame kit, brushless motors, and an ArduCopter flight control system that
makes a great aerial photography platform.

978-1-680-45171-

[LSI]

Make: Drones by David McGriffy

Copyright © 2017 David McGriffy. All rights reserved.

Printed in the United States of America.

Published by Maker Media, Inc., 1160 Battery Street East, Suite 125, San Francisco, CA 94111.

Maker Media books may be purchased for educational, business, or sales promotional use. Online edi- tions are also available for most titles ( http://safaribooksonline.com ). For more information, contact O’Reilly Media’s institutional sales department: 800-998-9938 or corporate@oreilly.com.

Editor: Roger Stewart Production Editor: Nicholas Adams Copyeditor: Charles Roumeliotis Proofreader: Rachel Head

Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Julie Cohen Illustrator: Rebecca Demarest

October 2016: First Edition

Revision History for the First Edition 2016-10-05: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781680451719 for release details.

Make:, Maker Shed, and Maker Faire are registered trademarks of Maker Media, Inc. The Maker Media logo is a trademark of Maker Media, Inc. Make: Drones and related trade dress are trademarks of Maker Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Maker Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the informa- tion contained herein.

Table of Contents

    1. What Makes a Drone Possible Preface ix
    • Motors
    • Batteries
    • Control Systems
    1. Popular Drone Control Systems
      • MultiWii
      • Dronecode
        • APM/ArduPilot
        • PX4/Pixhawk
      • DJI/Naza
      • KK2
      • CC3D/OpenPilot
      • Naze32/Baseflight/Cleanflight
      • Choosing a Flight Control System
    1. Drone Activities
      • Aerial Photography
      • FPV Racing
      • Education
      • Flying
    1. Improve the Hubsan X4
      • Goals and Test Methods
      • Battery Upgrade
      • Prop Upgrade
      1. Build the X4Wii
      • Parts
      • Build
        • Flashing New Code
        • Wiring
        • Assembly
      • Setup and Tuning
        • RC Rates
        • PIDs
        • Modes
      1. The Visible Drone
      • A Teensy CPU
      • Radios
      • IMU/AHRS
      • Power
      • Circuit Board with Motor Controllers
      • Frame/Motors/Props
      • Weight Budget
      1. Basic I/O Code
      • Setting Up the IDE
      • Main Loop
      • RC Receiver
      • Bluetooth
        • Motors
        1. Multirotor Aerodynamics
        • Lift and Thrust
        • Pitch and Roll
        • Yaw
        • Translational Lift
        • Vortex Ring State
        1. IMU/AHRS
        • Gyros
        • Accelerometers
        • IMU
        • Magnetometers
    1. Mode and Mix
      • Mode
        • Angle Mode
        • Rate Mode
      • Mix
      1. PIDs
        • The Algorithm
          • P—Proportional
          • I—Integral
          • D—Derivative
        • Implementation
        • Tuning
          • Theory
          • Practice
    1. Circuit Board and Motor Controllers
      • Design Tools and Files
      • Component Placement
    • Power Input and Distribution
    • Motor Controller
    • Schematic and Layout
    • Construction
    1. Construction and Tuning
    • Install the Controller and Connect the LEDs
    • Connect the Motors
    • Install the Radios
    • Complete the Frame
    • Ground Test
    • Flight Test and Future Work
    1. A Bigger Frame
    • The S500 Kit
    • Follow the Instructions
    1. Install the Power System
    • Mount the ESCs
    • Wire the Power Distribution Board
    • Mount the Motors
    • Determine Direction
    1. Brushless Motors and Their ESCs
    • Brushless Motors
    • ESCs
    • BECs
    1. Install the Flight Controller and Radios
    • Pixhawk Lite and Shock Mount
    • RC Radios
    • Telemetry Radio
    • Safety Switch
    • Testing
        1. GPS
        • History
        • Theory
        • HDOP
        • Installation
        1. Magnetometer
        • The Earth’s Magnetic Field
        • Declination and Deviation
        • Magnetoresistance
        • Use in Drones
    1. Flying the S500
      • Install the Props
      • Connect the Battery and Voltage Monitor
      • Radio and Accelerometer Calibration
      • Flight Modes
      • Initial Tuning
      • Final Checklist and First Flight
        1. Optical Flow, Sonar, and Lidar
        • Sonar
        • Lidar
        • Optical Flow Sensors
        • Visual Odometry
      1. Vibration
        • Causes of Vibration
        • Effects of Vibration
        • Damping and Isolation
        • Prop Balancing
      1. Failure Modes and Fault Tolerance
        • Failsafes
        • Redundancy
    1. Interfaces
      • Computer Interfaces
      • RC Radio Standards
        • DSM/DSM2/DSMX
        • FrSky
      • Servo/ESC Control
      • Telemetry
      • GPS
      1. The Future
        • Specialization
        • Regulation
        • Ease of Use
        • Safety
        • Human Flight
      • Index

Preface

Success

The successful people I have known all seem to have gotten there by some personal mix of talent, luck, and work. I hope that the mix turns out right in this book and that I succeed in inspiring you to make something. It will probably be a drone, but if it’s a great new garage door opener, I’ll count that as a success as well.

I have put my unique talents into this book, as you will into your project. I was born with a soldering iron in my hand, or almost, thanks to my father’s ham radio hobby. Also, largely due to his efforts, I started finding things to program when I was still a kid. I happen to love mathematics, which has served me well as a coder, of course. And there are several pilots on my father’s side of the family. But there are other threads in my life that led to drones.

From my mother’s side I get music. My love of music and my love of gear came together in recording technology. This led to computer audio and digital signal processing. And now we get back around to drones. Many of the very same algorithms I have coded for audio processing get used in drones to process sensor data and control inputs.

Add in some professional experience doing consulting in the control systems business, and perhaps you can see why I love building drones. It all comes together—building elec- tronics, flying, radios, programming, signal processing. But there was also some luck involved in the creation of Make: Drones.

My old friend Tim Deagan was working on his book, Make: Fire, and I shot some drone video of his fire projects. Then Roger, who would become our mutual editor, said, “Drones are hot, send me a book proposal on drones,” so I did.

Then there is the work. And I don’t just mean mine. Roger Stewart makes all those things happen that turn a bunch of files into a book on a shelf. Ron Parsons has saved me from many an error as technical editor. He also let me play on his Processor Technology Sol per-

ix

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

This element signifies a general note, tip, or suggestion.

This element indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, etc.) is available for download at http:// www.makedronesbook.com.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to con- tact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from Make: books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Make: Drones by David McGriffy (Maker Media). Copyright 2017 David McGriffy, 978-1-680-45171-9.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at bookpermissions@makermedia.com.

Preface xi

Safari ® Books Online

Safari Books Online offers a range of plans and pricing for enterprise, government, educa- tion, and individuals.

Members have access to thousands of books, training videos, and prepublication manu- scripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

Maker Media, Inc. 1160 Battery Street East, Suite 125 San Francisco, CA 94111 877-306-6253 (in the United States or Canada) 707-639-1355 (international or local)

Maker Media unites, inspires, informs, and entertains a growing community of resourceful people who undertake amazing projects in their backyards, basements, and garages. Maker Media celebrates your right to tweak, hack, and bend any technology to your will. The Maker Media audience continues to be a growing culture and community that believes in bettering ourselves, our environment, our educational system—our entire world. This is much more than an audience, it’s a worldwide movement that Maker Media is leading. We call it the Maker Movement.

For more information about Maker Media, visit us online:

Make: and Makezine.com: http://makezine.com Maker Faire: http://makerfaire.com Maker Shed: http://makershed.com

We have a web page for this book, where we list errata, examples, and any additional infor- mation. You can access this page at http://bit.ly/make-drones.

To comment or ask technical questions about this book, send email to bookques- tions@oreilly.com.

xii Make: Drones

And now we are getting closer to where the beauty lies.

As with the most interesting people and the best books, the real beauty of the multirotor drone is on the inside. An ArduCopter-based drone has four main inputs from two joysticks and four outputs to its motors. To compute those four outputs from those four inputs, it uses nearly three hundred parameters. At first it may appear that this is so complex as to be magic, but it’s not. It’s engineering. And precisely because of all the parts it doesn’t have, a drone turns out to be a wonderful platform to learn about engineering principles.

The algorithms used in drone control systems are basic, important, and beautiful. You’ll dis- cover that learning how to use them will be fun and interesting. But these methods have been around for decades. So whatever the aesthetics, they are not the breakthrough that made modern quadcopters possible. And make no mistake: there have been break- throughs.

I have flown radio control aircraft off and on for many years and have watched them with great interest since I was a kid. There have long been RC helicopters, but they were expen- sive and very hard to fly. Then there were toy helicopters, but to watch them fly is to know that they belong in the toy aisle. The military built cruise missiles, but they cost millions. Then one day a friend brought a quadcopter into the office. It would fit in your hand and it flew like an aircraft, not just a toy. And the punch line? It cost $20! Now that’s what I call a breakthrough.

So I bought one, then another, then a bigger one. Then I built one from scratch and started to modify the flight control code. After many crashes and much thought, I am now ready to say what has changed: motors, batteries, and control systems.

Drones Versus Quadcopters

You will see several terms for the flying things we will build here. Some take “drone” to mean only a military system or vehicle that can fly autono- mous missions. Since it is by far the shortest, easiest word for it, I intend to use the word “drone” for just about anything that can fly without a human on board. The military actually calls them unmanned aerial vehicles (UAVs) and the FAA calls them unmanned aerial systems (UASs), but I use enough acronyms in my life without using one where a one-syllable word

like “drone” will do. The term “multirotor” leaves out fixed-wing aircraft and traditional helicop- ters, but describes everything we will build here. The term “quadcopter” describes an even more limited class—only those with four, not six or eight, props—but still covers all of our projects. We will use these words to differentiate our drones from fixed-wing or six-rotor vehicles when needed, but also sometimes just for vari- ety.

Motors

That first little quadcopter I saw at the office, like most micro drones, used tiny electric motors. They are smaller but look essentially the same as the small DC motors I bought 10 to a bag as a kid, but those were nowhere close to powerful enough to lift themselves. It

2 Make: Drones

Motors

turns out that there is an essential difference between the quadcopter motors and the motors I was familiar with. Like many motors these days, they use rare earth magnets, but that’s not the essential difference. These “coreless” motors (Figure 1-2) are optimized for aviation.

Figure 1-2 6 mm, 7 mm, and 8.5 mm coreless motors

The windings in small motors, like nearly all electric magnets, are generally made around a core of some ferrous material like iron. This makes the magnets more efficient—electrically efficient, that is. It turns out, however, that weight is more important than energy efficiency in aviation, so someone thought to take out that heavy core, and our tiny, flight-ready motors were born.

These coreless motors, used in smaller drones, are often called “brushed” to differentiate them from the sort of motor used in larger multirotors, which have no brushes. In most motors, brushes riding on a series of contacts control which windings get energized in what order. In a brushless motor, first developed for floppy disk drives (see Figure 1-3), electronics control the windings instead of contacts, making a simpler, longer-lasting motor.

Chapter 1 3

Motors

Figure 1-4 A selection of 1S and 3S LiPos

LiPos come in all sizes and shapes, from batteries the size of a thick postage stamp to bat- teries the size of a suitcase that can literally run your house or your car. Their capacities and capabilities vary accordingly. They can be rather finicky things compared to say, nickel– metal hydride (NiMH) batteries. LiPos don’t like to be left fully charged for long but don’t want to be stored completely empty either. Treat them wrong and it is pretty easy to ruin them, or worse. They have a bit of a reputation for catching on fire, but with a few reason- able precautions LiPos will allow us to do things no other batteries will.

Control Systems

In between the batteries and the motors is the control system. Even the tiniest micro drone has several subsystems, including radio receivers, gyros, accelerometers, and, of course, a processor to tie it all together. Since each of these components is just a little black chip on a circuit board that looks much like those out of any modern consumer electronics gadget, people may be less aware of the advances that have made modern drone control systems possible.

Before looking at what’s new, however, it’s worth pointing out that some parts of these lit- tle control systems date back years or even decades. The processors used are fairly modern, but the microcontrollers of several years ago could have done this job as well. On the software side, the algorithms used, including the Kalman filter and PID controller, have been used by control systems engineers since long before the microprocessor was inven- ted.

Chapter 1 5

Control Systems

Having acknowledged the great work of engineers past, however, some aspects of drone control systems do represent new breakthroughs. The general shrinking of electronic com- ponents in both physical size and power consumption makes smaller drones possible. Modern design and manufacturing techniques allow these tiny chips to be integrated into task-specific circuit boards that can be economically made in small numbers. A flight con- troller, containing all the subsystems mentioned above and more, can be put on a single board that you could lose in a shirt pocket.

At least one of the chips on that little board represents a breakthrough that is more spe- cific to aviation: the gyro. Gyroscopes have been used to stabilize aircraft since Lawrence Sperry demonstrated his gyroscopic stabilizer apparatus on a Curtis C-2 biplane to a French audience in June 1914. As mentioned earlier, radio-controlled helicopters were notoriously hard to fly, so someone eventually made a gyroscopic stabilizer for them. The first models used physical spinning disks, just like the children’s toys, and thus were rather large and heavy for all but the biggest model helicopters. The price of a single axis stabil- izer would buy a complete midsized quadcopter today.

Now we can get three gyros and three accelerometers in a single chip (Figure 1-5) and they only cost a few bucks, even in small, maker-friendly quantities. And this brings us to one more breakthrough and pleasant surprise. It’s nothing new for a consumer gadget like a drone to be made more cheaply in China. What makes this new world of micro aviation so exciting for makers is that Chinese manufacturing has resulted in a range of drone parts that we can buy in single units, mix and match, and make into our own designs.

Figure 1-5 A gyroscope module and its inspiration

6 Make: Drones

Control Systems