1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merge branch 'laurent/OP-1698_Easy_setup_channel_passtrough' into next

This commit is contained in:
Laurent Lalanne 2015-02-07 19:02:19 +01:00
commit 21fe64eec0
5 changed files with 546 additions and 118 deletions

View File

@ -511,7 +511,7 @@ Typical value is 50% for + or X configuration on quads.</string>
<property name="title">
<string>Motor output channels</string>
</property>
<layout class="QGridLayout" name="gridLayout_7" columnstretch="1,1,0,0,1">
<layout class="QGridLayout" name="gridLayout_7" columnstretch="1,1,0,0,1,0,0">
<property name="leftMargin">
<number>9</number>
</property>
@ -524,61 +524,41 @@ Typical value is 50% for + or X configuration on quads.</string>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0" rowspan="5">
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="6" rowspan="5">
<layout class="QGridLayout" name="gridLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<property name="leftMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="MotorOutputLabel1_2">
<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>1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="multiMotorChannelBox1">
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<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>2</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="multiMotorChannelBox2">
<widget class="QComboBox" name="rcOutputChannelBox1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
<string>Select output channel for Accessory0 RcInput</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<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);
@ -587,19 +567,30 @@ font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>3</string>
<string>Accessory1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="multiMotorChannelBox3">
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
<string>RcOutput channels</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<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);
@ -608,19 +599,204 @@ font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>4</string>
<string>RC Output</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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>Accessory0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<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="multiMotorChannelBox4">
<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>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
<string>Select output channel for Accessory2 RcInput</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="rcOutputChannelBox2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Select output channel for Accessory1 RcInput</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<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>Accessory2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="toolTip">
<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>
</layout>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</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>Tricopter Yaw Servo channel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="5">
<layout class="QFormLayout" name="formLayout_5">
<property name="sizeConstraint">
@ -749,7 +925,143 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="2" column="4">
<item row="1" column="4">
<widget class="QComboBox" name="triYawChannelBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="5">
<layout class="QFormLayout" name="formLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="MotorOutputLabel1_2">
<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>1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="multiMotorChannelBox1">
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<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>2</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="multiMotorChannelBox2">
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<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>3</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="multiMotorChannelBox3">
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_15">
<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>4</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="multiMotorChannelBox4">
<property name="toolTip">
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="5" rowspan="5">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="MultirotorRevMixerCheckBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Reverse all motors</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -778,61 +1090,6 @@ margin:1px;</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="triYawChannelBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</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>Tricopter Yaw Servo channel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="MultirotorRevMixerCheckBox">
<property name="text">
<string>Reverse all motors</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -110,6 +110,17 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions()
if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.TRIYaw - 1] = QString("Tri-Yaw");
}
if (multi.Accessory0 > 0 && multi.Accessory0 <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.Accessory0 - 1] = QString("Accessory0");
}
if (multi.Accessory1 > 0 && multi.Accessory1 <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.Accessory1 - 1] = QString("Accessory1");
}
if (multi.Accessory2 > 0 && multi.Accessory2 <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
channelDesc[multi.Accessory2 - 1] = QString("Accessory2");
}
return channelDesc;
}
@ -120,6 +131,12 @@ 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);
@ -151,6 +168,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
m_aircraft->multiThrottleCurve->setXAxisLabel(tr("Input"));
m_aircraft->multiThrottleCurve->setYAxisLabel(tr("Output"));
updateEnableControls();
}
@ -319,6 +337,12 @@ void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent)
parent.addWidget(m_aircraft->mrYawMixLevel);
parent.addWidget(m_aircraft->triYawChannelBox);
parent.addWidget(m_aircraft->MultirotorRevMixerCheckBox);
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)
@ -342,6 +366,46 @@ void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
configData->multi.VTOLMotorNNW = 0;
}
void ConfigMultiRotorWidget::resetRcOutputs(GUIConfigDataUnion *configData)
{
configData->multi.Accessory0 = 0;
configData->multi.Accessory1 = 0;
configData->multi.Accessory2 = 0;
}
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++) {
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);
}
}
}
/**
Helper function to refresh the UI widget values
*/
@ -457,6 +521,12 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->triYawChannelBox, multi.TRIYaw);
}
setComboCurrentIndex(m_aircraft->rcOutputChannelBox1, multi.Accessory0);
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"));
@ -476,6 +546,13 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
Q_ASSERT(mixer);
// Reset all Mixers
resetMixers();
QList<QString> rcOutputList;
rcOutputList << "Accessory0" << "Accessory1" << "Accessory2";
setupRcOutputs(rcOutputList);
// Curve is also common to all quads:
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve());
@ -731,7 +808,6 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
m_aircraft->mrStatusLabel->setText(tr("Configuration OK"));
}
return airframeType;
}
@ -816,6 +892,62 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw * 127);
}
/**
Helper function: setup rc outputs. Takes a list of channel names in input.
*/
void ConfigMultiRotorWidget::setupRcOutputs(QList<QString> rcOutputList)
{
QList<QComboBox *> rcList;
rcList << m_aircraft->rcOutputChannelBox1 << m_aircraft->rcOutputChannelBox2 << m_aircraft->rcOutputChannelBox3;
GUIConfigDataUnion configData = getConfigData();
resetRcOutputs(&configData);
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);
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);
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);
if (curveAccessory2) {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
} else {
setMixerVectorValue(mixer, index - 1, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
}
}
}
}
setConfigData(configData);
}
/**
Helper function: setup motors. Takes a list of channel names in input.
*/
@ -1052,10 +1184,11 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
{
// Initialize configuration error flag
bool error = false;
QString channelNames = "";
// Iterate through all instances of multiMotorChannelBox
for (int i = 0; i < numMotors; i++) {
// Fine widgets with text "multiMotorChannelBox.x", where x is an integer
// Find widgets with his name "multiMotorChannelBox.x", where x is an integer
QComboBox *combobox = this->findChild<QComboBox *>("multiMotorChannelBox" + QString::number(i + 1));
if (combobox) {
if (combobox->currentText() == "None") {
@ -1064,9 +1197,40 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
pixmap.fill(QColor("red"));
combobox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true;
} else if (channelNames.contains(combobox->currentText(), Qt::CaseInsensitive)) {
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size, size);
pixmap.fill(QColor("orange"));
combobox->setItemData(combobox->currentIndex(), pixmap, Qt::DecorationRole); // Set color palettes
combobox->setToolTip(tr("Duplicate channel in motor outputs"));
} else {
combobox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
for (int index = 0; index < (int)ConfigMultiRotorWidget::CHANNEL_NUMELEM; index++) {
combobox->setItemData(index, 0, Qt::DecorationRole); // Reset all color palettes
combobox->setToolTip("");
}
}
channelNames += (combobox->currentText() == "None") ? "" : combobox->currentText();
}
}
// Iterate through all instances of rcOutputChannelBox
for (int i = 0; i < 3; i++) {
// Find widgets with his name "rcOutputChannelBox.x", where x is an integer
QComboBox *combobox = this->findChild<QComboBox *>("rcOutputChannelBox" + QString::number(i + 1));
if (combobox) {
if (channelNames.contains(combobox->currentText(), Qt::CaseInsensitive)) {
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size, size);
pixmap.fill(QColor("orange"));
combobox->setItemData(combobox->currentIndex(), pixmap, Qt::DecorationRole); // Set color palettes
combobox->setToolTip(tr("Channel already used"));
} else {
for (int index = 0; index < (int)ConfigMultiRotorWidget::CHANNEL_NUMELEM; index++) {
combobox->setItemData(index, 0, Qt::DecorationRole); // Reset all color palettes
combobox->setToolTip(tr("Select output channel for Accessory%1 RcInput").arg(i));
}
}
channelNames += (combobox->currentText() == "None") ? "" : combobox->currentText();
}
}

View File

@ -65,16 +65,19 @@ private:
virtual void registerWidgets(ConfigTaskWidget &parent);
virtual void resetActuators(GUIConfigDataUnion *configData);
virtual void resetRcOutputs(GUIConfigDataUnion *configData);
bool setupQuad(bool pLayout);
bool setupHexa(bool pLayout);
bool setupOcto();
bool setupMultiRotorMixer(double mixerFactors[8][3]);
void setupMotors(QList<QString> motorList);
void setupRcOutputs(QList<QString> rcOutputList);
void resetMixers();
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
void setYawMixLevel(int);
void updateRcCurvesUsed();
void updateAirframe(QString multiRotorType);
void setupEnabledControls(QString multiRotorType);

View File

@ -52,7 +52,10 @@ typedef struct {
uint VTOLMotorWNW : 4;
uint VTOLMotorNNW : 4; // 64 bits
uint TRIYaw : 4;
quint32 padding : 28; // 96 bits
uint Accessory0 : 4;
uint Accessory1 : 4;
uint Accessory2 : 4;
quint32 padding : 16; // 96 bits
quint32 padding1; // 128 bits
} __attribute__((packed)) multiGUISettingsStruct;

View File

@ -94,6 +94,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
case SystemSettings::AIRFRAMETYPE_HEXAX:
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
case SystemSettings::AIRFRAMETYPE_HEXA:
case SystemSettings::AIRFRAMETYPE_HEXAH:
// multirotor
channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
break;