From c7b6341b21f8f96fb7620e4cb115dc1e0de16e6b Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 30 Oct 2010 05:15:39 +0000 Subject: [PATCH] Improvements to the ccpm curve mixing UI git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2035 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/config/ccpm.ui | 330 +++++++++--------- .../src/plugins/config/configccpmwidget.cpp | 119 ++++++- ground/src/plugins/config/configccpmwidget.h | 2 + 3 files changed, 274 insertions(+), 177 deletions(-) diff --git a/ground/src/plugins/config/ccpm.ui b/ground/src/plugins/config/ccpm.ui index d1fb75f6b..aa41d1ea0 100644 --- a/ground/src/plugins/config/ccpm.ui +++ b/ground/src/plugins/config/ccpm.ui @@ -873,68 +873,82 @@ - 22 - 11 - 661 - 501 + 10 + 10 + 670 + 390 - - - + + + - - - - 10 - - - - Select aircraft type here - + - - Linear - - - - - Flat - - - - - Step - - - - - Custom - - - - - - - - - - Number of points + + + + 10 + + + Select aircraft type here + + + + Linear + + + + + Flat + + + + + Step + + + + + Exp + + + + + Log + + + + + Custom + + - - - - 2 - - - 10 - - - 5 - - + + + + + + 2 + + + 10 + + + 5 + + + + + + + Number of points + + + + @@ -1037,101 +1051,9 @@ - - + + - - - - - - - Blade Pitch Curve - - - - - - - - - - 0 - 0 - - - - - 150 - 150 - - - - - 200 - 200 - - - - - - - - Val: 0.00 - - - - - - - - - - - - - Throttle Curve - - - - - - - - - - 0 - 0 - - - - - 150 - 150 - - - - - 200 - 200 - - - - - - - - Val: 0.00 - - - - - - - - - - @@ -1402,31 +1324,93 @@ - - - - Qt::Horizontal - - - - 40 - 10 - - - + + + + + + + + Throttle Curve + + + + + + + + + + 0 + 0 + + + + + 150 + 150 + + + + + 200 + 200 + + + + + + + + Val: 0.00 + + + + - - - - Qt::Vertical - - - - 20 - 10 - - - + + + + + + + + Blade Pitch Curve + + + + + + + + + + 0 + 0 + + + + + 150 + 150 + + + + + 200 + 200 + + + + + + + + Val: 0.00 + + + + diff --git a/ground/src/plugins/config/configccpmwidget.cpp b/ground/src/plugins/config/configccpmwidget.cpp index 36791ab75..4f0456ddd 100644 --- a/ground/src/plugins/config/configccpmwidget.cpp +++ b/ground/src/plugins/config/configccpmwidget.cpp @@ -109,6 +109,10 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) m_ccpm->SwashplateImage->scene()->addItem(ServoZText); + resetMixer(m_ccpm->PitchCurve, 5); + resetMixer(m_ccpm->ThrottleCurve, 5); + + @@ -145,6 +149,7 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) //connect(m_ccpm->getccpmCurrent, SIGNAL(clicked()), this, SLOT(requestccpmUpdate())); connect(m_ccpm->ccpmGenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve())); connect(m_ccpm->NumCurvePoints, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurveSettings())); + connect(m_ccpm->CurveToGenerate, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCurveSettings())); connect(m_ccpm->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCurveSettings())); connect(m_ccpm->ccpmAngleW, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); connect(m_ccpm->ccpmAngleX, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); @@ -163,12 +168,14 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) connect(m_ccpm->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); connect(m_ccpm->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); connect(m_ccpm->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); + connect(m_ccpm->CurveSettings, SIGNAL(cellChanged (int, int)), this, SLOT(UpdateCurveWidgets())); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestccpmUpdate())); + + // connect(parent, SIGNAL(autopilotConnected()),this, SLOT(requestccpmUpdate())); } @@ -215,7 +222,7 @@ void ConfigccpmWidget::UpdateType() m_ccpm->CurveToGenerate->setEnabled(1); m_ccpm->CurveSettings->setColumnHidden(1,0); - m_ccpm->widget_2->setVisible(1); + m_ccpm->PitchCurve->setVisible(1); m_ccpm->customThrottleCurve2Value->setVisible(1); m_ccpm->label_41->setVisible(1); @@ -280,7 +287,7 @@ void ConfigccpmWidget::UpdateType() m_ccpm->CurveToGenerate->setCurrentIndex(0); m_ccpm->CurveToGenerate->setEnabled(0); m_ccpm->CurveSettings->setColumnHidden(1,1); - m_ccpm->widget_2->setVisible(0); + m_ccpm->PitchCurve->setVisible(0); m_ccpm->customThrottleCurve2Value->setVisible(0); m_ccpm->label_41->setVisible(0); } @@ -292,6 +299,43 @@ void ConfigccpmWidget::UpdateType() } +/** + Resets a mixer curve + */ +void ConfigccpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements) +{ + QList curveValues; + for (double i=0; iinitCurve(curveValues); +} + +void ConfigccpmWidget::UpdateCurveWidgets() +{ + int NumCurvePoints,i; + QList curveValues; + //get the user settings + NumCurvePoints=m_ccpm->NumCurvePoints->value(); + + curveValues.clear(); + for (i=0; iCurveSettings->item(i, 0 )->text().toDouble()); + } + // Setup all Throttle1 curves for all types of airframes + m_ccpm->ThrottleCurve->initCurve(curveValues); + + curveValues.clear(); + for (i=0; iCurveSettings->item(i, 1 )->text().toDouble()); + } + // Setup all Throttle1 curves for all types of airframes + m_ccpm->PitchCurve->initCurve(curveValues); +} + @@ -314,6 +358,28 @@ void ConfigccpmWidget::UpdateCurveSettings() } m_ccpm->CurveSettings->setVerticalHeaderLabels( vertHeaders ); + if (m_ccpm->CurveToGenerate->currentIndex()==0) + { + m_ccpm->CurveValue1->setMinimum(0.0); + m_ccpm->CurveValue2->setMinimum(0.0); + m_ccpm->CurveValue3->setMinimum(0.0); + } + else + { + m_ccpm->CurveValue1->setMinimum(-1.0); + m_ccpm->CurveValue2->setMinimum(-1.0); + m_ccpm->CurveValue3->setMinimum(0.0); + } + m_ccpm->CurveValue1->setMaximum(1.0); + m_ccpm->CurveValue2->setMaximum(1.0); + m_ccpm->CurveValue3->setMaximum(100.0); + m_ccpm->CurveValue1->setSingleStep(0.1); + m_ccpm->CurveValue2->setSingleStep(0.1); + m_ccpm->CurveValue3->setSingleStep(1.0); + m_ccpm->CurveValue1->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);; + m_ccpm->CurveValue2->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue); + m_ccpm->CurveValue3->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue); + if ( CurveType.compare("Flat")==0) { m_ccpm->CurveLabel1->setText("Value"); @@ -353,6 +419,42 @@ void ConfigccpmWidget::UpdateCurveSettings() m_ccpm->ccpmGenerateCurve->setVisible(true); m_ccpm->CurveToGenerate->setVisible(true); } + if ( CurveType.compare("Exp")==0) + { + m_ccpm->CurveLabel1->setText("Min"); + m_ccpm->CurveLabel1->setVisible(true); + m_ccpm->CurveValue1->setVisible(true); + m_ccpm->CurveLabel2->setText("Max"); + m_ccpm->CurveLabel2->setVisible(true); + m_ccpm->CurveValue2->setVisible(true); + m_ccpm->CurveLabel3->setText("Strength"); + m_ccpm->CurveLabel3->setVisible(true); + m_ccpm->CurveValue3->setVisible(true); + m_ccpm->CurveValue3->setMinimum(1.0); + m_ccpm->CurveValue3->setMaximum(100.0); + m_ccpm->CurveValue3->setSingleStep(1.0); + m_ccpm->CurveValue3->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);; + m_ccpm->ccpmGenerateCurve->setVisible(true); + m_ccpm->CurveToGenerate->setVisible(true); + } + if ( CurveType.compare("Log")==0) + { + m_ccpm->CurveLabel1->setText("Min"); + m_ccpm->CurveLabel1->setVisible(true); + m_ccpm->CurveValue1->setVisible(true); + m_ccpm->CurveLabel2->setText("Max"); + m_ccpm->CurveLabel2->setVisible(true); + m_ccpm->CurveValue2->setVisible(true); + m_ccpm->CurveLabel3->setText("Strength"); + m_ccpm->CurveLabel3->setVisible(true); + m_ccpm->CurveValue3->setVisible(true); + m_ccpm->CurveValue3->setMinimum(1.0); + m_ccpm->CurveValue3->setMaximum(100.0); + m_ccpm->CurveValue3->setSingleStep(1.0); + m_ccpm->CurveValue3->setCorrectionMode(QAbstractSpinBox::CorrectToNearestValue);; + m_ccpm->ccpmGenerateCurve->setVisible(true); + m_ccpm->CurveToGenerate->setVisible(true); + } if ( CurveType.compare("Custom")==0) { m_ccpm->CurveLabel1->setVisible(false); @@ -365,6 +467,7 @@ void ConfigccpmWidget::UpdateCurveSettings() m_ccpm->CurveToGenerate->setVisible(false); } + } void ConfigccpmWidget::GenerateCurve() { @@ -408,13 +511,21 @@ void ConfigccpmWidget::GenerateCurve() item->setText( tr( "%1" ).arg(value2) ); } } + if ( CurveType.compare("Exp")==0) + { + item->setText( tr( "%1" ).arg(value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1))) ); + } + if ( CurveType.compare("Log")==0) + { + item->setText( tr( "%1" ).arg(value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1))) ); + } } for (i=NumCurvePoints;i<10;i++) { item =m_ccpm->CurveSettings->item(i, CurveToGenerate ); item->setText( tr( "" ) ); } - + UpdateCurveWidgets(); } diff --git a/ground/src/plugins/config/configccpmwidget.h b/ground/src/plugins/config/configccpmwidget.h index f7534e83f..3c060136d 100644 --- a/ground/src/plugins/config/configccpmwidget.h +++ b/ground/src/plugins/config/configccpmwidget.h @@ -68,6 +68,8 @@ private: void GenerateCurve(); void UpdateMixer(); void UpdateType(); + void resetMixer(MixerCurveWidget *mixer, int numElements); + void UpdateCurveWidgets(); public slots: void requestccpmUpdate(); void sendccpmUpdate();