I know I said about using this post to investigate that value of 1.2, but I’m just going to sit on that for now in preference for yaw. There are a few aspects to this:
- During flight, currently the quadcopter stays facing whichever way it was facing on the ground; there’s a yaw angle PID and it’s target is 0. But should be trivial to change this yaw angle target so that the quadcopter faces the direction; the target for the yaw angle is derived from the velocity – either input or target to the velocity PID i.e. the way the quadcopter should or is flying. It’s a little bit tricker than it sounds for two reasons:
- The tan (velocity vectors) gives 2 possible angle and only consideration of signs of both vectors actually defines the absolute direction e.g. (1,1) and (-1,-1) needs to be 45° and 135° respectively.
- Care needs to be taken that the transition from one angle to the next goes the shortest way, and when flight transitions from movement to hover, the quad doesn’t rotate back to the takeoff orientation due to the velocity being 0,0 – the angle needs to be derived from what it was doing before it stopped.
It’s also worth noting this is only for looks and there are no flight benefits from doing this.
- The camera X and Y values are operating partially in the quadframe and partially in the earth frame. I need to rotate the X and Y values totally into the earth frame by accounting for yaw.
- Yaw tracking by the integrated gyro Z axis seems to be very stable, but I do need to include the compass readings for even longer term stability. I think I can get away with just using the compass X and Y values to determine the yaw angle but I’ll need to test this, but I have 2 further concerns:
- the first is that the compass needs calibration each time it boots up, just like is necessary with your phones. You can see from my previous post the offsets of the X and Y values as I span Zoe on my vinyl record player – see the circle is not centered on 0, 0.
- I’m not sure how much iron in the flight zone will affect the calibrations based on the distance of the compass from the iron; iron in my test area may be the structural beams inside the walls of a building indoors, or garden railings outside, for example.
First step is to include yaw into the camera processing as a matter of urgency. The magnetometer stuff can once more wait until it becomes absolutely necessary.
FYI the rotation matrix from Earth to Quadcopter from is as follows:
|xe| | cos ψ, sin ψ, 0| |xq| |ye| = |-sin ψ, cos ψ, 0| |yq| |ze| | 0, 0, 1| |zq|