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:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
                [data addObject:[NSString stringWithFormat:@"%f, %f, %f, %f, %f, %f, %f, %f, %f", motion.attitude.pitch, motion.attitude.roll, motion.attitude.yaw, motion.userAcceleration.x, motion.userAcceleration.y, motion.userAcceleration.z, motion.rotationRate.x, motion.rotationRate.y, motion.rotationRate.z]];
                NSLog(@".");
            }];
        }
    }else{
        recording = NO;
        NSLog(@"stopping recording");
        [self.motionManager stopDeviceMotionUpdates];
        [self.startRecording setTitle:@"Start Recording"];
        [InterfaceController openParentApplication:@{ @"data": data } reply:^(NSDictionary *replyInfo, NSError *error) {
            NSLog(@"Data has been saved.");
            NSLog(@"replyInfo %@", replyInfo);
        }];
    }
}

The parent application just writes all the data to a file. I recorded the watch rotating back and forth on all three axes (pitch, then roll, then yaw):

And then when I plotted the data, this is what I got:

The yaw is so noisy that you can't see a signal at all in there. I also have a similar problem when plotting the acceleration after jerking the watch in three different directions. I can see spikes of acceleration, but they don't seem to be direction dependent. Any ideas on how to improve this? Am I missing something? Could I just have a bad sensor in my watch?


回答1:


The reason is because I wasn't actually pulling data from the watch. It was pulling data from the phone. In order to pull data (currently only acc data is available from the watch) you need to have watchOS2 (currently in beta). Otherwise the watch will just get handed data from the phone.



来源:https://stackoverflow.com/questions/32466314/apple-watch-cmdevicemotion-is-not-giving-me-good-readings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!