Combine Gyroscope and Accelerometer Data

跟風遠走 提交于 2019-12-17 02:02:13

问题


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.

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.

Thank you for your help!

SOLUTION RESULTS:

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

Result #1

Result #2

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

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


回答1:


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);

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




回答2:


Gamasutra.com ran an article on using Kalman filters for WiiMote filtering.

There are some links to C++ source code at the end of the article.



来源:https://stackoverflow.com/questions/1586658/combine-gyroscope-and-accelerometer-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!