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
16
votes
3 answers

How best to give falling ball real world gravity

I'm a fairly new app dev and very new to Sprite Kit. I am creating a game where I want a ball to always fall downward as if it were in gravity. This is just a 2d app so all I want is when the ball is falling, when you tilt the phone to the left, the…
16
votes
5 answers

iOS - is Motion Activity Enabled in Settings > Privacy > Motion Activity

If an app requires access to Motion Activity data it asks the user at install. However if the user accidentally answers 'No', then the app will not work. I am looking for a way to check if the Motion Activity is enabled, so that I can prompt the…
NeilMortonNet
  • 1,460
  • 4
  • 16
  • 33
15
votes
1 answer

ARKit – How to put 3D Object on QRCode?

I'm actually trying to put a 3D Object on QRCode with ARKit For that I use a AVCaptureDevice to detect a QRCode and establish the area of the QRCode that gives me a CGRect. Then, I make a hitTest on every point of the CGRect to get the average 3D…
Alain Berrier
  • 577
  • 5
  • 22
15
votes
3 answers

CoreMotion crash(iPad-only) on invoking stopDeviceMotionUpdates

We have an instance of CMMotionManager in our app which we use to get sensor updates at a frequency of 5Hz. Following is the code we use to start motion…
Yogesh Maheshwari
  • 1,294
  • 2
  • 15
  • 36
14
votes
3 answers

Can I require an iPhone 5S for my app?

I'm writing an app which requires the M7 Motion co-processor chip in the iPhone 5S. Since this chip isn't in any other iPhone, the app will only function properly on an iPhone 5S. Is there any way to require that a user has an iPhone 5S before…
Jackson
  • 3,456
  • 3
  • 31
  • 50
12
votes
4 answers

DeviceMotion relative to world - multiplyByInverseOfAttitude

What is the correct way to use CMAttitude:multiplyByInverseOfAttitude? Assuming an iOS5 device laying flat on a table, after starting CMMotionManager with: CMMotionManager *motionManager = [[CMMotionManager alloc]init]; [motionManager…
Zaq
  • 686
  • 2
  • 8
  • 18
12
votes
2 answers

CMotionManager crash on instantiation

EDIT: This appears to be resolved on iOS 13. Leaving all the original details below. I'm getting a crash when instantiating my CMMotionManager object for Core Motion. This is on an iPhone Xs running iOS 12.0.1. I can reliably reproduce this with a…
smithco
  • 589
  • 4
  • 15
12
votes
1 answer

Actual frequency of device motion updates lower than expected, but scales up with setting

I am porting an app that I originally wrote using the accelerometer for IOS 3, to incorporate the new IOS 4 motion capabilities. While capturing motion, the application does little else - no graphics updates for example. I'm doing the following to…
J.Spiral
  • 475
  • 5
  • 10
12
votes
2 answers

Detect movement regardless device rotation

I search a way to detect the movement of the phone regardless how the user holds the phone. Some examples: I am interested in the vertical movement (like the user pulls the phone up) 'ignoring' if the phone lays on the table or held in the hand…
Thorsten
  • 121
  • 2
11
votes
2 answers

In IOS 11, DeviceMotion in background stopped working

My app reports and records location, altitude, rotation and accelerometer data (DeviceMotion) while in the background. This works fine on ios 10.3.3. On IOS 11, I no longer have access motion data while the device is locked. Altitude data and…
Nicholas K
  • 151
  • 1
  • 10
11
votes
3 answers

Recognize current device position as flat

So I have this app Im working on where you can roll the ball around the screen by tilting the device around(accelerometer). How can I alter the code below so that I don't have to hold the phone flat and have that as my neutral balance point. What I…
4GetFullOf
  • 1,738
  • 4
  • 21
  • 47
11
votes
1 answer

Attitude change - angles and axis issue - quaternion math

I have an app that records angles as user is walking around an object, while pointing device (preferably) at the center of the object. Angle gets reset on user's command - so reference attitude gets reset. Using Euler angles produces Gimbal lock, so…
Andrei G.
  • 1,510
  • 1
  • 13
  • 21
10
votes
1 answer

CoreMotion apparently calls UI API from background thread

At some point in my app I am initializing a CMMotionManager. This happens on the main thread. After doing so, the Xcode 10 main thread checker indicates that -[UIApplication applicationState] is not being called from the main thread. Indeed it is…
ff10
  • 2,866
  • 1
  • 29
  • 53
10
votes
2 answers

Objects falling towards earth regardless of device orientation

I have seen two ways to describe falling objects behaviour for different device orientation using CoreMotion framework. I have tried both version in code and they both seem to behave as what I expect, i.e. falling toward earth regardless of device…
Thor
  • 8,608
  • 10
  • 43
  • 113
10
votes
2 answers

Motion Manager is not working in Swift

I am try to use motion manager in Swift but the log inside my update block never prints. var motionManager: CMMotionManager = CMMotionManager() motionManager.accelerometerUpdateInterval = 0.01 println(motionManager.deviceMotionAvailable)…
Naitian
  • 103
  • 1
  • 1
  • 4
1
2
3
46 47