|
|
@ -9,19 +9,8 @@ QGCPX4SensorCalibration::QGCPX4SensorCalibration(QWidget *parent) : |
|
|
|
QWidget(parent), |
|
|
|
QWidget(parent), |
|
|
|
activeUAS(NULL), |
|
|
|
activeUAS(NULL), |
|
|
|
clearAction(new QAction(tr("Clear Text"), this)), |
|
|
|
clearAction(new QAction(tr("Clear Text"), this)), |
|
|
|
accelStarted(false), |
|
|
|
|
|
|
|
gyroStarted(false), |
|
|
|
|
|
|
|
magStarted(false), |
|
|
|
|
|
|
|
ui(new Ui::QGCPX4SensorCalibration) |
|
|
|
ui(new Ui::QGCPX4SensorCalibration) |
|
|
|
{ |
|
|
|
{ |
|
|
|
accelAxes << "x+"; |
|
|
|
|
|
|
|
accelAxes << "x-"; |
|
|
|
|
|
|
|
accelAxes << "y+"; |
|
|
|
|
|
|
|
accelAxes << "y-"; |
|
|
|
|
|
|
|
accelAxes << "z+"; |
|
|
|
|
|
|
|
accelAxes << "z-"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
connect(clearAction, SIGNAL(triggered()), ui->textView, SLOT(clear())); |
|
|
|
connect(clearAction, SIGNAL(triggered()), ui->textView, SLOT(clear())); |
|
|
|
|
|
|
|
|
|
|
@ -333,10 +322,8 @@ void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int sever |
|
|
|
text.startsWith("[mavlink pm]")) |
|
|
|
text.startsWith("[mavlink pm]")) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("progress")) { |
|
|
|
if (text.contains("progress <")) { |
|
|
|
qDebug() << "PROGRESS:" << text; |
|
|
|
|
|
|
|
QString percent = text.split("<").last().split(">").first(); |
|
|
|
QString percent = text.split("<").last().split(">").first(); |
|
|
|
qDebug() << "PERCENT CANDIDATE" << percent; |
|
|
|
|
|
|
|
bool ok; |
|
|
|
bool ok; |
|
|
|
int p = percent.toInt(&ok); |
|
|
|
int p = percent.toInt(&ok); |
|
|
|
if (ok) |
|
|
|
if (ok) |
|
|
@ -346,97 +333,64 @@ void QGCPX4SensorCalibration::handleTextMessage(int uasid, int compId, int sever |
|
|
|
|
|
|
|
|
|
|
|
ui->instructionLabel->setText(QString("%1").arg(text)); |
|
|
|
ui->instructionLabel->setText(QString("%1").arg(text)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text.startsWith("accel measurement started: ")) { |
|
|
|
if (text.contains("accel")) { |
|
|
|
QString axis = text.split("measurement started: ").last().left(2); |
|
|
|
qDebug() << "ACCEL" << text; |
|
|
|
setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(axis)); |
|
|
|
|
|
|
|
|
|
|
|
if (text.startsWith("accel measurement started: ")) { |
|
|
|
|
|
|
|
QString axis = text.split("measurement started: ").last().left(2); |
|
|
|
|
|
|
|
qDebug() << "AXIS" << axis << "STR" << text; |
|
|
|
|
|
|
|
setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(axis)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text.startsWith("directions left")) { |
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!text.contains(accelAxes[i])) { |
|
|
|
|
|
|
|
qDebug() << "FINISHED" << accelAxes[i]; |
|
|
|
|
|
|
|
accelDone[i] = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.startsWith("result for")) { |
|
|
|
if (text.startsWith("directions left: ")) { |
|
|
|
|
|
|
|
QString axis = text.split("directions left: ").last().left(2); |
|
|
|
QString axis = text.split("result for ").last().left(2); |
|
|
|
setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(axis)); |
|
|
|
|
|
|
|
|
|
|
|
qDebug() << "ACCELDONE AXIS" << axis << "STR" << text; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (axis == accelAxes[i]) |
|
|
|
|
|
|
|
accelDone[i] = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!accelDone[i]) { |
|
|
|
|
|
|
|
qDebug() << "NEW AXIS: " << accelAxes[i]; |
|
|
|
|
|
|
|
setInstructionImage(QString(":/files/images/px4/calibration/accel_%1.png").arg(accelAxes[i])); |
|
|
|
|
|
|
|
ui->instructionLabel->setText(tr("Axis %1 completed. Please rotate like shown here.").arg(axis)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("please rotate in a figure 8")) { |
|
|
|
if (text == "rotate in a figure 8 around all axis") { |
|
|
|
setInstructionImage(":/files/images/px4/calibration/mag_calibration_figure8.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/mag_calibration_figure8.png"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("accel calibration done")) { |
|
|
|
if (text.endsWith(" calibration: done") || text.endsWith(" calibration: failed")) { |
|
|
|
accelStarted = false; |
|
|
|
|
|
|
|
// XXX use a confirmation image or something
|
|
|
|
// XXX use a confirmation image or something
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
if (activeUAS) { |
|
|
|
if (text.endsWith(" calibration: done")) { |
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_XOFF"); |
|
|
|
ui->progressBar->setValue(100); |
|
|
|
activeUAS->requestParameter(0, "SENS_BOARD_ROT"); |
|
|
|
} else { |
|
|
|
|
|
|
|
ui->progressBar->setValue(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("gyro calibration done")) { |
|
|
|
|
|
|
|
gyroStarted = false; |
|
|
|
|
|
|
|
// XXX use a confirmation image or something
|
|
|
|
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
|
|
|
|
if (activeUAS) |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_XOFF"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("mag calibration done") |
|
|
|
|
|
|
|
|| text.contains("magnetometer calibration completed")) { |
|
|
|
|
|
|
|
magStarted = false; |
|
|
|
|
|
|
|
// XXX use a confirmation image or something
|
|
|
|
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
|
|
|
|
if (activeUAS) { |
|
|
|
if (activeUAS) { |
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_XOFF"); |
|
|
|
if (text.startsWith("accel ")) { |
|
|
|
activeUAS->requestParameter(0, "SENS_EXT_MAG_ROT"); |
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_XOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_YOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_ZOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_XSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_YSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_ACC_ZSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_BOARD_ROT"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (text.startsWith("gyro ")) { |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_XOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_YOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_ZOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_XSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_YSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_GYRO_ZSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_BOARD_ROT"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (text.startsWith("mag ")) { |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_XOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_YOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_ZOFF"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_XSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_YSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_MAG_ZSCALE"); |
|
|
|
|
|
|
|
activeUAS->requestParameter(0, "SENS_EXT_MAG_ROT"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("accel calibration started")) { |
|
|
|
if (text.endsWith(" calibration: started")) { |
|
|
|
accelStarted = true; |
|
|
|
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("gyro calibration started")) { |
|
|
|
|
|
|
|
gyroStarted = true; |
|
|
|
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (text.contains("mag calibration started")) { |
|
|
|
|
|
|
|
magStarted = false; |
|
|
|
|
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// XXX color messages according to severity
|
|
|
|
// XXX color messages according to severity
|
|
|
|
|
|
|
|
|
|
|
|
QPlainTextEdit *msgWidget = ui->textView; |
|
|
|
QPlainTextEdit *msgWidget = ui->textView; |
|
|
@ -457,7 +411,6 @@ void QGCPX4SensorCalibration::gyroButtonClicked() |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
ui->instructionLabel->setText(tr("Please do not move the system at all.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void QGCPX4SensorCalibration::magButtonClicked() |
|
|
|
void QGCPX4SensorCalibration::magButtonClicked() |
|
|
@ -465,7 +418,6 @@ void QGCPX4SensorCalibration::magButtonClicked() |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
ui->instructionLabel->setText(tr("Please put the system in a rest position.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void QGCPX4SensorCalibration::accelButtonClicked() |
|
|
|
void QGCPX4SensorCalibration::accelButtonClicked() |
|
|
@ -473,15 +425,6 @@ void QGCPX4SensorCalibration::accelButtonClicked() |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
setInstructionImage(":/files/images/px4/calibration/accel_z-.png"); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0); |
|
|
|
activeUAS->executeCommand(MAV_CMD_PREFLIGHT_CALIBRATION, 1, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
ui->progressBar->setValue(0); |
|
|
|
accelStarted = true; |
|
|
|
|
|
|
|
accelDone[0] = false; |
|
|
|
|
|
|
|
accelDone[1] = false; |
|
|
|
|
|
|
|
accelDone[2] = false; |
|
|
|
|
|
|
|
accelDone[3] = false; |
|
|
|
|
|
|
|
accelDone[4] = false; |
|
|
|
|
|
|
|
accelDone[5] = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->instructionLabel->setText(tr("Please hold the system very still in the shown orientations.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void QGCPX4SensorCalibration::contextMenuEvent(QContextMenuEvent* event) |
|
|
|
void QGCPX4SensorCalibration::contextMenuEvent(QContextMenuEvent* event) |
|
|
|