Founder and President: Hersh Godse

Website Documentation by: Hersh Godse


This is the website and online documentation of Westview High School's quadcopter and robotics club. Recently, flying robots such as quadcopters have had a tremendous gain in popularity. Applications of such devices range from remote visual inspection to aerial filming to transportation of light packages. The uses of quadcopters are virtually endless, but controlling them manually requires much skill, time, and effort. Consequently, a large field of research today is developing field controllers and algorithms that fly quadcopters autonomously (without human guidance). This is a difficult task because quadcopters have a limited amount of weight they can support, so the computing power and sensors available are severely restricted. To provide an introduction in this vast field, this club has the following three objectives:

  • Understand how quadcopters work and the parts needed to create them

  • Build a quadcopter for the fun of flying

  • Learn about the sensors, control systems, algorithms, and theories needed to fly quadcopters


Current tasks

  • Understand how quadcopters work

  • Survey Do It Yourself quadcopter kits available for indoor flying

  • Arrive at appropriate programmable open source hw/sw platform

  • Explore quadcopter virtual simulators

  • Understand parts of quadcopter to order

  • Learn appropriate sensors to use, how they work, data collection, calibration

  • Understand sensor feedback algorithms (PID) to correct for error in controller

  • Explore and understand existing open source flight controllers to create own controller


Logistics

The club is after-school on Wednesdays in room S230 from 2:35 to 3:30. It is supervised by Mr. Mak and led by Hersh Godse.



Navigation

The quadcopter has four motors. To stay level the thrust force from all four of the motors should exactly be equal to the force gravity has on the quadcopter. As the thrust and gravity are equal and opposite, the forces will cancel out and the quadcopter hovers. Two motors rotate clockwise and two rotate counterclockwise. This is so that the torques created by the rotation all cancel out and the quadcopter does not spin. If all rotors moved clockwise for example, the quadcopter would uncontrollably spin to the right.

To make the quadcopter go up or down, equally increase or decrease the power in each motor. This will make the thrust force more or less than the force of gravity resulting in the desired movement.

  

To make the quadcopter go in a particular direction such as forward or backward, make the power in the motor opposite to the desired direction high relative to the power in the motor in the desired direction. For example, to make the quadcopter go forwards, the power in the back motor should be more than the power in the front motor. The higher thrust in the back motors causes the quadcopter to lean forwards, and results in a 'push' forwards.


Finally, to make the quadcopter spin left or right increase the power in the counterclockwise or clockwise rotating motors respectively. This is because the higher power increases the torque of motors that cause movement in the desired direction. Remember, if we wish to keep the quadcopter stationary and turn at the same time, we must increase the power in the pair of motors turning in the desired direction and reduce the power in the other two motors. This makes the net torque point in a specific direction (left or right) and still keeps the total thrust equal to gravity. If we just increased the power in two of the motors, the quadcopter would turn and go up at the same time.


Quadcopter Parts

Motors and Propellers

The quadcopter needs four motors along with four propellers to maneuver properly. It is best to get motors and propellers designed for each other to ensure a viable, less expensive build. The motors used in quadcopters are brushless for longer life and longevity.


The rotor of the motor has two magnets fixed to it that rotate around three sets of coulds (sets A, B, and C in the figure below). By powering different coulds at certain times, the magnets are attracted to the could 'in front' of them and are repelled from the coulds 'behind' them. By applying positive, negative, or neutral charges to the three could sets as shown in the current phase chart in the figure below, the rotor and its magnets are rotated without any contact. For additional information see the following explanation:

https://www.youtube.com/watch?v=bCEiOnuODac



ESCs

Electronic speed controllers, or ESCs, control the speed of motors by sending power pulses to the motors based on information from the flight controller. ESCs convert the power value for the motors into pulses that move the motors. Four are needed, one for each motor. Again, it is best to use ESCs designed to work with the chosen motors.


Battery

Due to the limited carrying capability of quadcopters, the battery must have a high power to weight ratio. Thus, it is best to use Lithium Polymer (LiPo) batteries. When selecting batteries, it is important to note battery voltage and capacity. Each LiPo battery cell provides 3.7 volts. Capacity describes how much power a battery can store. It is measured in milliamp hours (mAh). Capacity measures how much load must be placed on the battery to discharge it over an hour. A battery rated at 500 mAh would discharge in one hour if it had a 500 milliamp load. It is also important not to completely discharge a LiPo battery - doing so would overheat the battery and thus ruin the part and create a safety hazard. To be safe, LiPos should not be discharged below 80% capacity.


Frame

The frame of the quadcopter should securely mount all parts of the quadcopter and protect the flight controller along with other parts from crashes. Several frames can be found online, and several kits including frames, motors, propellers, and ESCs can be bought. To save time, we will purchase a kit with matching motors, propellers, and ESCs online.


Sensors

Quadcopters have three axes - X, Y, and Z. To control them, sensor readings are necessary to understand how much the quadcopter has moved. Based on the sensor readings the flight controller can change motor powers to keep the quadcopter on the right track. To get accurate sensor readings, three accelerometers and three gyro sensors are needed, one for each axis. This makes for a total of six sensors. Gyro sensors measure rotation rate in an axis, and  accelerometers measure force of gravity in an axis. These readings are combined to find out the angle amount that the quadcopter has moved; more on this later. Additional sensors the quadcopter can use are compass sensors/magnetometers for measurement of direction, barometric (outdoors)/ultrasonic (indoors) sensors for measurement of height, and GPS sensors for measurement of position on a larger scale.


Flight Controller

Planes are inherently stable and glide through the air. Helicopters are more stable than quadcopters due to the tail rotor. Quadcopters are quite unstable and it is easy for a gust of wind, a push, or some other interference to result in a crash. In order to avoid such crashes and to control the quadcopter, a flight controller is needed. The flight controller is the heart of the quadcopter. It takes raw readings from the sensors to understand the current position of the quadcopter, and compares that position to the desired position of the quadcopter. It accordingly changes the powers of the motors to adjust the quadcopter. The flight controller is the hardest part to create and is where most of the learning occurs. In order to receive signals from a human, the controller will need some sort of wireless connection (WiFi or bluetooth).


Quadcopter Terminology

The three axises have names as follows:

  • Yaw is the angle psi (ψ) around the vertical Z (green) axis

  • Roll is the angle phi (φ) around the X (red) axis, and is the amount leaning sideways on the Y axis

  • Pitch is the angle theta (θ) around the Y (blue) axis, and is the amount leaning forward on X axis

  • Tilt is a measurement in the horizontal XY plane that combines roll and pitch (not necessary but useful)

  • Altitude is the height of the quadcopter (not based on axis rotations)

The following figure shows how changes in motor power correlate to changes in the above terms.


Recall that hovering is achieved when the net force of the motor propellers equals the downward force of gravity. As seen in the drawings above, where the arrows thicken = more power, and vice versa, one can easily change altitude by going above or below the force of gravity. Because ascending and descending are in respect to gravity and not a propulsion force of zero, the motor powers should never go negative. In other words, no thrust upwards is needed to push down the quadcopter - gravity takes care of this for us.


Changing pitch is just like tilting upwards or downwards if you are the passenger in an airplane - rotation around the y-axis. To accomplish a change in pitch in quadcopters, the two motors perpendicular to the pitch axis need to gain ans lose power in conjunction to rotate. In the example above, those two motors are rotors 2 and 3. Rotor 2 is given more power, and therefore thrusts one side of the quadcopter upwards on the y-axis. Rotor 3 is given less power and the other side of the quadcopter is pushed down by gravity. Hence, a change in pitch is achieved by increasing and decreasing the powers of the x-axis motors appropriately.

For airplanes, the roll axis is along the body of the aircraft, and changing the roll angle causes one wing to rise, and the other to fall. In quadcopters, roll is an angle of the x-axis and is controlled by the motors perpendicular to that axis. These motors, which are 1 and 4 above, are located along the y-axis or pitch axis. Like pitch, a change in roll is achieved by increasing and decreasing the power of the y-axis motors appropriately.

The yaw axis of a quadcopter is like the yaw axis of the plane - the rotation about the center of the body or he z-axis. Unlike pitch and roll, yaw is achieved by increasing the power of both motors on opposite sides. Recall that a quadcopter has a torque when the propellers spin in a given direction, and two cancel that force so the quadcopter will stay in place, adjacent rotors move in opposite directions. To rotate around the yaw axis, more power is given to the motors that turn in the same direction. In the example above these are rotors 1 and 4. By increasing the power of the rotors on opposite sides, the net torque is no longer zero, and the quad will begin to spin around its center. Another action to note is decreasing the power of the other two rotors, or 2 and 3 in the example above. This makes the turn more efficient, faster, and keeps the net force the same as gravity when the desired effect is to hover.


Combining Motions

Combing the rotations around the x, y, and z axis are what form the complex maneuvers of quadcopters. The actual learning and complicated part of quadcopters are these calculations. As we learn the math behind combining motions into a complicated maneuver, we will start forming our own flight controller. The following sections on Reference frames, Euler Angles, PID algorithms, and others show the basic building blocks of a flight controller in math terms.


Reference Frames and the Frame Conversion Matrix

The Quadcopter Reference Frame is the three axes of the quadcopter. The Earth Reference Frame has the horizon as the XY horizontal plane and has the direction of gravity (down) as the vertical axis. See the below figure for clarification. If the quadcopter stays stationary, the two frames are identical. However if the quadcopter tilts, the two will differ. We can easily tell what directions are horizontal and vertical, but the quadcopter cannot. This is because sensor readings are relative to the quadcopter, not to the earth. In order for the flight controller to provide proper corrections, those corrections must be with respect to true horizontal and vertical, not the current horizontal and vertical of the tilted quadcopter. Thus the sensor readings, relative to the quadcopter reference frame, must be converted to be relative to the earth reference frame by using a complex matrix known as the Frame Conversion Matrix.


Deriving angles from Sensors and Fusion Sensors

Gyro sensors measure the rate of rotation of the quadcopter in a certain axis. By taking the integral (summation) of values of the gyro sensor, one can derive the angle difference between the quadcopter and earth reference frames in an axis. Since the code doesn't run infinitely fast and sample readings at every instant, true integration is impossible; a summation of readings over a period of time is only an approximation of the true integral. As time goes on, the difference between the approximation of angle (from summation) and the true angle (from true integration) increases. Thus gyro sensors are most accurate in short term and drift long term.


Acceleration sensors measure the force of gravity in g's. If the quadcopter was perfectly horizontal, the X, Y, and Z accelerometers would read 0, 0, 1g. Then, if the quadcopter tilts θ degrees in the horizontal plane, the vertical force of gravity would be g*cos(θ); the horizontal force would be g*sin(θ). Simple calculation can thus convert accelerometer gravity readings into θ angle values. However this can only work if the quadcopter does not accelerate in addition to gravity (gravity is only acceleration acting upon quadcopter). This is most of the time true (not met when taking off or landing). The accelerometers have much noise from motors and propellers, and as a result are inconsistent and inaccurate over short term. However, averaging out values in the long term is quite accurate.


Thus gyro sensors are accurate short term and acceleration sensors are accurate long term. A Fusion Sensor using a Complementary Filter uses gyro sensors to determine angle over short term and accelerometers over long term. Below is a graphical representation of this process:

PID Sensor Feedback Algorithm

Due to several sources of noise and interference when flying quadcopters (such as motors and propellers, wind, bumping into objects), a mechanism is needed to smoothly correct the quadcopter and reduce errors. If the quadcopter should be perfectly horizontal but has a slight tilt, the difference between its current tilt position and the desired horizontal position is the error. Sensors are used to calculate the error in the angles of the quadcopter frame direction relative to earth. PID or Proportional Integral Derivative is an algorithm that outputs correction for error:

  • Proportional to the error (directly related with the amount of error)

  • Integral to the error (based on a summation of errors over time)

  • Differential to the error (based on the most recent change in error)

A greater correction means a larger change in motor power values implemented to correct the quadcopter's position. Several PID mechanisms are needed in the flight controller to change the power of the motors to correct for errors and smoothen out the flight.


Euler Angles


Instead of having angles to represent the changes in X, Y and Z axises between the two reference frames, simply focus on two axises - X and Z to simplify the problem of describing the three-dimensional rotation between two frames. We can use three angles to describe the three-dimensional differences. These three angles show the change in two of the axises. By knowing the exact difference between two of the axises of the reference frames, the third Y axis is automatically known. 

The above picture shows how Euler angles are used to describe the change between two reference frames. The three angles are α, β, and γBlue represents the 'Earth' reference frame, while red represents that of the quadcopter. The blue circle is the Earth's xy plane; the red circle is the quadcopter's XY plane. The green axis N (which stands for 'line of nodes') is the intersection of the XY planes of the two reference frames. Note how the N axis perpendicular to the motion of angle β (the movement of z to Z). 

The reason the X, Z, and N axises are used are because of Euler's rotation theorem. Euler's rotation theorem uses a series of complex matrices to convert angles α, β, and γ into a three-dimensional rotation. Basically, through the theorem's complicated matrix, if you know angles α, β, and γ (we will know these from our fusion sensor of gyro/accelerometer!!), you can understand how the blue axises become the red axises.

First, rotation α occurs at the z axis, turning the xy plane of the Earth reference frame. Through this first rotation, x moves to N. We shall call this intermediate x-axis state x'. The z axis is unchanged since the rotation is about itWe will ignore the y axis since it is not needed for Euler's theorem. 

Next, rotation β occurs about N, also known as x'. This moves z to the final Zx' will remain unchanged. It will also move the xy plane to the final XY plane.

Finally rotation γ occurs about the final Z axis. This rotation turns the XY plane. The rotation of the XY plane will move x' (N) to the final X axis. 

Through all these three rotations, y will go to the final Y axis.

Flight Control Diagram

TBD


Frame Conversion Matrix

TBD



10DOF sensor

 -Three gyro sensors in three axises, three accelerometers in three axises, altitude sensor

   -(Also three magnetometers in three axises, not using for now)

   -TBD