iPhone 上的加速器范围是多少?

发布于 2024-07-16 01:12:50 字数 56 浏览 7 评论 0原文

我似乎无法在网上找到任何关于此的文档,而且我正在谷歌搜索的内容给了我很多相互矛盾的信息......

I can't seem to find any documentation online about this, and what I am googling is giving me a lot of conflicting information...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情独悲 2024-07-23 01:12:51

来自 iphonedevsdk.com

第一个中使用的加速度计
和第二代iPhone(我
假设 iPod touch 也能运行
有两种模式:+/- 2 g 和 +/- 8 g。
(事实上​​,正如你所观察到的,他们
报告加速度稍稍超出
标称范围。 准确度不是
不过,规格超出了该范围。)

Apple 在 +/- 2 g 范围内运行它们
模式。 存在一个权衡:当前
标称分辨率为 0.018 g,
根据数据表(虽然我的
第一代 iPhone 使用
0.018168604,根据 AccelerometerGraph 的修改版本)。 在里面
+/- 8 g 模式,分辨率会粗四倍。

我认为苹果决定越精细
分辨率会比
范围更广。 (我宁愿看到更精细的
分辨率高于0.018 g。 所以两者都不是
我们非常满意。)

您无法使用任何方式更改模式
API 的已发布功能。 自从
他们将加速度作为
双倍,理论上他们可以允许
改变模式,简单地看一下
重新调整 A/D 值时的模式,
在报告加速度之前。 (这
设置模式的明显位置是
在设置的调用中
接收加速度计的应用程序
信息。)但是,对于落后的
兼容性,操作系统必须
将加速度计模式设置为 +/- 2 g
在应用程序的开头。
并且没有任何后台进程
可以允许设置
加速计模式。

From iphonedevsdk.com:

The accelerometers used in the first
and second generation iPhones (and I
assume also the iPod touches) operate
in two modes: +/- 2 g, and +/- 8 g.
(Actually, as you observed, they
report accelerations somewhat outside
the nominal range. Accuracy is not
spec'ed outside that range, though.)

Apple operates them in the +/- 2 g
mode. There is a tradeoff: The current
resolution is nominally 0.018 g,
according to the datasheet (though my
first generation iPhone uses
0.018168604, according to a modified version of AccelerometerGraph). In the
+/- 8 g mode, the resolution would be four times cruder.

I assume Apple decided that the finer
resolution would be more useful than
the wider range. (I'd rather see finer
resolution than 0.018 g. So neither of
us is fully satisfied.)

You cannot change the mode with any
published feature of the APIs. Since
they are passing acceleration as a
double, they could theoretically allow
a change in mode, and simply look at
the mode when rescaling the A/D value,
before reporting acceleration. (The
obvious place to set the mode would be
in the call which sets up the
application to receive accelerometer
information.) However, for backward
compatibility, the OS would have to
set the accelerometer mode to +/- 2 g
at the beginning of the application.
And none of the background processes
could be allowed to set the
accelerometer mode.

猫七 2024-07-23 01:12:51

当您移动设备时,aGauge 应用程序会显示来自加速度计的原始数据。 它还可以帮助您找到设备的“翻转”阈值。

The aGauge app displays this raw data coming from the accelerometer as you move the device. It can also help you find the "flip" threshold for your device.

故人爱我别走 2024-07-23 01:12:51

我创建了以下应用程序来尝试测试范围...

UIAccelerometer *objAccelerometer;
UILabel *lblxmin, *lblxmax, *lblymin, *lblymax, *lblzmin, *lblzmax;
UILabel *lblxnow, *lblynow, *lblznow;

float xmin = 0.0, xmax = 0.0, ymin = 0.0, ymax = 0.0, zmin = 0.0, zmax = 0.0, xnow = 0.0, ynow = 0.0, znow = 0.0;

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {   
    //NSLog (@"%f, %f, %f", acceleration.x, acceleration.y, acceleration.z);
    xnow = acceleration.x;
    ynow = acceleration.y;
    znow = acceleration.z;
    if (xnow < xmin) { xmin = xnow; }
    if (ynow < ymin) { ymin = ynow; }
    if (znow < zmin) { zmin = znow; }

    if (xnow > xmax) { xmax = xnow; }
    if (ynow > ymax) { ymax = ynow; }
    if (znow > zmax) { zmax = znow; }

    lblxmin.text = [NSString stringWithFormat:@"%f", xmin];
    lblymin.text = [NSString stringWithFormat:@"%f", ymin];
    lblzmin.text = [NSString stringWithFormat:@"%f", zmin];

    lblxmax.text = [NSString stringWithFormat:@"%f", xmax];
    lblymax.text = [NSString stringWithFormat:@"%f", ymax];
    lblzmax.text = [NSString stringWithFormat:@"%f", zmax];

    lblxnow.text = [NSString stringWithFormat:@"%f", xnow];
    lblynow.text = [NSString stringWithFormat:@"%f", ynow];
    lblznow.text = [NSString stringWithFormat:@"%f", znow];

}

-(void) invokeAccelerometer {   
    objAccelerometer = [UIAccelerometer sharedAccelerometer];
    objAccelerometer.delegate = self;
    objAccelerometer.updateInterval = (1.0 / 10.0);
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    lblxmin = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 40)];
    lblxnow = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 100, 40)];
    lblxmax = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 100, 40)];

    lblymin = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 100, 40)];
    lblynow = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 100, 40)];
    lblymax = [[UILabel alloc] initWithFrame:CGRectMake(200, 60, 100, 40)];

    lblzmin = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 100, 40)];
    lblznow = [[UILabel alloc] initWithFrame:CGRectMake(100, 110, 100, 40)];
    lblzmax = [[UILabel alloc] initWithFrame:CGRectMake(200, 110, 100, 40)];

    [self.view addSubview:lblxmin];
    [self.view addSubview:lblxnow];
    [self.view addSubview:lblxmax];

    [self.view addSubview:lblymin];
    [self.view addSubview:lblynow];
    [self.view addSubview:lblymax];

    [self.view addSubview:lblzmin];
    [self.view addSubview:lblznow];
    [self.view addSubview:lblzmax];

    [self invokeAccelerometer];

    [super viewDidLoad];
}

问题是,当我沿水平/垂直轴旋转 iPod 然后将其翻转时,我得到如下值:

xmin -1.271802

xmax 1.180959

ymin -1.344477

ymax 1.108285

zmin -2.30713

zmax 2.325581

如果我拿起 iPod 并摇晃它,我会得到...

x -2.325581 到 2.307413

y -2.325581 到 2.307413

z -2.307413 到 2.325581

你知道它在测量什么吗?

我想出的最好的办法是:

垂直轴

x = -1 如果向左倾斜 ( <| )

x = +1 如果一直向右倾斜 ( |> )

  • 其中 <| 是屏幕面向的方向,并且 | 是 iPod 的底部

y ~ -1 如果屏幕面向您,垂直于地板(“站立”)

y ~ 1 如果背向您(并且上下颠倒)

I created the following application to try to test out the ranges...

UIAccelerometer *objAccelerometer;
UILabel *lblxmin, *lblxmax, *lblymin, *lblymax, *lblzmin, *lblzmax;
UILabel *lblxnow, *lblynow, *lblznow;

float xmin = 0.0, xmax = 0.0, ymin = 0.0, ymax = 0.0, zmin = 0.0, zmax = 0.0, xnow = 0.0, ynow = 0.0, znow = 0.0;

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {   
    //NSLog (@"%f, %f, %f", acceleration.x, acceleration.y, acceleration.z);
    xnow = acceleration.x;
    ynow = acceleration.y;
    znow = acceleration.z;
    if (xnow < xmin) { xmin = xnow; }
    if (ynow < ymin) { ymin = ynow; }
    if (znow < zmin) { zmin = znow; }

    if (xnow > xmax) { xmax = xnow; }
    if (ynow > ymax) { ymax = ynow; }
    if (znow > zmax) { zmax = znow; }

    lblxmin.text = [NSString stringWithFormat:@"%f", xmin];
    lblymin.text = [NSString stringWithFormat:@"%f", ymin];
    lblzmin.text = [NSString stringWithFormat:@"%f", zmin];

    lblxmax.text = [NSString stringWithFormat:@"%f", xmax];
    lblymax.text = [NSString stringWithFormat:@"%f", ymax];
    lblzmax.text = [NSString stringWithFormat:@"%f", zmax];

    lblxnow.text = [NSString stringWithFormat:@"%f", xnow];
    lblynow.text = [NSString stringWithFormat:@"%f", ynow];
    lblznow.text = [NSString stringWithFormat:@"%f", znow];

}

-(void) invokeAccelerometer {   
    objAccelerometer = [UIAccelerometer sharedAccelerometer];
    objAccelerometer.delegate = self;
    objAccelerometer.updateInterval = (1.0 / 10.0);
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    lblxmin = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 40)];
    lblxnow = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 100, 40)];
    lblxmax = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 100, 40)];

    lblymin = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 100, 40)];
    lblynow = [[UILabel alloc] initWithFrame:CGRectMake(100, 60, 100, 40)];
    lblymax = [[UILabel alloc] initWithFrame:CGRectMake(200, 60, 100, 40)];

    lblzmin = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 100, 40)];
    lblznow = [[UILabel alloc] initWithFrame:CGRectMake(100, 110, 100, 40)];
    lblzmax = [[UILabel alloc] initWithFrame:CGRectMake(200, 110, 100, 40)];

    [self.view addSubview:lblxmin];
    [self.view addSubview:lblxnow];
    [self.view addSubview:lblxmax];

    [self.view addSubview:lblymin];
    [self.view addSubview:lblynow];
    [self.view addSubview:lblymax];

    [self.view addSubview:lblzmin];
    [self.view addSubview:lblznow];
    [self.view addSubview:lblzmax];

    [self invokeAccelerometer];

    [super viewDidLoad];
}

The problem is, when I rotate my iPod along the horizontal/vertical axes and then flip it over, I get values like:

xmin -1.271802

xmax 1.180959

ymin -1.344477

ymax 1.108285

zmin -2.30713

zmax 2.325581

If I take the iPod and shake the heck out of it, I get...

x -2.325581 to 2.307413

y -2.325581 to 2.307413

z -2.307413 to 2.325581

Any ideas what it's measuring?

The best I've come up with is:

vertical axis

x = -1 if tilted to the left ( <| )

x = +1 if tilted all the way to the right ( |> )

  • where < is the way the screen faces, and | is the bottom of the iPod

y ~ -1 if screen is facing you, perpendicular to floor ("standing up")

y ~ 1 if facing away from you (and upside down)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文