sách gpt4 ăn đã đi

Cảm biến TYPE_LINEAR_ACCELERIC của Android - nó hiển thị những gì?

In lại Tác giả: IT Lão Cao Thời gian cập nhật: 28-10-2023 21:38:17 34 4
mua khóa gpt4 giày nike

我正在开发用于汽车加速跟踪的应用程序。我使用标准加速度计,事先在特定位置进行校准。

然后,假设手机的方向没有改变,我记录了指定时间的加速度计数据并计算了移动参数,其中之一是测试结束时汽车的速度。

在笔直的水平道路上运行良好:误差只有百分之几。

但后来我发现,在 API 级别 10 中有一个名为 TYPE_LINEAR_ACCELERATION 的虚拟传感器,据我所知,它必须满足我的需求:过滤重力、方向变化 -所以我可以使用它并获得移动设备的纯线性加速。

但在现实生活中..

我做了一个简单的应用程序,做了一个小测试:

//public class Accelerometer implements SensorEventListener { ...
public void onSensorChanged(SensorEvent se)
{
if(!active)
trở lại;

lastX = se.values[SensorManager.DATA_X];
lastY = se.values[SensorManager.DATA_Y];
lastZ = se.values[SensorManager.DATA_Z];
long now = System.currentTimeMillis();
interval = now - lastEvetn;
lastEvetn = now;
out.write(Float.toString(lastX) + ";" +
Float.toString(lastY) + ";" +
Float.toString(lastZ) + ";" +
Long.toString(interval) + "\n");
}

我用以下参数绑定(bind)了一个监听器:

  mSensorManager.registerListener(linAcc,
mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION),
SensorManager.SENSOR_DELAY_GAME);

它工作正常,但是当我分析数据转储时,计算速度类似于 V = V0 + AT,其中 V0 = 0 首先是 - 之前的间隔速度这,A = 加速度 (SQRT (x*x+y*y+z*z))(t = 间隔时间),最终我得到一个非常低的速度 - 比实际速度低三倍.

将传感器类型更改为 TYPE_ACCELEROMETER,校准并使用相同的公式计算速度 - 我得到了很好的结果,更接近现实。

所以,问题是:

Sensor.TYPE_LINEAR_ACCELERATION 真正显示了什么?

我哪里错了,或者 Sensor.TYPE_LINEAR_ACCELERATION 实现有什么问题?

我使用的是三星 Nexus S 手机。

câu trả lời hay nhất

非常有趣的问题!!!!

我正在开发类似于您的应用程序的东西。我发现关于 TYPE_LINEAR_ACCELERATION 的内容让我很不高兴。

1) TYPE_LINEAR_ACCELERATION、TYPE_GRAVITY、ecc 仅适用于 Android 2.3(及更高版本)所以我有 Android 2.2,我无法测试它们。

2) TYPE_LINEAR_ACCELERATION 并不像它应该的那么准确,因为减去重力时有一些简单的问题。实际上是一种“传感器融合”,它使用加速度计和方向来知道重力的方向,然后再下降。它。

在这里我找到了一个非常有用的答案来解释它:

https://groups.google.com/forum/#!topic/android-developers/GOm9yhTFZaM

TYPE_ACCELEROMETER uses the accelerometer and only the accelerometer. It returns raw accelerometer events, with minimal or no processing at all.

TYPE_GYROSCOPE (if present) uses the gyroscope and only the gyroscope. Like above, it returns raw events (angular speed un rad/s) with no processing at all (no offset / scale compensation).

TYPE_ORIENTATION is deprecated. It returns the orientation as yaw/ pitch/roll in degres. It's not very well defined and can only be relied upon when the device has no "roll". This sensor uses a combination of the accelerometer and the magnetometer. Marginally better results can be obtained using SensorManager's helpers. This sensor is heavily "processed".

TYPE_LINEAR_ACCELERATION, TYPE_GRAVITY, TYPE_ROTATION_VECTOR are "fused" sensors which return respectively the linear acceleration, gravity and rotation vector (a quaternion). It is not defined how these are implemented. On some devices they are implemented in h/w, on some devices they use the accelerometer + the magnetometer, on some other devices they use the gyro.

On Nexus S and Xoom, the gyroscope is currently NOT used. They behave as if there was no gyro available, like on Nexus One or Droid. We are planing to improve this situation in a future release.

Currently, the only way to take advantage of the gyro is to use TYPE_GYROSCOPE and integrate the output by hand.

I hope this helps,

Mathias

无论如何,在网络上的各个地方,我都没有找到关于手机传感器及其潜力的最佳词汇,因为它们并不准确......

使用卡尔曼滤波器可以达到更高的精度,但我不知道如何......

关于Android TYPE_LINEAR_ACCELERATION 传感器 - 它显示什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7858759/

34 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress