Using the IMU6050 IMU, one can use the accelerometer to calibrate for the drift in x and y rotational axes by applying a complementary filter.
However, I haven't found a way to calibrate for the drift in the z direction. If it's drifting, eventually the situation appears where the axes of x and y are switched, and the program starts to fail.
How to calibrate the drift around the z-axis?