简体   繁体   English

ANDROID上的磁场传感器校准

[英]Magnetic Field Sensor calibration on ANDROID

I'm making an application that works as a compass.. 我正在制作一个作为指南针的应用程序..

I'm using the accelerometer and the magnetic field sensors to compute the azimuth angle through, sensor.getOrientation() . 我正在使用加速度计和磁场传感器来计算方位角,即sensor.getOrientation()

I'm searching for something that can improve the magnetic field sensor accuracy, since I'm getting it state of accuracy as UNRELIABLE! 我正在寻找可以提高磁场传感器精度的东西,因为我的准确度已达到不可靠状态!

Any one knows anything about this?I'm looking for something that can be either hardcoded or for instance just physically moving the phone until it gets calibrated! 任何人都对此有所了解吗?我正在寻找可以硬编码的东西,或者只是物理移动手机直到它被校准!

Just a few points 只需几点

The figure 8 motion works sometimes and not others, I have no idea why, they really need to have some kind of code based way to check if the 8 motion worked (Assuming that the physical motion is actually required) 图8运动有时会起作用而不是其他运动,我不知道为什么,它们确实需要某种基于代码的方式来检查8运动是否有效(假设实际需要物理运动)

They also need a way to detect that calibration is required, I looked at the code for the accuracy output (the unreliable constant) and once they send it to you they will not send it again, so for instance if you calibrate but then come within a strong magnetic field it will not resend (not sure why they did that) 他们还需要一种方法来检测是否需要校准,我查看了准确输出的代码(不可靠的常数),一旦他们发送给你,他们就不会再发送它,所以例如如果你校准然后进来一个强大的磁场,它不会重新发送(不知道为什么他们这样做)

One not completely reliable way to detect ongoing issues is that you can also use the magnetic sensor output and do something like field=sqrt(x*x+y*y+z*z) and check that field falls between say 25 and 65 and then ask the user to calibrate if it does not. 检测正在发生的问题的一种不完全可靠的方法是你也可以使用磁传感器输出并执行类似field = sqrt(x * x + y * y + z * z)的操作并检查该字段是否介于25和65之间然后要求用户校准,如果没有。

The bottom line after testing 18 phones is that I would never depend on a Android based compass with the current crop of phones, accuracy would always be in question. 测试18部手机之后的底线是,我绝不会依赖基于Android的指南针和当前的手机,准确性总是有问题的。

I have also found even if you are lucky and have a fairly reliable phone you can never be sure that it's calibrated without checking it against a real compass, which kind of defeats the purpose. 我也发现,即使你很幸运并拥有一部相当可靠的手机,你也永远无法确定它是否经过校准而没有在真正的指南针上进行检查,这种目的无法实现。

NOTE: On a lot of the mis-behaving phones we have found that the sensor writes a calibration file and a tmp file with the same name. 注意:在很多行为不当的手机上,我们发现传感器会写一个校准文件和一个同名的tmp文件。 If you delete those files and re-boot the phones the calibration file is recreated with zero'd values and the cold start and general calibration problems resolve themselves. 如果删除这些文件并重新启动电话,则会使用零值重新创建校准文件,冷启动和一般校准问题将自行解决。

The bad news is that they are stored in /data/misc and require root privileges to get at (thanks Google & Sensor mfg!) so even though I suspect this would solve a lot of problems for a lot of developers it just is not viable from a marketplace app perspective. 坏消息是它们存储在/ data / misc中并且需要root权限才能获得(感谢Google和传感器制造商!)所以即使我怀疑这会为很多开发人员解决很多问题,但它不可行从市场应用程序的角度来看。

This is not a final answer (I don't know anything for sure), but my understanding from online posts is that waving the phone around in a figure of 8 a few times while the compass is in use is supposed to trigger automatic recalibration. 这不是最后的答案(我当然不知道任何事情),但我对在线帖子的理解是,在使用指南针的情况下,以8的数字挥动手机应该会触发自动重新校准。 This is what the google maps app suggests, for example. 例如,这就是谷歌地图应用程序建议的内容。 I don't know whether this is dependent on application functionality (something in maps that detects the waving by accelerometer and triggers a recalibration), or something in the android stack, or something specific to per-phone implementations. 我不知道这是否依赖于应用程序功能(在地图中检测到加速度计挥动并触发重新校准的东西),或者在Android堆栈中的某些东西,或者特定于每个电话实现的东西。 Try it and see! 试试看吧!

Eg discussion: http://androidforums.com/epic-4g-support-troubleshooting/217317-cant-get-compass-calibrate.html 例如讨论: http//androidforums.com/epic-4g-support-troubleshooting/217317-cant-get-compass-calibrate.html

This reference appears to suggest this per-axis / figure-8 rotation process is built-in functionality: http://m.eclipsim.com/gpsstatus/ 此参考似乎表明这个每轴/图8旋转过程是内置功能: http//m.eclipsim.com/gpsstatus/

And here another article that claims this is built-in functionality, and that you don't even need to be running a compass-consuming app for the recalibration to work: http://www.ichimusai.org/2009/06/20/how-to-calibrate-the-htc-magic-compass/ 在这里另一篇声称这是内置功能的文章,你甚至不需要运行一个消耗指南针的应用程序来重新校准工作: http//www.ichimusai.org/2009/06/20 /如何对校准最HTC魔法罗盘/

I am developing for Android. 我正在为Android开发。 I'm using Titanium Alloy as development tool with the Titanium Geolocation module. 我正在使用Titanium Alloy作为Titanium Geolocation模块的开发工具。

I have only tested 2 devices [Galaxy Note and S4] against a commercial magnetic compass. 我只针对商用磁罗盘测试了2个设备[Galaxy Note和S4]。 Following a calibration process [tilt along the 3 axis] and using 2 different compass apps and the app I'm working on, the Android compass seems accurate enough for basic use ... correlation was good enough for my purpose anyway. 在校准过程[沿着3轴倾斜]并使用2个不同的指南针应用程序和我正在使用的应用程序之后,Android指南针看起来足够准确以便基本使用......无论如何,相关性已经足够我的目的了。 I also found the device compass reading to be very sensitive to other magnetic and electrical field interference ... initial mistake I made was to use the compass feature whilst device was in a device protector with a magnetic closure facility [quite common on tabs] ... this interference is particularly strong. 我还发现设备罗盘读数对其他磁场和电场干扰非常敏感...我犯的最初错误是使用罗盘功能,而设备在带有磁性闭合装置的设备保护器中[在标签上非常常见]。 ..这种干扰特别强烈。 I thus need to suggest to users of my app to remove device protectors, keep device free of other electronics and then do standard calibration before initializing the app. 因此,我需要向我的应用程序的用户建议删除设备保护器,使设备不受其他电子设备的影响,然后在初始化应用程序之前进行标准校准。

Another option is: 另一种选择是:

Go To sensors menu: #*0#* 转到传感器菜单: #*0#*

Then if you see a red line in Magnetic Sensor section and a Need for Calibration you should recalibrate your compass. 然后,如果您在Magnetic Sensor部分看到红线并且Need for Calibration ,则应重新校准指南针。

How; 怎么样;

According those guys ; 那些家伙说 ;

Turn the Samsung Galaxy Mini S5 around all of its axes until the red line in the black circle changes color from red to blue. 将三星Galaxy Mini S5绕其所有轴旋转,直到黑色圆圈中的红线从红色变为蓝色。 You can also run through a motion that follows the shape of an 8. It may be that several attempts are needed to calibrate the compass... 您还可以按照8的形状运行。可能需要多次尝试来校准指南针......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM