Android获得标准化加速 [英] Android get normalized acceleration

查看:100
本文介绍了Android获得标准化加速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望获得Android手机的加速度矢量.问题在于,加速度计坐标是相对于手机旋转的.我想要的是绝对"加速度,即无论手机面对哪种方式,它都应返回相同的值. (我想检测正在滑雪的用户是否在不使用GPS的情况下滑下斜坡.我还需要能够区分滑行和升降椅的上升.)

I wish to get the acceleration vector of an Android phone. The problem is, the accelerometer coordinates are relative to the phone's rotation. What I want is the "absolute" acceleration, i.e., it should return the same values whichever way the phone is facing. (I want to detect if a user that is skiing is sliding down a slope without using GPS. I also need to be able to differentiate sliding and going up the chairlift.)

我可能可以通过将加速度计与陀螺仪结合使用来获得这些值,但是我不知道如何用陀螺仪的偏移量来补偿加速度计的值.

I can probably get those values by combining the accelerometer with the gyroscope, but I have no idea how I could offset the accelerometer's values with the gyroscope's.

这可能吗?如果可以,怎么办?

Is this possible, and if so, how?

推荐答案

您描述的内容无法完成,除非您重新定义了该问题.为了帮助您重新定义它,我将概述主要问题:

What you describe can't be done, unless you redefine the problem a bit. To help you redefine it, I'll outline the main issues:

首先,我想您所说的绝对加速度"是相对于地理参考的加速度.单靠加速度计是无法做到的,因为它不了解地理参考.如果您向gps移得足够远,或使用指南针,也许可以解决这个问题,但是每个问题都有其自己的问题(尽管至少问题是可以解决的).

First, I'm guessing that what you mean by "absolute acceleration" is acceleration with respect to geographical reference. The can't be done with the accelerometer alone, since it has no idea about geographical references. If you move far enough for the gps, or use the compass, you might be able to get around this, but each of these has its own issues (though at least the problem is soluble).

第二个问题是,仅使用加速度计就无法完全区分重力和加速度(这被称为等效原理").因此,任何测得的加速度将始终是重力和加速度的矢量和,但是这些方程式始终存在多个解,并且在通常情况下加速度小于重力的情况下,您实际上无法确定任何有关加速度的信息. .但是由于重力在某种程度上是恒定的,因此也有一些方法可以解决,例如使用陀螺仪,或者您的用户可以将手机固定在一个固定的方向上(例如,通过观察像地平线这样的外部提示),并且这两种方式中的任何一种方法可能会让您减去重力的影响,但这通常是一个不小的问题.

The second issue is that gravity and acceleration are completely indistinguishable using an accelerometer alone (this is known as the "equivalence principle"). Therefore, any measured acceleration will always be the vector sum of gravity and the acceleration, but there are always multiple solutions to these equations, and in the usual cases where the acceleration is smaller than gravity, you really can't determine anything about the acceleration. Since gravity is somewhat constant though, there are ways around this too, using, say, a gyroscope, or maybe your user could hold the phone in a fixed orientation (e.g., by looking at external cues like the horizon), and either of these approaches might let you subtract the influence of gravity, but it's generally a non-trivial problem.

最后一个要点是,您似乎正在以固定于地球的坐标系中进行思考,而手机的加速度计仅是固定在手机上的.那就是加速度计的z轴与地球的上下方向没有任何关系-而这种关系将取决于手机的方向.确实,很多人都喜欢固定在地上的系统,但电话根本不知道这一点.您可以使用外部线索(GPS,磁场,陀螺仪,重力,水平线等)来尝试对齐它们,但是仅从加速度计获得一个任意读数,该信息就不存在了.

The final point to not is that you seem to be thinking in an earth-fixed coordinate system and the phone's accelerometer is only phone-fixed. That is the accelerometer's z-axis many not have anything to do with up and down on the earth -- and the relationship will depend on the orientation of the phone. Really, many people would prefer an earth-fixed system, but the phone just doesn't know that. You can use external cues (GPS, magnetic field, gyroscope, gravity, horizon, etc) to try to align them, but given only a single arbitrary reading form the accelerometer, the information just isn't there.

定义:
加速度矢量:这是来自加速度计的x,y,z读数(每个读数取决于手机的方向),有时写为A =(a x , a y ,a z ).
加速度幅度:这是a = sqrt(a x 2 + a y 2 + a z 2 ),并且这不应取决于手机的方向(如果不同的轴被校准为相同).如果手机是固定的,则基本上只是重力的读数.还请注意,使用此度量会丢失加速度矢量中的许多信息.
归一化加速度:加速度方向,具有1号幅度,,A/a
地球坐标中的加速度:我认为这是您真正想要的,没有简单的方法可以得到,而且即使您可以,我也不认为它会像有用的那样有用乍一看.

Definitions:
acceleration vector: this is the x, y, z reading from the accelerometer (and each reading will depend on the phones orientation), sometimes written as A=(ax, ay, az).
acceleration magnitude: this is a=sqrt(ax2 + ay2 + az2), and this should not depend on the phones orientation (if the different axes are calibrated to be the same). If the phone is stationary, this will basically just be a reading of gravity. Note also that a lot of the information in the acceleration vector is lost using this measure.
normalized acceleration: The acceleration direction, that has magniture 1, i.e., A/a
acceleration in earth coordinates: I think this is what you really want, there's just no easy way to get it, and really even if you could, I don't think it would be as useful as it might seem at first.

滑雪:
我认为您可以根据加速度计的测量值来确定某人何时滑雪.使用加速度计,颠簸和转弯之类的东西都应该非常有特色.对于这些,我将使用完整的加速度矢量.例如,反过来,加速度大小将保持大致恒定,并且方向将扫掠.还要注意自由落体(即,基本上,无论何时滑雪者没有将其天空/脚/臀部/地面等置于地面上,无论是在颠簸/跳下时还是在向上或从升降椅上掉下来时,他们都处于上升状态) ,自由落体的加速度幅度将为零.对于升降椅,似乎在大部分飞机上都可能具有独特的节奏摆动.

Skiing:
I think you have a good shot at determining when someone is skiing based on the measurements from the accelerometer. Things like bumps and turns should all be quite distinctive using the accelerometer. For these I'd use the full acceleration vector. For example, in turns, the acceleration magnitude would stay roughly constant and the direction would sweep. Also note that free-fall (i.e., basically whenever the skier doesn't have their skies/feet/butt/etc on the ground, whether they're going upward when launching off a bump/jump, or falling out of the chairlift), the acceleration magnitude will be zero in free-fall. For the chairlift, it seems that it will likely have a distinctive rhythmic sway mostly within a single plane.

所有这些事情都可以弄清楚.如果您确实要解决此问题,我建议您在滑雪时记录来自加速度计的数据,并查看是否可以根据数据的特征确定何时进行滑雪. (我的猜测是,您的主要绊脚石将是数学,因为想出一种可以区分滑雪特征的算法可能有点棘手,因此审查向量似乎是一个好主意数学以及诸如点积和叉积之类的东西,而且,我怀疑在另一个称为FFT或Fourier变换的主题上,对整理滑雪缆车相对于秋千的时间和频率特征可能很有用)

All of these things could be figured out. I'd recommend, if you really want to solve this problem, is to record data from your accelerometer while skiing, and see if you can determine when you're skiing based on the characteristics of the data. (My guess is, that your major stumbling block with this will be math, because it might be a bit tricky to come up with an algorithm the can distinguish the signatures of skiing, so it seems that it would be a good idea to review vector math, and things like dot-products and cross-products, and also, I suspect that a little bit on another topic known as FFTs or Fourier transforms might be useful in sorting out the time and frequency signatures of skiing vs swinging in the chair lift.)

您还可以折叠GPS测量,这不那么可靠,也不能提供良好的时间分辨率,但至少可以用来仔细检查算法.

You could also fold in GPS measurements, which wouldn't be as reliable, or give good time resolution, but could at least be used to double-check your algorithm.

这篇关于Android获得标准化加速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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