互补滤波器(陀螺仪+加速度)与Android [英] Complementary filter (Gyro + accel) with Android

查看:1874
本文介绍了互补滤波器(陀螺仪+加速度)与Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我做了一些研究,同时使用加速度计+陀螺仪使用这些传感器为例来跟踪智能手机没有GPS的帮助(看到这个帖子) <一href="http://stackoverflow.com/questions/7499959/indoor-positioning-system-based-on-gyroscope-and-accelerometer">Indoor基于陀螺仪和加速度计定位系统

Recently I have made some research to use both the accelerometer + Gyroscope to use those senser to track a smartphone without the help of the GPS (see this post) Indoor Positioning System based on Gyroscope and Accelerometer

有关为此我需要我的方向(角度(俯仰,滚转等)),所以这里是我迄今所做的:

For that purpose I will need my orientation (angle (pitch, roll etc..)) so here what i have done so far:

public void onSensorChanged(SensorEvent arg0) {
    if (arg0.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
    {
        accel[0] = arg0.values[0];
         accel[1] = arg0.values[1];
   accel[2] = arg0.values[2];
   pitch = Math.toDegrees(Math.atan2(accel[1], Math.sqrt(Math.pow(accel[2], 2) + Math.pow(accel[0], 2))));

  tv2.setText("Pitch: " + pitch + "\n" + "Roll: " + roll);

   } else if (arg0.sensor.getType() == Sensor.TYPE_GYROSCOPE )
{
  if (timestamp != 0) {
  final float dT = (arg0.timestamp - timestamp) * NS2S;         
  angle[0] += arg0.values[0] * dT;
  filtered_angle[0] = (0.98f) * (filtered_angle[0] + arg0.values[0] * dT) + (0.02f)* (pitch);
   }        
   timestamp = arg0.timestamp;
 }
}

在这里,我想角(只是用于测试)从我的加速度计(间距),从整合gyroscope_X低谷时与互补的过滤器过滤它

Here I'm trying to angle (just for testing) from my accelerometer (pitch), from integration the gyroscope_X trough time filtering it with a complementary filter

filtered_angle [0] =(0.98f)*(filtered_angle [0] + gyro_x *的dT)+(0.02f)*(节距)

filtered_angle[0] = (0.98f) * (filtered_angle[0] + gyro_x * dT) + (0.02f)* (pitch)

与胸苷开始或多或少0.009 secondes

但我不知道为什么,但我的角度是不是真的准确......当设备在桌子上的位置平(屏幕朝上)

But I don't know why but my angle are not really accurate...when the device is position flat on the table (Screen facing up)

Pitch (angle fromm accel) = 1.5 (average) 
Integrate gyro = 0 to growing (normal it's drifting) 
filtered gyro angle = 1.2

当我抬起90°的电话(见屏幕面壁在我面前)

and when I lift the phone of 90° (see the screen is facing the wall in front of me)

Pitch (angle fromm accel) = 86 (MAXIMUM) 
Integrate gyro = he is out ok its normal 
filtered gyro angle = 83 (MAXIMUM)

因此​​,角度永远不会达到90???即使我试着举起手机多一点... 为什么它不走,直到90°?是我的计算错了吗?或者是传感器废话的质量?

So the angles never reach 90 ??? Even if I try to lift the phone a bit more... Why doesn't it going until 90° ? Are my calculation wrong? or is the quality of the sensor crap?

这我不知道它的一个另一件事是:与Android,我不读出传感器的价值,但我通知时,他们改变。问题是,当你在$ C $看c中的加速度和陀螺仪共享相同的方法....所以当我计算滤波的角度,我会采取加速措施的间距0.009秒前,不是吗?是我的问题,也许源?

AN other thing that I'm wondering it is that: with Android I don't "read out" the value of the sensor but I'm notified when they change. The problem is that as you see in the code the Accel and Gyro share the same method.... so when I compute the filtered angle I will take the pitch of the accel measure 0.009 seconds before, no ? Is that maybe the source of my problem?

感谢您!

推荐答案

我只能<一href="http://stackoverflow.com/questions/7499959/indoor-positioning-system-based-on-gyroscope-and-accelerometer/7500306#7500306">repeat我自己。

您获得位置通过集成的线性加速两次,但错误是可怕的。这是在实践中无用的。换句话说,你正在试图解决是不可能的。

You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. In other words, you are trying to solve the impossible.

你真正可以做的是跟踪只是方向。

What you actually can do is to track just the orientation.

滚转,俯仰和偏航都是邪恶的,不使用它们。检查我已经推荐的视频,在38:25。

Roll, pitch and yaw are evil, do not use them. Check in the video I already recommended, at 38:25.

下面是一个如何跟踪定位与陀螺仪优秀教程和加速度计。

Here is an excellent tutorial on how to track orientation with gyros and accelerometers.

类似的问题,你可能会找到有用的:

Similar questions that you might find helpful:

跟踪iPhone的小运动,没有GPS
什么是手机加速度计的真实世界的准确性用于定位的时候?
如何计算从静止状态垂直方向上手机的运动?
的iOS:运动precision在三维空间
如何使用加速度计来测量距离为Android应用开发
移动距离由加速度
需要找到距离使用陀螺仪+加速度计

track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
How to use Accelerometer to measure distance for Android Application Development
Distance moved by Accelerometer
Need to find Distance using Gyro+Accelerometer

这篇关于互补滤波器(陀螺仪+加速度)与Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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