read some articules that say that you need a digital compass but in some other places say that the mpu6050 can do it.
I know that i should add the yaw correction on the servos positions but what i can figure out yet is how to calculate the yaw using the mpu6050.
Hi Marco,You don't require a compass. In either rate or auto-level modes, yaw is controlled by rate (degrees/s) and is measured using only your gyroscope's Z-axis.The compass is required when you need to know the aircraft's heading and is really only necessary in conjunction with a GPS for automated flight.Convert your pilot's yaw rate input to degrees/s and use this as the setpoint of your yaw rate PID. Take the gyroscope Z-axis (also in degrees/s) and make this the input to the yaw rate PID.For a bicopter, the motor mixing for yaw axis should make the servos move the propellers in opposing directions. As the servos are opposite to each other, you can just add (100% of) the yaw rate PID output directly to your servos' centre signals. Usually the centre signal is around 1500us or thereabouts. If the yaw rate is too weak or too strong then just adjust the yaw rate PID's gain.
I am working on this but after converting gz to angle i am getting this result
Hi Marco,You don't need to convert the gz to angle. Just divide the raw gz value by 131 (for the gyro set at its default of ±250°/s full scale) to get the yaw rate in degrees/s.To get the bicopter flying initially you only need the gyroscope measuring degrees/s, the calculations shouldn't have anything to do with angle.
The thing is, and correct me if i am wrong, if i use Gy i am not sure if the bicopter will go back to a 0 degrees position if something alter the pitch same thing with Gx.I tried it yesterday but as i mentioned when i alter the pitch the bicopter reacts but it doesn't go back to 0 degrees position
In auto-level mode you use two outer roll and pitch angle (degrees) PID control loops to control the inner rate (degrees/s) PID control loops. In this mode the pilot setpoint for roll and pitch is an angle, for instance in degrees, between ±45°. The input for these two outer PID loops is the roll and pitch angle, taken from the complementary filter, (that fuses the integral of the gyroscope with the angle generated from the accelerometer to give a reliable angle estimate). The output from these outer PID loops is then used as the input to the roll and pitch rate PID controllers. The inner, nested rate control loops still provide the flight stability, but rather than the pilot driving them directly, as in rate mode, they're now driven by the outer control loops that maintain angle.
You got exactly to the point of what i am trying to achieve.
I do not see how an output in degrees can be the input of a pid that works in degrees/s
Do you have some example that i can work with?
float roll = PID(pilotRollAngle - compFilterRollAngle); // Outer roll angle PIDfloat pitch = PID(pilotPitchAngle - compFilterPitchAngle); // Outer pitch angle PID float rollRate = PID(roll - gyroRollRate); // Inner roll rate PIDfloat pitchRate = PID(pitch - gyroPitchRate); // Inner pitch rate PIDfloat yawRate = PID(pilotYawRate - gyroYawRate); // Inner yaw rate PID