Book Image

Designing Purpose-Built Drones for Ardupilot Pixhawk 2.1

By : Ty Audronis
Book Image

Designing Purpose-Built Drones for Ardupilot Pixhawk 2.1

By: Ty Audronis

Overview of this book

The Ardupilot platform is an application ecosystem that encompasses various OS projects for drone programming, flight control, and advanced functionalities.The Ardupilot platform supports many Comms and APIs, such as DroneKit, ROS, and MAVLink. It unites OS drone projects to provide a common codebase. With the help of this book, you will have the satisfaction of building a drone from scratch and exploring its many recreational uses (aerial photography, playing, aerial surveillance, and so on). This book helps individuals and communities build powerful UAVs for both personal and commercial purposes. You will learn to unleash the Ardupilot technology for building, monitoring, and controlling your drones.This is a step-by-step guide covering practical examples and instructions for assembling a drone, building ground control unit using microcontrollers, QgroundControl, and MissionPlanner. You can further build robotic applications on your drone utilizing critical software libraries and tools from the ROS framework. With the help of DroneKit and MAVLink (for reliable communication), you can customize applications via cloud and mobile to interact with your UAV.
Table of Contents (16 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Purposes for drones


Drones are just for taking pictures, right? Wrong! Drones can be useful for just about anything and everything. Here are just a few examples:

  • Suffering in a drought (hello, California) but need to water your crops? You can use a drone to map your whole farm. Then, run analysis on crop health, so that you know where to direct water. All the while sipping iced tea on your porch.
  • Want to walk the golf course, but don't want to hire a caddy or carry your own clubs? Caddy drone to the rescue! Make a motorized golf trolley, and have it follow the GPS signal on your cell phone as your walk the golf course.
  • Maybe you're a herpetologist on an expedition to a remote location and you found a new species of tree frog. Get it back to base-camp from miles away in an autonomous powered glider. Just load the frog into the payload bay, give it a toss above the treeline and let it fly (and land at) home! Then, just wait for base camp to get the specimen and send the powered glider back to you for your expedition to continue.
  • You're a lifeguard at a beach and see someone having trouble. Launch an aerial drone that drops a boat-drone to tow the person back to shore. All the while, you don't have to leave your station (leaving the rest of the beach-goers without a lifeguard). You can meet the victim at the beach with medical supplies you may need and you're not too exhausted to help out!

The list goes on and on and on. If you can think of something requiring delivery of an item, manual labour requiring movement to another location, or just something to save time, a purpose for a drone will be found. The possibilities are quite literally limitless.

The following image shows the (Israeli Defense Force) Air Mule. It is an autonomous ambulance drone designed to go into the battlefield and airlift wounded soldiers and civilians back to a medical facility at over 100 miles per hour, all with no pilot onboard:

There is some fear that drones will eventually replace people on certain jobs. This fear is slowly being realized with autonomous cars (as UBER is talking about rolling out). After all, these are drones too. However, I prefer to think of it as freeing people from the mundane tasks in favour of the pursuit of their imaginations (like figuring out more uses for drones). Besides, people are still needed to maintain drones, monitor them, and analyse the data they provide. (At least until artificial intelligence (AI) is better at abstracting ideas and problem solving.)

It goes even further than a single drone for a single purpose though. With swarming, multiple drones can specialize in parts of a task and cooperate to achieve a very complicated result. For instance:

  • Geologists deploying swarms of aerial drones to get infra-red imagery of fault lines while additional swarms of rovers (with seismic sensors) can monitor those fault lines for activity. That sort of purpose can save thousands of lives.
  • Swarms of submersible micro-drones in the oceans can monitor currents and track tidal-waves headed toward land. They could even be powered using the kinetic energy of the currents to generate their electricity. People could be evacuated in time to save them.
  • In the event of a natural disaster, electricity (and therefore communications) is the cause of many casualties. A swarm of communication drones (cell tower repeater replacements) can fan out across a country to re-establish the communication networks in a matter of minutes.

These are certainly some altruistic and noble uses for swarming, but the military also sees the benefit of drone swarms. The following image shows a recent test of drone swarms (deployed by dropping them from a pair of f-18 Hornets) used to map out a battle-field in real-time for mission commanders and soldiers on the ground:

Drone swarms can also be used by the entertainment industry to cover sporting events, if one drone is running low on batteries, another takes off to take its place. Drone swarms could be deployed over golf courses to help enthusiasts find their ill-hit balls that have gone off into the weeds. Farmers could use drone swarms to monitor crops, plant seeds, monitor watering patterns (and waste from evaporating water, or atomized sprinklers going into the air).

Again, the uses for drones are limitless.

We could list potential uses for drones all day, all night, every day, and every year, for our lifetimes. So, how do we realize this potential?

Well, to figure out how to make drones, we'll always first start off with how to implement existing tech and components to make what we want. The first step is to think in terms of what types of drones exist currently.

Types of drones

Drones come in two categories with several subcategories. There are surface/subsurface drones, and aerial drones. Let's dive further into each.

USV drones

USV simply stands for either Unmanned Surface Vehicle or Unmanned Submersible Vehicle. The same acronym of USV is used for both. These types of drones are usually referred to as Rovers or Submersibles respectively.

Rovers

Rovers usually either have treads (like a tank) or wheels (like a car). The Mars Rovers are great examples of USV Rovers. They move along the surface of Mars taking various readings and measurements in an effort to explore the surface of another planet without the risk to human life. The following picture shows one of these Mars Rovers:

Not every endeavor for a rover needs to be quite so lofty as to explore another planet. Rovers are currently used in aspects of our daily lives (the iRobot Roomba is a daily life example of a USV Rover) all the way through exploring our own planet (rovers designed to explore lava flows—areas far too dangerous and inhospitable to humans).

However, rovers don't have to simply be driven across the ground. Some rovers are actually boats designed to skid across the surface of water for various purposes. An example of boat-drone USV is the one designed by the US Navy to escort ships through pirate-ridden waters, and protect naval vessels from other hostile vessels in dangerous waters (eliminating, or at least reducing, the need for bloated battle-groups).

In this book, we will be designing three surface rovers:

  • A basic autonomous RC car which serves no purpose other than your education on the basics of implementing the Ardupilot interface.
  • A water USV that serves the purpose of a duck decoy which autonomously navigates pre-planned routes around a pond for hunters. Hmm... one wonders what that might go for in a store?
  • A ground USV golf caddy. This will show you how to make a rover follow a GPS tracker (in the form of the user's cell phone). This caddy is designed to move your clubs around the golf course without having to carry your bag, nor even tell the caddy where to go. It will simply follow you.
Submersibles

Submersibles are vehicles designed to go beneath the surface of a liquid. Traditionally, this liquid is water. However, submersible vehicles could potentially be used to monitor other liquids, such as fermentation tanks at breweries, mixing tanks at chemical plants, and diving into raw sewage tanks. Other than diving into a vat of beer, I'm sure you can see how using drones is preferable to diving in yourself.

We won't be attempting to create a submersible in this book. However, the techniques employed are very similar to the subject matter of this book. Submersibles should only be attempted by highly experienced drone designers, as they'll have to contend with reduced ability to utilize GPS, reduced radio transmission distance, and highly reduced visibility in water (or other liquids). Therefore, technologies such as forward looking infrared (FLIR), signal repeaters, and collision avoidance (via SONAR) should be considered. However, as you can see from the following image, the similarities between underwater drones and fixed-wing aerial drones (airplanes) are fairly obvious:

The similarities between the Navy's "Ocean Glider" submersible drone and the original X-1 airplane (the airplane which first broke the sound-barrier) are rather astounding.

UAV drones

UAV stands for Unmanned Aerial Vehicle. Simply stated, this is any drone that flies. However, much like the term USV can also include submersibles, this category can also cover vehicles that go into space (such as the Pioneer satellites, the Cassini probe, or even the Air Force's replacement for the Space Shuttle—the X37B.

The US Air Force's X37b can be drop-launched from a high-flying airplane, or mounted to a rocket. It can also autonomously stay in space for several years, change orbital paths, and return to the ground for an autonomous landing. The actual payloads and missions are classified. You didn't really think we'd rely on Russia and civilian agencies for all the United States' needs in space, did you?

We won't bother to get into space any further. After all, if you're working for NASA you probably don't need this book. Still, it was cool to mention. In the air, UAVs can be broken into five essential categories:

Multirotors

Sometimes, people refer to these as quadcopters or quadrocopters. Technically, this isn't accurate unless the multirotor has four-propellers. There are also hexacopters (six-propellers), octacopters, (eight-propellers), and even all the way up to thirty-two-propellers (although I have no idea what that word would even be). So, you can see how multirotor simplifies it all. After all, they are essentially the same type of aircraft, just with more or less motors and propellers. (It's like calling a monofoil and a biplane an airplane, but calling a monofoil a biplane is incorrect).

How do multicopters fly?

The principle is simple. So simple (in fact) that you may wonder why these weren't a thing until recently. Propellers blow air down to provide lift and the airframe (the whole body) tilts to direct that thrust behind (to go forward), in front (to go backward), or to either side (to slide left or right). You can see this in the following illustration:

But then there's controlling it.

It requires thousands of calculations per second to decide exactly how much power should go to each motor to keep the aircraft level and stable in the air. No two motors come out exactly the same. So, it's not just a matter of providing equal voltage to each motor. It's a matter of adjusting that voltage to each motor based on what's currently happening to the aircraft. So, in essence the aircraft doesn't fly it reacts to its inability to fly and compensates for it. And then there's turning (yaw).

You may notice there's no tail rotor on a multicopter. Tail rotors on traditional helicopters serve two functions:

  • Keep the airframe (the body) of the aircraft from spinning out of control. After all, Newtonian Physics tells us that for every action, there is an equal and opposite reaction. If the motor is turning the primary rotor, what's to stop it from spinning the body in the opposite direction?
  • By varying the pitch of the blades on the tail rotor, more or less thrust (as well as the direction of the thrust) can be controlled. This lets the pilot yaw the aircraft (turn it).

So, how does a multirotor achieve yaw? The answer is in the preceding first reason. There are (usually) even numbers of rotors on a multicopter. Half of these rotors spin in one direction (clockwise) and the other half in the other direction (anti-clockwise). When you want to turn left, the blades spinning to the right speed up and the blades spinning to the left slow down. This way, the effective lift remains the same but the torque from the motors yaws the aircraft to the left. The opposite happens when turning to the right. The following illustration shows this in action:

This is also why tricopters (three rotors) are largely not used. They were notoriously unstable and battery-inefficient. They looked super cool though. Rather like the drop ship from the movie Aliens. However, a variation of the hexacopter (six-rotors) uses that motif (which brings us to yet another variation on blade-configuration). A flat-hexacopter has all-six blades stationed on a single plane. The over-under version of a hexacopter looks like a tricopter with three basic lift points, but counter-rotating blades stacked atop one another so one plane of blades moves in one direction; while the one following moves opposite.

The following picture shows a standard quadcopter (upper left), an over-under hexacopter (upper-right), and a flat-hexacopter (bottom). Most configurations for multicopters are now flat, as it's more efficient for battery time and lift capabilities:

So, as you can see, multicopters are a platform based on a simple principle that is extremely complicated to make work. You (the pilot) don't actually fly a multicopter. It flies itself. Instead, you really just tell it where to go and what to do. You don't pilot a multicopter, you wrangle it.

For the guidance system (in our case we'll be using Pixhawk 2.1—an Ardupilot-based system) to accurately calculate what each motor should be doing there is a plethora of sensors it needs:

  • Accelerometers: Measure the attitude of the aircraft to see whether it's level, what direction it's moving in (relative to last attitude). These essentially measure the linear velocity. So, there need to be several of these sensors in order to measure all axis of movement. The Pixhawk has three accelerometers which are quite good and very fast. However, more can be added.
  • Gyroscopes: These differ from accelerometers in that they sense angular movement (roll, pitch, and yaw). Each gyroscope measures one axis of movement, so three are needed. Pixhawk includes three gyros.
  • Magnetometers: This sensor functions essentially as a compass. They measure the Earth's magnetic field and can tell the vehicle's relative heading to north. However, as aircraft can roll and pitch, one should be implemented for each axis and compared to each other (as one magnetometer may get locked if perpendicular to north). Pixhawk has three of these.
  • Barometers: A barometer measures air pressure. Because air pressure changes at various altitudes, this method can tell the relative altitude to the takeoff point. Amazingly, these can be quite accurate (down to individual inches) depending on the number of sensors, and their sensitivity. Pixhawk has two built in.
  • Global positioning system (GPS): GPS tells the Pixhawk where it is (on the planet). We'll get deeper into GPS and how it works in a later chapter, but let's just say that not all GPS receivers are created equally. GPS is an approximation and various factors determine how accurate it is. GPS is not included with Pixhawk. You must buy your own GPS module for it.

So, accuracy of sensors is extremely important (as you can see) with regard to flying multicopters. If it's truly flying itself and you're just telling it where to go, you want that robot brain to have as much information (which is as accurate) as possible.

The myth with multicopters is that they're extremely simple. This is probably because they are fairly easy to fly. That myth should be dispelled right here and now. Of all the drone-types, they are the most difficult to design and build. You'll find that parts should work together, but don't. You'll find that balancing lift to flight-time is extremely difficult. And you'll find that when things go wrong, they go very wrong. Trust me I have the scars to prove it. So, when we get into multicopters, please pay the utmost attention to safety. They are essentially flying Cuisinarts.

Fixed-wing drones – airplanes

Airplanes are considered by many as the Holy Grail of UAVs. They can generally fly for a lot longer than multicopters (as they have wings and don't have to use up battery power on lift). They are much easier to fly (as they can actually glide and, if the motor cuts out, they don't drop like a rock). However, the difficulty with airplanes is takeoff and landing.

Since airplanes don't hover, they must be moving at speed to take off and land. Landing an airplane isn't too easy either. They must touch the ground softly, or they may bounce up again, stall, and crash. So, how do you design a drone to land at speed softly? It's not easy. But Pixhawk has been known to do this pretty well.

Also, since an airplane needs to maintain a certain speed in the air to keep wind flowing over the wings in order to provide lift (called air speed); the guidance system needs to know how fast it's moving through the air (not just in relation to the ground). In addition to all of the sensors employed by the Pixhawk for a multicopter; one more sensor is needed for an airplane a pitot tube.

You'll find a pitot tube on any real airplane to measure airspeed. This device is the little sticks you see protruding from the sides or nose of the airplane. The following image shows how a pitot tube works:

Image courtesy of Wikimedia commons

The following image shows a pitot tube on a piloted aircraft:

The Pixhawk does not have this sensor, but one can be purchased to use with it.

Fixed-wing drones can also be launched in a variety of ways. Some are thrown; others are launched on catapult systems, while still others are launched by taking off like traditional aircraft (rolling takeoff with wheels).

The following image shows one of my drones (2012) being launched via a catapult system known as a Jetapult:

Since this drone had a seven-foot wingspan, it was far too large to launch by throwing it. The system was very simple. It used PVC pipe to angle the aircraft and slide it up at a slight angle while a bungie cord pulled the aircraft forward at a high rate of acceleration. If you look closely, you can see the black bungie cord wadded up on the ground just behind the (now flying) drone. The release was a simple foot-pedal that slid a ring off a peg.

Although this is a simple mechanism, even military drones are sometimes launched from catapults (as shown in the following image):

Hybrid drones – VTOL

You may wonder why we spent so much time on takeoff and landing. Vertical Takeoff and/or Landing (VTOL) drones solve a lot of issues, but present a high degree of complexity. These drones can take off like a helicopter (or multicopter), fly like an airplane, and land again like a helicopter/multicopter.

The XplusOne (by Xcraft) takes off and can even fly like a quadcopter, but then it can transition into forward flight like an airplane. As you can see though, designing such an aircraft is incredibly difficult. Wind resistance from the wing (when vertical) can create instability during multirotor flight and transitioning to airplane flight can be equally difficult. However, the most difficult proposition of all is coming back to quad-flight for landing. How do you keep the aircraft from ballooning (gaining altitude) and then stalling into a crash? You should only attempt this when you have a high degree of funding and experience, because it's virtually guaranteed that you'll crash it several times before tuning your design to be just right.

Helicopter drones

Traditional helicopters do have some advantages. They can fly faster than multicopters (usually) and are more stable during forward flight (due to a tail fin and horizontal fins). They can also (sometimes) stay in the air longer, as they do not require the quick responsiveness of electric motors. Therefore, they can fly using combustion engines or even turbo-shaft engines, meaning they can carry more fuel and fly for longer. The following picture shows a US Navy helicopter drone:

However, traditional helicopters shift the pitch of their blades through the use of a swash plate. They also (usually) shift the pitch of their tail rotor blades using a similar method (albeit less complicated). A swash plate is basically two plates that rotate and move up and down the rotor shaft to alter the pitch of the blades. How does a helicopter tilt forward to start moving? The swash plate tilts and shafts going down to the swash plate make the blades bite into the air more at the back of the helicopter, and bite less toward the front (producing more downforce at the rear and less at the front).

All of these moving mechanical parts require lubing and maintenance between every flight. The more complex a machine is, the more opportunity there is for failure. So, although there are advantages to traditional helicopters the disadvantages (in terms of cost and maintenance schedule) make them a nonstarter for many.

The following image shows how a swash plate works. The red disk remains stationary and rotates or moves up and down. Meanwhile, the beige parts turn with the rotor head and the aqua control rods shift the pitch of the blades depending on where they are positioned during their rotation cycle:

That's the end of helicopters for the purposes of this book. As there really is little difference between helicopters and multicopters for the purposes of our Pixhawk, we have chosen to cover multicopters in this book.

Dirigible drones – Blimps

Blimps are actually pretty great. They can stay aloft for extremely extended periods of time. They are very stable as well. However, they can be a bit of an eyesore to landscapes as they have to be quite large to carry any sort of payload. The following image shows a Navy dirigible drone:

There are some other drawbacks to dirigible drones. They must be inflated, costing large amounts of money each time you fly in whatever lighter-than-air gas you choose to use (helium, hydrogen, and so on). They are also highly susceptible to strong wind currents (due to their lighter-than-air nature). So, strong engines must be employed to counteract those currents. This adds more weight and therefore more size to the blimp. Due to these limitations and costs, dirigibles are not widely used.

It's a shame, because mechanically, they are the simplest drones to design. It is just that in practice, they are expensive and largely impractical.