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

OP-190 Added support for the flightmode switch settings in the config gadget. Let me know if you like the UI!

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1945 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-10-11 19:03:27 +00:00 committed by edouard
parent 6d6ec37474
commit 1824440c8e
4 changed files with 502 additions and 29 deletions

View File

@ -589,6 +589,9 @@ void ConfigAirframeWidget::setupAirframeUI(QString frameType)
m_aircraft->multiMotor6->setEnabled(true);
m_aircraft->multiMotor7->setEnabled(true);
m_aircraft->multiMotor8->setEnabled(true);
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(33);
m_aircraft->mrYawMixLevel->setValue(12);
}
}

View File

@ -82,7 +82,14 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
<< m_config->ch5Rev
<< m_config->ch6Rev
<< m_config->ch7Rev;
inSliders << m_config->ch0Slider
<< m_config->ch1Slider
<< m_config->ch2Slider
<< m_config->ch3Slider
<< m_config->ch4Slider
<< m_config->ch5Slider
<< m_config->ch6Slider
<< m_config->ch7Slider;
// Now connect the widget to the ManualControlCommand / Channel UAVObject
@ -129,6 +136,25 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
m_config->ch6Output->addItem("None");
m_config->ch7Output->addItem("None");
// And the flight mode settings:
field = obj->getField(QString("Pos1FlightMode"));
m_config->fmsModePos1->addItems(field->getOptions());
m_config->fmsModePos2->addItems(field->getOptions());
m_config->fmsModePos3->addItems(field->getOptions());
field = obj->getField(QString("Pos1StabilizationSettings"));
channelsList.clear();
channelsList.append(field->getOptions());
m_config->fmsSsPos1Roll->addItems(channelsList);
m_config->fmsSsPos1Pitch->addItems(channelsList);
m_config->fmsSsPos1Yaw->addItems(channelsList);
m_config->fmsSsPos2Roll->addItems(channelsList);
m_config->fmsSsPos2Pitch->addItems(channelsList);
m_config->fmsSsPos2Yaw->addItems(channelsList);
m_config->fmsSsPos3Roll->addItems(channelsList);
m_config->fmsSsPos3Pitch->addItems(channelsList);
m_config->fmsSsPos3Yaw->addItems(channelsList);
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings")));
fieldList = obj->getFields();
foreach (UAVObjectField* field, fieldList) {
@ -137,7 +163,7 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
m_config->ch1Output->addItem(field->getName());
m_config->ch2Output->addItem(field->getName());
m_config->ch3Output->addItem(field->getName());
m_config->ch4Output->addItem(field->getName());
m_config->ch4Output->addItem(field->getName());
m_config->ch5Output->addItem(field->getName());
m_config->ch6Output->addItem(field->getName());
m_config->ch7Output->addItem(field->getName());
@ -161,6 +187,12 @@ ConfigServoWidget::ConfigServoWidget(QWidget *parent) : ConfigTaskWidget(parent)
connect(m_config->saveRCInputToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate()));
connect(m_config->getRCInputCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate()));
// Flightmode panel is connected to the same as rcinput because
// the underlying object is the same!
connect(m_config->saveFmsToSD, SIGNAL(clicked()), this, SLOT(saveRCInputObject()));
connect(m_config->saveFmsToRAM, SIGNAL(clicked()), this, SLOT(sendRCInputUpdate()));
connect(m_config->getFmsCurrent, SIGNAL(clicked()), this, SLOT(requestRCInputUpdate()));
connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject()));
connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate()));
connect(m_config->getRCOutputCurrent, SIGNAL(clicked()), this, SLOT(requestRCOutputUpdate()));
@ -197,17 +229,8 @@ void ConfigServoWidget::sendChannelTest(int value)
if (!m_config->channelOutTest->isChecked())
return;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorCommand")));
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorCommand")));
/*
QStringList channelsList;
channelsList << "ch0OutSlider" << "ch1OutSlider" << "ch2OutSlider" << "ch3OutSlider" << "ch4OutSlider"
<< "ch5OutSlider" << "ch6OutSlider" << "ch7OutSlider";
int idx = channelsList.indexOf(QRegExp(ob->objectName()));
*/
UAVObjectField * channel = obj->getField("Channel");
channel->setValue(value,index);
obj->updated();
@ -485,10 +508,6 @@ void ConfigServoWidget::reverseChannel(bool state)
}
/********************************
* Input settings
*******************************/
@ -498,9 +517,7 @@ void ConfigServoWidget::reverseChannel(bool state)
*/
void ConfigServoWidget::requestRCInputUpdate()
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ManualControlSettings")));
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlSettings")));
Q_ASSERT(obj);
obj->requestUpdate();
@ -569,7 +586,6 @@ void ConfigServoWidget::requestRCInputUpdate()
m_config->ch6Assign->setCurrentIndex(0);
m_config->ch7Assign->setCurrentIndex(0);
// Update all channels assignements
QList<UAVObjectField*> fieldList = obj->getFields();
foreach (UAVObjectField* field, fieldList) {
@ -578,6 +594,35 @@ void ConfigServoWidget::requestRCInputUpdate()
}
}
// Update all the flight mode settingsin the relevant tab
field = obj->getField(QString("Pos1FlightMode"));
m_config->fmsModePos1->setCurrentIndex((m_config->fmsModePos1->findText(field->getValue().toString())));
field = obj->getField(QString("Pos2FlightMode"));
m_config->fmsModePos2->setCurrentIndex((m_config->fmsModePos2->findText(field->getValue().toString())));
field = obj->getField(QString("Pos3FlightMode"));
m_config->fmsModePos3->setCurrentIndex((m_config->fmsModePos3->findText(field->getValue().toString())));
field = obj->getField(QString("Pos1StabilizationSettings"));
m_config->fmsSsPos1Roll->setCurrentIndex(m_config->fmsSsPos1Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos1Pitch->setCurrentIndex(m_config->fmsSsPos1Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos1Yaw->setCurrentIndex(m_config->fmsSsPos1Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
field = obj->getField(QString("Pos2StabilizationSettings"));
m_config->fmsSsPos2Roll->setCurrentIndex(m_config->fmsSsPos2Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos2Pitch->setCurrentIndex(m_config->fmsSsPos2Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos2Yaw->setCurrentIndex(m_config->fmsSsPos2Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
field = obj->getField(QString("Pos3StabilizationSettings"));
m_config->fmsSsPos3Roll->setCurrentIndex(m_config->fmsSsPos3Roll->findText(
field->getValue(field->getElementNames().indexOf("Roll")).toString()));
m_config->fmsSsPos3Pitch->setCurrentIndex(m_config->fmsSsPos3Pitch->findText(
field->getValue(field->getElementNames().indexOf("Pitch")).toString()));
m_config->fmsSsPos3Yaw->setCurrentIndex(m_config->fmsSsPos3Yaw->findText(
field->getValue(field->getElementNames().indexOf("Yaw")).toString()));
}
@ -634,11 +679,11 @@ void ConfigServoWidget::sendRCInputUpdate()
// will get the setting.
// First, reset all channel assignements:
QStringList channelsList;
channelsList << "Roll" << "Pitch" << "Yaw" << "Throttle" << "FlightMode";
foreach (QString channel, channelsList) {
field = obj->getField(channel);
field->setValue(field->getOptions().last());
QList<UAVObjectField*> fieldList = obj->getFields();
foreach (UAVObjectField* field, fieldList) {
if (field->getUnits().contains("channel")) {
field->setValue(field->getOptions().last());
}
}
// Then assign according to current GUI state:
@ -675,6 +720,27 @@ void ConfigServoWidget::sendRCInputUpdate()
field->setValue(field->getOptions().at(7));
}
// Send all the flight mode settings
field = obj->getField(QString("Pos1FlightMode"));
field->setValue(m_config->fmsModePos1->currentText());
field = obj->getField(QString("Pos2FlightMode"));
field->setValue(m_config->fmsModePos2->currentText());
field = obj->getField(QString("Pos3FlightMode"));
field->setValue(m_config->fmsModePos3->currentText());
field = obj->getField(QString("Pos1StabilizationSettings"));
field->setValue(m_config->fmsSsPos1Roll->currentText(), field->getElementNames().indexOf("Roll"));
field->setValue(m_config->fmsSsPos1Pitch->currentText(), field->getElementNames().indexOf("Pitch"));
field->setValue(m_config->fmsSsPos1Yaw->currentText(), field->getElementNames().indexOf("Yaw"));
field = obj->getField(QString("Pos2StabilizationSettings"));
field->setValue(m_config->fmsSsPos2Roll->currentText(), field->getElementNames().indexOf("Roll"));
field->setValue(m_config->fmsSsPos2Pitch->currentText(), field->getElementNames().indexOf("Pitch"));
field->setValue(m_config->fmsSsPos2Yaw->currentText(), field->getElementNames().indexOf("Yaw"));
field = obj->getField(QString("Pos3StabilizationSettings"));
field->setValue(m_config->fmsSsPos3Roll->currentText(), field->getElementNames().indexOf("Roll"));
field->setValue(m_config->fmsSsPos3Pitch->currentText(), field->getElementNames().indexOf("Pitch"));
field->setValue(m_config->fmsSsPos3Yaw->currentText(), field->getElementNames().indexOf("Yaw"));
// ... and send to the OP Board
obj->updated();
@ -838,6 +904,21 @@ void ConfigServoWidget::updateChannels(UAVObject* controlCommand)
}
firstUpdate = true;
}
//Update the Flight mode channel slider
UAVObject* obj = getObjectManager()->getObject("ManualControlSettings");
// Find the channel currently assigned to flightmode
field = obj->getField("FlightMode");
int chIndex = field->getOptions().indexOf(field->getValue().toString());
if ( chIndex < field->getOptions().length()) {
int chMin = inSliders.at(chIndex)->minimum();
int chMax = inSliders.at(chIndex)->maximum();
if ((chMax-chMin) > 0) {
int val = controlCommand->getField("Channel")->getValue(chIndex).toInt();
int chCur = (val-chMin)*100/(chMax-chMin);
m_config->fmsSlider->setValue(chCur);
}
}
}

View File

@ -55,6 +55,7 @@ private:
int mccDataRate;
UAVObject::Metadata accInitialData;
QList<QSlider*> outSliders;
QList<QSlider*> inSliders;
QList<QSpinBox*> outMin;
QList<QSpinBox*> outMax;
QList<QCheckBox*> reversals;

View File

@ -23,7 +23,7 @@
</rect>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -1658,7 +1658,7 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="saveRCOutputToSD">
<property name="geometry">
<rect>
<x>480</x>
<x>490</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -1675,7 +1675,7 @@ Applies and Saves all settings to SD</string>
<widget class="QPushButton" name="getRCOutputCurrent">
<property name="geometry">
<rect>
<x>260</x>
<x>270</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -1691,7 +1691,7 @@ Applies and Saves all settings to SD</string>
<widget class="QPushButton" name="saveRCOutputToRAM">
<property name="geometry">
<rect>
<x>370</x>
<x>380</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -2115,6 +2115,394 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Flight Mode Switch Settings</string>
</attribute>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>331</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Setup the behaviour of the flight mode switch:</string>
</property>
</widget>
<widget class="QSlider" name="fmsSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>60</x>
<y>70</y>
<width>20</width>
<height>231</height>
</rect>
</property>
<property name="toolTip">
<string>This slider moves when you move the flight mode switch
on your remote. Setup the flightmode channel on the RC Input tab
if you have not done so already.</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>33</number>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>120</x>
<y>50</y>
<width>41</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Mode</string>
</property>
</widget>
<widget class="QComboBox" name="fmsModePos3">
<property name="geometry">
<rect>
<x>100</x>
<y>100</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsModePos2">
<property name="geometry">
<rect>
<x>100</x>
<y>170</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsModePos1">
<property name="geometry">
<rect>
<x>100</x>
<y>240</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>210</x>
<y>40</y>
<width>361</width>
<height>251</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Roll</string>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Pitch</string>
</property>
</widget>
<widget class="QLabel" name="label_10">
<property name="geometry">
<rect>
<x>260</x>
<y>40</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Yaw</string>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos3Roll">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos3Pitch">
<property name="geometry">
<rect>
<x>130</x>
<y>60</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos3Yaw">
<property name="geometry">
<rect>
<x>250</x>
<y>60</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos2Roll">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos2Pitch">
<property name="geometry">
<rect>
<x>130</x>
<y>130</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos2Yaw">
<property name="geometry">
<rect>
<x>250</x>
<y>130</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos1Roll">
<property name="geometry">
<rect>
<x>10</x>
<y>200</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos1Pitch">
<property name="geometry">
<rect>
<x>130</x>
<y>200</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="fmsSsPos1Yaw">
<property name="geometry">
<rect>
<x>250</x>
<y>200</y>
<width>89</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_14">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>191</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Stabilization Settings</string>
</property>
</widget>
</widget>
<widget class="QLabel" name="label_11">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Pos. 3</string>
</property>
</widget>
<widget class="QLabel" name="label_12">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Pos. 2</string>
</property>
</widget>
<widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>10</x>
<y>240</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Pos. 1</string>
</property>
</widget>
<widget class="QPushButton" name="getFmsCurrent">
<property name="geometry">
<rect>
<x>270</x>
<y>310</y>
<width>93</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Retrieve settings from OpenPilot</string>
</property>
<property name="text">
<string>Get Current</string>
</property>
</widget>
<widget class="QPushButton" name="saveFmsToRAM">
<property name="geometry">
<rect>
<x>380</x>
<y>310</y>
<width>93</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Send to OpenPilot but don't write in SD.
Be sure to set the Neutral position on all sliders before sending!</string>
</property>
<property name="text">
<string>Save to RAM</string>
</property>
</widget>
<widget class="QPushButton" name="saveFmsToSD">
<property name="geometry">
<rect>
<x>490</x>
<y>310</y>
<width>93</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Be sure to set the Neutral position on all sliders before sending!
Applies and Saves all settings to SD</string>
</property>
<property name="text">
<string>Save to SD</string>
</property>
</widget>
<widget class="QLabel" name="label_15">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>201</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Warning: avoid &quot;Manual&quot;</string>
</property>
</widget>
<widget class="QLabel" name="label_16">
<property name="geometry">
<rect>
<x>10</x>
<y>330</y>
<width>201</width>
<height>17</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>for multirotors!</string>
</property>
</widget>
</widget>
</widget>
</widget>
<resources/>