I'm not having problem with the CODE, I want to know what does the iPhone use for CoreMotions (because I'd like to repair it / get it repaired).
I'm not sure if this should be posted here or not.
I would like to know what does the iPhone use to send motion updates. And what does it use to process them.
My problem is, there's some problem with my iPhone, since it's not sending motion updates. I wrote a small project, to test what I'm receiving. On a working device I got output like this:
2013-11-15 09:39:44.415 GyroTest[12165:60b] QuaternionX -0.508156 QuaternionY -0.515390 QuaternionZ 0.487396 QuaternionW 0.488463
UserAccelX 0.002124 UserAccelY 0.007351 UserAccelZ 0.006973
RotationRateX -0.051634 RotationRateY 0.080035 RotationRateZ 0.025516
MagneticFieldX 0.000000 MagneticFieldY 0.000000 MagneticFieldZ 0.000000 MagneticFieldAccuracy -1 @ 386510.678629
2013-11-15 09:39:44.418 GyroTest[12165:60b] -1.395383
2013-11-15 09:39:44.419 GyroTest[12165:60b] -1.522387
2013-11-15 09:39:44.420 GyroTest[12165:60b] -2.972348
But on my device (the faulty one) I get:
2013-11-15 09:39:18.191 GyroTest[12165:60b] (null)
2013-11-15 09:39:18.192 GyroTest[12165:60b] 0.000000
2013-11-15 09:39:18.193 GyroTest[12165:60b] 0.000000
2013-11-15 09:39:18.194 GyroTest[12165:60b] 0.000000
Here's my sample project:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.motionManager = [[CMMotionManager alloc] init];
self.referenceAttitude = nil;
[self enableGyro];
for (int i = 0 ; i < 100 ; ++i) {
[self getDeviceGLRotationMatrix];
}
}
-(void) enableGyro{
CMDeviceMotion *deviceMotion = self.motionManager.deviceMotion;
CMAttitude *attitude = deviceMotion.attitude;
self.referenceAttitude = attitude;
[self.motionManager startGyroUpdates];
[self.motionManager startAccelerometerUpdates];
[self.motionManager startDeviceMotionUpdates];
[self.motionManager startMagnetometerUpdates];
}
-(void) getDeviceGLRotationMatrix
{
CMDeviceMotion *deviceMotion = self.motionManager.deviceMotion;
CMAttitude *attitude = deviceMotion.attitude;
if (self.referenceAttitude != nil)
[attitude multiplyByInverseOfAttitude:self.referenceAttitude];
NSLog(@"------------------");
NSLog(@"%@",self.motionManager.deviceMotion);
NSLog(@"%f",attitude.yaw);
NSLog(@"%f",attitude.pitch);
NSLog(@"%f",attitude.roll);
sleep(1);
}