Because of the math(s) problems, I had to start questioning anything to do with angles in Phoebe’s code.
I’ve confirmed the MPU6050 uses the right hand rule consistently throughout. For the accelerometer:
- forward acceleration (X-axis) is a positive value (index finger points forward))
- leftward acceleration (Y-axis) is a positive value (middle finger points left)
- vertical acceleration (Z-axis) is a positive value (thumb points up)
This results in nose down being a negative pitch angle and port down also being a negative roll angle, which matches Phoebe’s code.
For the gyroscope, with your right hand in a fist and thumb pointing in a positive direction, and viewing the axis from behind, clockwise rotation is positive. This does lead to an oddity: positive rotation around the Y-axis leads to positive pitch rotation which when integrated from zero produces a positive angle, which is the opposite from the accelerometer angle. Luckily, the code negates the Y-axis gyro readings to they both agree on the sign of the angle.
18 months ago, I just worked this all out through experimentation, but it’s good to know the right-handed rule for my next post.