apple watch CMDeviceMotion is not giving me good r

2019-08-10 09:03发布

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):

enter image description here

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

pitch plot roll plot yaw plot

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条回答
做个烂人
2楼-- · 2019-08-10 09:19

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.

查看更多
登录 后发表回答