diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 84378e342..0640c639b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -358,7 +358,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) // rudder channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); // ailerons channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; @@ -542,13 +542,13 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) // First Vtail servo setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, -pitch); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yaw); // Second Vtail servo channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yaw); } m_aircraft->fwStatusLabel->setText("Mixer generated"); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index d39ce03a2..ebafdea31 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -216,7 +216,7 @@ void OutputCalibrationPage::setupVehicle() case SetupWizard::FIXED_WING_AILERON: loadSVGFile(FIXEDWING_SVG_FILE); m_wizardIndexes << 0 << 1 << 2 << 2 << 2; - m_vehicleElementIds << "aileron-single" << "ail2-frame" << "ail2-motor" << "ail2-aileron" << "ail2-elevator" << "ail2-rudder"; + m_vehicleElementIds << "singleaileron" << "singleaileron-frame" << "singleaileron-motor" << "singleaileron-aileron" << "singleaileron-elevator" << "singleaileron-rudder"; m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO << SERVO << SERVO; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4; m_channelIndex << 0 << 2 << 0 << 1 << 3; @@ -298,6 +298,7 @@ void OutputCalibrationPage::setupVehicle() void OutputCalibrationPage::setupVehicleItems() { m_vehicleItems.clear(); + m_arrowsItems.clear(); m_vehicleBoundsItem = new QGraphicsSvgItem(); m_vehicleBoundsItem->setSharedRenderer(m_vehicleRenderer); m_vehicleBoundsItem->setElementId(m_vehicleElementIds[0]); @@ -319,6 +320,46 @@ void OutputCalibrationPage::setupVehicleItems() m_vehicleScene->addItem(item); m_vehicleItems << item; + + bool addArrows = false; + + if ((m_vehicleElementIds[i].contains("left")) || (m_vehicleElementIds[i].contains("right")) + || (m_vehicleElementIds[i].contains("elevator")) || (m_vehicleElementIds[i].contains("rudder")) + || (m_vehicleElementIds[i].contains("steering")) || (m_vehicleElementIds[i] == "singleaileron-aileron")) { + addArrows = true; + } + + if (addArrows) { + QString arrowUp = "-up"; // right if rudder / steering + QString arrowDown = "-down"; // left + + QGraphicsSvgItem *itemUp = new QGraphicsSvgItem(); + + itemUp->setSharedRenderer(m_vehicleRenderer); + QString elementUp = m_vehicleElementIds[i] + arrowUp; + itemUp->setElementId(elementUp); + itemUp->setZValue(i + 10); + itemUp->setOpacity(0); + + QRectF itemBounds = m_vehicleRenderer->boundsOnElement(elementUp); + itemUp->setPos(itemBounds.x() - parentBounds.x(), itemBounds.y() - parentBounds.y()); + m_vehicleScene->addItem(itemUp); + + m_arrowsItems << itemUp; + + QGraphicsSvgItem *itemDown = new QGraphicsSvgItem(); + itemDown->setSharedRenderer(m_vehicleRenderer); + QString elementDown = m_vehicleElementIds[i] + arrowDown; + itemDown->setElementId(elementDown); + itemDown->setZValue(i + 10); + itemDown->setOpacity(0); + + itemBounds = m_vehicleRenderer->boundsOnElement(elementDown); + itemDown->setPos(itemBounds.x() - parentBounds.x(), itemBounds.y() - parentBounds.y()); + m_vehicleScene->addItem(itemDown); + + m_arrowsItems << itemDown; + } } } @@ -345,6 +386,24 @@ void OutputCalibrationPage::setupVehicleHighlightedPart() } } +void OutputCalibrationPage::showElementMovement(bool isUp, qreal value) +{ + QString highlightedItemName = m_vehicleItems[m_currentWizardIndex]->elementId(); + + for (int i = 0; i < m_arrowsItems.size(); i++) { + QString upItemName = highlightedItemName + "-up"; + QString downItemName = highlightedItemName + "-down"; + if (m_arrowsItems[i]->elementId() == upItemName) { + QGraphicsSvgItem *itemUp = m_arrowsItems[i]; + itemUp->setOpacity(isUp ? value : 0); + } + if (m_arrowsItems[i]->elementId() == downItemName) { + QGraphicsSvgItem *itemDown = m_arrowsItems[i]; + itemDown->setOpacity(isUp ? 0 : value); + } + } +} + void OutputCalibrationPage::setWizardPage() { qDebug() << "Wizard index: " << m_currentWizardIndex; @@ -390,6 +449,9 @@ void OutputCalibrationPage::setWizardPage() } } setupVehicleHighlightedPart(); + // Hide arrows + showElementMovement(true, 0); + showElementMovement(false, 0); } void OutputCalibrationPage::initializePage() @@ -551,6 +613,9 @@ void OutputCalibrationPage::enableServoSliders(bool enabled) ui->servoMinAngleSlider->setEnabled(enabled); ui->servoMaxAngleSlider->setEnabled(enabled); ui->reverseCheckbox->setEnabled(!enabled); + // Hide arrows + showElementMovement(true, 0); + showElementMovement(false, 0); } bool OutputCalibrationPage::checkAlarms() @@ -654,6 +719,27 @@ void OutputCalibrationPage::on_servoCenterAngleSlider_valueChanged(int position) ui->servoMaxAngleSlider->setValue(value); } } + + quint16 minValue = (ui->reverseCheckbox->isChecked()) ? ui->servoMaxAngleSlider->value() : ui->servoMinAngleSlider->value(); + quint16 maxValue = (ui->reverseCheckbox->isChecked()) ? ui->servoMinAngleSlider->value() : ui->servoMaxAngleSlider->value(); + quint16 range = maxValue - minValue; + // Reset arows + showElementMovement(true, 0); + showElementMovement(false, 0); + + // 30% "Dead band" : no arrow display + quint16 limitLow = minValue + (range * 0.35); + quint16 limitHigh = maxValue - (range * 0.35); + quint16 middle = minValue + (range / 2); + qreal arrowOpacity = 0; + if (value < limitLow) { + arrowOpacity = (qreal)(middle - value) / (qreal)(middle - minValue); + showElementMovement(ui->reverseCheckbox->isChecked(), arrowOpacity); + } else if (value > limitHigh) { + arrowOpacity = (qreal)(value - middle) / (qreal)(maxValue - middle); + showElementMovement(!ui->reverseCheckbox->isChecked(), arrowOpacity); + } + debugLogChannelValues(); } @@ -666,8 +752,8 @@ void OutputCalibrationPage::on_servoMinAngleSlider_valueChanged(int position) QList currentChannels; getCurrentChannels(currentChannels); quint16 currentChannel = currentChannels[0]; - m_actuatorSettings[currentChannel].channelMin = value; + ui->servoPWMValue->setText(tr("Output value : %1 µs (Min)").arg(value)); // Adjust neutral and max if (ui->reverseCheckbox->isChecked()) { @@ -697,8 +783,8 @@ void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position) QList currentChannels; getCurrentChannels(currentChannels); quint16 currentChannel = currentChannels[0]; - m_actuatorSettings[currentChannel].channelMax = value; + ui->servoPWMValue->setText(tr("Output value : %1 µs (Max)").arg(value)); // Adjust neutral and min if (ui->reverseCheckbox->isChecked()) { diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h index dd02fd885..f3173b012 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h @@ -78,6 +78,7 @@ private: void startWizard(); void setupVehicleItems(); void setupVehicleHighlightedPart(); + void showElementMovement(bool isUp, qreal value); void setWizardPage(); void enableButtons(bool enable); void enableServoSliders(bool enabled); @@ -98,6 +99,7 @@ private: QList m_vehicleElementIds; QList m_vehicleElementTypes; QList m_vehicleItems; + QList m_arrowsItems; QList m_vehicleHighlightElementIndexes; QList m_channelIndex; QList m_wizardIndexes; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg index c75382518..eada74c14 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg +++ b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg @@ -23,7 +23,7 @@ sodipodi:docname="fixedwing-shapes-wizard.svg">image/svg+xml6 +6 -4 - - - - -4 -4 + x="239.17444" + y="352.68146">4 \ No newline at end of file + style="fill:#414042" /> + + + +4 + \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/ground-shapes-wizard.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/ground-shapes-wizard.svg index 0c8b13289..907718a25 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/ground-shapes-wizard.svg +++ b/ground/openpilotgcs/src/plugins/setupwizard/resources/ground-shapes-wizard.svg @@ -26,7 +26,7 @@ inkscape:export-ydpi="70.479134">image/svg+xml