mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
Improvements to the ccpm curve mixing UI
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2035 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
dbe20a7eab
commit
c7b6341b21
@ -873,68 +873,82 @@
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>22</x>
|
||||
<y>11</y>
|
||||
<width>661</width>
|
||||
<height>501</height>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>670</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="CurveType">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select aircraft type here</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Number of points</string>
|
||||
<widget class="QComboBox" name="CurveType">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select aircraft type here</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Exp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Log</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="NumCurvePoints">
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="NumCurvePoints">
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Number of points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -1037,101 +1051,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_18">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="text">
|
||||
<string>Blade Pitch Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MixerCurveWidget" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="customThrottleCurve2Value">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_39">
|
||||
<property name="text">
|
||||
<string>Throttle Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MixerCurveWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="customThrottleCurve1Value">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="CurveSettings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -1402,31 +1324,93 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_39">
|
||||
<property name="text">
|
||||
<string>Throttle Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MixerCurveWidget" name="ThrottleCurve" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="customThrottleCurve1Value">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_18">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="text">
|
||||
<string>Blade Pitch Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MixerCurveWidget" name="PitchCurve" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="customThrottleCurve2Value">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
@ -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<double> curveValues;
|
||||
for (double i=0; i<numElements; i++) {
|
||||
curveValues.append(i/(numElements-1));
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
mixer->initCurve(curveValues);
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::UpdateCurveWidgets()
|
||||
{
|
||||
int NumCurvePoints,i;
|
||||
QList<double> curveValues;
|
||||
//get the user settings
|
||||
NumCurvePoints=m_ccpm->NumCurvePoints->value();
|
||||
|
||||
curveValues.clear();
|
||||
for (i=0; i<NumCurvePoints; i++)
|
||||
{
|
||||
curveValues.append(m_ccpm->CurveSettings->item(i, 0 )->text().toDouble());
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
m_ccpm->ThrottleCurve->initCurve(curveValues);
|
||||
|
||||
curveValues.clear();
|
||||
for (i=0; i<NumCurvePoints; i++)
|
||||
{
|
||||
curveValues.append(m_ccpm->CurveSettings->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();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user