指南针给我疯狂的数据,需要校准还是传感器坏了? [英] Compass give me crazy data, is calibration needed or it's the sensor broken?

查看:38
本文介绍了指南针给我疯狂的数据,需要校准还是传感器坏了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理 Android 传感器数据.我的应用程序使用

I'm working with android sensor data. My application use

SensorManager.getRotationMatrixFromVector(
            mRotationMatrix , event.values);

它一直运行良好,直到今天早上,旋转矩阵开始发送大量噪声数据(一秒内将 N 更改为 W).

and it has been working well until this morning, when the rotation matrix started to send a lot of noise data (Change N to W in a second).

我的代码没有问题,因为星期五正在工作并且没有进行任何更改.我使用了市场上的指南针应用程序,指南针给出了随机数据.

It's not a problem with my code, because on friday was working and no changes have been done. I have used a compass app from the market, and the compass is giving random data.

我已经在另一台平板电脑上测试了我的应用,它运行良好.

I have tested my app on another tablet, and it is working well.

有人知道为什么会这样吗?传感器有问题?需要校准吗?

Does someone know why is this happening? A problem with the sensor? Does it need a calibration?

推荐答案

我在手机上使用这些电子罗盘做了很多工作,很可能你的代码或传感器没有任何问题.

I've worked quite a lot with these electronic compasses on mobile phones and its quite possible that there is nothing wrong with your code or sensor.

相反,这很可能是您的环境有问题.一直有磁场干扰地球的磁场.从电气设备干扰到支撑建筑物的金属结构.归根结底,指南针只是一块磁铁.如果你站在一大块金属旁边,指南针会被它吸引并指向它而不是磁北极.

Instead it could very well be a problem with your environment. There are magnetic fields interfering with the earth's magnetic fields all the time. From electrical equipment interference to the metal structure holding up a building. At the end of the day a compass is just a magnet. If you stand beside a large lump of metal the compass will be attracted to it and point to it rather than the magnetic north pole.

试试这个:安装 GPS 状态然后关闭所有过滤(设置... gps & 传感器...传感器过滤...无过滤).进行校准(8 字形波浪形物体),然后将手机移到办公桌周围……靠近显示器、电缆等.您会看到它变得疯狂.信息完全不可靠.我过去发现将手机向右移动几英寸会完全改变其读数.真正的指南针也会发生同样的情况.严格来说没有问题".设备的罗盘给自己分配了最强的磁场.甚至附近岩石的磁性成分也会干扰指南针.

Try this: Install GPS status then turn off all filtering (settings... gps & sensors...sensor filtering... no filtering). Do the calibration (figure of 8 wavy stuff) and then move the phone around your desk.. near monitors, cables, etc. You'll see it go crazy. The information is completely unreliable. I found in the past that moving the phone a few inches to the right completely changed its reading. The same happens with a real compass. Strictly speaking there is no "problem". The device's compass is assigning itself with the strongest magnetic field. Even the magnetic content of nearby rocks can interfere with the compass.

作为进一步的测试,我刚刚在安装了指南针应用程序的手机上放置了一个真正的(定向)指南针.真正的指南针现在指向除磁北以外的任何地方.两个设备相互干扰.

As a further test I've just placed a real (orienteering) compass over my phone which has a compass app installed. The real compass is now pointing everywhere but magnetic North. The two devices are interfering with each other.

所以我的建议是..去一个开阔的地方,比如公园或田野,远离任何潜在的干扰和电线,(如果你有一个真正的指南针来检查 GPS 状态 应用指向正确的方向),然后查看您的指南针是否按预期工作.

So my advice is.. go somewhere in the open, like a park or field, away from any potential interference and power lines, (if you have one bring a real compass to check that the GPS status app is pointing the right way), and see if your compass works as you'd expect.

额外:@resus 的回答在校准时也很重要.在每个轴上旋转手机几次.看起来很傻,但它确实可以正确校准.

Extra: The answer from @resus is also important when calibrating. Rotate the phone a few times in each axis. Looks silly but it does calibrate it properly.

额外 2:使用 您的 GPS 的罗盘方位?这将要求设备移动(步行速度应该没问题),但您无需担心任何干扰.只要您的 GPS 信号良好,它就会提供准确的读数.

Extra 2: Would it be possible/practical to use the compass bearing of your GPS? It would require that the device be moving (walking speed should be fine) but you would not need to worry about any interference. It should give an accurate reading provided your GPS signal is good.

额外 3:我刚刚想到了另一个想法..您可以尝试对传感器应用低通滤波器.这意味着传感器读数的突然变化被过滤掉了..看看这个答案.如果这还不够好,网上有很多算法供您选择.

Extra 3: Another thought just occurred to me.. You could try apply a low pass filter to the sensor. This means that the sudden changes in the sensor reading are filtered out .. have a look at this answer. And if that doesn't do a good job there are lots of algorithms on the web for you to choose from.

这篇关于指南针给我疯狂的数据,需要校准还是传感器坏了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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