...
***Note: I think it’s a good idea to worry about elevators and airspeed in another module. From what I understand, there is no interdependence.
Radius of the turn
Given a certain desired radius of the turn at a given airspeed, there exists a formula to compute the required bank angle:
phi = arctan(v^2/rg), where v is the airspeed, r is the radius, g is gravity and phi is the bank angle.
...
Slipping and skidding turns
A slip is when the bank angle is too great for the rate of the turn, so the airplane starts "slipping" towards the inside of the turn. In a sliding slipping turn, the relative wind vector points from the inside of the turn. A skid is when the bank angle is too small for the rate of the turn, so the airplane starts "skidding" towards the outside of the turn. In a skidding turn, the relative wind vector points from the outside of the turn. A coordinated turn is the middle point between these 2; that is what we are aiming for. In a coordinated turn, the relative wind vector is pointing directly through the center line of the aircraft.
...
Now, once the wings bank, a phenomenon known as adverse yaw occurs. The upwards wing has more lift than the downwards wing as it yaws (that’s why its going up while the other one is going down). Because of this, its inherent drag, (a drag force proportional to the lift generated), will be larger than the lower wing, and this will tend to yaw the aircraft towards the outside of the desired turn. that means the aircraft starts to “slip”. To counteract that slip, rudder must be applied. But actually, more rudder must be applied than just what’s needed to counteract the adverse yaw. If exactly that quantity was applied, the airplane would be moving forward and in the direction of the bank (because the banked wings provide some sideways force), but would be pointing only forward! We would still be slipping. So rudder needs to be applied until the nose points in the direction of motion of the airplane, that is when coordinated flight is achieved.
...
Centripetal and “centrifugal” forces
In a slipping turn, there is too much centripetal force for the turn to be coordinated. From the pilot’s perspective, he feels too little “centrifugal force” and it feels like he’s falling towards the inside of the turn. The seat restricts him, but nothing restricts the inclinometer ball, that finds its way to the inside side of the center point. If there was an accelerometer on board it would measure a force pointing towards the outside of the turn. You can think of an accelerometer as being a ball on a spring, and the measurement is of how much the spring compresses. Since the ball is forced to the inside of the turn, the spring would create a force towards the inside outside of the turn to compensate. In this case, adding rudder to steer the nose “into” the turn effectively decreases the radius of the turn. When the radius is small enough that the centripetal force is correct, we enter coordinated flight.
...
Current heading
Desired heading
accelerometer Accelerometer readings ( only y is required)
...
Use PID on the headings to determine the bank angle, probably just P or PI (a maximum bank angle should definitely be selected though).
Depending on the bank angle, determine a rudder angle setpoint. This can be done with a simple linear equation that should be tuned experimentally.
Feed the value of the y accelerometer reading into a PID algorithm (probably just P or PI). Vary the rudder around it’s its set point based on this value to maintain turn coordination.
Return the determined values of the requested bank angle and the requested rudder angle.