core-motion

How to rotate UIView using transform?

风格不统一 提交于 2019-12-23 15:08:27
问题 I have a UIView which I am trying to transform (rotate) using the pitch value you can get from coremotion attitude. I am using transform however I am not sure my code is correct as the UIView is not doing anything. This is my code its being called several times per second. - (void)setLabelValueRoll:(double)roll pitch:(double)pitch yaw:(double)yaw { self.yLabel.text = [NSString stringWithFormat:@"pitch: %f", pitch]; CATransform3D transform; transform = CATransform3DMakeRotation(pitch + M_PI_2,

Compute rate of change of orientation(angular measurement) along y axis?

∥☆過路亽.° 提交于 2019-12-22 12:07:13
问题 I want to compute rate of change of orientation of the iPhone along y axis. 1. Initially i need to define the reference as y axis, 2. Then measure the rate of change of orientation(angular measurement) from the defined reference. Does CMAttitude provides a reliable angular measurements to implement this? Or Can i use rotational matrix or integrate gyroscope data(I implement this method, but it's not going to work due to the drift of the gyroscope). So please suggest me a reliable method to

How to use CMMotionActivityManager and receive updates?

匆匆过客 提交于 2019-12-21 21:32:38
问题 I want to create an app that can receive and process motion updates in order to understand if the user is stationary, walking, running or is on a transport. I've seen on the reference that CMMotionActivityManager can be useful for me. The CMMotionActivityManager class provides access to the motion data stored by a device. Motion data reflects whether the user is walking, running, in a vehicle, or stationary for periods of time. I'm new to app developing and I don't understand how to use the

How to use CMMotionActivityManager and receive updates?

家住魔仙堡 提交于 2019-12-21 21:26:06
问题 I want to create an app that can receive and process motion updates in order to understand if the user is stationary, walking, running or is on a transport. I've seen on the reference that CMMotionActivityManager can be useful for me. The CMMotionActivityManager class provides access to the motion data stored by a device. Motion data reflects whether the user is walking, running, in a vehicle, or stationary for periods of time. I'm new to app developing and I don't understand how to use the

How to avoid roll in SceneKit camera controlled by Core Motion?

自作多情 提交于 2019-12-21 12:54:08
问题 I'm setting my SceneKit camera to the current CMDeviceMotion attitude using the CMDeviceMotion extension described in this answer: func deviceDidMove(motion: CMDeviceMotion?, error: NSError?) { if let motion = motion { let orientation = motion.gaze(atOrientation: UIApplication.sharedApplication().statusBarOrientation) cameraNode.orientation = orientation } } This works beautifully, however, I'd like to block the rotation (roll) and only allow the camera to turn around (yaw) and pitch. I tried

Swift gyroscope yaw, pitch, roll

耗尽温柔 提交于 2019-12-21 05:15:33
问题 I'm doing a project for my school, for a programming subject. I'm working in Xcode in Swift. I would like to make an application that uses Gyroscope. I don't know but somehow it won't run on my iphone because of some errors in Xcode that I don't know how to fix.When I run the program is says "fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)" The main thing of my project is to display rotations (yaw,pitch,roll) in degrees on iphone screen using gyroscope. I would

How do I retrieve accelerometer data correctly with Swift in iOS?

不打扰是莪最后的温柔 提交于 2019-12-20 15:25:32
问题 I am trying to record the data from the iPhone's accelerometer (my own iPhone 5s) and set a label on the screen to that data using String(format: "%.2f", data) where data is the value for the specific axis I want to record. To do this I set up a CMMotionManager and began recording accelerometer data, and I have a timer that constantly updates the text in the label. However, I am getting an error from Xcode: "fatal error: unexpectedly found nil while unwrapping an Optional value". Here is the

How do I retrieve accelerometer data correctly with Swift in iOS?

五迷三道 提交于 2019-12-20 15:25:08
问题 I am trying to record the data from the iPhone's accelerometer (my own iPhone 5s) and set a label on the screen to that data using String(format: "%.2f", data) where data is the value for the specific axis I want to record. To do this I set up a CMMotionManager and began recording accelerometer data, and I have a timer that constantly updates the text in the label. However, I am getting an error from Xcode: "fatal error: unexpectedly found nil while unwrapping an Optional value". Here is the

Swift CoreMotion detect Tap or Knock on device while in background

旧时模样 提交于 2019-12-20 10:12:05
问题 I am currently in the Process of building my first iOS Swift app, with this app I want to perform an action while the app is running in the background. The action needs to be performed once the user taps twice on the device. I've enabled Background Modes: Location updates in the app Capabilities And setup a AccelerometerUpdatesToQueue function in the AppDelegate: let manager = CMMotionManager() func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject

Do I get more accurate or faster accelerometer readings with Core Motion?

安稳与你 提交于 2019-12-20 01:07:36
问题 I can use this method of the Core Motion framework: - (void)startAccelerometerUpdatesToQueue:(NSOperationQueue *)queue withHandler:(CMAccelerometerHandler)handler as an alternative to the - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration UIAccelerationDelegate method of UIKit. There, I have to specify the frequency of updates. I want to get acceleration data as fast and accurate as possible. Is Core Motion my friend here? What's the frequency