如何提高内置iPhone指南针的稳定性和准确性?

时间:2012-11-06 13:59:26

标签: iphone compass-geolocation

我的didUpdateHeading代码如下:

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    if (newHeading.headingAccuracy < 0)
    {
        _realHeading = -9999;

        NSLog(@"heading accuracy < 0");

        return;
    }


    // Use the true heading if it is valid.
    [self.locationManager dismissHeadingCalibrationDisplay];

    _newHeading = Retain(newHeading);


    if (self.useMagneticHeading == YES)
        _realHeading = _newHeading.magneticHeading;
    else
        _realHeading = _newHeading.trueHeading;


    // Adjust for device rotation.
    UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation;

    switch (orientation)
    {
        case UIDeviceOrientationPortraitUpsideDown:
            _realHeading = _realHeading + 180.0f;
            break;
        case UIDeviceOrientationLandscapeLeft:
            _realHeading = _realHeading + 90.0f;
            break;
        case UIDeviceOrientationLandscapeRight:
            _realHeading = _realHeading + 270.0f;
            break;
        default:
            break;
    }
    while (_realHeading > 360.0f)
        _realHeading = _realHeading - 360;



}

有效。

但它很跳跃。传感器摆动和波动很大。

有没有人设法以某种方式提高内置iPhone指南针的稳定性和准确性?

也许使用其他传感器(加速?,陀螺?)。或者也许是一些软件算法?

0 个答案:

没有答案