FRC Java Implementation of the SparkFun 6 Degrees of Freedom IMU Digital Combo Board

SERT Team 2521 has been experimenting with the new SparkFun 6 Degrees of Freedom IMU Digital Combo Board. Following an excellent article at http://bildr.org/2012/03/stable-orientation-digital-imu-6dof-arduino/ and sample code from here: http://wiki.oz9aec.net/index.php/6DOF_Digital_IMU we are now able to obtain both Gyro and Accelerometer data from this board.

The classes can be found here:

The big lesson learned was “correct addresses are key”. The code in WPILIB for the ADXL345 had a hard-coded address that was not correct for this combo board. The only change I made to this file was the address. The gyro took some more care as it uses partial bytes for control data. My hack of a method for setting up the masks is nothing to be excited about, but it works.

Many thanks to the author of the original work published 7/31/2011 by Jeff Rowberg <jeff at rowberg dot net>. https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/ITG3200

  • Joe Bussell
  • Mentor Team 2521

Usage:

In our Sensors class:
private ADXL345_I2C_SparkFun m_accel;
private GyroITG3200 m_gyro;

In our Sensors() constructor:
m_accel = new ADXL345_I2C_SparkFun(I2C.Port.kOnboard, Accelerometer.Range.k16G);

m_gyro = new GyroITG3200(I2C.Port.kOnboard);
m_gyro.initialize();

Methods to get Gyro data:
public double getAngleX() {
return m_gyro.getRotationX();
}

public double getAngleY() {
	return m_gyro.getRotationY();
}

public double getAngleZ() {
	return m_gyro.getRotationZ();
}

Were you able to get the gyro to work and return an angle?

From what I understand from your code, its seems like you are just getting the rate of rotation. According to the datasheet, the GYRO_OUT_ registers contain the rate of rotation. The gyro rate needs to be converted to degrees per second and then integrated to get the angle.

I also worked on a driver for this gyro, but it seemed to be filtering out a lot of the readings, so I ended up with a lot of drift. This is how I did it: https://gist.github.com/lopsided98/ef6c0f8cacacad9d398b

We are still pretty early in our progress with this. What we do have is raw values from the registers for all three gyro orientations and all three acceleration vectors from this combo board showing up on our Smart Dashboard. When I change the orientation of the device I see a ‘~reasonable’ change in the data. We still need to perform some test runs, gather data, and make sense of what we have.

I really appreciate your link. There are several concepts in your code that we will review and likely adopt. On one hand I wish I had your source three days ago. On the other hand it was a fun tour through an engineering problem with our students.

Hey guys,

How are you all going? I wanted to thank you so much for your Java implementation for this combo board. I’m attempting to use it now with a beaglebone black in addition to my real-time java code.

I’m just having trouble hooking everything up correctly - the edu.wpi libraries you use, are they specific to the boards you were communicating with? I’m assuming I’d have to replace those libraries with my BeagleBone Black board I2C libraries, yeah?

I’ll continue trying, and if I come up with a solution I’ll also add my code into a public repo and post it here for everyone.

I just hate the eclipse environment. Trying to add board dependencies and importing them to existing code can be such a pain in the neck with the IDE.