From 87de0f5b21aa68fb4a1f1f8f5caece3d78f81909 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Wed, 10 Apr 2013 10:18:22 -0400 Subject: [PATCH] New config windows, dynamically generated based on ANY qgw files in the configuration directories --- src/ui/QGCVehicleConfig.cc | 63 ++++++++++++++++- src/ui/QGCVehicleConfig.ui | 140 +++++++++---------------------------- 2 files changed, 94 insertions(+), 109 deletions(-) diff --git a/src/ui/QGCVehicleConfig.cc b/src/ui/QGCVehicleConfig.cc index e1b95610ac..59013fc862 100644 --- a/src/ui/QGCVehicleConfig.cc +++ b/src/ui/QGCVehicleConfig.cc @@ -8,6 +8,7 @@ #endif #include +#include #include "QGCVehicleConfig.h" #include "UASManager.h" @@ -188,9 +189,66 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) QGCToolWidget* tool; + QDir autopilotdir(qApp->applicationDirPath() + "/files/" + mav->getAutopilotTypeName().toLower()); + QDir generaldir = QDir(autopilotdir.absolutePath() + "/general/widgets"); + QDir vehicledir = QDir(autopilotdir.absolutePath() + "/" + mav->getSystemTypeName().toLower() + "/widgets"); + if (!autopilotdir.exists("general")) + { + //TODO: Throw some kind of error here. There is no general configuration directory + qDebug() << "invalid general dir"; + } + if (!autopilotdir.exists(mav->getAutopilotTypeName().toLower())) + { + //TODO: Throw an error here too, no autopilot specific configuration + qDebug() << "invalid vehicle dir"; + } + qDebug() << autopilotdir.absolutePath(); + qDebug() << generaldir.absolutePath(); + qDebug() << vehicledir.absolutePath(); + + foreach (QString file,generaldir.entryList(QDir::Files | QDir::NoDotAndDotDot)) + { + if (file.toLower().endsWith(".qgw")) { + tool = new QGCToolWidget("", this); + if (tool->loadSettings(generaldir.absoluteFilePath(file), false)) + { + toolWidgets.append(tool); + //ui->sensorLayout->addWidget(tool); + QGroupBox *box = new QGroupBox(this); + box->setTitle(tool->objectName()); + box->setLayout(new QVBoxLayout()); + box->layout()->addWidget(tool); + ui->multiRotorAttitudeLayout->addWidget(box); + } else { + delete tool; + } + } + } + + foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot)) + { + if (file.toLower().endsWith(".qgw")) { + tool = new QGCToolWidget("", this); + if (tool->loadSettings(vehicledir.absoluteFilePath(file), false)) + { + toolWidgets.append(tool); + //ui->sensorLayout->addWidget(tool); + QGroupBox *box = new QGroupBox(this); + box->setTitle(tool->objectName()); + box->setLayout(new QVBoxLayout()); + box->layout()->addWidget(tool); + ui->fixedWingAttitudeLayout->addWidget(box); + } else { + delete tool; + } + } + } + + + // Load calibration tool = new QGCToolWidget("", this); - if (tool->loadSettings(defaultsDir + "px4_calibration.qgw", false)) + if (tool->loadSettings(autopilotdir.absolutePath() + "/" + mav->getSystemTypeName().toLower() + "/calibration.qgw", false)) { toolWidgets.append(tool); ui->sensorLayout->addWidget(tool); @@ -199,6 +257,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) } // Load multirotor attitude pid + /* tool = new QGCToolWidget("", this); if (tool->loadSettings(defaultsDir + "px4_mc_attitude_pid_params.qgw", false)) { @@ -256,7 +315,7 @@ void QGCVehicleConfig::setActiveUAS(UASInterface* active) //ui->fixedWingPositionLayout->addWidget(tool); } else { delete tool; - } + }*/ updateStatus(QString("Reading from system %1").arg(mav->getUASName())); } diff --git a/src/ui/QGCVehicleConfig.ui b/src/ui/QGCVehicleConfig.ui index 9725d9a282..08334459d9 100644 --- a/src/ui/QGCVehicleConfig.ui +++ b/src/ui/QGCVehicleConfig.ui @@ -40,7 +40,7 @@ - 1 + 0 @@ -751,22 +751,22 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:18pt;">Sensor Calibration</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">The PX4FMU sensors can be calibrated with the buttons on the right. Gyroscope (GYRO) and Accelerometer (ACCEL) calibrations have to be performed with a static, unmoved system. The magnetometer calibration needs to be performed while moving the device.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt;">Magnetometer Calibration</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Carefully follow the instructions. Click on MAG to start the calibration. Watch the communication console for further instructions (Available through Main Menu -&gt; Tool Widgets -&gt; Communication Console). Do not calibrate the vehicle in vincinity of metal, e.g. from a table or chair. Start the calibration, leave the system unmoved on the table. Wait for the double beep. Next move the system in a figure eight, roll and pitch it strongly, rotate around all axes and perform the figure eight also upside-down. The calibration is finished after the triple beep.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt;">Accelerometer Calibration</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Put the system on an absolutely level surface and press ACCEL, wait for the the triple beep. Do not move the system. If no flat surface is available, rather not calibrate the system.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt;">Gyroscope Calibration</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">The orientation is not important for this calibration, but do not move the system until the triple beep or the matching text message in the console.</span></p></body></html> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:18pt;">Sensor Calibration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:16pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:12pt;">The PX4FMU sensors can be calibrated with the buttons on the right. Gyroscope (GYRO) and Accelerometer (ACCEL) calibrations have to be performed with a static, unmoved system. The magnetometer calibration needs to be performed while moving the device.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:12pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:16pt;">Magnetometer Calibration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:16pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:12pt;">Carefully follow the instructions. Click on MAG to start the calibration. Watch the communication console for further instructions (Available through Main Menu -&gt; Tool Widgets -&gt; Communication Console). Do not calibrate the vehicle in vincinity of metal, e.g. from a table or chair. Start the calibration, leave the system unmoved on the table. Wait for the double beep. Next move the system in a figure eight, roll and pitch it strongly, rotate around all axes and perform the figure eight also upside-down. The calibration is finished after the triple beep.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:12pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:16pt;">Accelerometer Calibration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:16pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:12pt;">Put the system on an absolutely level surface and press ACCEL, wait for the the triple beep. Do not move the system. If no flat surface is available, rather not calibrate the system.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:12pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:16pt;">Gyroscope Calibration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Lucida Grande'; font-size:16pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:12pt;">The orientation is not important for this calibration, but do not move the system until the triple beep or the matching text message in the console.</span></p></body></html> @@ -774,19 +774,12 @@ p, li { white-space: pre-wrap; } - Multirotor Control + General Config 20 - - - - Load Platform Defaults - - - @@ -800,50 +793,20 @@ p, li { white-space: pre-wrap; } - - - - - - - Position + + + + Load Platform Defaults - - - 0 - - - - - true - - - - - 0 - 0 - 98 - 28 - - - - - 0 - - - - - - - - - + + + - Attitude + Configuration @@ -859,8 +822,8 @@ p, li { white-space: pre-wrap; } 0 0 - 98 - 28 + 740 + 442 @@ -881,49 +844,12 @@ p, li { white-space: pre-wrap; } - Fixed Wing Control + Hardware Specific Config - + 20 - - - - Position - - - - 0 - - - - - true - - - - - 0 - 0 - 98 - 28 - - - - - 0 - - - - - - - - - - - @@ -950,7 +876,7 @@ p, li { white-space: pre-wrap; } - Attitude + Configuration @@ -966,8 +892,8 @@ p, li { white-space: pre-wrap; } 0 0 - 98 - 28 + 740 + 442 -- GitLab