# Gyro/Accelerometer Fusion

I would like to compensate for drift in my gyro using an acceleromoter. I collected some data from the accelerometer and gryo and I am looking for some help in designing a filter.

1. My first question is if the accelerometer data looks reasonable since this is the first time I have used an accelerometer. The accelerometer is lying flat on the robot.

• The first attachment (acc_data_1.bmp) shows readings while the robot was stationary (first half) and then moving. I don’t understand why the z-axis is jumping around while the robot is stationary (or why it is moving at all even when the robot is driving around).

• The second and third attachements (acc_data_2.bmp and acc_data_3.bmp) show the acceleromoter data and gyro data during a sequence of motions.

Time 368.5-373: Robot turns 90 degrees
Time 373-375: Robot drives 5 feet
Time 375-378.5: Robot turns 90 degrees
Time 378.5 - 381.5 Robot drives 10 feet
Time 381.5-384.5: Robot turns 90 degrees

If I am correct the x-axis is forward/reverse motion of the robot and the y-axis is side to side motion of the robot. I think I can see reasonable correlation from the accelerometer data (for example acceleration followed by deceleration in the x-axis when making the 5’ and 10’ position moves).

I would like other opinions on the quality of this data and if I should proceed with trying to create a filter.

1. If the data is correct I would then appreciate any suggestions for a filter design. I attempted to implement the suggestion here but I don’t really understand it enough to get it working. One of the main sticking points is how to convert the G’s from the accelerometer to degrees.

Some theory may be helpful, some practical pointers would be nice, some code or psuedo-code would be awesome! I will leave this sort of open ended and see where it goes.

acc_data_3.bmp (1.92 MB)
acc_data_1.bmp (1.72 MB)
acc_data_2.bmp (1.72 MB)

acc_data_3.bmp (1.92 MB)
acc_data_1.bmp (1.72 MB)
acc_data_2.bmp (1.72 MB)

If you intend to use this to track your robots position it will not work. I have tried this before with FIRST grade sensors and they aren’t even close to accurate enough. A commercial inertial measurement unit (IMU, google it) would do the job, but it’s orders of magnitude too expensive for an FRC robot.

I’m not looking to maintain an absolute heading/field position. I am only doing relative moves, i.e. reset the gyro and move X degrees. It already works well and the gyro filtering is not really required but I thought it would be nice to have and would be a good learning experience.

website?

Oops, I meant sensors. Smartphones and autocorrect :P. In this case, why is it necessary to have the accelerometer at all? Translation should affect gyro readings at all.