Join Steven Lipton for an in-depth discussion in this video Introducing altitude, part of Advanced iOS App Development: Core Motion.
- [Instructor] We've looked at the three axes on your device for movement and rotation in device motion. There are a few more sensors outside device motion which you as a developer query more directly, such as the magnetometer, and the altimeter. Let's go back to that Z-Axis. As you saw with attitude changes like roll or pitch, the Z-Axis is no longer up or down, but some other measure of the direction of the face of the phone. We adjusted for that, in the fencing app, by changing the axes. An alternative for changes in height for your phone independent of the attitude is called Altitude.
Starting with iPhone 6, there is a separate sensor for altitude call the Altimeter. On a run in the mountains, the altimeter will be figuring changes in how much up or down a mountain you are. This is a low power alternative to the much more accurate GPS. Altitude uses an air pressure sensor, measuring air pressure in kilopascals. The altimeter in your phone is a very sensitive device, maybe too sensitive. Altitude is not the only factor affecting air pressure. You have an error of 1 to 2 kilopascals between a sunny day and a thunderstorm.
Temperature also changes pressure. We've discussed noise already. Device motion tries to minimize noise by taking some factors into consideration. One strategy for lessening noise in an altimeter is a simple one. Instead of reporting absolute positions, core of motion reports changes in motion. Because of noise and no reference point, the altimeter gives us a change in altitude, not the altitude itself. I know if I move up or down five or ten meters, but I don't know my exact altitude. You can use the gyroscope, and the accelerometer in raw modes, but as we've discussed them using device motion, let's look at these last two, the altitude and altimeter, for raw data.
- Reading Core Motion data
- Understanding Core Motion methods
- Creating a pedometer app
- Using pace and distance data from Core Motion
- Pushing and pulling device motion data
- Accessing the altitude sensors
- Working with the motion activity manager (CMMotionActivityManager)