how to use altimeter ? (increase & decreases method)

566 Views Asked by At

I am a pilot and ios developer. I would like to know if it is possible to create two methods that can send notifications when the altitude increases and another when the altitude decreases (takeoff and landing). I have already created a code that can retrieve the altitude.

- (CMAltimeter *)altimeter
{
    if (!_altimeter) {
        _altimeter = [[CMAltimeter alloc] init];
    }

    return _altimeter;
}

if you want, I can share the project with Dropbox to show you my code.

2

There are 2 best solutions below

3
Gereon On

Your code only creates a CMAltimeter instance.

To get altitude data, use startRelativeAltitudeUpdatesToQueue after checking if your device actually supports altimeter measurements, and send the notifications when you've detected a takeoff or landing in the callback:

if ([CMAltimeter isRelativeAltitudeAvailable]) {
    CMAltimeter* altimeter = [[CMAltimeter alloc] init];

    NSOperationQueue* queue = [[NSOperationQueue alloc] init];
    [altimeter startRelativeAltitudeUpdatesToQueue:queue withHandler:^(CMAltitudeData* altitudeData, NSError* error) {
        // your code here
    }];
}
2
meaning-matters On

Few remarks:

  • You probably need to filter out altimeter signal noise using a low pass filter.
  • For sure you need to define a threshold value for altimeter changes, because you don't want to be triggered continuously at every 0.1m change.
  • The altimeter is a relative measurement. This means that you'd have to tell the app when you're on the ground; a kind of 0-level set.
  • Of course you can't use this in pressurised plane.
  • Plane speed probably influences the local pressure inside a non-pressurised plane.
  • Fuselage vibrations probably influences the local pressure.

@Geroen's answer shows how to get altimeter updates.

I think you should first make the app to just show the altimeter value on a large UILabel and see how that looks during a flight. This will give you an idea how messy the data is.