core-motion

How to calculate correct velocity values from accerometer

ⅰ亾dé卋堺 提交于 2019-12-02 19:52:27
I need to calculate iphone velocity in space, punch speed for example. My first question is: Are the acceleration values accelerometer:didAccelerate with this filtering actions: gravity_x = acceleration.x * kFilteringFactor + gravity_x * (1.0 - kFilteringFactor); gravity_y = acceleration.y * kFilteringFactor + gravity_y * (1.0 - kFilteringFactor); gravity_z = acceleration.z * kFilteringFactor + gravity_z * (1.0 - kFilteringFactor); float gravityNorm = sqrt(gravity_x * gravity_x + gravity_y * gravity_y + gravity_z * gravity_z); accelX = acceleration.x - gravity_x / gravityNorm; accelY =

get pitch, yaw, roll from a CMRotationMatrix

落花浮王杯 提交于 2019-12-02 17:47:12
I have a CMRotationMatrix *rot and i would like to get the pitch, yaw, roll from the matrix. Any ideas how i could do that? Thanks iSeeker Its better to use the Quaternion than Euler angles.... The roll, pitch and yaw values can be derived from quaternion using these formulae: roll = atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z) pitch = atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z) yaw = asin(2*x*y + 2*z*w) It can be implemented as: CMQuaternion quat = self.motionManager.deviceMotion.attitude.quaternion; myRoll = radiansToDegrees(atan2(2*(quat.y*quat.w - quat.x*quat.z), 1 - 2*quat.y*quat.y - 2*quat.z*quat

Safe update interval for startDeviceMotionUpdatesToQueue:withHandler:?

六月ゝ 毕业季﹏ 提交于 2019-12-02 01:09:55
问题 EDIT: added a global and now it's working. But I still have my doubts.. Please read on :) I want to get the acceleration exercised on the Y-axis whenever I need to and use it in different parts of my code. In this example I'm using it inside a while-loop for testing purposes.. My code is working but Am I using the the UpdateToQueue... method correctly or is this kind of an "unorthodox" way of achieving what I want? I've set the Update Interval at 30 ms, do you think this is a "safe" update

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

旧街凉风 提交于 2019-12-01 19:35:19
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 of readings I can expect from that method of Core Motion? The documentation doesn't talk about it. Edit

Get pitch, roll and yaw relative to geographic north on iOS?

非 Y 不嫁゛ 提交于 2019-12-01 09:18:33
I see that I can retrieve CMAttitude from a device and from it I can read 3 values which I need (pitch, roll and yaw). As I understand, this CMAttitude object is managed by CoreMotion which is a Sensor Fusion manager for calculating correct results from compass, gyro and accelerometer together (on Android it is SensorManager Class). So my questions are: Are those values (pitch, roll and yaw) relative to the magnetic north and gravity? If above is correct, how can I modify it to give me results relative to the geographic north? If a device (such as iPhone 3GS) doesn't have an gyroscope, do I

How to replace UIAccelerometer with CMMotionManager?

岁酱吖の 提交于 2019-12-01 07:42:37
问题 I'm new to iOS development. I follow the tutorial from Ray Wenderlich to create a little location based AR app. However, the tutorial uses an AR Toolkit which has not been updated for a while. The UIAccelerometer it uses has already been deprecated since iOS 5, so when I try to run it on my iPhone (iOS 7.0.4), the Xcode says that there are 3 warnings, and all of them are caused by UIAccelerometer. The result it leads to is that all the marks stay at the center of the screen one above another,

I get OSSpinLockLock when calling startDeviceMotionUpdatesToQueue inside a controller

☆樱花仙子☆ 提交于 2019-12-01 04:37:14
In my root controller I have a property with the CMMotionManager @property (strong, nonatomic) CMMotionManager *MManager; In its getter I do lazy instantiation. When the controller's view loads, I call this method - (void)reloadAccelerometer { NSLog(@"Away we go"); self.MManager.deviceMotionUpdateInterval = 10.0/60.0; [self.MManager startDeviceMotionUpdatesToQueue:self.queue withHandler:^(CMDeviceMotion *motion, NSError *error) { NSLog(@"Y values is: %f", motion.userAcceleration.y); }]; } I see "Away we go" in the NSLog and then immediately the app crashes and I get this thread log libsystem

I get OSSpinLockLock when calling startDeviceMotionUpdatesToQueue inside a controller

谁说胖子不能爱 提交于 2019-12-01 02:21:52
问题 In my root controller I have a property with the CMMotionManager @property (strong, nonatomic) CMMotionManager *MManager; In its getter I do lazy instantiation. When the controller's view loads, I call this method - (void)reloadAccelerometer { NSLog(@"Away we go"); self.MManager.deviceMotionUpdateInterval = 10.0/60.0; [self.MManager startDeviceMotionUpdatesToQueue:self.queue withHandler:^(CMDeviceMotion *motion, NSError *error) { NSLog(@"Y values is: %f", motion.userAcceleration.y); }]; } I

NSTimeInterval to unix timestamp

妖精的绣舞 提交于 2019-11-30 20:33:37
I'm getting CMDeviceMotion objects from CMMotionManager . One of the properties of the CMDeviceMotion is timestamp, which is expressed as a NSTimeInterval (double). This allows for "sub millisecond" timestamp precision, according to documentation. [motionManager startDeviceMotionUpdatesToQueue:motionQueue withHandler:^(CMDeviceMotion *motion, NSError *error) { NSLog(@"Sample: %d Timestamp: %f ",counter, motion.timestamp); } Unfortunately, NSTimeInterval is calculated since last device boot, posing significant challenges to using it in its raw form. Does anyone have a working code to convert

Is there any way to remove the small bias along the gravity axis in the accelerometer data

不问归期 提交于 2019-11-30 18:20:28
问题 Similar to this question: CMDeviceMotion userAcceleration drift I'm using CMDeviceMotion.userAcceleration in iOS5 SDK to plot its x, y, z components over time. Like the above post, I see z acceleration component shows always small positive values (0.005 - 0.015) while x and y components are centering along zero (-0.005 - 0.005) when my iPhone 4s is sitting on a flat surface. This small bias keeps adding up to the estimated velocity (which I compute by integrating the acceleration data) even