苹果手表 CMDeviceMotion 没有给我很好的读数 [英] apple watch CMDeviceMotion is not giving me good readings

查看:40
本文介绍了苹果手表 CMDeviceMotion 没有给我很好的读数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我只是记录一堆运动数据并将其保存到文件中.然而,当我绘制数据时,我很难相信我得到了正确的读数.这是我的手表代码:

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?

推荐答案

原因是因为我实际上并没有从手表中提取数据.它正在从手机中提取数据.为了提取数据(目前只有 acc 数据可从手表中获得),您需要有 watchOS2(目前处于测试阶段).否则手表只会从手机获取数据.

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.

这篇关于苹果手表 CMDeviceMotion 没有给我很好的读数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆