RTIMULibDemo::RTIMULibDemo() : QMainWindow() { // This is some normal Qt GUI stuff ui.setupUi(this); layoutWindow(); layoutStatusBar(); // This code connects up signals from the GUI connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.actionSelectFusionAlgorithm, SIGNAL(triggered()), this, SLOT(onSelectFusionAlgorithm())); connect(ui.actionCalibrateAccelerometers, SIGNAL(triggered()), this, SLOT(onCalibrateAccelerometers())); connect(ui.actionCalibrateMagnetometers, SIGNAL(triggered()), this, SLOT(onCalibrateMagnetometers())); connect(ui.actionSelectIMU, SIGNAL(triggered()), this, SLOT(onSelectIMU())); connect(m_enableGyro, SIGNAL(stateChanged(int)), this, SLOT(onEnableGyro(int))); connect(m_enableAccel, SIGNAL(stateChanged(int)), this, SLOT(onEnableAccel(int))); connect(m_enableCompass, SIGNAL(stateChanged(int)), this, SLOT(onEnableCompass(int))); connect(m_enableDebug, SIGNAL(stateChanged(int)), this, SLOT(onEnableDebug(int))); // create the imu thread and connect up the signal m_imuThread = new IMUThread(); connect(m_imuThread, SIGNAL(newIMUData(const RTIMU_DATA&)), this, SLOT(newIMUData(const RTIMU_DATA&)), Qt::DirectConnection); connect(this, SIGNAL(newIMU()), m_imuThread, SLOT(newIMU())); m_imuThread->resumeThread(); // This value allows a sample rate to be calculated m_sampleCount = 0; // start some timers to get things going m_rateTimer = startTimer(RATE_TIMER_INTERVAL * 1000); // Only update the display 10 times per second to keep CPU reasonable m_displayTimer = startTimer(100); m_fusionType->setText(RTFusion::fusionName(m_imuThread->getSettings()->m_fusionType)); }
void RTIMULibDemo::onSelectIMU() { SelectIMUDlg dlg(m_imuThread->getSettings(), this); if (dlg.exec() == QDialog::Accepted) { emit newIMU(); } }
void RTIMULibDemo::onSelectFusionAlgorithm() { SelectFusionDlg dlg(m_imuThread->getSettings(), this); if (dlg.exec() == QDialog::Accepted) { emit newIMU(); m_fusionType->setText(RTFusion::fusionName(m_imuThread->getSettings()->m_fusionType)); } }
int main() { settings = new RTIMUSettings("RTIMULib"); bool mustExit = false; imu = NULL; newIMU(); // set up for calibration run imu->setCompassCalibrationMode(true); imu->setAccelCalibrationMode(true); magCal = new RTIMUMagCal(settings); magCal->magCalInit(); magMinMaxDone = false; accelCal = new RTIMUAccelCal(settings); accelCal->accelCalInit(); // set up console io struct termios ctty; tcgetattr(fileno(stdout), &ctty); ctty.c_lflag &= ~(ICANON); tcsetattr(fileno(stdout), TCSANOW, &ctty); // the main loop while (!mustExit) { displayMenu(); switch (tolower(getchar())) { case 'x' : mustExit = true; break; case 'm' : doMagMinMaxCal(); break; case 'e' : doMagEllipsoidCal(); break; case 'a' : doAccelCal(); break; } } printf("\nRTIMULibCal exiting\n"); return 0; }
void RTIMULibDemo::onCalibrateMagnetometers() { m_imuThread->getIMU()->setCompassCalibrationMode(true); MagCalDlg dlg(this, m_imuThread->getSettings()); connect(m_imuThread, SIGNAL(newIMUData(const RTIMU_DATA&)), &dlg, SLOT(newIMUData(const RTIMU_DATA&)), Qt::DirectConnection); if (dlg.exec() == QDialog::Accepted) { } disconnect(m_imuThread, SIGNAL(newIMUData(const RTIMU_DATA&)), &dlg, SLOT(newIMUData(const RTIMU_DATA&))); emit newIMU(); }