0

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.

meaning-matters
  • 21,929
  • 10
  • 82
  • 142

2 Answers2

1

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
    }];
}
Gereon
  • 17,258
  • 4
  • 42
  • 73
  • precisely my question is how to detect a take or landing ? –  Jan 21 '18 at 20:59
  • Your initial question was "is it possible to create two methods that can send notifications" and the answer to that is yes (within the restrictions @meaning-matters mentioned, and those imposed by the hardware). My answer refers to the fact that you hadn't really "created code that retrieves the altitude". Writing the core logic of your app for you is not what SO is for, sorry. – Gereon Jan 22 '18 at 07:31
  • I don't understand your code. can you explain me with an example please ? thanks –  Feb 05 '18 at 22:11
0

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.

meaning-matters
  • 21,929
  • 10
  • 82
  • 142
  • Sorry I don't understand. I've code a ne project. Can you explain directly in the project ? thank you very much. https://www.dropbox.com/sh/bvixzxk9ubk55vp/AABAvvbYsPb8UDaigNSP6g_Sa?dl=0 –  Jan 21 '18 at 21:11
  • @Pierre-LouisLrt Sorry man, I don't have the time to start writing this all out in code for you. If you want to make a sensible app I think you really first need to make sure you understand (some of) the concepts I'm mentioning. Having the raw altimeter data is just the start, it requires good understanding and effort to turn this raw data in a good avionics instrument app. – meaning-matters Jan 21 '18 at 21:15