1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-66 Fixed wing : Roll differential mixing, GUI part

This commit is contained in:
Laurent Lalanne 2015-07-29 06:38:10 +02:00
parent 31c30d752f
commit d0306f77e8
2 changed files with 118 additions and 3 deletions

View File

@ -222,7 +222,7 @@ margin:1px;</string>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<width>65</width>
<height>0</height>
</size>
</property>
@ -290,7 +290,7 @@ margin:1px;</string>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<width>65</width>
<height>0</height>
</size>
</property>
@ -326,6 +326,77 @@ margin:1px;</string>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="elevonLabel3">
<property name="minimumSize">
<size>
<width>50</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> Roll Diff</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="elevonSlider3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>65</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of Roll differential in percent</string>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="elevonSliderLabel3">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -735,5 +806,21 @@ margin:1px;</string>
</hint>
</hints>
</connection>
<connection>
<sender>elevonSlider3</sender>
<signal>valueChanged(int)</signal>
<receiver>elevonSliderLabel3</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>511</x>
<y>222</y>
</hint>
<hint type="destinationlabel">
<x>511</x>
<y>378</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -3,6 +3,7 @@
*
* @file configfixedwingwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
@ -136,9 +137,18 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonSlider1->setEnabled(false);
m_aircraft->elevonSlider2->setEnabled(false);
m_aircraft->elevonSlider3->setEnabled(true);
m_aircraft->elevonSlider1->setValue(100);
m_aircraft->elevonSlider2->setValue(100);
// Get values saved if frameType = current frameType set on board
if (field->getValue().toString() == "FixedWing") {
m_aircraft->elevonSlider3->setValue(getMixerValue(mixer, "RollDifferential"));
} else {
m_aircraft->elevonSlider3->setValue(0);
}
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
planeimg->setElementId("elevon");
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon"));
@ -157,14 +167,17 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonSlider1->setEnabled(true);
m_aircraft->elevonSlider2->setEnabled(true);
m_aircraft->elevonSlider3->setEnabled(true);
// Get values saved if frameType = current frameType set on board
if (field->getValue().toString() == "FixedWingElevon") {
m_aircraft->elevonSlider1->setValue(getMixerValue(mixer, "MixerValueRoll"));
m_aircraft->elevonSlider2->setValue(getMixerValue(mixer, "MixerValuePitch"));
m_aircraft->elevonSlider3->setValue(getMixerValue(mixer, "RollDifferential"));
} else {
m_aircraft->elevonSlider1->setValue(100);
m_aircraft->elevonSlider2->setValue(100);
m_aircraft->elevonSlider3->setValue(0);
}
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
planeimg->setElementId("vtail");
@ -187,14 +200,17 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonSlider1->setEnabled(true);
m_aircraft->elevonSlider2->setEnabled(true);
m_aircraft->elevonSlider3->setEnabled(true);
// Get values saved if frameType = current frameType set on board
if (field->getValue().toString() == "FixedWingVtail") {
m_aircraft->elevonSlider1->setValue(getMixerValue(mixer, "MixerValueYaw"));
m_aircraft->elevonSlider2->setValue(getMixerValue(mixer, "MixerValuePitch"));
m_aircraft->elevonSlider3->setValue(getMixerValue(mixer, "RollDifferential"));
} else {
m_aircraft->elevonSlider1->setValue(100);
m_aircraft->elevonSlider2->setValue(100);
m_aircraft->elevonSlider3->setValue(0);
}
}
@ -220,6 +236,7 @@ void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent)
parent.addWidget(m_aircraft->fwRudder2ChannelBox);
parent.addWidget(m_aircraft->elevonSlider1);
parent.addWidget(m_aircraft->elevonSlider2);
parent.addWidget(m_aircraft->elevonSlider3);
}
void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData)
@ -270,6 +287,7 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
// Get mixing values for GUI sliders (values stored onboard)
m_aircraft->elevonSlider3->setValue(getMixerValue(mixer, "RollDifferential"));
if (frameType == "FixedWingElevon" || frameType == "Elevon") {
m_aircraft->elevonSlider1->setValue(getMixerValue(mixer, "MixerValueRoll"));
m_aircraft->elevonSlider2->setValue(getMixerValue(mixer, "MixerValuePitch"));
@ -361,8 +379,12 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
// ailerons
setMixerValue(mixer, "FirstRollServo", m_aircraft->fwAileron1ChannelBox->currentIndex());
channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// Store differential value onboard
setMixerValue(mixer, "RollDifferential", m_aircraft->elevonSlider3->value());
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127);
@ -442,6 +464,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -yaw);
// ailerons
setMixerValue(mixer, "FirstRollServo", m_aircraft->fwAileron1ChannelBox->currentIndex());
channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// Compute mixer absolute values
@ -449,6 +472,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
roll = (double)(m_aircraft->elevonSlider1->value() * 1.27);
// Store sliders values onboard
setMixerValue(mixer, "RollDifferential", m_aircraft->elevonSlider3->value());
setMixerValue(mixer, "MixerValuePitch", m_aircraft->elevonSlider2->value());
setMixerValue(mixer, "MixerValueRoll", m_aircraft->elevonSlider1->value());
@ -511,12 +535,14 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
// ailerons
setMixerValue(mixer, "FirstRollServo", m_aircraft->fwAileron1ChannelBox->currentIndex());
channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// Roll mixer value, currently no slider (should be added for Ailerons response ?)
roll = 127;
// Store Roll fixed value onboard
// Store Roll fixed and RollDifferential values onboard
setMixerValue(mixer, "MixerValueRoll", 100);
setMixerValue(mixer, "RollDifferential", m_aircraft->elevonSlider3->value());
// First Aileron (left)
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
@ -529,6 +555,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
}
// vtail (pitch / yaw mixing)
channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// Compute mixer absolute values
@ -539,6 +566,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
setMixerValue(mixer, "MixerValuePitch", m_aircraft->elevonSlider2->value());
setMixerValue(mixer, "MixerValueYaw", m_aircraft->elevonSlider1->value());
// First Vtail servo
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, -pitch);