Android的TYPE_LINEAR_ACCELERATION传感器 - 这是什么表现? [英] Android TYPE_LINEAR_ACCELERATION sensor - what does it show?

查看:3173
本文介绍了Android的TYPE_LINEAR_ACCELERATION传感器 - 这是什么表现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的应用为汽车加速跟踪。我使用的标准加速度计,校准它事先特定的位置。

I am developing application for car acceleration tracking. I used standard accelerometer, calibrating it in specific position beforehand.

然后,假设手机的取向是不会改变的,我记录加速度计数据在指定的时间和计算出的移动参数,其中之一是汽车的速度在试验结束

Then, assuming phone's orientation is not changing, I logged the accelerometer data for a specified time and calculated move parameters, one of which is the car's speed at the end of the test.

它的工作原理相当好,在一条直线,横公路:错误的百分之几。

It works rather well, on a straight, horizontal road: error of a few percent.

但后来我发现,在API级别10有一个虚拟的传感器叫做 TYPE_LINEAR_ACCELERATION 和,据我了解,它必须做什么,我需要:过滤重力方向改变 - 所以我可能会使用它,并获得移动设备的纯线性加速度

But then I found out, that in API-level 10 there is a virtual sensor called TYPE_LINEAR_ACCELERATION and, as far as I understand, it must do what I need: filter gravity, orientation changes - so I may use it and get pure linear acceleration of mobile device.

但在现实生活中。

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

I made a simple application, that does a little test:

//public class Accelerometer implements SensorEventListener { ...
public void onSensorChanged(SensorEvent se) 
{
    if(!active)
        return;

    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");
}

我绑定一个监听器具有以下参数:

I bind a listener with the following parameters:

  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 =时间)的区间,最终我得到一个非常低的速度 - 比实际速度小于三次

It works OK, but when I analyzed data dump, calculating speed like V = V0 + AT, where V0 = 0 at first, then - speed of interval before this, A = acceleration (SQRT (x*x+y*y+z*z)) (t = time of interval), eventually I get a very low speed - three times less than real speed.

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

Changing Sensor type to TYPE_ACCELEROMETER, calibrating and using same formula to calculate speed - I get good results, much closer to reality.

所以,问题是:

这是什么 Sensor.TYPE_LINEAR_ACCELERATION 真正显现?

我在哪里错了,或者是一些错误 Sensor.TYPE_LINEAR_ACCELERATION 实施?

Where am I wrong, or is something wrong with Sensor.TYPE_LINEAR_ACCELERATION implementation?

我用三星Nexus S手机。

I used Samsung Nexus S phone.

推荐答案

很有趣的问题!!!!

我开发somethig类似的应用程序。我发现约TYPE_LINEAR_ACCELERATION不是为我感到高兴。

I'm developing somethig similar to your application. What i found about TYPE_LINEAR_ACCELERATION isn't happy for me.

1)TYPE_LINEAR_ACCELERATION,TYPE_GRAVITY,ECC只为Android 2.3的实现(上) 所以,我有Android 2.2的,我无法对它们进行测试。

1) TYPE_LINEAR_ACCELERATION, TYPE_GRAVITY, ecc are implemented only for Android 2.3 (and up) So i have Android 2.2 and i can't test them.

2)TYPE_LINEAR_ACCELERATION也不是那么准确,因为它会是这样,因为有一些简单的问题substract的严重性的时候。实际上是使用加速度计和方位知道在哪里指向的重力,然后潜艇是传感器融合。吧。

2) TYPE_LINEAR_ACCELERATION isn't so accurate as it would be, because there are some simple problem when substract the gravity. In fact is a "sensor fusion" that uses accelerometer and orientation to know where is directed the gravity and then subs. it.

在这里,我发现了一个非常有用的答案解释:

Here i found a very usefull answer that explain it:

https://groups.google.com/forum/#​​!主题/ Android的开发者/ GOm9yhTFZaM

TYPE_ACCELEROMETER 使用加速计,只有加速。   它返回原始加速度计的事件,以最小的或不处理在   所有。

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

TYPE_GYROSCOPE (如present)使用陀螺仪和唯一的陀螺仪。   像以上,则返回原始事件(角速度未弧度/秒),没有   在所有的处理(无偏移/缩放补偿)。

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 是德precated。它返回的方向偏航/   俯仰/卷在degres。它不是很明确,只能是   依靠当设备没有滚。这个传感器采用   组合的加速度计和磁力计。轻微   更好的结果可以用的SensorManager的助手来获得。本   传感器是大量处理。

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 是   它返回各自的线性加速度融合的传感器,   重力和旋转向量(四元数)。它没有定义如何   这些都是实施。在某些设备上,他们在H / W实现,   在某些设备上他们所使用的加速​​度计+磁强计,上   其他一些设备,他们使用陀螺。

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.

在的Nexus S和Xoom的,陀螺仪是当前未使用。他们的行为   因为如果没有可用的陀螺一样,在Nexus One和Droid的。我们   刨去改善这种状况在将来的版本。

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.

目前,采取陀螺的优点的唯一方法是使用   TYPE_GYROSCOPE并用手整合的输出。

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

我希望这可以帮助,

马蒂亚斯

总之,在各个地方在网络上,我发现关于手机的传感器和他们的潜力没有最好的词,因为这是不准确的事实......

Anyway, in various place on the web i found no best word about phone sensor and their potential, due to the fact that aren't accurate...

有些比较precision可以利用卡尔曼滤波器来达到的,但我不知道如何...

Some more precision can be reached using Kalman filter, but i have no idea how...

这篇关于Android的TYPE_LINEAR_ACCELERATION传感器 - 这是什么表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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