core-motion

Detect acceleration in absolute vertical axis

时光总嘲笑我的痴心妄想 提交于 2019-12-13 20:28:50
问题 I'm writing an app in which I want to access the acceleration data in an absolute vertical axis (i.e., from the ground to the floor), but with CoreMotion I'm only able to retrieve acceleration from the device's relative axis. For example if the device is laying flat on the table, it's vertical axis is actually at 90º from the absolute vertical axis. I've been playing with the gyro data to try to fix this, but data don't make sense. // Make sure the accelerometer hardware is available. if self

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

CMPedometer queryPedometerDataFromDate returns error 103

耗尽温柔 提交于 2019-12-13 11:46:05
问题 I'm trying to do a query to the pedometer cache on an iPhone 6 with iOS 8.1.2, I'm using objective-c, I have imported CoreMotion framework and included it in the project the code looks like this NSDate *startDate = [[NSDate date] dateByAddingTimeInterval:-60*60*12]; NSDate *endDate = [NSDate date]; CMPedometer *pedo = [[CMPedometer alloc]init]; [pedo queryPedometerDataFromDate:startDate toDate:endDate withHandler:^(CMPedometerData *pedometerData, NSError *error) { if (error) { NSLog(@"error:

CMDeviceMotion userAcceleration is upside down?

醉酒当歌 提交于 2019-12-12 08:55:42
问题 I'm seeing some unexpected readings from the userAcceleration field in CMDeviceMotion. When I look at the raw accelerometer data from CMAccelerometerData, I see that if the iPhone is flat on a table the reading is 1G straight down (1G in -Z axis) and if I drop the iphone (on a soft surface of course) then the acceleromtere reading goes to zero as expected. That's all fine. When I instead use the CMDeviceMotion class, the userAcceleration reading is zero as expected when the iPhone is flat on

Detect device forward backward movement

£可爱£侵袭症+ 提交于 2019-12-12 04:48:14
问题 By any way can I find whether my device is moving forward or backward. Consider if I have kept my device on a moving object say a rc toy car facing front to take movie where all it goes. Can I detect whether the car is going forward or backward. Is it possible possible with map sdk for movement about 10meter? How long it should move to get the result with map sdk ? 回答1: With the accelerometer sensor, you know the position of the phone in relation with the car, you absolutely can detect the

CoreMotionActivityManager returning either Automotive or Automotive + Stationary true

人走茶凉 提交于 2019-12-12 04:38:05
问题 I'm trying to detect Automotive ActivtyType, however the problem is if "I go on a drive and then stop the car and stay in the car" and simply check the coreMotion logs: I would continue to get numerous mixed callbacks of either high Confidence: Automotive: True, Stationary: True or high confidence: Automotive: True, Stationary: False or low confidence: Automotive: True, Stationary: True I do not get an only Stationary: True, it always comes with automotive being True as well There's not much

Unable to find Cocoapod MotionKit framework Derived Data

早过忘川 提交于 2019-12-12 03:58:46
问题 I installed the library with Pod. But I got the following error when I build the app: error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: \ /Users/taiyuanz/Library/Developer \ /Xcode/DerivedData/RollingBall-gbmnblxxirswheemtfgncxsqywkj/Build/\ Products/Debug-iphoneos/Ballman.app/Frameworks/MotionKit (No such file or directory) This happens after I upgraded the Xcode. How to fix such error? 回答1: Xcode > Window > Projects >

Why am I not getting any accelerometer update?

拈花ヽ惹草 提交于 2019-12-12 02:03:27
问题 I am trying to get accelerometer updates with CoreMotion and Swift, here is what I placed in my viewDidLoad : override func viewDidLoad() { super.viewDidLoad() let motionManager = CMMotionManager() motionManager.accelerometerUpdateInterval = 0.2 motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue()) { (info:CMAccelerometerData!,error:NSError!) in if error != nil { println(error) } else { println("OK") } } } The problem is that it looks like my closure never gets

How to identify iPhone SHAKE in Swift? [duplicate]

浪尽此生 提交于 2019-12-11 14:23:16
问题 This question already has answers here : Detect shake gesture IOS Swift (7 answers) Closed 2 years ago . Hi I want to identify the iPhone SHAKE when user shakes their phone, either in background mode or in foreground mode of the app. Please assist me. Thanks in advance. 回答1: The main trick is that you need to have some UIView (not UIViewController) that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events: class

apple watch CMDeviceMotion is not giving me good readings

我与影子孤独终老i 提交于 2019-12-11 10:04:53
问题 Currently, I am just recording a bunch of motion data and saving it to a file. However, when I plot the data, I am having a hard time believing I am getting the right readings. Here is my watch code: - (IBAction)startStopRecording { if (!recording){ NSLog(@"starting to record"); recording = YES; data = [[NSMutableArray alloc] init]; [self.startRecording setTitle:@"Stop Recording"]; if (self.motionManager.deviceMotionAvailable) { [self.motionManager startDeviceMotionUpdatesToQueue: