An IMU (Inertial measurement unit) is a compound sensor which typically includes an accelerometer, gyro, and compass. The sensor values are often passed through a Kalman filter to reduce noise and are typically used by airborne vehicles.
In your appInitHardware you should initialise the sensor:-
Then in your main loop you can read the sensor using:-
Once read then the values are available in the following member variables:-
ACCEL_TYPE xa = device.imu.x_axis_mG;
ACCEL_TYPE ya = device.imu. y_axis_mG;
ACCEL_TYPE za = device.imu. z_axis_mG;
GYRO_TYPE xr = device.imu.x_axis_degrees_per_second;
GYRO_TYPE yr = device.imu.y_axis_degrees_per_second;
GYRO_TYPE zr = device.imu.z_axis_degrees_per_second;
COMPASS_TYPE yaw = device.imu.bearingDegrees;
COMPASS_TYPE roll = device.imu.rollDegrees;
COMPASS_TYPE pitch = device.imu.pitchDegrees;
Or they can all be dumped to the rprintf destination using:
- Sparkfun/razor.h - The Sparkfun Razor 9DoF IMU board contains an accelerometer, gyros for roll, pitch and yaw and a magnetometer compass and communicates with your board via a TTL level UART, or directly to your PC with the addition of a (MAX232 type) level shifter.