Questions tagged [core-motion]

Core Motion is a framework within Apple's iOS SDK used to access all kind of motion sensor data. Introduced in version 4.0 it is the recommended way of accessing gyroscope or accelerometer data, and since version 5.0 magnetometer (compass) data as well.

Citing from Event Handling Guide for iOS:

Core Motion is a system framework that obtains motion data from sensors on a device and presents that data to applications for processing. The handling of the sensor data and the application of related algorithms occurs on Core Motion’s own thread. The items of hardware that detect and originate these motion events are the accelerometer and the gyroscope. (The gyroscope is currently available only on iPhone 4.) Core Motion publishes an Objective-C programmatic interface that enables applications to receive device-motion data of various types, which they can then process in appropriate ways.

Core Motion is replacing the older UIAccelerometer framework wich is still available but deprecated in version 5.x.

705 questions
65
votes
4 answers

In iOS, what is the difference between the Magnetic Field values from the Core Location and Core Motion frameworks?

I have two ways of getting the magnetic fields (strength, x, y, and z) using the iOS device's magnetometer. 1) Core Location Used the CLHeading from CLLocationManagerDelegate method locationManager:didUpdateHeading:. This is similar to Apple's…
MiuMiu
  • 1,875
  • 2
  • 18
  • 27
36
votes
5 answers

CoreMotion updates in background state

With the M7 chip in the latest iOS devices one can get programmatically notified as the user goes from stationary to running, walking, etc using CMMotionActivityManager. Stava and Runkeeper have both used this to auto-pause GPS polling (shut off the…
Parrots
  • 25,268
  • 14
  • 56
  • 78
35
votes
4 answers

Detecting if a user is moving in a car

NOTICE: This question was originally posted before Apple introduced motion-detection hardware and associated APIs in the iOS SDK. Answers to this question, however, remain relevant. I'm creating an iPhone iOS app which involves tracking a user's…
Sam Spencer
  • 8,158
  • 12
  • 70
  • 130
34
votes
5 answers

iPhone - understanding iPhone rotation

I am banging my head on the wall trying to understand this. See the next picture. Suppose I have an iPhone resting on a table. At this time the rotation readings thru core motion are 0,0,0 for yaw, roll and pitch (picture A). Then I roll it 90…
Duck
  • 32,792
  • 46
  • 221
  • 426
26
votes
5 answers

How does knocktounlock work?

I am trying to figure out how knocktounlock.com is able to detect "knocks" on the iPhone. I am sure they use the accelerometer to achieve this, however all my tries come up with false flags (if user moves, jumps, etc it sometimes fires) Basically, I…
Jonovono
  • 3,347
  • 3
  • 38
  • 61
26
votes
1 answer

CMMotionActivityManager - Receiving motion activity updates while app is suspended or in background

I've been testing the new Motion Activity Manager APIs (CMMotionActivityManager). I want to create an app that can receive and process motion updates from startActivityUpdatesToQueue while the app is not running in the foreground. I correctly…
user2853019
  • 261
  • 3
  • 3
26
votes
2 answers

Finding normal vector to iOS device

I would like to use CMAttitude to know the vector normal to the glass of the iPad/iPhone's screen (relative to the ground). As such, I would get vectors like the following: Notice that this is different from orientation, in that I don't care how…
22
votes
2 answers

Simple iPhone motion detect

I need to detect when the gyroscope / accelerometer is activated a certain amount. Basically to detect when there is movement of the device. I don't know anything about Core Motion. Maybe someone can direct me to a starters tutorial or…
Linuxmint
  • 4,646
  • 11
  • 42
  • 64
20
votes
2 answers

How to create a new CMAttitude Reference Frame to make the gravity be on the Y axis

I want to be able to change the Device Motion Manager Reference frame (for the gyro) so that I have my gravity vector on the Y axis. Usually when you start Device Motion Manager Updates you will only have the z axis of the phone aligned with…
Pochi
  • 13,198
  • 2
  • 58
  • 99
20
votes
5 answers

Detecting when someone begins walking using Core Motion and CMAccelerometer Data

I'm trying to detect three actions: when a user begins walking, jogging, or running. I then want to know when the stop. I've been successful in detecting when someone is walking, jogging, or running with the following code: -…
Apollo
  • 7,820
  • 27
  • 91
  • 177
19
votes
1 answer

Main Thread Checker warning with CoreMotion, only appearing on 2018 model iPhones

The following is an extremely simplified version of the issue: import UIKit import CoreMotion class ViewController: UIViewController { private let manager = CMMotionManager() private let interval = 0.01 override func viewWillAppear(_…
CodeBender
  • 30,010
  • 12
  • 103
  • 113
19
votes
4 answers

Technique World tracking performance is being affected by resource constraints

While running an ARKit session with world tracking enabled, the Xcode console shows log messages about (I presume: reduced) tracking performance, even though The AR Session is in Normal tracking state, I am using the device in a well-lit office…
PDK
  • 1,230
  • 11
  • 24
18
votes
2 answers

SceneKit – Mapping physical 360 rotation

I am having a hard time mapping device motion (sensor fusion) to SceneKit node rotation. The premise of the problem is as follows, I have sphere, and the camera is positioned to be inside the the sphere such that the geometric center of sphere and…
egghese
  • 2,088
  • 15
  • 26
18
votes
1 answer

iPhone collecting CoreMotion data in the background. (longer than 10 mins)

I am trying to collect coreMotion acceleration data in the background for longer than 10 minutes. This must be possible since apps like Sleep Cycle do this. I just want to make sure this is allowed though, since it does not seem to be one of…
Jonovono
  • 3,347
  • 3
  • 38
  • 61
18
votes
1 answer

Continuous accelerometer updates while in the background on iOS

I have researched this topic thoroughly before asking the question but need to ensure that I have come to the right conclusions and, if so, I would like help on implementing this as efficiently as possible. It is essential for my app to receive…
BYZZav
  • 1,344
  • 17
  • 30
1
2 3
46 47