结合陀螺仪和加速度计数据 [英] Combine Gyroscope and Accelerometer Data

查看:43
本文介绍了结合陀螺仪和加速度计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Lego Mindstorm 的 NXT 系统构建一个平衡机器人.我正在使用 HiTechnic 的两个传感器,第一个是加速度计,第二个是陀螺仪.我已经成功地过滤掉了来自传感器和衍生角度的噪音,范围在 -90 到 90 度之间,0 度是完美平衡的.

I am building a balancing robot using the Lego Mindstorm's NXT system. I am using two sensors from HiTechnic, the first being an Accelerometer and the second being a Gyroscope. I've successfully filtered out noise from both sensors and derived angles for both in a range between -90 and 90 degrees, with 0 degrees being perfectly balanced.

我的下一个挑战是结合两个传感器值来校正陀螺仪随时间的漂移.下面是我根据实际数据创建的示例图,用于演示陀螺仪的漂移:

My next challenge is to combine both of the sensor values to correct for the Gyroscope's drift over time. Below is an example graph I created from actual data to demonstrate the drift from the gyroscope:

我见过的最常用的方法是使用卡尔曼滤波器来组合这些传感器.但是,我不是微积分专家,我真的不懂数学符号,但我确实懂源代码中的数学.

The most commonly used approach I've seen to make combining these sensors rock solid is by using a Kalman filter. However, I'm not an expert in calculus and I really don't understand mathematical symbols, I do understand math in source code though.

我正在使用 RobotC(就像任何其他 C 衍生产品一样),如果有人能给我提供如何在 C 中完成此操作的示例,我将不胜感激.

I'm using RobotC (which is like any other C derivative) and would really appreciate if someone can give me examples of how to accomplish this in C.

感谢您的帮助!

解决方案:

好的,kersny 通过向我介绍互补过滤器解决了我的问题.这是说明我的结果的图表:

Alright, kersny solved my problem by introducing me to complementary filters. This is a graph illustrating my results:

结果 #1

结果 #2

如您所见,滤波器校正陀螺漂移并将两个信号合并为一个平滑信号.

As you can see, the filter corrects for gyroscopic drift and combines both signals into a single smooth signal.

因为无论如何我都在修复损坏的图像,所以我认为展示我用来生成这些数据的装备会很有趣:

Since I was fixing the broken images anyways, I thought it would be fun to show the rig I used to generate this data:

推荐答案

卡尔曼滤波器非常棒,但我发现互补滤波器更容易实现,结果相似.我发现的用于编码互补过滤器的最佳文章是 这个维基(连同这篇文章关于将传感器转换为工程单位)和 此页面 上的 zip 文件中的 PDF(在技​​术文档下,我相信 zip 中的文件名是 filter.pdf);

Kalman Filters are great and all, but I find the Complementary Filter much easier to implement with similar results. The best articles that I have found for coding a Complementary Filter are this wiki (along with this article about converting sensors to Engineering units) and a PDF in the zip file on this page (Under Technical Documentation, I believe the file name in the zip is filter.pdf);

附注.如果您坚持使用卡尔曼滤波器,这里是一些 C 语法代码,用于实现它的 Arduino.

PS. If your stuck on a Kalman Filter, here is some C-syntax code for the Arduino that implements it.

这篇关于结合陀螺仪和加速度计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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