Instead of doing my own sensor fusion, I am using the Quaternions available from iOS and converting them to Euler angles.
I walked around in a rectangle shape for few times and I observe that the shape is not as expected. I am plotting the shape by plotting the Yaw values. Please see below. It appears that the heading deviates significantly. I maintained the path while walking.
How do I correct the Yaw values so I get correct rectangle shape.