为 iOS 4 加速度计/陀螺仪数据收集编写测试用例
我正在为 iPhone (iOS 4.2) 开发一个应用程序,它需要能够从加速度计和陀螺仪收集大量数据。我目前正在考虑使用 CoreMotion 框架将数据放入接受器类(我将其写入数据库)。
但是,为了代码质量,我想编写一些测试用例来测试我的接受器类。通过研究,似乎没有任何明确的方法可以做到这一点 - CoreMotion 只是将数据输出为浮点数,但我不只是想将大量浮点数输入到接受器类中,因为这不会复制 CoreMotion 的行为方式- 而只是漂浮物的馈送将如何。
当“他们”说它将以 x 赫兹生成数据并且该数据将在给定的 y 和 z 范围之间时,假设 CoreMotion 是苹果生成的类是否公平?
任何有关编写和开发测试用例以及与我的整体设计有关的想法/提示将不胜感激。
I'm developing an app for iPhone (iOS 4.2) which needs to be able to collect large amounts of data from the accelerometer and gyroscope. I'm current looking at using the CoreMotion framework to get the data into an acceptor class (from which I'm writing it to a database).
However, for code quality I want to write some test cases to test my acceptor class. Through research there doesn't seem to be any clear way to do this - CoreMotion just outputs data as floats, but I don't just want to feed a load of floats into the acceptor class, because that won't replicate how CoreMotion behaves - rather just how a feed of floats will.
Is it fair to assume that as CoreMotion is an apple-produced class when "they" say it will produce data at x-hertz, and this data will be between the range of y and z that this is a given?
Any ideas/hints relating to writing and developing test cases, and additionally relating to my overall design would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在开发者网站上下载核心运动茶壶示例。您将能够设置每秒返回数据的速率(赫兹)。您还可以请求核心运动的时间戳,以获得加速度计/陀螺仪数据的准确时间。
加速度计不准确。您可以使用它来大致了解当前加速度,这对于检测运动方向很有用,但对于获取距离或速度没有帮助。
Download the core motion teapot sample on the developer website. You'll be able to set the rate (hertz) of returned data per second. You can also request timestamp from core motion to get the exact time of the accelerometer / gyroscope data.
The accelerometer isn't accurate. You can use it to get a general idea of current acceleration which is useful for detecting direction of movement but not for getting distances or velocity.