1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-1698 Add curve choice for all accessory outputs

This commit is contained in:
Laurent Lalanne 2015-02-01 14:59:18 +01:00
parent 8c0a33cd6f
commit f18aa3d2cb
3 changed files with 144 additions and 63 deletions

View File

@ -525,28 +525,38 @@ Typical value is 50% for + or X configuration on quads.</string>
<number>9</number>
</property>
<item row="0" column="6" rowspan="5">
<layout class="QFormLayout" name="formLayout">
<layout class="QGridLayout" name="gridLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="leftMargin">
<number>10</number>
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="1" column="1">
<widget class="QComboBox" name="rcOutputChannelBox1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Select output channel for Accessory0 RcInput</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>90</width>
<height>16</height>
<height>0</height>
</size>
</property>
<property name="styleSheet">
@ -557,7 +567,7 @@ font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>RC Input</string>
<string>Accessory1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -625,8 +635,37 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="rcOutputChannelBox1">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>90</width>
<height>16</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>RC Input</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="rcOutputChannelBox3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -640,30 +679,7 @@ margin:1px;</string>
</size>
</property>
<property name="toolTip">
<string>Select output channel for Accessory0 RcInput</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>Accessory1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<string>Select output channel for Accessory2 RcInput</string>
</property>
</widget>
</item>
@ -709,22 +725,44 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="rcOutputChannelBox3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="toolTip">
<string>Select output channel for Accessory2 RcInput</string>
<string>RcOutput curve</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>Curve</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="rcOutputCurveBox1">
<property name="toolTip">
<string>Select output curve for Accessory0 RcInput</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="rcOutputCurveBox2">
<property name="toolTip">
<string>Select output curve for Accessory1 RcInput</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="rcOutputCurveBox3">
<property name="toolTip">
<string>Select output curve for Accessory2 RcInput</string>
</property>
</widget>
</item>

View File

@ -131,6 +131,13 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
populateChannelComboBoxes();
QStringList mixerCurveList;
mixerCurveList << "Curve1" << "Curve2";
m_aircraft->rcOutputCurveBox1->addItems(mixerCurveList);
m_aircraft->rcOutputCurveBox2->addItems(mixerCurveList);
m_aircraft->rcOutputCurveBox3->addItems(mixerCurveList);
// Setup the Multirotor picture in the Quad settings interface
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -162,6 +169,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
m_aircraft->multiThrottleCurve->setXAxisLabel(tr("Input"));
m_aircraft->multiThrottleCurve->setYAxisLabel(tr("Output"));
updateEnableControls();
}
@ -333,6 +341,9 @@ void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent)
parent.addWidget(m_aircraft->rcOutputChannelBox1);
parent.addWidget(m_aircraft->rcOutputChannelBox2);
parent.addWidget(m_aircraft->rcOutputChannelBox3);
parent.addWidget(m_aircraft->rcOutputCurveBox1);
parent.addWidget(m_aircraft->rcOutputCurveBox2);
parent.addWidget(m_aircraft->rcOutputCurveBox3);
}
void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
@ -366,16 +377,31 @@ void ConfigMultiRotorWidget::resetRcOutputs(GUIConfigDataUnion *configData)
void ConfigMultiRotorWidget::resetMixers()
{
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
for (int channel = 0; channel < (int)ConfigMultiRotorWidget::CHANNEL_NUMELEM; channel++) {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 0);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 0);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 0);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 0);
resetMixerVector(mixer, channel);
}
}
void ConfigMultiRotorWidget::updateRcCurvesUsed()
{
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox1, VehicleConfig::MIXER_THROTTLECURVE1);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox2, VehicleConfig::MIXER_THROTTLECURVE1);
setComboCurrentIndex(m_aircraft->rcOutputCurveBox3, VehicleConfig::MIXER_THROTTLECURVE1);
for (int channel = 0; channel < (int)ConfigMultiRotorWidget::CHANNEL_NUMELEM; channel++) {
QString mixerType = getMixerType(mixer, channel);
if (mixerType == "Accessory0" && getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)) {
setComboCurrentIndex(m_aircraft->rcOutputCurveBox1, VehicleConfig::MIXER_THROTTLECURVE2);
} else if (mixerType == "Accessory1" && getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)) {
setComboCurrentIndex(m_aircraft->rcOutputCurveBox2, VehicleConfig::MIXER_THROTTLECURVE2);
} else if (mixerType == "Accessory2" && getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)) {
setComboCurrentIndex(m_aircraft->rcOutputCurveBox3, VehicleConfig::MIXER_THROTTLECURVE2);
}
}
}
@ -498,6 +524,8 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->rcOutputChannelBox2, multi.Accessory1);
setComboCurrentIndex(m_aircraft->rcOutputChannelBox3, multi.Accessory2);
updateRcCurvesUsed();
// Now, read mixing values stored on board and applies values on sliders.
m_aircraft->mrPitchMixLevel->setValue(getMixerValue(mixer, "MixerValuePitch"));
m_aircraft->mrRollMixLevel->setValue(getMixerValue(mixer, "MixerValueRoll"));
@ -877,26 +905,41 @@ void ConfigMultiRotorWidget::setupRcOutputs(QList<QString> rcOutputList)
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
int curveAccessory0 = m_aircraft->rcOutputCurveBox1->currentIndex();
int curveAccessory1 = m_aircraft->rcOutputCurveBox2->currentIndex();
int curveAccessory2 = m_aircraft->rcOutputCurveBox3->currentIndex();
foreach(QString rc_output, rcOutputList) {
int index = rcList.takeFirst()->currentIndex();
if (rc_output == QString("Accessory0")) {
configData.multi.Accessory0 = index;
if (index) {
setMixerType(mixer, index - 1, VehicleConfig::MIXERTYPE_ACCESSORY0);
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
if (curveAccessory0) {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2 , 127);
} else {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1 , 127);
}
}
} else if (rc_output == QString("Accessory1")) {
configData.multi.Accessory1 = index;
if (index) {
setMixerType(mixer, index - 1, VehicleConfig::MIXERTYPE_ACCESSORY1);
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
if (curveAccessory1) {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2 , 127);
} else {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1 , 127);
}
}
} else if (rc_output == QString("Accessory2")) {
configData.multi.Accessory2 = index;
if (index) {
setMixerType(mixer, index - 1, VehicleConfig::MIXERTYPE_ACCESSORY2);
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
if (curveAccessory2) {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2 , 127);
} else {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1 , 127);
}
}
}
}

View File

@ -77,7 +77,7 @@ private:
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
void setYawMixLevel(int);
void updateRcCurvesUsed();
void updateAirframe(QString multiRotorType);
void setupEnabledControls(QString multiRotorType);