Tuesday, November 30, 2010

[imu] Microstrain 3DM-GX1

Recently I've been playing around with a MicroStrain 3DM-GX1, which is a pretty decent IMU. I found myself in need of an IMU for a project I'm working on, and the lab just happened to have a GX1 lying around.

While the GX1 itself is a solid piece of hardware, the software is a little bit lacking. This is especially true for linux; MicroStrain provides only a small example to get euler angles. It would have been nice if they had provided a library and API, but it was easy enough to write one from scratch using the 3DM-GX1 Data Communications Protocol document.

I feel obligated to say here that MicroStrains documentation is excellent, and really simplified the whole process. I also had to email customer support once or twice, and they were very helpful.

So I wrote a C++ library to talk to the GX1. It was relatively painless because the GX1 uses a serial interface and I could simply use the unix termios API. While the GX1 supports polling and continuous modes, I focused on polling because it's more flexible. To get data from the IMU the following must occur:
  • Set a command to the GX1
  • Wait for result buffer
  • Read the result buffer
  • Parse the result to get meaningful data
My API combines these steps into a single function call for easy, readable, OO programming. For example calling "imu.get_euler()" would return the Euler angles, so it's very simple.