菜鸟教程小白 发表于 2022-12-12 08:52:12

ios - 从苹果 watch (而不是 iPhone)获取加速度计和陀螺仪数据?


                                            <p><p>看完<a href="/image/xQywS.png" rel="noreferrer noopener nofollow">this question</a> ,我尝试编写一个快速程序,将 watch 加速度计和陀螺仪数据保存到文件中。 </p>

<pre><code>@implementation InterfaceController{
    NSMutableArray *accData;
    bool recording;
}
- (void)awakeWithContext:(id)context {
    ;
    // Configure interface objects here.
    self.motionManager = [ init];
    ;
}

- (IBAction)startStopRecording {
    if (!recording){//We are starting to record.
      recording = YES;
      accData = [ init];
      ;
       withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
            ];
      }];
    }else{
      recording = NO;//we are stopping the recording
      ;
      ;
      [InterfaceController openParentApplication:@{ @&#34;accData&#34;: accData } reply:^(NSDictionary *replyInfo, NSError *error) { //this method saves the array to a csv file.
            NSLog(@&#34;Data has been saved.&#34;);
      }];
    }
}
</code></pre>

<p>我已经绘制了这些数据,并且在我的一生中,无论我多么用力地摇晃 watch ,我的所有图表都是这样的:</p>

<p> <a href="/image/xQywS.png" rel="noreferrer noopener nofollow"><img src="/image/xQywS.png" alt="enter image description here"/></a> </p>

<p>直到 8 小时后,我才开始怀疑我不是从 watch 上获取加速度数据,而是从手机(仍然坐在我旁边的 table 上)获取的。我进行了一些测试并确认这正是正在发生的事情。</p>

<p>这让我想到了最初的问题。如何从 watch 而不是 iPhone 中提取加速度/陀螺仪/数据?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>问题是我没有运行 watchOS2。我以为我是,但它仍处于测试阶段,我还没有安装它。我得到的数据是来自手机的加速度计数据。另外,目前,您只能使用 watchOS2 从 watch 获取 acc 数据,而不能获取陀螺仪数据。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 从苹果 watch (而不是 iPhone)获取加速度计和陀螺仪数据?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32486922/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32486922/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 从苹果 watch (而不是 iPhone)获取加速度计和陀螺仪数据?