Question

I'm trying to program an augmented reality application with iOS 4. To test this application, I have an iPhone 3GS.

I will explain my problem with an example:

I want to see the name of a mountain top on my device. When I see that mountain on my device screen I see a label with its name.

The idea is to see that label over the mountain or in front of it, but I see the label on the right of the mountain.

I have the same problem if I have more that one location (two mountains and a church, for example). I always see the label on the right.

I'm using iPhone AR Toolkit.

Do I have a problem with iPhone's compass? Do you know why I'm having this problem?

This method is invoked to start listening GPS:

- (void)startListening
{   
    // start our heading readings and our accelerometer readings.
    if (![self locationManager]) {
        CLLocationManager *newLocationManager = [[CLLocationManager alloc] init];
        [self setLocationManager: newLocationManager];
        [newLocationManager release];
        [[self locationManager] setHeadingFilter: 1.0];
        [[self locationManager] setDistanceFilter:2.0];
        [[self locationManager] setDesiredAccuracy: kCLLocationAccuracyNearestTenMeters];
        [[self locationManager] startUpdatingHeading];
        [[self locationManager] startUpdatingLocation];
        [[self locationManager] setDelegate: self];
    }

    if (![self accelerometerManager])
    {
        [self setAccelerometerManager: [UIAccelerometer sharedAccelerometer]];
        [[self accelerometerManager] setUpdateInterval: 0.75];
        [[self accelerometerManager] setDelegate: self];
    }

    if (![self centerCoordinate]) 
        [self setCenterCoordinate:[ARCoordinate coordinateWithRadialDistance:1.0 inclination:0 azimuth:0]];
}

You can find full source code here.

UPDATE

I have also modified the following to use true heading, but I'm getting the same problem:

- (void)locationManager:(CLLocationManager *)manager
       didUpdateHeading:(CLHeading *)newHeading
{
    //latestHeading = degreesToRadian(newHeading.magneticHeading);
    latestHeading = degreesToRadian(newHeading.trueHeading);

    if (prevHeading == -1)  
        prevHeading = newHeading.magneticHeading;

    [self updateCenterCoordinate];
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top