2012-11-08 3 views
2

CMCalibratedMagneticField은 항상 0을 반환합니다.CMCalibratedMagneticField가 업데이트되지 않습니다.

CMAccelerationCMMagnetometerData 값도 반환합니다. CMCalibratedMagneticField만이 아니기 때문에 바이어스가없는 자기장이기 때문에 필요합니다.

iPhone 4S에서 테스트 중입니다.

[MotionManager startDeviceMotionUpdatesToQueue:deviceQueue 
            withHandler:^(CMDeviceMotion *motion, NSError *error) { 
     CMCalibratedMagneticField f = motion.magneticField; 

     //CMMagneticField t = motion.; 
     //CMAcceleration s = motion.gravity; Works! 
     //_xlabelnew.text = [NSString stringWithFormat:@"%f", s.x]; 

     _xlabelnew.text = [NSString stringWithFormat:@"%f", f.field.x]; 
     _ylabelnew.text = [NSString stringWithFormat:@"%f", f.field.y]; 
     _zlabelnew.text = [NSString stringWithFormat:@"%f", f.field.z]; 

     //_totallabelnew.text = [NSString stringWithFormat:@"%f", sqrt(f.field.x*f.field.x + f.field.y*f.field.y + f.field.z*f.field.z)]; 

    }]; 

답변

3

자력계의 정확성을 확인 했습니까? 내 추측은 motion.magneticField.accuracy에 대한 귀하의 가치입니다 -1 (uncalibrated). 불행히도 나는 이것이 왜 있는지 전혀 모른다. 자력계가 잘 작동한다고해도 iPhone 4와 똑같은 것을 얻고 있습니다.

내가 알아들을 수있는 유일한 사실은 전화가 공장을 떠나기 전에 결코 조정되지 않았다는 것입니다.하지만 이는 내 4S가 내 4S보다 의미가 있습니다. 보정 된 필드 기능은 2011 년 10 월 공개적으로 출시 된 iOS 5.0의 새로운 기능으로, iPhone 4가 출시 된 지 1 년이 넘었습니다. 하지만 전화기가 5.0과 함께 출시되었으므로 출시되는 하드웨어가 지원하는 소프트웨어 기능과 일치 할 것이라고 생각할 것입니다. 다시, 단지 추측. 죄송합니다 더 도움이 될 수 없습니다. 다행히도 진짜 대답을 찾을 수 있기를 바랍니다. 자기 자력계를 교정 할 계획입니다.

프리 스케일은이를위한 무료 도구를 제공합니다. 소프트웨어 (및 유용한 문서)는 여기에서 볼 수 있습니다. 다운로드하려면 무료 계정을 만들어야 할 수도 있지만 기억이 안납니다.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=eCompass

업데이트 : 아이폰 5의 보류를 얻었고, CMCalibratedMagneticField는 잘했다.

0
[MotionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical toQueue:deviceQueue 
           withHandler:^(CMDeviceMotion *motion, NSError *error) { 
    CMCalibratedMagneticField f = motion.magneticField; 

    //CMMagneticField t = motion.; 
    //CMAcceleration s = motion.gravity; Works! 
    //_xlabelnew.text = [NSString stringWithFormat:@"%f", s.x]; 

    _xlabelnew.text = [NSString stringWithFormat:@"%f", f.field.x]; 
    _ylabelnew.text = [NSString stringWithFormat:@"%f", f.field.y]; 
    _zlabelnew.text = [NSString stringWithFormat:@"%f", f.field.z]; 

    //_totallabelnew.text = [NSString stringWithFormat:@"%f", sqrt(f.field.x*f.field.x + f.field.y*f.field.y + f.field.z*f.field.z)]; 

}];