So far the sw development included basic functionality of jogging going to directly modify the speed engine and leaving the user to their modulation.
At this point I want to introduce the concept of control in which the ‘operator indicates the’ desired angle and the controller, our rapberry pi, must decide the speed ‘of the engines.
The theoretical relationship between the quadcopter angle (be it roll, pitch, yaw, or a combination of them) can be found on the page of the quadcopter. The balance that you get is unstable and just a minimal disturbance (such as a breath of wind) can cause this balance is lost.
In reality we must also consider asymmetries of construction (structure, propellers, etc..), Or non-constant behavior of the motors.
That translates into the need to know:
• what ‘s the instantaneous behavior of the aircraft
• what ‘s the real relationship between angles and speed engines as different from the theoretical
For the first point we must introduce something that can read the current state of the quadcopter, say a sensor. In most cases, a sensor mounted on board as a gyroscope or gyro+ accelerometer.
The gyro returns the angular velocity from which the integral angle is achieved. The accelerometer returns l’ acceleration in its components x, y, z
Thus, known the current angle and the target angle,it can be possible to calculate the error and decide a strategy to modulate the speed of the engines.
This strategy results in a control method called PID.
It is assumed that the relationship between two variables (in our case motor angular speed and angle) is approximated to three components:
• Proportional (P) = kp * Ei
• Integral (I) = Ki * sum (Ei) * t
• Derivative (D) = kd * (Ei-Ei-1) / t
Where Ei and ‘target error between w and w ith current instantly, you’ cycle time of the loop where the various k must be determined empirically.
The pid so returns the variation of the motor speed in order to minimize E.
A loop that reads from the sensor, calculates the correction with pid,applies the motor w is the basis of the angle control loop
In the future posts I will dedicate a specific description of the following blocks: sensor, PID and control loop with the purpose of defining the final structure of the program.