Android - motodroid 1 上的加速计一开始报告的值不正确?

发布于 2024-09-30 12:24:57 字数 1016 浏览 2 评论 0原文

所以我正在编写一个检测运动的应用程序,并且需要针对各种运动进行校准。在过去的几天里,我注意到在注册 SensorEventListener 后,onSensorChanged(SensorEvent) 抛出不完整(因此是错误的).values[ ]。这种行为搞砸了我的校准过程,并且表示运动的力量太大了。我已经验证,我下载和测试的每个加速度计日志应用程序都是这种情况,因此它不是特定于我的代码的错误。我认为这可能是由于硬件故障(可能特定于我的 moto droid 1)或我正在使用的自定义 ROM 的软件错误(Simply Stunning 4.9,来自 Froyo 2.2.1 源代码)引起的。

示例:

sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SENSOR_DELAY);
....
onSensorChanged(SensorEvent event){
    // event.values[0] = 0.0
    // event.values[1] = -0.47
    // event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
    // event.values[0] = 0.08
    // event.values[1] = -0.47
    // event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
   // event.values[0] = 0.08 
   // event.values[1] = -0.47 
   // event.values[2] = 10.1
}

如您所见,通常需要读取 2 次读数才能获得所有正确值。

任何人都可以在 moto droid 1 或其他手机上确认或否认此行为吗?您认为一个好的解决方案是删除前 2 个或 3 个读数,这样它们就不会扭曲我的校准吗?

So I'm writing an app that detects movement, and needs to be calibrated to various movements. Over the past few days, I've noticed that right after a SensorEventListener is registered, onSensorChanged(SensorEvent) throws out incomplete (and therefore erroneous) .values[]. This behavior screws up my calibration process, and the amount of force that signifies a movement is way too high. I have verified that this is the case for every accelerometer logging app I have downloaded and tested, so its not an error specific to my code. I think this might be caused by bad hardware (possibly specific to my moto droid 1), or a software bug by the custom ROM I'm using (Simply Stunning 4.9, from Froyo 2.2.1 source.)

Example:

sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SENSOR_DELAY);
....
onSensorChanged(SensorEvent event){
    // event.values[0] = 0.0
    // event.values[1] = -0.47
    // event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
    // event.values[0] = 0.08
    // event.values[1] = -0.47
    // event.values[2] = 0.0
}
....
onSensorChanged(SensorEvent event){
   // event.values[0] = 0.08 
   // event.values[1] = -0.47 
   // event.values[2] = 10.1
}

As you can see, it often takes 2 readings before all of the correct values are accessible.

Can anyone confirm or deny this behavior on the moto droid 1 or other phone? Do you think a good solution is to just drop the first 2 or 3 readings so that they don't warp my calibration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停滞 2024-10-07 12:24:57

对我来说听起来很合理。也许您可以首先以最快的延迟注册您的听众,这样您就可以快速消除那些不良读数,然后以您想要的校准更新速率重新注册。您可以使用两个不同的侦听器,第一个侦听器将杂物排除在外,然后注销自身并注册另一个(好的)侦听器。

Sounds reasonable to me. Perhaps you could register your listener at first with the FASTEST delay so you get those few bad readings out of the way quickly, then re-register with your desired update rate for your calibration. You could use two different listeners, the first one gets the crud out of the way, then unregisters itself and registers the other (good) one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文