Quadcopters is a very active topic, it is fun and easy to build, and make use of rich set of sensors for stabilizing and navigation. So if you like flying, mechanics and programming then go for quadcopter.
We can find on the Internet a lot of quadcopter frames, configuration, boards and firmware. All those who build a quadcopter target how to make it stand still and to move smooth. A lot of papers and researches that ranges from simple topics to PhD level topics where only few can read it –well not me -.
Through all these researches you can see there is no unified clear view of sensor position and functioning to achieve the “Stand-Still Move-Smooth” target. You can see a control system where there is a mix of gyro, accelerometer and magnetic sensors all together in magical formulas; you can even find the word “magic” mentioned explicitly in many source codes on the Internet in code comment sections.
The topic aims to build blocks where each sensor function can fit in; it defines the type of data and information we need in different modules for quadcopter to achieve stability. It does not come with new formulas or similar stuff, it does not even talk math.
Because different sensors give different data, with different rates and sensitivity, many algorithms were discovered to try to combine data from many sensors to get better readings, although this is useful however –from my view point- it helped in a way or another to make many grey areas between different control layers. On the other side, different control layers do depend on each other to perform.
In the following sections we will discuss different control functions and layers.
Stabilization Control Function
First we need to unify and agree on some wordings. When we fly a quadcopter using a simple board that contains Gyro only such as famous KK v2.1, we expect quadcopter to be balanced which is the single essential function for a multirotor. This needs a trained human to level the quadcopter and navigate.
Quadcopter itself as a system –in this layer- does not aware of anything external including its orientation and angles. For example when pilot moves forward, quadcopter tilt forward, for an a while gyros acts back to prevent this tilt and keep the quadcopter orientation, but pilot gives more power to rear motor and less power to front motor to overcome this trend and finally quadcopter tilts forward and gyros start to think that this is the zero reference and tries to balance the quadcopter to keep this tilt angle.
The quadcopter is simply not aware of what angle is. So let us define stabilization-balancing is the act of keeping or try to keep the same tilt angle.
Gyros are the most useful sensor for this task, because of the following reasons:
- Its response is very fast compared to other sensors such as accelerometer.
- It measures angular velocity fast and accurately.
For sure the major drawback of these sensors is drifting, and this is an embedded feature, so you cannot use them to make your quadcopter angle-aware. So using gyros can make quadcopter balanced but completely not aware of external environment.
Next level of upgrading quadcopter is to make it aware of its orientation compared to its external environment. We mean by this is to make it angle-aware, angle is an internal positioning problem, it handles its position with earth, on the contrary of altitude and direction-aware, which is more related to relative position with other objects on earth.
Some may disagree and suggest to include altitude, but altitude is related to the X-Y-Z position i.e. longitude, latitude and altitude which forms a map positioning, and map is used to know our position relative to other objects. However angle in our aspect cares only about make our quadcopter “Stand-Still”. Drift in X,Y or Z position can still act but still quadcopter internally feels it stands still which is true is we consider earth as unlimited flat area with nothing on it where position is meaningless.
Accelerometers help quadcopter not only to balance, but also to detect the right title angle and stabilization-restoring back position when pilot apply force that changes it for a while. So let’s define restore as the part of part of stabilization that keep quadcopter or try to keep it in a certain defined tilt angle which is normally zero in case we want to keep it horizontal.
To conclude the above the first control function is stabilization, which is achieved by satisfying two layers, balancing and restoring.
Orientation Control Function
This layer acts with external environment and relative orientation. This layer many handled by YAW, it is used to make your quadcopter keep a certain YAW direction. Orientation control function is divided into two layers; balancing and restoring. Balancing is to stop quadcopter from rotating.
Again gyro is our choice to balance YAW, specifically if we implement PID, then I-factor is our dominant factor here. It can keep an eye on slight rotations where value is low and P-factor is not enough to stop it. I-factor keeps accumulates till it either hits its max limit or stops quadcopter rotation. “hefnycopter 0.52 fixed a major issue in PID where I-factor was set to zero every loop, and hence there were a YAW issue where you need to trim your TX.
Once this was fixed I could set rudder to zero trim and fly easily, although the motors were not balanced and in bad condition. I-factor could overcome this hardware issue and make the quadcopter stable for me”.
So orientation-balancing is the act of making quadcopter resist rotation, and eventually stop the rotation act given our PID for Z-Axis gyro is configured probably. Quadcopter is not aware of any angles or directions here; it does not know what direction its front faces.
Now restoring sub-function of orientation control, here we need more sensors as gyros and accelerometers are useless here. Quadcopter starts to set orientation to face certain direction. It needs a sensor that gives different readings when it rotates horizontally. This feature is achieved by using magnetometer. Magnetometer is simply an electronic compass, it gives readings in X-Y-Z directions, but what we focus here is the Z-Axis assuming quadcopter is horizontal; some math is required to get the absolution magnetic field direction if quadcopter is not horizontal in case we look for high accuracy.
It is important to highlight here that making a quadcopter faces a certain object is not implemented using this orientation-restoring sub-function. As this means quadcopter is aware of its relative position to that object which is the function of navigation. So setting a target facing direction can be set by higher functions. However the mechanism of rotating quadcopter to keep facing a given direction is the task of orientation-restoring sub-function.
To conclude, orientation control function is divided into two sub-functions; balancing which try to stop quadcopter from rotating, and restoring which use balance to rotate quadcopter to face a certain direction.
This is the most advanced function for quadcopter. Normally it is done by the human pilot. If you want your quadcopter to perform these functions you need some more sensors, mainly a GPS sensor that is capable of measuring absolute position and altitude, also you can measure speed and moving direction by applying some math on positioning information. Still you can enhance the readings by using more sensors such as sonar, optical-flow and barometer sensors. Regardless of the sensors and its accuracy, we are looking here of information type that can be extracted from data received from these sensors. Information here is longitude, latitude, altitude and speed.
This control-function is divided into three sub-functions, balancing, restoring and navigation.
Position-Balancing is the act of resisting changing the absolute position of quadcopter. For example quadcopter can try to keep altitude from change; however it cannot get back to the o l altitude if it changes by applying high throttle. This can be achieved using Z-Axis for accelerometer. Quadcopter can monitor gravity and tries to keep it 9.8 by applying throttle adjustments, still quadcopter is not aware of altitude value, it only resist moving vertically. For resisting drift in X and Y direction, you cannot use Accelerometer X-Axis or Y-Axis, although it is sensitive to these drift forces that cause drift, but it is busy restoring tilt-angle and assumes any changes in X or Y Axis readings are due to title angle changes. Normally we can use optical-flow to allow position-balancing in X-Y directions.
Using Position-Restoring we can achieve the ultimate “Stand-Still” performance, using the correct set of sensors we can reverse actions to keep our quadcopter in the same X-Y-Z position and facing a certain object. For altitude restoring, quadcopter needs sensors that can give it altitude value such as barometer, sonar or GPS, each of them has its pros and cons, but the point here is that the give the data we need regardless of its quality and working conditions.
Position-Restoring depends directly on the existence, performance, quality of both Orientation-Restoring and Stabilization-Restoring to achieve to perform. It reads from sensors such as GPS then sets the target angles X-Y-Z to restore position and let orientation and stabilization work on the details.
Position-Navigation now it is time to “Move-Smooth” target. Making quadcopter navigate from a position to another by giving a predefined plan or by tracking an object without human intervention is what distinguishes a toy RC quadcopter from a flying smart robot. Sensors needed here are more advanced, data we need here is absolute X-Y-Z position, speed, orientation. More advanced sensors here can be used to extract a 3D information from environment using Z-CAM provided in Kinect. It is the field where computer vision can help quadcopter to make a huge jump, similar to the jump of 8086 to Pentium 4.
Control Functions Dependency
The below diagram shows different functions and layers proposed in the framework. Different sub-functions in different layers depend on each other. Some actually cannot exist without the existence of more primitive sub-functions in other layers, and domains.
For example Acc XY-Axis depends directly on the ability of quadcopter to balance itself using gyro, so it does not concern about losing balance while commanding quadcopter to change title angle. Also navigation layer are directly dependent on restoring layer of all control-function domain.
Other interactions arise in real live, while in simple math model of quadcopter they may not appear. Gyro Z-Axis changes motor speed to make use of torque to rotate quadcopter, in math the thrust should not change due to these changes, but in reality, thrust is not linear with PWM signal sent to ESC, also motors are not 100% identical, same applies to propellers. All of these factors can be neglected –to a certain extend- leaving Stabilization function to take care of all of these issues.
The below table shows different sensors and their usage in each control-function domain.
Numbers shows how much a sub-function can be fulfilled using a certain sensor.
When we go through different sourcecodes for quadcopter systems, we do not find these separation, sometimes because the idea is not crystal clear, sometimes because there exist a formula i.e. control logic; that can make a function or two without the need to separate. But most importantly sometimes sensors are used to correct each other. For example it is normal to use gyro and accelerometer in a complementary function to accurate angle reading. Also more complex algorithm such as Kalman or AHRS combines three sensors gyro, accelerometer and magnetometer to get accurate angle readings and remove noise. All these methods comes with good results, however the control-functions are performed and each in its order but can be combined in some formulas.
Stabilization-Balancing: is the act of keeping or try to keep the same tilt angle.
Stabilization-Restoring: is the act of stabilization that keep quadcopter or try to keep it in a certain defined tilt angle which is normally zero in case we want to keep it horizontal.
Orientation-balancing: is the act of making quadcopter resist rotation, and eventually stop the rotation act given our PID for Z-Axis gyro is configured probably. A quadcopter is not aware of any angles or directions here; it does not know what direction its front faces.
Orientation-Restoring: is the act of setting quadcopter orientation to face certain direction based on earth magnetic field not facing a certain object.
Position-Balancing: is the act of resisting changing the absolute position of quadcopter. Position can be any absolute longitude, latitude and altitude.
Position-Restoring: is the act of coming back to given longitude, latitude and altitude after applying forces to temporary change these attributes.
Position-Navigation: is the ability to follow certain check points, each point has its own longitude, latitude, altitude, direction and speed.