Note that there are some explanatory texts on larger screens.

plurals
  1. POCoreMotion iOS 5 attitude with reference frame doesn't work
    primarykey
    data
    text
    <p>i'm trying the new features of CoreMotion, above all the possibility to set the reference frame, but if i use a DeviceMotionHandler and the reference frame set to CMAttitudeReferenceFrameXTrueNorthZVertical the output is the some of CMAttitudeReferenceFrameXArbitraryCorrectedZVertical. i start the app with the iphone always in the same yaw rotation respect my desk, and i test different initial yaw rotation, but the result is always the same.</p> <pre><code>motionManager = [[CMMotionManager alloc] init]; motionManager.showsDeviceMovementDisplay = YES; motionManager.deviceMotionUpdateInterval = 1.0/60.0; CMDeviceMotionHandler motionHandler = ^ (CMDeviceMotion *motion, NSError *error) { NSLog(@"%f %f %f", motion.attitude.pitch, motion.attitude.roll, motion.attitude.yaw); }; [motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical toQueue:[NSOperationQueue currentQueue] withHandler:motionHandler]; </code></pre> <p>i found the solution of my problem, but i can't understand why the previous code doesn't work. I add just a CMAttitude variable *a in motionHandler.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; motionManager = [[CMMotionManager alloc] init]; motionManager.showsDeviceMovementDisplay = YES; motionManager.deviceMotionUpdateInterval = 1.0/60.0; CMDeviceMotionHandler motionHandler = ^ (CMDeviceMotion *motion, NSError *error) { CMAttitude *a = motionManager.deviceMotion.attitude; labelAngle.text = [NSString stringWithFormat:@"%f %f %f",a.pitch, a.roll,a.yaw]; labelAngle2.text = [NSString stringWithFormat:@"%f %f %f", motion.attitude.pitch, motion.attitude.roll, motion.attitude.yaw]; }; [motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical toQueue:[NSOperationQueue currentQueue] withHandler:motionHandler];} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload