diff --git a/ground/src/plugins/config/configairframewidget.cpp b/ground/src/plugins/config/configairframewidget.cpp index ac6445d78..ccfee6de9 100644 --- a/ground/src/plugins/config/configairframewidget.cpp +++ b/ground/src/plugins/config/configairframewidget.cpp @@ -589,6 +589,9 @@ void ConfigAirframeWidget::setupAirframeUI(QString frameType) m_aircraft->multiMotor6->setEnabled(true); m_aircraft->multiMotor7->setEnabled(true); m_aircraft->multiMotor8->setEnabled(true); + m_aircraft->mrRollMixLevel->setValue(33); + m_aircraft->mrPitchMixLevel->setValue(33); + m_aircraft->mrYawMixLevel->setValue(12); } } diff --git a/ground/src/plugins/config/configservowidget.cpp b/ground/src/plugins/config/configservowidget.cpp index e65185f3e..18d546bdd 100644 --- a/ground/src/plugins/config/configservowidget.cpp +++ b/ground/src/plugins/config/configservowidget.cpp @@ -82,7 +82,14 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent) << m_config->ch5Rev << m_config->ch6Rev << m_config->ch7Rev; - + inSliders << m_config->ch0Slider + << m_config->ch1Slider + << m_config->ch2Slider + << m_config->ch3Slider + << m_config->ch4Slider + << m_config->ch5Slider + << m_config->ch6Slider + << m_config->ch7Slider; // Now connect the widget to the ManualControlCommand / Channel UAVObject @@ -129,6 +136,25 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent) m_config->ch6Output->addItem("None"); m_config->ch7Output->addItem("None"); + // And the flight mode settings: + field = obj->getField(QString("Pos1FlightMode")); + m_config->fmsModePos1->addItems(field->getOptions()); + m_config->fmsModePos2->addItems(field->getOptions()); + m_config->fmsModePos3->addItems(field->getOptions()); + field = obj->getField(QString("Pos1StabilizationSettings")); + channelsList.clear(); + channelsList.append(field->getOptions()); + m_config->fmsSsPos1Roll->addItems(channelsList); + m_config->fmsSsPos1Pitch->addItems(channelsList); + m_config->fmsSsPos1Yaw->addItems(channelsList); + m_config->fmsSsPos2Roll->addItems(channelsList); + m_config->fmsSsPos2Pitch->addItems(channelsList); + m_config->fmsSsPos2Yaw->addItems(channelsList); + m_config->fmsSsPos3Roll->addItems(channelsList); + m_config->fmsSsPos3Pitch->addItems(channelsList); + m_config->fmsSsPos3Yaw->addItems(channelsList); + + obj = dynamic_cast(objManager->getObject(QString("ActuatorSettings"))); fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { @@ -137,7 +163,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent) m_config->ch1Output->addItem(field->getName()); m_config->ch2Output->addItem(field->getName()); m_config->ch3Output->addItem(field->getName()); - m_config->ch4Output->addItem(field->getName()); + m_config->ch4Output->addItem(field->getName()); m_config->ch5Output->addItem(field->getName()); m_config->ch6Output->addItem(field->getName()); m_config->ch7Output->addItem(field->getName()); @@ -161,6 +187,12 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent) connect(m_config->saveRCInputToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); connect(m_config->getRCInputCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); + // Flightmode panel is connected to the same as rcinput because + // the underlying object is the same! + connect(m_config->saveFmsToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject())); + connect(m_config->saveFmsToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate())); + connect(m_config->getFmsCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate())); + connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject())); connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate())); connect(m_config->getRCOutputCurrent, SIGNAL(clicked()), this, SLOT(requestRCOutputUpdate())); @@ -197,17 +229,8 @@ void ConfigServoWidget::sendChannelTest(int value) if (!m_config->channelOutTest->isChecked()) return; - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorCommand"))); - UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ActuatorCommand"))); - -/* - QStringList channelsList; - channelsList << "ch0OutSlider" << "ch1OutSlider" << "ch2OutSlider" << "ch3OutSlider" << "ch4OutSlider" - << "ch5OutSlider" << "ch6OutSlider" << "ch7OutSlider"; - int idx = channelsList.indexOf(QRegExp(ob->objectName())); - */ UAVObjectField * channel = obj->getField("Channel"); channel->setValue(value,index); obj->updated(); @@ -485,10 +508,6 @@ void ConfigServoWidget::reverseChannel(bool state) } - - - - /******************************** * Input settings *******************************/ @@ -498,9 +517,7 @@ void ConfigServoWidget::reverseChannel(bool state) */ void ConfigServoWidget::requestRCInputUpdate() { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); - UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ManualControlSettings"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlSettings"))); Q_ASSERT(obj); obj->requestUpdate(); @@ -569,7 +586,6 @@ void ConfigServoWidget::requestRCInputUpdate() m_config->ch6Assign->setCurrentIndex(0); m_config->ch7Assign->setCurrentIndex(0); - // Update all channels assignements QList fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { @@ -578,6 +594,35 @@ void ConfigServoWidget::requestRCInputUpdate() } } + // Update all the flight mode settingsin the relevant tab + field = obj->getField(QString("Pos1FlightMode")); + m_config->fmsModePos1->setCurrentIndex((m_config->fmsModePos1->findText(field->getValue().toString()))); + field = obj->getField(QString("Pos2FlightMode")); + m_config->fmsModePos2->setCurrentIndex((m_config->fmsModePos2->findText(field->getValue().toString()))); + field = obj->getField(QString("Pos3FlightMode")); + m_config->fmsModePos3->setCurrentIndex((m_config->fmsModePos3->findText(field->getValue().toString()))); + field = obj->getField(QString("Pos1StabilizationSettings")); + m_config->fmsSsPos1Roll->setCurrentIndex(m_config->fmsSsPos1Roll->findText( + field->getValue(field->getElementNames().indexOf("Roll")).toString())); + m_config->fmsSsPos1Pitch->setCurrentIndex(m_config->fmsSsPos1Pitch->findText( + field->getValue(field->getElementNames().indexOf("Pitch")).toString())); + m_config->fmsSsPos1Yaw->setCurrentIndex(m_config->fmsSsPos1Yaw->findText( + field->getValue(field->getElementNames().indexOf("Yaw")).toString())); + field = obj->getField(QString("Pos2StabilizationSettings")); + m_config->fmsSsPos2Roll->setCurrentIndex(m_config->fmsSsPos2Roll->findText( + field->getValue(field->getElementNames().indexOf("Roll")).toString())); + m_config->fmsSsPos2Pitch->setCurrentIndex(m_config->fmsSsPos2Pitch->findText( + field->getValue(field->getElementNames().indexOf("Pitch")).toString())); + m_config->fmsSsPos2Yaw->setCurrentIndex(m_config->fmsSsPos2Yaw->findText( + field->getValue(field->getElementNames().indexOf("Yaw")).toString())); + field = obj->getField(QString("Pos3StabilizationSettings")); + m_config->fmsSsPos3Roll->setCurrentIndex(m_config->fmsSsPos3Roll->findText( + field->getValue(field->getElementNames().indexOf("Roll")).toString())); + m_config->fmsSsPos3Pitch->setCurrentIndex(m_config->fmsSsPos3Pitch->findText( + field->getValue(field->getElementNames().indexOf("Pitch")).toString())); + m_config->fmsSsPos3Yaw->setCurrentIndex(m_config->fmsSsPos3Yaw->findText( + field->getValue(field->getElementNames().indexOf("Yaw")).toString())); + } @@ -634,11 +679,11 @@ void ConfigServoWidget::sendRCInputUpdate() // will get the setting. // First, reset all channel assignements: - QStringList channelsList; - channelsList << "Roll" << "Pitch" << "Yaw" << "Throttle" << "FlightMode"; - foreach (QString channel, channelsList) { - field = obj->getField(channel); - field->setValue(field->getOptions().last()); + QList fieldList = obj->getFields(); + foreach (UAVObjectField* field, fieldList) { + if (field->getUnits().contains("channel")) { + field->setValue(field->getOptions().last()); + } } // Then assign according to current GUI state: @@ -675,6 +720,27 @@ void ConfigServoWidget::sendRCInputUpdate() field->setValue(field->getOptions().at(7)); } + // Send all the flight mode settings + field = obj->getField(QString("Pos1FlightMode")); + field->setValue(m_config->fmsModePos1->currentText()); + field = obj->getField(QString("Pos2FlightMode")); + field->setValue(m_config->fmsModePos2->currentText()); + field = obj->getField(QString("Pos3FlightMode")); + field->setValue(m_config->fmsModePos3->currentText()); + + field = obj->getField(QString("Pos1StabilizationSettings")); + field->setValue(m_config->fmsSsPos1Roll->currentText(), field->getElementNames().indexOf("Roll")); + field->setValue(m_config->fmsSsPos1Pitch->currentText(), field->getElementNames().indexOf("Pitch")); + field->setValue(m_config->fmsSsPos1Yaw->currentText(), field->getElementNames().indexOf("Yaw")); + field = obj->getField(QString("Pos2StabilizationSettings")); + field->setValue(m_config->fmsSsPos2Roll->currentText(), field->getElementNames().indexOf("Roll")); + field->setValue(m_config->fmsSsPos2Pitch->currentText(), field->getElementNames().indexOf("Pitch")); + field->setValue(m_config->fmsSsPos2Yaw->currentText(), field->getElementNames().indexOf("Yaw")); + field = obj->getField(QString("Pos3StabilizationSettings")); + field->setValue(m_config->fmsSsPos3Roll->currentText(), field->getElementNames().indexOf("Roll")); + field->setValue(m_config->fmsSsPos3Pitch->currentText(), field->getElementNames().indexOf("Pitch")); + field->setValue(m_config->fmsSsPos3Yaw->currentText(), field->getElementNames().indexOf("Yaw")); + // ... and send to the OP Board obj->updated(); @@ -838,6 +904,21 @@ void ConfigServoWidget::updateChannels(UAVObject* controlCommand) } firstUpdate = true; } + //Update the Flight mode channel slider + UAVObject* obj = getObjectManager()->getObject("ManualControlSettings"); + // Find the channel currently assigned to flightmode + field = obj->getField("FlightMode"); + int chIndex = field->getOptions().indexOf(field->getValue().toString()); + if ( chIndex < field->getOptions().length()) { + int chMin = inSliders.at(chIndex)->minimum(); + int chMax = inSliders.at(chIndex)->maximum(); + if ((chMax-chMin) > 0) { + int val = controlCommand->getField("Channel")->getValue(chIndex).toInt(); + int chCur = (val-chMin)*100/(chMax-chMin); + m_config->fmsSlider->setValue(chCur); + } + } + } diff --git a/ground/src/plugins/config/configservowidget.h b/ground/src/plugins/config/configservowidget.h index c45388d83..7f8be7b08 100644 --- a/ground/src/plugins/config/configservowidget.h +++ b/ground/src/plugins/config/configservowidget.h @@ -55,6 +55,7 @@ private: int mccDataRate; UAVObject::Metadata accInitialData; QList outSliders; + QList inSliders; QList outMin; QList outMax; QList reversals; diff --git a/ground/src/plugins/config/settingswidget.ui b/ground/src/plugins/config/settingswidget.ui index 2ef501f9c..fc3e18dd6 100644 --- a/ground/src/plugins/config/settingswidget.ui +++ b/ground/src/plugins/config/settingswidget.ui @@ -23,7 +23,7 @@ - 1 + 2 @@ -1658,7 +1658,7 @@ p, li { white-space: pre-wrap; } - 480 + 490 310 93 27 @@ -1675,7 +1675,7 @@ Applies and Saves all settings to SD - 260 + 270 310 93 27 @@ -1691,7 +1691,7 @@ Applies and Saves all settings to SD - 370 + 380 310 93 27 @@ -2115,6 +2115,394 @@ p, li { white-space: pre-wrap; } + + + Flight Mode Switch Settings + + + + + 10 + 10 + 331 + 17 + + + + Setup the behaviour of the flight mode switch: + + + + + false + + + + 60 + 70 + 20 + 231 + + + + This slider moves when you move the flight mode switch +on your remote. Setup the flightmode channel on the RC Input tab +if you have not done so already. + + + 100 + + + Qt::Vertical + + + QSlider::TicksBelow + + + 33 + + + + + + 120 + 50 + 41 + 17 + + + + + 75 + true + + + + Mode + + + + + + 100 + 100 + 89 + 31 + + + + + + + 100 + 170 + 89 + 31 + + + + + + + 100 + 240 + 89 + 31 + + + + + + + 210 + 40 + 361 + 251 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 20 + 40 + 62 + 17 + + + + Roll + + + + + + 140 + 40 + 62 + 17 + + + + Pitch + + + + + + 260 + 40 + 62 + 17 + + + + Yaw + + + + + + 10 + 60 + 89 + 31 + + + + + + + 130 + 60 + 89 + 31 + + + + + + + 250 + 60 + 89 + 31 + + + + + + + 10 + 130 + 89 + 31 + + + + + + + 130 + 130 + 89 + 31 + + + + + + + 250 + 130 + 89 + 31 + + + + + + + 10 + 200 + 89 + 31 + + + + + + + 130 + 200 + 89 + 31 + + + + + + + 250 + 200 + 89 + 31 + + + + + + + 20 + 10 + 191 + 17 + + + + + 75 + true + + + + Stabilization Settings + + + + + + + 10 + 110 + 62 + 17 + + + + Pos. 3 + + + + + + 10 + 180 + 62 + 17 + + + + Pos. 2 + + + + + + 10 + 240 + 62 + 17 + + + + Pos. 1 + + + + + + 270 + 310 + 93 + 27 + + + + Retrieve settings from OpenPilot + + + Get Current + + + + + + 380 + 310 + 93 + 27 + + + + Send to OpenPilot but don't write in SD. +Be sure to set the Neutral position on all sliders before sending! + + + Save to RAM + + + + + + 490 + 310 + 93 + 27 + + + + Be sure to set the Neutral position on all sliders before sending! +Applies and Saves all settings to SD + + + Save to SD + + + + + + 10 + 310 + 201 + 17 + + + + + 75 + true + + + + Warning: avoid "Manual" + + + + + + 10 + 330 + 201 + 17 + + + + + 75 + true + + + + for multirotors! + + +