320
« on: November 06, 2015, 06:14:17 PM »
Hi- you can leave the library as it is. It's a bit tricky to figure out, but in your main loop you can have:
#include "I2Cdev.h"
#include "RTIMUSettings.h"
#include "RTIMU.h"
#include "RTFusionRTQF.h"
#include "CalLib.h"
#include <EEPROM.h>
RTIMU *imu; // the IMU object
RTFusionRTQF fusion; // the fusion object
RTIMUSettings settings; // the settings object
void setup()
{
Wire.begin();
imu = RTIMU::createIMU(&settings);
imu->IMUInit();
fusion.setGyroEnable(true);
fusion.setAccelEnable(true);
//fusion.setCompassEnable(true);
}
int currentXdata=0;
int currentYdata=0;
void loop()
{
if (imu->IMURead()) { // get the latest data if ready yet
fusion.newIMUData(imu->getGyro(), imu->getAccel(), imu->getCompass(), imu->getTimestamp());
currentXdata=fusion.getFusionPose().x()* RTMATH_RAD_TO_DEGREE;
currentYdata=fusion.getFusionPose().y()* RTMATH_RAD_TO_DEGREE;
}
//do stuff with currentXdata and currentYdata
}
You might want the data as floats etc, but this should get you closer to accessing the data in a way that you can easily save to the SD card using the standard libraries.