cmmotionmanager

iOS之 CoreMotion 框架

二次信任 提交于 2020-04-07 06:01:20
在项目中经常会使用到重力加速度,陀螺仪,最近在一个项目中使用到了CoreMotion 框架,需求是:上下摇摆手机控制智能椅子的角度调节,该项目是使用蓝牙4.0进行通讯的,在iOS 内已经封装好了CoreBluetooth 框架,不过需要iPHone4s 以上的手机,和iPad min 以上的平板电脑才有蓝牙4.0. 今天在这里先记录一下CoreMotion 框架的使用. 主要的类:CMMotionManager , NSOperationQueue. 下面是一个被我封装过的一个类。 项目需要导入CoreMotion.Framework 在.h 文件需要#import <CoreMotion/CoreMotion.h> .h文件代码: #import <Foundation/Foundation.h> #import <CoreMotion/CoreMotion.h> typedef enum _MotionDirection {UNKNOWDIRECTION=0,UP,DOWN}MotionDirection; @interface iCtrlCMManager : NSObject @property (nonatomic,retain) CMMotionManager * ictrlCMManager; @property (nonatomic,assign)

CMMotionManager - getting heading using CMMotionManager exclusively

主宰稳场 提交于 2020-01-15 12:14:34
问题 I have managed to get compass heading using CLLocationManager but because my app already uses CMMotionManager I would like to measure heading using exclusively CMMotionManager. Like all Apple vague documentation, you have to guess how to use their APIs. I have tried to use this to measure heading [self.motionManager setMagnetometerUpdateInterval:1.0/30.0]; //30 Hz [self.motionManager startMagnetometerUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMMagnetometerData

deviceMotion not returning anything for pitch, roll, or yaw

陌路散爱 提交于 2020-01-05 04:00:31
问题 I'm trying to get some simple code working to log the pitch, roll, and yaw of my iPhone 4S. It's firing the timer correctly, but the values of pitch, roll, and yaw, are always displayed in the console as 0.0000000. What am I missing here? Any help appreciated! Here's my .h file: @interface ViewController : UIViewController @property (nonatomic, retain) CMMotionManager *motionManager; @property(readonly, weak) CMDeviceMotion *deviceMotion; -(void)doSomething; @end And here's my .m file:

Please help me correctly apply device rotation data

笑着哭i 提交于 2019-12-23 10:58:09
问题 So I have a bit of a project I am trying to do. I am trying to get the devices rotation relative to gravity, and translation from where it started. So basically getting "tracking" data for the device. I plan to basically apply this by making a 3d pt that will mimic the data I record from the device later on. Anyway to attempt to achieve this I thought it would be best to work with scene kit that way I can see things in 3 dimensions just like the data I am trying to record. Right now I have

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

Finding distance using accelerometer in iPhone

蹲街弑〆低调 提交于 2019-12-22 01:42:53
问题 Please suggest some beginning point in this process of finding distance displaced by an iPhone. The requirement of accuracy in current system is in cm , and displacement can be in 3D. What I have already done is 1. Tried using sound to calculated distance between between 2 iPhones, but I need distance calculation with one iPhone only, i.e need displacement. 2. Tried CMMotionManager and its accelerometer data, but values received is helpless. I think I need a good filter to get useful data out

Use Quaternions to compute yaw, pitch and roll from iphone?

爱⌒轻易说出口 提交于 2019-12-19 11:23:21
问题 I have seen many questions and articles mentioning that Quaternions can be used to derive better,accurate and stable yaw, pitch and roll readings from the iPhone rather than reading it's direct yaw, pitch and roll readings. But at the same time, I haven't seen any proper methods of implementing Quaternions in iPhone platform. As a beginner, It's really hard to know, How these Quaternions works and implementing them in a piece of code? (Sorry for not providing any code as i have no idea of how

CMDeviceMotion yaw values unstable when iPhone is vertical

*爱你&永不变心* 提交于 2019-12-18 13:01:47
问题 In a iOS prototype I use a combination of CMDeviceMotion.deviceMotion.yaw and CLHeading.trueHeading to make stable compass heading that is responsive and accurate. This works well when the iPhone is held flat, where I have a graphical arrow that point to a stable compass heading. The problem appear when the iPhone is held vertical in portait mode. The UIDeviceOrientation constantly changes from UIDeviceOrientationFaceDown to UIDeviceOrientationFaceUp and back. This makes the yaw value to skip

iOS CMMotionActivity Manager, how to detect stop signs when the car is stop?

半世苍凉 提交于 2019-12-13 19:02:01
问题 I am working on a project for detecting the user's current motion, and I use the CMMotionActivityManager with these motions includes 'Stationary', 'Walking', 'Automotive', 'Running'. Now there is a requirements for I need to know the location when people parked the car. But the thing is, I only need the location when people parked at last. How to eliminate the influence of the stop signs. Because people always stop when they are driving. If the car is stopped, then the status will be

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

安稳与你 提交于 2019-12-06 06:14:24
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 get this done? Thank you in advance! First, just to clarify: Rotation rates are not measured "from" any