From d8086d6b72867bb98438c38e0badc91d9ecc39cf Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 14 Oct 2010 21:48:58 +0000 Subject: [PATCH] OP-138 Small updates to config widget, start of custom configuration interface, lots of work to do still... git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1961 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/config/airframe.ui | 61 +- .../plugins/config/configairframewidget.cpp | 88 +- .../src/plugins/config/configairframewidget.h | 1 + .../src/plugins/config/images/quad-shapes.svg | 1359 ++++++++++++++++- 4 files changed, 1389 insertions(+), 120 deletions(-) diff --git a/ground/src/plugins/config/airframe.ui b/ground/src/plugins/config/airframe.ui index 8b4c1fbcb..e5d75ff58 100644 --- a/ground/src/plugins/config/airframe.ui +++ b/ground/src/plugins/config/airframe.ui @@ -69,7 +69,7 @@ - 1 + 3 @@ -1280,7 +1280,10 @@ p, li { white-space: pre-wrap; } - + + + 2 + @@ -1304,7 +1307,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -1313,8 +1316,8 @@ p, li { white-space: pre-wrap; } - 150 - 150 + 100 + 100 @@ -1323,6 +1326,7 @@ p, li { white-space: pre-wrap; } 200 + @@ -1355,7 +1359,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -1364,8 +1368,8 @@ p, li { white-space: pre-wrap; } - 150 - 150 + 100 + 100 @@ -1395,7 +1399,7 @@ p, li { white-space: pre-wrap; } - + Qt::Horizontal @@ -1409,7 +1413,7 @@ p, li { white-space: pre-wrap; } - + @@ -1419,7 +1423,7 @@ p, li { white-space: pre-wrap; } - + @@ -1429,7 +1433,7 @@ p, li { white-space: pre-wrap; } - + 500 @@ -1449,7 +1453,13 @@ p, li { white-space: pre-wrap; } - + + + + 0 + 0 + + 8 @@ -1461,6 +1471,11 @@ p, li { white-space: pre-wrap; } 50 + + + Type + + Curve 1 @@ -1488,50 +1503,50 @@ p, li { white-space: pre-wrap; } - C0 + Ch 0 - C1 + Ch 1 - C2 + Ch 2 - C3 + Ch 3 - C4 + Ch 4 - C5 + Ch 5 - C6 + Ch 6 - C7 + Ch 7 - + - + diff --git a/ground/src/plugins/config/configairframewidget.cpp b/ground/src/plugins/config/configairframewidget.cpp index 970cf1aca..0db57aab6 100644 --- a/ground/src/plugins/config/configairframewidget.cpp +++ b/ground/src/plugins/config/configairframewidget.cpp @@ -188,7 +188,7 @@ void ConfigAirframeWidget::enableFFTest() { // Role: // - Check if all three checkboxes are checked - // - Every other timer event: toggle engine from 1/3 to 2/3 + // - Every other timer event: toggle engine from 45% to 55% // - Every other time event: send FF settings to flight FW if (m_aircraft->ffTestBox1->isChecked() && m_aircraft->ffTestBox2->isChecked() && @@ -196,26 +196,15 @@ void ConfigAirframeWidget::enableFFTest() if (!ffTuningInProgress) { // Initiate tuning: - // Setup a special mixer with all channels disabled but one - // and no RPY dependency. UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); accInitialData = mdata; mdata.flightAccess = UAVObject::ACCESS_READONLY; -/* - mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE; - mdata.gcsTelemetryAcked = false; - mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; - // NOTE: if actuators not updated at least every 100ms, then the - // flight sw goes into failsafe, hence this very low update period: - mdata.gcsTelemetryUpdatePeriod = 25; - */ obj->setMetadata(mdata); } // Depending on phase, either move actuator or send FF settings: if (ffTuningPhase) { // Send FF settings to the board - // We can already setup the feedforward here, as it is common to all platforms UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); UAVObjectField* field = obj->getField(QString("FeedForward")); field->setDouble((double)m_aircraft->feedForwardSlider->value()/100); @@ -342,6 +331,7 @@ void ConfigAirframeWidget::requestAircraftUpdate() // Setup all Throttle1 curves for all types of airframes m_aircraft->fixedWingThrottle->initCurve(curveValues); m_aircraft->multiThrottleCurve->initCurve(curveValues); + m_aircraft->customThrottle1Curve->initCurve(curveValues); // Load the Settings for fixed wing frames: if (frameType.startsWith("FixedWing")) { @@ -1240,22 +1230,79 @@ bool ConfigAirframeWidget::setupHexa() return true; } +/** + Updates the custom airframe settings based on the current airframe + */ +void ConfigAirframeWidget::updateCustomAirframeUI() +{ + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVObjectField* field = obj->getField(QString("ThrottleCurve1")); + QList curveValues; + // If the 1st element of the curve is <= -10, then the curve + // is a straight line (that's how the mixer works on the mainboard): + if (field->getValue(0).toInt() <= -10) { + for (double i=0; igetNumElements(); i++) { + curveValues.append(i/(field->getNumElements()-1)); + } + } else { + for (unsigned int i=0; i < field->getNumElements(); i++) { + curveValues.append(field->getValue(i).toDouble()); + } + } + m_aircraft->customThrottle1Curve->initCurve(curveValues); + + field = obj->getField(QString("ThrottleCurve2")); + curveValues.clear();; + // If the 1st element of the curve is <= -10, then the curve + // is a straight line (that's how the mixer works on the mainboard): + if (field->getValue(0).toInt() <= -10) { + for (double i=0; igetNumElements(); i++) { + curveValues.append(i/(field->getNumElements()-1)); + } + } else { + for (unsigned int i=0; i < field->getNumElements(); i++) { + curveValues.append(field->getValue(i).toDouble()); + } + } + m_aircraft->customThrottle2Curve->initCurve(curveValues); + + // Retrieve Feed Forward: + field = obj->getField(QString("FeedForward")); + m_aircraft->customFFSlider->setValue(field->getDouble()*100); + field = obj->getField(QString("AccelTime")); + m_aircraft->customFFaccel->setValue(field->getDouble()); + field = obj->getField(QString("DecelTime")); + m_aircraft->customFFdecel->setValue(field->getDouble()); + field = obj->getField(QString("MaxAccel")); + m_aircraft->customFFMaxAccel->setValue(field->getDouble()); + + // Update the table: + for (int i=0; i<8; i++) { + + } + +} + + + /** Sends the config to the board (airframe type) - We do all the tasks commong to all airframes, or family of airframes, and + We do all the tasks common to all airframes, or family of airframes, and we call additional methods for specific frames, so that we do not have a code that is too heavy. - */ +*/ void ConfigAirframeWidget::sendAircraftUpdate() { QString airframeType; if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { // Save the curve (common to all Fixed wing frames) UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - UAVObjectField* field = obj->getField("ThrottleCurve1"); + // Remove Feed Forward, it is pointless on a plane: + UAVObjectField* field = obj->getField(QString("FeedForward")); + field->setDouble(0); + field = obj->getField("ThrottleCurve1"); QList curve = m_aircraft->fixedWingThrottle->getCurve(); for (int i=0;isetValue(curve.at(i),i); @@ -1274,18 +1321,13 @@ void ConfigAirframeWidget::sendAircraftUpdate() } else if (m_aircraft->aircraftType->currentText() == "Multirotor") { // We can already setup the feedforward here, as it is common to all platforms UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); UAVObjectField* field = obj->getField(QString("FeedForward")); - Q_ASSERT(field); field->setDouble((double)m_aircraft->feedForwardSlider->value()/100); field = obj->getField(QString("AccelTime")); - Q_ASSERT(field); field->setDouble(m_aircraft->accelTime->value()); field = obj->getField(QString("DecelTime")); - Q_ASSERT(field); field->setDouble(m_aircraft->decelTime->value()); field = obj->getField(QString("MaxAccel")); - Q_ASSERT(field); field->setDouble(m_aircraft->maxAccelSlider->value()); // Curve is also common to all quads: @@ -1308,8 +1350,10 @@ void ConfigAirframeWidget::sendAircraftUpdate() airframeType = "Octo"; } + // Now reflect those settings in the "Custom" panel as well + updateCustomAirframeUI(); } else { - airframeType = "FixedWing"; + airframeType = "Custom"; } UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); diff --git a/ground/src/plugins/config/configairframewidget.h b/ground/src/plugins/config/configairframewidget.h index c388686fb..cae3788d5 100644 --- a/ground/src/plugins/config/configairframewidget.h +++ b/ground/src/plugins/config/configairframewidget.h @@ -53,6 +53,7 @@ private: bool setupQuad(bool pLayout); bool setupHexa(); bool setupOcto(); + void updateCustomAirframeUI(); void resetField(UAVObjectField * field); void resetMixer (MixerCurveWidget *mixer, int numElements); diff --git a/ground/src/plugins/config/images/quad-shapes.svg b/ground/src/plugins/config/images/quad-shapes.svg index c1eb0214d..86753993a 100644 --- a/ground/src/plugins/config/images/quad-shapes.svg +++ b/ground/src/plugins/config/images/quad-shapes.svg @@ -9,8 +9,8 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" + width="649.92664" + height="953.03302" id="svg2917" version="1.1" inkscape:version="0.47 r22583" @@ -31,6 +31,13 @@ inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d" /> + + @@ -110,7 +121,8 @@ + id="layer1" + transform="translate(-61.479602,-20.72994)"> + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + d="m 176.7767,75.039597 c 0,13.110458 -10.62813,23.738584 -23.73858,23.738584 -13.11046,0 -23.73859,-10.628126 -23.73859,-23.738584 0,-13.110459 10.62813,-23.738585 23.73859,-23.738585 13.11045,0 23.73858,10.628126 23.73858,23.738585 z" /> + transform="translate(60,54)" /> + d="m 176.7767,75.039597 c 0,13.110458 -10.62813,23.738584 -23.73858,23.738584 -13.11046,0 -23.73859,-10.628126 -23.73859,-23.738584 0,-13.110459 10.62813,-23.738585 23.73859,-23.738585 13.11045,0 23.73858,10.628126 23.73858,23.738585 z" /> 2 4 @@ -254,7 +266,7 @@ sodipodi:open="true" sodipodi:end="3.5351905" sodipodi:start="0" - transform="matrix(0.76640028,0,0,0.76640028,-30.17891,72.386372)" + transform="matrix(0.76640028,0,0,0.76640028,-26.17891,72.386372)" sodipodi:type="arc" style="fill:none;stroke:#000000;stroke-width:2.60960245;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" id="path3868" @@ -262,9 +274,9 @@ sodipodi:cy="75.039597" sodipodi:rx="23.738585" sodipodi:ry="23.738585" - d="m 176.7767,75.039597 a 23.738585,23.738585 0 1 1 -45.662,-9.104071" /> + d="m 176.7767,75.039597 c 0,13.110458 -10.62813,23.738584 -23.73858,23.738584 -13.11046,0 -23.73859,-10.628126 -23.73859,-23.738584 0,-3.124577 0.61685,-6.218415 1.81517,-9.104071" /> + d="m 105.07143,134.50504 4.28571,-3.92857 2.85715,5.35714" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + d="m 105.07143,134.50504 4.28571,-3.92857 2.85715,5.35714" + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + + - - - @@ -1369,7 +1375,7 @@ + transform="translate(-333.06929,156.22454)"> + transform="translate(-221.98072,218.59427)"> + transform="translate(-245.40819,213.68837)"> @@ -1759,7 +1765,7 @@ id="g4037" transform="translate(-196.53811,217.69364)"> + + + + + + + + + + 1 + 2 + 3 + 4 + + + + + + + + + + + + + + + + 1 + 3 + 5 + 7 + + + + + + + + + + + + + + + 2 + 4 + 6 + 8 + + + + + + + + + 1 + 2 + 3 + 4 + + + + + + + + + + + + + + + 1 + 3 + 5 + 7 + + + + + + + + + + + + + + + 2 + 4 + 6 + 8 + + + + + + 2 + 3 + + + + + + + 1 + + + + + + + 1 + 2 + + + + 3 + + + 4 + + + + 5 + + + + + 6 + + + + + + + 2 + + + 3 + + + + + + + + + 1 + + + + +