title: Madgwick's sensor fusion algorithm on iOS
body: <p>i'm trying to run <a href="http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/" rel="nofollow noreferrer">Madgwick's sensor fusion algorithm</a> on iOS. Since the code is open source i already included it in my project and call the methods with the provided sensor values.</p>
  
  <p>But it seems, that the algorithm expects the sensor measurements in a different coordinate system. The Apple CoreMotion Sensor System is given on the right side, Madgewick's on the left. Here is the picture of the <a href="https://i.imgur.com/WLKVVm6.jpg" rel="nofollow noreferrer">different coordinate systems</a>. Both systems follow the right hand rule.
  For me it seems like there is a 90 degree rotation around the z axis. But this didn't work.</p>
  
  <p><img src="https://i.imgur.com/WLKVVm6.jpg" alt="different coordinate systems"></p>
  
  <p>I also tried to flip x and y (and invert z) axis as suggested by <a href="https://stackoverflow.com/questions/13499838/delay-in-yaw-pitch-and-roll-values/16214450#16214450">other stackoverflow posts</a> for WP but this didn't work also. So do you have a hint?
  Would be perfect if Madgwick's alogithm output could be in the same system as the CoreMotion output (CMAttitudeReferenceFrameXMagneticNorthZVertical).</p>
  
  <p>Furthermore I'm looking for a good working value for <strong>betaDef</strong> on the iPhone. <strong>betaDef</strong> is kind of the proportional gain and is currently set to 0.1f.</p>
  
  <p>Any help on how to achieve the goal would be appreciated. </p>