i am using following code but keep giving me 0 values please check what i am doing wrong
UILabel *rollLabel = [[UILabel alloc] init];
CMQuaternion quat = self.motionManager.deviceMotion.attitude.quaternion;
float myRoll = radiansToDegrees(atan2(2*(quat.y*quat.w - quat.x*quat.z), 1 - 2*quat.y*quat.y - 2*quat.z*quat.z)) ;
float myPitch = radiansToDegrees(atan2(2*(quat.x*quat.w + quat.y*quat.z), 1 - 2*quat.x*quat.x - 2*quat.z*quat.z));
float myYaw = radiansToDegrees(asin(2*quat.x*quat.y + 2*quat.w*quat.z));
[rollLabel setText:[NSString stringWithFormat:@"ROLL = %f , - Pitch = %f, , - Yaw = %f", myRoll, myPitch, myYaw]];
rollLabel.frame = CGRectMake(0, 0, 400, 150);
rollLabel.backgroundColor=[UIColor greenColor];
rollLabel.textColor=[UIColor blackColor];
[self.view addSubview:rollLabel];
thanks for your help
first I would try if all objects are not nil, then check if you actually run the motionManager itself, something like:
next question can be if your code is running on the main thread
there are many options which can cause the issue you have