Incorrect compass header values โ€‹โ€‹using CoreMotion

I use CoreMotion to get the ccompass header, and I noticed some problems with the compass header.

My initial initialization is CoreMotion. I got a CMMotionManager object, locationManager, which is an instance of CMMotionManager.

// initialize CoreMotion motionManager = [CMMotionManager new]; [motionManager setDeviceMotionUpdateInterval:1.0/30.0]; [motionManager setShowsDeviceMovementDisplay:YES]; [self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical]; 

Location data is updated every 1 / 30.0 seconds.

For debugging purposes, I have a UILabel that shows me the current compass header updated at every update interval. While the application starts, I always need to do magic 8 to calibrate the compass.

After calibrating the compass, the heading for north and south is correct for almost 2-5 seconds.

Immediately after a couple of seconds, the compass goes wild and the corners jump. Basically, his swimming is about 10-20 degrees from the starting position in both directions. Admitted to get a tougher result. After 30-60 seconds, each time the south and north intersect or show east and west.

At the WWDC 2011 session, they talked about how they calculate each sensor with another to compensate for these problems. Is there something that I missed when configuring CoreMotion that I have such huge problems with accurate course results?

I checked the compass now with 3 devices (2 iPhone 4 and iPhone 4) inside and outside the buildings. I was in the fields, in small towns and large cities. This happens all the time. Apple's compass application example is almost accurate with 90% accuracy in my tests. Unfortunately, Apple does not open it.

Thanks for reading.

+8
iphone augmented-reality core-motion compass-geolocation
source share
1 answer

Using CoreMotion through CoreLocation will give you what you are looking for.

By default, the handset will execute a calibration digit of 8 to disable it, override locationManagerShouldDisplayHeadingCalibration: as follows:

 - (BOOL)locationManagerShouldDisplayHeadingCalibration: (CLLocationManager *)manager { return NO; } 

It is not clear from the code of your question if you call startUpdateHeading . If not, do this:

 if( [CLLocationManager locationServicesEnabled] && [CLLocationManager headingAvailable]) { [myLocationManager startUpdatingLocation]; [myLocationManager startUpdatingHeading]; } 

You can get crazy results if you do not enable the header filter, I would recommend that you do it. After that, you simply get the header changes in the deletion of the location manager when you didUpdateHeading .

Also note that if the phone is in landscape mode, you will need to adjust the title to the appropriate number of degrees (+/- 90), since the title is always in the Portrait control system.

+3
source share

All Articles