# What's the minimum number of sensors for a hobby GPS waypoint-following UAV?

I would like to develop my own guidance, navigation and control (GN&C) flight software on a Raspberry Pi, for a small hobby fixed-wing UAV. From a physical standpoint, what is the minimum set of sensors/inputs needed to implement plain old GPS waypoint-following?

I understand I have a lot of math to learn, but what is the minimum set of inputs for that math? I have experience with embedded C++ for vehicle entertainment systems, but no knowledge in the aviation realm.

• What's your location? I was under the impression most of the developed world only allowed line-of-sight, operator-controlled operation. Is that not the case? – Jeffrey supports Monica Jul 10 '19 at 13:59
• What is allowed is not the same as what is possible. – quiet flyer Jul 10 '19 at 14:13
• A raspberry pi is a terrible choice for this: big, power hungry, and far too much hardware and especially software complexity that can fail in impossible to replicate or understand ways. Practical things like this use a mid-size microcontroller with a free serial port to interface the GPS. – Chris Stratton Jul 10 '19 at 18:36
• @ChrisStratton so true. Somebody tried controlling RGB LEDs using software clocking of PWM on a Pi, and got quite the dazzle of colors... the answer was "have the Pi command an Arduino to do the actual clocking"... – Harper - Reinstate Monica Jul 10 '19 at 23:06
• Along the lines of what Jeffrey was saying, this is indeed illegal in the USA. Hobbyist drones must remain within the line-of-sight of the operator and below 400 ft AGL. And, seriously, unlike many government regulations, there are very good reasons for these rules (namely, the manned aircraft above that level,) so please follow them. Of course, if all of your waypoints are within your line-of-sight and under 400 AGL, then you're good to go. – reirab Jul 11 '19 at 0:04

The absolute minimum for a generalized vehicle that needs to know its position and attitude (orientation) in space is one per degree of freedom. This can be reduced if we have information about the natural modes of the system and their stability.

For simplicity, let's assume a vehicle moving in 3 dimensions, that means a total of 6 DoF:

• 3 coordinates in space to know the position
• 3 angles (or similar) to know the attitude

The simplest way to meet these requirements are accelerometers for the XYZ coordinates and gyroscopes for the angles, and these are often packaged together into an IMU. Technically you don't even need an actual GPS as long as you know the coordinates of the starting location, as you can just integrate from it to know your position. This is known as dead reckoning via inertial navigation and it works this way (let's use coordinate $$x$$ as an example):

• You need to know the initial value $$x$$ and its rate of change: $$x_0, \dot{x}_0$$
• Listen to the values of the $$\ddot{x}$$ accelerometer.
• Integrate the acceleration to obtain the speed: $$\dot{x}=\int{\ddot{x}\,dx}+\dot{x}_0$$
• Integrate the speed to obtain the position: $$x=\int{\dot{x}\,dx}+x_0$$

Of course this has multiple shortcomings. Real-world accelerometers have noise, gyroscopes have drift, your starting location is probably inaccurate, your vehicle likely needs more data than that to operate and the whole systems I just described had no way of finding itself if it resets in-mission.

For a realistic barebones project like you described you will need:

• 3 accelerometers (in an IMU)
• 3 gyroscopes (in an IMU)
• 3 magnetometers (usually come with the IMU and help keep the previous 2 in line)
• GPS (can be bundled with the IMU and you specifically wanted it)

Further data sources are desirable but greatly complicate the FCS architecture, since you need to properly weight the data, after all, you don't want the aircraft to trust the magnetometer more than the gyros and show you a little trick it learned when passing near a magnetic anomaly.

In particular, a Pitot probe is good to have know your airspeed as opposed to your ground speed. An alpha vane is a bit of a luxury and not needed unless you are pushing the flight envelope.

Any ground-watching sensor with sufficient update rate, range and accuracy (IR, laser, LiDAR, acoustic, etc) will allow you to smooth your landings, and which one you pick should depend on your design and budget; they all have pros and cons.

From the coding standpoint, if you are serious about doing this by yourself from scratch, you should look into real time systems, Kalman filters and the vast field of sensor fusion. Also learn some aerodynamics while at it, so that the airframe itself is not a black box to you. You can run an FCS on an Arduino, even for quadcopters, if you are content with just a basic SAS.

There is a large community of hobby UAV builders online that can provide you with an almost off the shelf solution for your FCS (Ardupilot), if you prefer that approach. I personally often find their documentation lacking, so I suggest you at least learn the basics behind what you are doing, to help you navigate the inevitable gaps in the manual. Also, since it is an open source project, you can then fill in those gaps.

• With a dynamical model of the system you don't necessarily need as many sensors as there are degrees of freedom in the state. It just needs to be "observable". – pericynthion Jul 10 '19 at 8:50
• @pericynthion correct me if I'm wrong, but unless your DoFs are somehow linear combinations of each other I don't think you can do away with any without loss of information. The $x,y,z$ axis are orthogonal and while the Euler angles have a singular case (gimbal lock) they provide a minimum sufficient representation of attitude. – AEhere supports Monica Jul 10 '19 at 9:48
• @pericynthionif unless of course you mean that we can reconstruct the attitude state from the trajectory and inputs, which is not the case in the practical world. – AEhere supports Monica Jul 10 '19 at 12:27
• You are wrong :) although I meant to say "detectable" rather than "observable". It's sufficient to have as many sensors as there are unstable modes of the dynamical system, provided those sensors give adequately orthogonal observations. – pericynthion Jul 10 '19 at 16:37
• Importantly, it is not necessary that the sensors you do have be perfect, nor that your dynamical model is perfect, nor that there are no disturbances (e.g. wind gusts). – pericynthion Jul 10 '19 at 16:43

It's probably possible with only the GPS receiver, but it wouldn't be easy and you might have to make some compromises on the airframe design to achieve the necessary passive stability.

The traditional set of sensors for this kind of application are, roughly in order of priority:

1. GPS
2. 3-axis rate gyro
3. 3-axis accelerometer
4. 3-axis magnetometer
5. pitot
6. alpha vane or multi-port pitot
7. beta vane
8. baro altimeter
9. laser, radar or ultrasonic altimeter if you want to do autonomous landings

Since this is your first UAV, I would strongly recommend having the first 4 sensors and probably #5 and/or #6 (but maybe use those for diagnostics and analysis rather than control, since they can be a bit tricky with nonlinearities and reliability).

• Not so! #1, #8, and one third of #2 crossed the Atlantic. See my answer. – Camille Goudeseune Jul 10 '19 at 20:09
• @pericynthion: thanks, good info.... which of these would assist with the stability? – Greg McNulty Jul 11 '19 at 0:53

If you just want your UAV to fly to a waypoint, you could do it with a GPS sensor alone, if it was based on a very stable aircraft like a "Gentle Lady" or "Radian" r.c. sailplane, as long as you weren't flying it in very strong wind where there was the possibility of the aircraft going backwards over the ground when pointing into the wind and flying at trim speed. I suppose you would probably want an altitude sensor as well, unless you just want to apply enough power that the aircraft is slowly climbing throughout the autonomous portion of the flight. Of course, you could just get the altitude information from the GPS sensor.

If you decided to add a 1-axis yaw rate gyro, this would allow for smoother control. But in the context of a very stable aircraft as your basic platform, you really don't need any more than that, if your basic goal is to keep it simple.

Speaking from the viewpoint of one who has successfully controlled an ultralight aircraft in cloud using only a 1-axis electronic turn rate indicator, GPS, and wet compass-- and the compass was spinning backwards half the time. Control in specific limited circumstances (i.e. smooth air, not attempting constant circling in thermal updraft, making only very low-rate turns) was possible without the turn rate indicator, and a robot would surely do a better job of this than a human.

Just do sufficient testing to be sure the aircraft isn't prone to severe pitch "phugoid" oscillations at the CG you are using.

• So you can do it with a GPS alone as long as the wind stands still and you have an extremely stable aircraft without any disturbances like engine torque, slight asymmetries of the fuselage, etc? Can you provide an example of this working in real life? – AEhere supports Monica Jul 10 '19 at 14:29
• "So you can do it with a GPS alone as long as the wind stands still and you have an extremely stable aircraft without any disturbances like engine torque, slight asymmetries of the fuselage, etc? Can you provide an example of this working in real life?" -- just google "free-flight model airplanes" to see what is possible w/ inherent stability. Which have a single engine and prop so torque is not a non-issue, but it still works. Eliminate the requirement for the initial steep climb, and it seems trivial to use info from a GPS to fly to a waypoint. – quiet flyer Jul 10 '19 at 16:40
• @AEhere pretty much any "trainer" type RC airplane will fly quite fine "hands off" (of the control sticks) in reasonable conditions - it's designed so that you correct a mistake by letting go. The timescale at which you need to apply course or altitude correction is within the capabilities of a GPS that is maintaining view of a reasonable number of satellites. That said, a glider is not really the right platform, those are designed for efficiency not stability and so take more active piloting to maintain a course. Think abstracted Cessna, Piper or Champ with extra dihedral. – Chris Stratton Jul 10 '19 at 18:35
• AEhere - in reality it is the other way around, a robot hitting waypoints and keeping altitude in a bracket has a far, far simpler job than a human RC pilot who needs to repeatedly get the plane turned around before it flies out of sight, has to learn to unmap directions when flying towards themselves, and to see through false impressions of attitude that are easy at certain viewing angles. These aren't planes that depart from stable flight - most trainers won't even really spin intentionally and most of the "2nd year" configurations will recover with neutralized controls. – Chris Stratton Jul 10 '19 at 20:43
• @quietflyer, Fully agree. People advising a multitude of sensors apparently never built a free-flight model. I would perhaps add that for such a stable platform, you only need 1 (rudder) or 2 (+power for altitude) DOF control, and it can be driven straight from the guidance computer. The rest will take care of itself. – Zeus Jul 11 '19 at 1:10
• GPS
• Barometric sensor occasionally recalibrated from the GPS
• Tach to maintain constant piston-engine RPM
• Gyro for roll stability

These inputs sufficed for an autonomous chain-of-waypoints transatlantic flight sixteen years ago.

• Fascinating, thanks for sharing this! – AEhere supports Monica Jul 10 '19 at 17:47
• And I bet they could have done fine without the baro, especially with a more recent GPS with a 10 Hz output rate. – pericynthion Jul 10 '19 at 21:37
• @quietflyer It's not a free flight design, but it does have enough dihedral for coupling roll and yaw, what would you use accelerometers for? Or why do you care if the wings are level so long as you are going the right way? I suspect they had a gyro because they didn't have a compass and so needed to use slowly developing GPS heading information for their steering correction. This was before you could buy a reprogrammable 6-axis strapdown IMU for \$15 in a toy store; today of course you'd just go with a 9-axis chip and decide later what is useful, but the question is about minimums. – Chris Stratton Jul 11 '19 at 15:05
• @ChrisStratton minor nitpick: roll and yaw are always coupled in conventional airframes, what dihedral does here is stabilize the spiral mode, which is the most likely to give you trouble otherwise. – AEhere supports Monica Jul 12 '19 at 7:17
• @ChrisStratton later I noticed the link said they had a roll rate gyro. Really I think you could use either roll rate or yaw rate or canted to sense both as per turn "coordinator" but it might be hard to do entirely without, unless you had more dihedral. In my tests the gyro axis was canted as per turn "coordinator". – quiet flyer Jul 12 '19 at 12:35

Perhaps a summary introduction in control theory could help you. From a control point of view, your aircraft is a dynamic system, which can be described by a state and a dynamic model.

The state is simply a collection of variables of where the aircraft is in each point of time. For a full description, you would have the position and attitude in space, as well as their first derivatives. Any other inertia may also have their own state variable; for example, the propeller speed.

The state equations describe how the state evolves in time. From these equations (especially in linearized form), we can distill a number of (eigen)modes. These modes describe a certain behaviour of the system, and come in two forms: stable and unstable modes. A stable mode is a system dynamic that, for a finite input (perturbation), does not lead to any state variable going to infinity. Note that this does not mean that the state variables go back to some constant value: a bounded oscillation can still be considered stable! An unstable mode is a dynamic that for finite input leads to unbounded growth of some state variable.

To see how many sensors you need, you will want a few things. First of all, you want your system to be stable. Obviously, this means that you want to have a set of sensors that can measure any unstable mode (detectability), and a set of actuators that can control unstable modes (stabilizability). There are a number of (possibly) unstable modes, the most important of wich is spiral divergence. Many fixed-wing aircraft have no inherent roll stability, so you will want to be able to sense your roll angle (a yaw rate or heading sensor could work too, due to the roll/yaw coupling). Furthermore, there is simply your linear motion, which is also unstable (this may seem counter-intuitive, but all it means that you can get infinitely far from your initial point by travelling in a straight line). For this, you will want some kind of position sensor (most likely, a GPS).

All other dynamic modes are not inherently unstable in a fixed-wing aircraft, although your particular design may have some additional instabilities, like an unstable phugoid motion, for which you want to be able to measure and control the pitch motion.

So, the absolute minimum is two to three sensors (latitude and longitude and probably roll or yaw), and use feed-forward for all other variables (set trim and power based on desired altitude and speed, and just go for it). In practice, nobody would build an UAV with just three sensors. There are two reasons for this,

• Sensor inaccuracy. Measuring attitude is hard. A gyroscope will inevitably drift over time, and as such, you will need some other sensors to correct for this.
• Performance. You ideally want to travel in a straight line to the target, not swaying left and right in lazy semicircles while bobbing up and down a phugoid, praying to a suitable deity that the trim- and power settings leave enough margin to go over that mountain on a hot day.

For a hobby UAV, it typically turns out that sensors are relatively cheap, thanks to MEMS. You would typically use a 3-axis accelerometer, 3-axis (roll rate) gyroscope and 3-axis magnetometer (compass), and why not have a barometer and thermometer as well? And since you use a GPS, you might as well use its altitude data. If you use a brushless DC motor, it should be no effort to measure the prop speed. I think you will find it a lot easier to make a working UAV with these off-the-shelf components (and open-source software that is typically written for these sensors) than finding a single-axis gyroscope sensor and writing your own software.

Furthermore, using more sensors significantly simplifies your observability. This is the notion of being able to infer the state of the system from the outputs. In theory, if your model is sufficiently complex, you need very few sensors to estimate the current state (dead reckoning). However, if you can actually measure your states, your model is no longer as important, and your UAV will be able to respond much better and be less sensitive to changes in the environment or the UAV itself.

• Inherent roll stability does exist, as a result of dynamics involving sideslip; otherwise free-flight model airplanes would be impossible. – quiet flyer Jul 12 '19 at 12:44
• @quietflyer I suppose you must be right. I'll change the answer accordingly. – Sanchises Jul 12 '19 at 17:05
• It's a great answer- but possibly to a slightly different question than the one that was asked! Please leave it up anyway :) – quiet flyer Jul 12 '19 at 18:50
• I really like this answer, but as you can see there is some debate around the stability of the lateral-directional modes. Can the spiral mode be stabilized to a sufficient degree that we can safely eschew it from our sensor needs? Or would a stable spiral mode simply be like roll subsidience, in that roll rates tend to die but the absolute roll remains? – AEhere supports Monica Jul 15 '19 at 7:45
• @sanchises: really good info thanks. Which \ how many state equations are needed ? – Greg McNulty Jul 25 '19 at 4:56

The ArduPilot project has probably already done a lot of the work for you, if you're more interested in the end result than in the process of creating it for yourself. Even if you choose not to use their software, there's probably good information regarding which sensors and how many are necessary.

• @craig-s-cottingham: thanks, yes this will be my reference as I go along re-inventing the wheel for learning purposes... – Greg McNulty Jul 11 '19 at 1:07