J'utilise ce code pour définir la position du périphérique. Rouler & Les valeurs de hauteur semblent bonnes (elles sont 0 lorsque l'appareil est sur la table), mais lorsque le lacet est 0, la boussole pointe vers l'ouest. Qu'est-ce qui ne va pas?CMAttitudeReferenceFrameXTrueNorthZVertical ne pointe pas vers le nord
[self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical toQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMDeviceMotion *motion, NSError *error){
[self performSelectorOnMainThread:@selector(handleDeviceMotion:) withObject:motion waitUntilDone:YES];
}];
}
}
- (void)handleDeviceMotion:(CMDeviceMotion*)motion {
CMAttitude *attitude = motion.attitude;
double yaw = attitude.yaw * 180/M_PI;
double pitch = attitude.pitch * 180/M_PI;
double roll = attitude.roll * 180/M_PI;
self.xLabel.text = [NSString stringWithFormat:@"%7.4f", yaw];
self.yLabel.text = [NSString stringWithFormat:@"%7.4f", pitch];
self.zLabel.text = [NSString stringWithFormat:@"%7.4f", roll];
[self sendDeviceAttitudeLogWithYaw:yaw pitch:pitch roll:roll];
}
Merci pour la description parfaite! Maintenant, je comprends. – am1kk
Si ma réponse vous a aidé et a eu raison, veuillez l'accepter (coche). Merci! – matt
C'est génial! J'ai allumé l'application boussole sur mon iPad et j'ai toujours trouvé qu'il y avait un écart de 90 ° entre le nord et la tête du téléphone. –