System performance and battery use when using the accelerometer and gyroscope - ios

I’m working on a project that incorporates the use of the accelerometer and gyroscope.
In the specific app I’m working on, I turn on (e.g. .startGyroUpdatesToQueue) the accelerometer and gyroscope when required and off (e.g. .stopGyroUpdates()) when not needed similar to Apple's documentation recommendations.
However, I’ve noticed that there can be a slight delay when turning the accelerometer and gyroscope back on which the user notices every now and then. So the preference is to keep the accelerometer and gyroscope always on so the user gets a uninterrupted experience.
Questions:
1 - How efficient is the accelerometer and gyroscope on the system performance and battery use when these are enabled in an app?
2 - Is there evidence/data of the system performance and battery use when the accelerometer and gyroscope are on?
3 - Is there a way to pause the accelerometer and gyroscope instead of completely turning it off?

Answering number 3 first, on modern iPhones (5S and later) the accelerometer is never really turned off and resides in a special motion coprocessor. On these devices, the energy cost for creating the data is constant, but getting the data is expensive. It requires a timer to routinely wake up the main processor, read the data, wake up your application and execute an event on one of your threads. The closest thing to what you're asking would be for a way to have the timer turned on but not have it feed into your app. There does not appear to be a way to do this and the energy savings would probably not be that great if there were.
With that in mind, 1 is going to be fairly subjective. The processor and your app are both going to spend more time running, but if you were already doing work on the CPU will it add that much? Similarly, if users only spend 5% of their time in a screen where you don't need the accelerometer versus 50% of their time, the overall energy impact of having it constantly on will be a lot less. That really brings us to the heart of the question, number 2.
If you want to see what energy costs are associated with constantly polling the accelerometer versus only turning it on when needed, you should profile your app. When debugging your app, you can view CPU, energy, and other impacts of your app directly in Xcode using the Debug Navigator (⌘6). This is explained in Apple's Energy Efficiency Guide of iOS Apps: Measure Energy Impact with Xcode. You can also get a more detailed analysis with Instruments. Apple provides full details in their Energy Efficiency Guide of iOS Apps: Measure Energy Impact with Instruments.
Using the above tools, you should be able to get a feel for how much more energy will take to keep your accelerometer always on, and be able to make a reasoned decision about what to do.

Related

User Activity Static/running/Walking/Driving based on CoreMotion data only

How can we detect user is driving/walking/running/static with CoreMotion data.
We can get user activity in iPhone 5s using CMMotionActivityManager. But how to get in lower version devices.
With the help of CLLocationManager I can get the device speed and based on speed I can decide the user state, which drain battery life of device.
Is there any possibility to detect Device State based on Core motion only?
Some application like like Place me app does, It detect user activity based on Coremotion data.
It is nice Machine Learning task. You need to
collect lots of data and annotate it (label each sample, whether it is driving/walking/running/static),
design a feature vector,
then train an appropriate classifier.
The details really wouldn't fit here, I suggest googleing "accelerometer activity recognition". In particular, among the first hits I find
Human Activity Recognition from Accelerometer Data Using a Wearable Device
Activity Recognition from Accelerometer Data
quite readable, relevant and useful.
The bad news is that it is more work to implement it than you probably think. Much more work. :(
In any case, I hope this answer helps a little bit.

Does iPhone/iPad use GPS and GLONASS in the same time? Can I manage them?

I know that iPhone/iPad could use GPS and GLONASS, but does they use they in the same time?
I didn't find that info in documentation. GPS demand 4 satellites for proper work, (3 without altitude). Same thing with GLONASS. So, if we use just GPS we get 4 satellites and get's our standard GPS accuracy, and it's tolerance about 10-20 meters in open sky. I didn't find specified accuracy on wiki GPS page, maybe I just missed, but anyway my numbers is close. As said wikipedia, GLONASS accuracy for civilian usage is very slightly less accurate than GPS, but on high latitudes (north or south), GLONASS' accuracy is better than that of GPS due to the orbital position of the satellites. GLONASS
So, if we use both systems simultaneously, we have a great accuracy improvement because we have 8+ satellites from both systems. My question is: does iPhone/iPad use both systems and their location coordinates still sometimes very inaccurate? Is there a way to turn on/off one of the systems?
iOS locates the current location with all available services. That means GPS, mobile telephony transmitters (mobile cells), WLAN, and the newer iPhone with GLONASS. We have no way to decide programmatically which system exactly we want to use, but there are different ways to use the iOS location services. The desired accuracy and other parameters can be set via the CoreLocation Framework classes.
You should read the Location Awareness Programming Guide from Apple.
The main advantage of using GLONASS together with GPS is in situations with bad view to the sky, e.g., in urban canyons.
In that case, the additional GLONASS satellites may help.
In open sky situations, a combined GPS/GLONASS has no accuracy benefit to a GPS chip alone.
You cannot switch off any one of the GNSS systems in iOS. (iPhone 4S is the first iPhone that uses combined GPS/GLONASS).

Best practice to implement location based service in iOS

What is the best (meaning least power consumption) way to use some location based service in an iOS application? E.g. checking the position in the background every x sec/min.
I've read about geofencing, but I'm not familiar with it in detail (how often it is updating location etc.).
Thanks for sharing any ideas
There is no best practice, it depends much on your application, which location accuracy it needs. How fast you need a position change, etc.
Either you need to be accurate to under 30m then you need GPS, which uses Power (8h of recording is possible at best location quality without using the phone otherwise)
Or you need much less accuracy, typically 1km, then it works with Cell Tower or Wifi location, which uses less power.
In between there is nothing reliable. (e.g 100m accuracy with low power, does not really exist, at least I would not trust such a setting, there are no published measurements how accurate an iphone really is in the lower accuracy settings).

Ios real time audio analysis battery life improvement

I'm doing real time audio analysis with accelerate framework, my application consumes too much battery, how can i improve battery life without data loss in my analysis.

core location constants meaning

I am very confused about the meaning of the core location constants. For example for my app I would like to get accuracy readings within 100 meters and it looks like kCLLocationAccuracyHundredMeters would be the appropriate choice. However with this settings I often get points with accuracy worse than +- one thousand meters and when I disable wifi. Are these core location constants only relevant when wifi is enabled or does it sound like I am doing something wrong? It seems weird that Apple wants developers to not have to worry about the underlying hardware (i.e. whether it is using gps, wifi, or cell towers) but have the accuracy totally depend on wifi being enabled.
Thanks for your help.
GPS readings depend on a LOT more than just your accuracy setting. For example if you are not using wifi and you try to take a reading from indoors I have seen GPS be several thousand meters off consistently until you go outside. If you are planning on making your app accurate for indoors I would not plan on relying on the typical GPS. If your major use case is outside than GPS is VERY accurate.
The accuracy constants are how you "request" a specific accuracy. What you actually get depends on what is available. CL will try to give you your requested accuracy (or better) but it will give you what it has even if it is worse accuracy while it is trying to get better accuracy location.
If you wait long enough (and ignore the locations that aren't good enough) then you will eventually get better accuracy location unless it can't be done (such as when GPS satellites aren't visible or there is no WiFi, etc).

Resources