mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-907 step 3: more vehicle config code cleanups
This commit is contained in:
parent
14a0da076d
commit
3520a7c055
@ -285,6 +285,61 @@ void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
configData->heli.ServoIndexZ = 0;
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_UNUSED(frameType);
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex);
|
||||
|
||||
//ccpm mixing options
|
||||
m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState);
|
||||
m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState);
|
||||
m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState);
|
||||
|
||||
//correction angle
|
||||
m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle);
|
||||
|
||||
//update sliders
|
||||
m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmPitchScale->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmPitchScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmRollScale->setValue(config.heli.SliderValue2);
|
||||
m_aircraft->ccpmRollScaleBox->setValue(config.heli.SliderValue2);
|
||||
m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0);
|
||||
|
||||
//servo assignments
|
||||
setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ);
|
||||
|
||||
//throttle
|
||||
setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle);
|
||||
//tail
|
||||
setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail);
|
||||
|
||||
getMixer();
|
||||
}
|
||||
|
||||
QString ConfigCcpmWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = updateConfigObjects();
|
||||
|
||||
setMixer();
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::UpdateType()
|
||||
{
|
||||
int TypeInt, SingleServoIndex, NumServosDefined;
|
||||
@ -756,59 +811,6 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
QString ConfigCcpmWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = updateConfigObjects();
|
||||
|
||||
setMixer();
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_UNUSED(frameType);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex);
|
||||
|
||||
//ccpm mixing options
|
||||
m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState);
|
||||
m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState);
|
||||
m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState);
|
||||
|
||||
//correction angle
|
||||
m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle);
|
||||
|
||||
//update sliders
|
||||
m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmPitchScale->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmPitchScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_aircraft->ccpmRollScale->setValue(config.heli.SliderValue2);
|
||||
m_aircraft->ccpmRollScaleBox->setValue(config.heli.SliderValue2);
|
||||
m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0);
|
||||
m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0);
|
||||
|
||||
//servo assignments
|
||||
setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY);
|
||||
setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ);
|
||||
|
||||
//throttle
|
||||
setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle);
|
||||
//tail
|
||||
setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail);
|
||||
|
||||
getMixer();
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::SetUIComponentVisibilities()
|
||||
{
|
||||
m_aircraft->ccpmRevoMixingBox->setVisible(0);
|
||||
|
@ -57,7 +57,6 @@ class ConfigCcpmWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
ConfigCcpmWidget(QWidget *parent = 0);
|
||||
@ -67,7 +66,6 @@ public:
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
void getMixer();
|
||||
void setMixer();
|
||||
void saveccpmUpdate();
|
||||
@ -77,8 +75,6 @@ protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
Ui_CcpmConfigWidget *m_aircraft;
|
||||
|
||||
QGraphicsSvgItem *SwashplateImg;
|
||||
@ -100,17 +96,19 @@ private:
|
||||
SwashplateServoSettingsStruct newSwashLvlConfiguration;
|
||||
|
||||
int MixerChannelData[6];
|
||||
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
int ShowDisclaimer(int messageID);
|
||||
virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget
|
||||
|
||||
bool updatingFromHardware;
|
||||
bool updatingToHardware;
|
||||
|
||||
// TODO ?
|
||||
QString updateConfigObjects();
|
||||
|
||||
private slots:
|
||||
// TODO ?
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual bool throwConfigError(QString airframeType);
|
||||
|
||||
void ccpmSwashplateUpdate();
|
||||
@ -131,7 +129,6 @@ private slots:
|
||||
void enableSwashplateLevellingControl(bool state);
|
||||
void setSwashplateLevel(int percent);
|
||||
void SwashLvlSpinBoxChanged(int value);
|
||||
// TODO ?
|
||||
virtual void refreshValues() {}; // Not used
|
||||
};
|
||||
|
||||
|
@ -26,9 +26,6 @@
|
||||
*/
|
||||
#include "configcustomwidget.h"
|
||||
#include "mixersettings.h"
|
||||
//#include "systemsettings.h"
|
||||
//#include "actuatorsettings.h"
|
||||
//#include "actuatorcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
@ -41,7 +38,14 @@
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
//const QString ConfigCustomWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
|
||||
QStringList ConfigCustomWidget::getChannelDescriptions()
|
||||
{
|
||||
QStringList channelDesc;
|
||||
for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget())
|
||||
@ -74,83 +78,10 @@ ConfigCustomWidget::~ConfigCustomWidget()
|
||||
void ConfigCustomWidget::setupUI(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||
|
||||
for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
m_aircraft->customMixerTable->setColumnWidth(i,
|
||||
(m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ConfigCustomWidget::getChannelDescriptions()
|
||||
{
|
||||
QStringList channelDesc;
|
||||
|
||||
for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());
|
||||
|
||||
// Update the table:
|
||||
for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) {
|
||||
QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel);
|
||||
if (q->currentText() == "Disabled") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
|
||||
} else if (q->currentText() == "Motor") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
|
||||
} else if (q->currentText() == "Servo") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
|
||||
} else if (q->currentText() == "CameraRoll") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
|
||||
} else if (q->currentText() == "CameraPitch") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH);
|
||||
} else if (q->currentText() == "CameraYaw") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
|
||||
} else if (q->currentText() == "Accessory0") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
|
||||
} else if (q->currentText() == "Accessory1") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
|
||||
} else if (q->currentText() == "Accessory2") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
|
||||
} else if (q->currentText() == "Accessory3") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
|
||||
} else if (q->currentText() == "Accessory4") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
|
||||
} else if (q->currentText() == "Accessory5") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
|
||||
}
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
|
||||
m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
|
||||
m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL,
|
||||
m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH,
|
||||
m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
|
||||
m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
|
||||
}
|
||||
|
||||
return "Custom";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,6 +91,8 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
@ -219,6 +152,60 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to
|
||||
*/
|
||||
QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());
|
||||
|
||||
// Update the table:
|
||||
for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) {
|
||||
QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel);
|
||||
if (q->currentText() == "Disabled") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
|
||||
} else if (q->currentText() == "Motor") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
|
||||
} else if (q->currentText() == "Servo") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
|
||||
} else if (q->currentText() == "CameraRoll") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
|
||||
} else if (q->currentText() == "CameraPitch") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH);
|
||||
} else if (q->currentText() == "CameraYaw") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
|
||||
} else if (q->currentText() == "Accessory0") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
|
||||
} else if (q->currentText() == "Accessory1") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
|
||||
} else if (q->currentText() == "Accessory2") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
|
||||
} else if (q->currentText() == "Accessory3") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
|
||||
} else if (q->currentText() == "Accessory4") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
|
||||
} else if (q->currentText() == "Accessory5") {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
|
||||
}
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
|
||||
m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
|
||||
m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL,
|
||||
m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH,
|
||||
m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
|
||||
m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
|
||||
}
|
||||
|
||||
return "Custom";
|
||||
}
|
||||
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
@ -238,7 +225,8 @@ void ConfigCustomWidget::showEvent(QShowEvent *event)
|
||||
int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM;
|
||||
for (int i = 0; i < channelCount; i++) {
|
||||
m_aircraft->customMixerTable->setColumnWidth(i,
|
||||
(m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount);
|
||||
(m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width())
|
||||
/ channelCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +241,8 @@ void ConfigCustomWidget::resizeEvent(QResizeEvent *event)
|
||||
int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM;
|
||||
for (int i = 0; i < channelCount; i++) {
|
||||
m_aircraft->customMixerTable->setColumnWidth(i,
|
||||
(m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount);
|
||||
(m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width())
|
||||
/ channelCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ class ConfigCustomWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
ConfigCustomWidget(QWidget *parent = 0);
|
||||
@ -55,23 +54,18 @@ public:
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
Ui_CustomConfigWidget *m_aircraft;
|
||||
|
||||
private slots:
|
||||
virtual bool throwConfigError(int numMotors);
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
//signals:
|
||||
// void configurationChanged();
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual bool throwConfigError(int numMotors);
|
||||
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configfixedwingwidget.h"
|
||||
//#include "configvehicletypewidget.h"
|
||||
#include "mixersettings.h"
|
||||
#include "systemsettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
@ -41,6 +40,41 @@
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
QStringList ConfigFixedWingWidget::getChannelDescriptions()
|
||||
{
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
QStringList channelDesc;
|
||||
for (int i = 0; i < (int) (ConfigFixedWingWidget::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.fixedwing.FixedWingPitch1 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingPitch2 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingRoll1 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingRoll2 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingYaw1 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingYaw2 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2");
|
||||
}
|
||||
if (configData.fixedwing.FixedWingThrottle > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle");
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget())
|
||||
{
|
||||
@ -51,7 +85,9 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
|
||||
m_aircraft->fixedWingType->addItems(fixedWingTypes);
|
||||
|
||||
// Set default model to "Elevator aileron rudder"
|
||||
m_aircraft->fixedWingType->setCurrentIndex(0);
|
||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
||||
|
||||
setupUI(m_aircraft->fixedWingType->currentText());
|
||||
|
||||
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
|
||||
}
|
||||
@ -141,38 +177,6 @@ void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
configData->fixedwing.FixedWingThrottle = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigFixedWingWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigFixedWingWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.fixedwing.FixedWingPitch1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingPitch1-1] = QString("FixedWingPitch1");
|
||||
if (configData.fixedwing.FixedWingPitch2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingPitch2-1] = QString("FixedWingPitch2");
|
||||
if (configData.fixedwing.FixedWingRoll1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingRoll1-1] = QString("FixedWingRoll1");
|
||||
if (configData.fixedwing.FixedWingRoll2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingRoll2-1] = QString("FixedWingRoll2");
|
||||
if (configData.fixedwing.FixedWingYaw1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingYaw1-1] = QString("FixedWingYaw1");
|
||||
if (configData.fixedwing.FixedWingYaw2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingYaw2-1] = QString("FixedWingYaw2");
|
||||
if (configData.fixedwing.FixedWingThrottle > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingThrottle-1] = QString("FixedWingThrottle");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to update the UI widget objects
|
||||
*/
|
||||
@ -205,7 +209,6 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Virtual function to refresh the UI widget values
|
||||
*/
|
||||
@ -213,6 +216,8 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
|
@ -46,7 +46,6 @@ class ConfigFixedWingWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
ConfigFixedWingWidget(QWidget *parent = 0);
|
||||
@ -55,23 +54,19 @@ public:
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
private:
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
Ui_FixedWingConfigWidget *m_aircraft;
|
||||
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
bool setupFrameFixedWing(QString airframeType);
|
||||
bool setupFrameElevon(QString airframeType);
|
||||
bool setupFrameVtail(QString airframeType);
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual bool throwConfigError(QString airframeType);
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGFIXEDWINGWIDGET_H
|
||||
|
@ -41,6 +41,32 @@
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
|
||||
{
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
QStringList channelDesc;
|
||||
for (int i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.ground.GroundVehicleSteering1 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1");
|
||||
}
|
||||
if (configData.ground.GroundVehicleSteering2 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2");
|
||||
}
|
||||
if (configData.ground.GroundVehicleThrottle1 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1");
|
||||
}
|
||||
if (configData.ground.GroundVehicleThrottle2 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2");
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget())
|
||||
{
|
||||
@ -51,7 +77,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
|
||||
m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
|
||||
|
||||
// Set default model to "Turnable (car)"
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(0);
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
|
||||
|
||||
setupUI(m_aircraft->groundVehicleType->currentText());
|
||||
|
||||
@ -169,66 +195,6 @@ void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
configData->ground.GroundVehicleThrottle2 = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.ground.GroundVehicleSteering1 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1");
|
||||
}
|
||||
if (configData.ground.GroundVehicleSteering2 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2");
|
||||
}
|
||||
if (configData.ground.GroundVehicleThrottle1 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1");
|
||||
}
|
||||
if (configData.ground.GroundVehicleThrottle2 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2");
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = "GroundVehicleCar";
|
||||
|
||||
// Save the curve (common to all ground vehicle frames)
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
|
||||
// Remove Feed Forward, it is pointless on a ground vehicle:
|
||||
setMixerValue(mixer, "FeedForward", 0.0);
|
||||
|
||||
// set the throttle curves
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve());
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve());
|
||||
|
||||
// All airframe types must start with "GroundVehicle"
|
||||
if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") {
|
||||
airframeType = "GroundVehicleCar";
|
||||
setupGroundVehicleCar(airframeType);
|
||||
} else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
|
||||
airframeType = "GroundVehicleDifferential";
|
||||
setupGroundVehicleDifferential(airframeType);
|
||||
} else { // "Motorcycle"
|
||||
airframeType = "GroundVehicleMotorcycle";
|
||||
setupGroundVehicleMotorcycle(airframeType);
|
||||
}
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to refresh the UI widget values
|
||||
*/
|
||||
@ -236,6 +202,8 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType;
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
@ -315,6 +283,37 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = "GroundVehicleCar";
|
||||
|
||||
// Save the curve (common to all ground vehicle frames)
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
|
||||
// Remove Feed Forward, it is pointless on a ground vehicle:
|
||||
setMixerValue(mixer, "FeedForward", 0.0);
|
||||
|
||||
// set the throttle curves
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve());
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve());
|
||||
|
||||
// All airframe types must start with "GroundVehicle"
|
||||
if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") {
|
||||
airframeType = "GroundVehicleCar";
|
||||
setupGroundVehicleCar(airframeType);
|
||||
} else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
|
||||
airframeType = "GroundVehicleDifferential";
|
||||
setupGroundVehicleDifferential(airframeType);
|
||||
} else { // "Motorcycle"
|
||||
airframeType = "GroundVehicleMotorcycle";
|
||||
setupGroundVehicleMotorcycle(airframeType);
|
||||
}
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
/**
|
||||
Setup balancing ground vehicle.
|
||||
|
@ -54,19 +54,17 @@ public:
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
private:
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
Ui_GroundConfigWidget *m_aircraft;
|
||||
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
bool setupGroundVehicleCar(QString airframeType);
|
||||
bool setupGroundVehicleDifferential(QString airframeType);
|
||||
bool setupGroundVehicleMotorcycle(QString airframeType);
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual bool throwConfigError(QString airframeType);
|
||||
|
||||
};
|
||||
|
@ -43,6 +43,50 @@
|
||||
|
||||
const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
|
||||
|
||||
|
||||
QStringList ConfigMultiRotorWidget::getChannelDescriptions()
|
||||
{
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
QStringList channelDesc;
|
||||
for (int i = 0; i < (int) (ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++) {
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
multiGUISettingsStruct multi = configData.multi;
|
||||
|
||||
if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorN - 1] = QString("VTOLMotorN");
|
||||
}
|
||||
if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorNE - 1] = QString("VTOLMotorNE");
|
||||
}
|
||||
if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorNW - 1] = QString("VTOLMotorNW");
|
||||
}
|
||||
if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorS - 1] = QString("VTOLMotorS");
|
||||
}
|
||||
if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorSE - 1] = QString("VTOLMotorSE");
|
||||
}
|
||||
if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorSW - 1] = QString("VTOLMotorSW");
|
||||
}
|
||||
if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorW - 1] = QString("VTOLMotorW");
|
||||
}
|
||||
if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.VTOLMotorE - 1] = QString("VTOLMotorE");
|
||||
}
|
||||
if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
channelDesc[multi.TRIYaw - 1] = QString("Tri-Yaw");
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
|
||||
ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1)
|
||||
{
|
||||
@ -58,30 +102,30 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
|
||||
quad->setSharedRenderer(renderer);
|
||||
quad->setElementId("quad-x");
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
scene->addItem(quad);
|
||||
scene->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->setScene(scene);
|
||||
|
||||
//m_multirotor = new ConfigMultiRotorWidget(m_aircraft);
|
||||
//m_multirotor->quad = quad;
|
||||
uiowner = this;
|
||||
setupUI(m_aircraft->multirotorFrameType->currentText());
|
||||
//setupUI(m_aircraft->multirotorFrameType->currentText());
|
||||
|
||||
QStringList multiRotorTypes;
|
||||
multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" <<
|
||||
"Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
|
||||
"Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
|
||||
m_aircraft->multirotorFrameType->addItems(multiRotorTypes);
|
||||
|
||||
// Set default model to "Quad X"
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(2);
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
|
||||
setupUI(m_aircraft->multirotorFrameType->currentText());
|
||||
|
||||
connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
|
||||
|
||||
// Connect the multirotor motor reverse checkbox
|
||||
connect(m_aircraft->MultirotorRevMixerCheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
|
||||
|
||||
//m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
|
||||
@ -92,7 +136,6 @@ ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
|
||||
void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
Q_ASSERT(uiowner);
|
||||
Q_ASSERT(quad);
|
||||
|
||||
qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType;
|
||||
@ -106,7 +149,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
// disable all motor channel boxes
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
// do it manually so we can turn off any error decorations
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(uiowner, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox) {
|
||||
combobox->setEnabled(false);
|
||||
combobox->setItemData(0, 0, Qt::DecorationRole);
|
||||
@ -117,7 +160,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 3, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
@ -129,7 +172,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
|
||||
|
||||
// init mixer levels
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
@ -140,7 +183,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
@ -150,7 +193,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||
@ -161,7 +204,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
@ -172,7 +215,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
@ -182,7 +225,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||
@ -193,7 +236,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(25);
|
||||
m_aircraft->mrPitchMixLevel->setValue(25);
|
||||
@ -203,7 +246,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
@ -213,7 +256,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
@ -221,79 +264,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
}
|
||||
|
||||
// Draw the appropriate airframe
|
||||
drawAirframe(frameType);
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::drawAirframe(QString frameType)
|
||||
{
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType;
|
||||
|
||||
invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1;
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - invert motors" << invertMotors;
|
||||
|
||||
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("tri");
|
||||
} else {
|
||||
quad->setElementId("tri_reverse");
|
||||
}
|
||||
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-x");
|
||||
} else {
|
||||
quad->setElementId("quad-x_reverse");
|
||||
}
|
||||
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-plus");
|
||||
} else {
|
||||
quad->setElementId("quad-plus_reverse");
|
||||
}
|
||||
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-hexa");
|
||||
} else {
|
||||
quad->setElementId("quad-hexa_reverse");
|
||||
}
|
||||
} else if (frameType == "HexaX" || frameType == "Hexacopter X") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-hexa-H");
|
||||
} else {
|
||||
quad->setElementId("quad-hexa-H_reverse");
|
||||
}
|
||||
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("hexa-coax");
|
||||
} else {
|
||||
quad->setElementId("hexa-coax_reverse");
|
||||
}
|
||||
} else if (frameType == "Octo" || frameType == "Octocopter") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-octo");
|
||||
} else {
|
||||
quad->setElementId("quad-octo_reverse");
|
||||
}
|
||||
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-octo-v");
|
||||
} else {
|
||||
quad->setElementId("quad-octo-v_reverse");
|
||||
}
|
||||
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("octo-coax-P");
|
||||
} else {
|
||||
quad->setElementId("octo-coax-P_reverse");
|
||||
}
|
||||
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("octo-coax-X");
|
||||
} else {
|
||||
quad->setElementId("octo-coax-X_reverse");
|
||||
}
|
||||
}
|
||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
// drawAirframe(frameType);
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
@ -309,268 +280,6 @@ void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
|
||||
configData->multi.TRIYaw = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigMultiRotorWidget::getChannelDescriptions()
|
||||
{
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (int i=0; i < (int)(ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
multiGUISettingsStruct multi = configData.multi;
|
||||
|
||||
if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN");
|
||||
if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE");
|
||||
if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW");
|
||||
if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS");
|
||||
if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE");
|
||||
if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW");
|
||||
if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW");
|
||||
if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE");
|
||||
if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.TRIYaw-1] = QString("Tri-Yaw");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::setYawMixLevel(int value)
|
||||
{
|
||||
if(value<0)
|
||||
{
|
||||
m_aircraft->mrYawMixLevel->setValue((-1)*value);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aircraft->mrYawMixLevel->setValue(value);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType;
|
||||
QList<QString> motorList;
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
// Curve is also common to all quads:
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
|
||||
|
||||
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
||||
airframeType = "QuadP";
|
||||
setupQuad(true);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Quad X") {
|
||||
airframeType = "QuadX";
|
||||
setupQuad(false);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter") {
|
||||
airframeType = "Hexa";
|
||||
setupHexa(true);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter X") {
|
||||
airframeType = "HexaX";
|
||||
setupHexa(false);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") {
|
||||
airframeType = "HexaCoax";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(6)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSE";
|
||||
setupMotors(motorList);
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.5, 1, -1 },
|
||||
{ 0.5, 1, 1 },
|
||||
{ 0.5, -1, -1 },
|
||||
{ 0.5, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 0, 1 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
|
||||
airframeType = "Octo";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 0, -1 },
|
||||
{ 1, -1, 1 },
|
||||
{ 0, -1, -1 },
|
||||
{ -1, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 1, 1 },
|
||||
{ 0, 1, -1 },
|
||||
{ 1, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
|
||||
airframeType = "OctoV";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// IMPORTANT: Assumes evenly spaced engines
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.33, -1, -1 },
|
||||
{ 1 , -1, 1 },
|
||||
{ -1 , -1, -1 },
|
||||
{ -0.33, -1, 1 },
|
||||
{ -0.33, 1, -1 },
|
||||
{ -1 , 1, 1 },
|
||||
{ 1 , 1, -1 },
|
||||
{ 0.33, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
|
||||
airframeType = "OctoCoaxP";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 0, -1 },
|
||||
{ 1, 0, 1 },
|
||||
{ 0, -1, -1 },
|
||||
{ 0, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 0, 1 },
|
||||
{ 0, 1, -1 },
|
||||
{ 0, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
|
||||
airframeType = "OctoCoaxX";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE"
|
||||
<< "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 1, -1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, -1, -1 },
|
||||
{ 1, -1, 1 },
|
||||
{ -1, -1, -1 },
|
||||
{ -1, -1, 1 },
|
||||
{ -1, 1, -1 },
|
||||
{ -1, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
|
||||
airframeType = "Tri";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(3)) {
|
||||
return airframeType;
|
||||
|
||||
}
|
||||
if (m_aircraft->triYawChannelBox->currentText() == "None") {
|
||||
m_aircraft->mrStatusLabel->setText("<font color='red'>Error: Assign a Yaw channel</font>");
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
||||
setupMotors(motorList);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
|
||||
SetConfigData(config);
|
||||
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.5, 1, 0 },
|
||||
{ 0.5, -1, 0 },
|
||||
{ -1, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
|
||||
// tell the mixer about tricopter yaw channel
|
||||
|
||||
int channel = m_aircraft->triYawChannelBox->currentIndex() - 1;
|
||||
if (channel > -1) {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
|
||||
}
|
||||
|
||||
m_aircraft->mrStatusLabel->setText(tr("Configuration OK"));
|
||||
|
||||
}
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::reverseMultirotorMotor(){
|
||||
QString frameType = m_aircraft->multirotorFrameType->currentText();
|
||||
drawAirframe(frameType);
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
*/
|
||||
@ -578,6 +287,8 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
@ -861,7 +572,264 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
|
||||
drawAirframe(frameType);
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType;
|
||||
QList<QString> motorList;
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
// Curve is also common to all quads:
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
|
||||
|
||||
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
||||
airframeType = "QuadP";
|
||||
setupQuad(true);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Quad X") {
|
||||
airframeType = "QuadX";
|
||||
setupQuad(false);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter") {
|
||||
airframeType = "Hexa";
|
||||
setupHexa(true);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter X") {
|
||||
airframeType = "HexaX";
|
||||
setupHexa(false);
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") {
|
||||
airframeType = "HexaCoax";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(6)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSE";
|
||||
setupMotors(motorList);
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.5, 1, -1 },
|
||||
{ 0.5, 1, 1 },
|
||||
{ 0.5, -1, -1 },
|
||||
{ 0.5, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 0, 1 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
|
||||
airframeType = "Octo";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 0, -1 },
|
||||
{ 1, -1, 1 },
|
||||
{ 0, -1, -1 },
|
||||
{ -1, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 1, 1 },
|
||||
{ 0, 1, -1 },
|
||||
{ 1, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
|
||||
airframeType = "OctoV";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// IMPORTANT: Assumes evenly spaced engines
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.33, -1, -1 },
|
||||
{ 1 , -1, 1 },
|
||||
{ -1 , -1, -1 },
|
||||
{ -0.33, -1, 1 },
|
||||
{ -0.33, 1, -1 },
|
||||
{ -1 , 1, 1 },
|
||||
{ 1 , 1, -1 },
|
||||
{ 0.33, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
|
||||
airframeType = "OctoCoaxP";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 0, -1 },
|
||||
{ 1, 0, 1 },
|
||||
{ 0, -1, -1 },
|
||||
{ 0, -1, 1 },
|
||||
{ -1, 0, -1 },
|
||||
{ -1, 0, 1 },
|
||||
{ 0, 1, -1 },
|
||||
{ 0, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
|
||||
airframeType = "OctoCoaxX";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(8)) {
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE"
|
||||
<< "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW";
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 1, 1, -1 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, -1, -1 },
|
||||
{ 1, -1, 1 },
|
||||
{ -1, -1, -1 },
|
||||
{ -1, -1, 1 },
|
||||
{ -1, 1, -1 },
|
||||
{ -1, 1, 1 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
|
||||
airframeType = "Tri";
|
||||
|
||||
//Show any config errors in GUI
|
||||
if (throwConfigError(3)) {
|
||||
return airframeType;
|
||||
|
||||
}
|
||||
if (m_aircraft->triYawChannelBox->currentText() == "None") {
|
||||
m_aircraft->mrStatusLabel->setText("<font color='red'>Error: Assign a Yaw channel</font>");
|
||||
return airframeType;
|
||||
}
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
||||
setupMotors(motorList);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
|
||||
SetConfigData(config);
|
||||
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixerMatrix[8][3] = {
|
||||
{ 0.5, 1, 0 },
|
||||
{ 0.5, -1, 0 },
|
||||
{ -1, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
|
||||
// tell the mixer about tricopter yaw channel
|
||||
|
||||
int channel = m_aircraft->triYawChannelBox->currentIndex() - 1;
|
||||
if (channel > -1) {
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
|
||||
}
|
||||
|
||||
m_aircraft->mrStatusLabel->setText(tr("Configuration OK"));
|
||||
|
||||
}
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::setYawMixLevel(int value)
|
||||
{
|
||||
if (value < 0) {
|
||||
m_aircraft->mrYawMixLevel->setValue(-value);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(true);
|
||||
} else {
|
||||
m_aircraft->mrYawMixLevel->setValue(value);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::reverseMultirotorMotor(){
|
||||
QString frameType = m_aircraft->multirotorFrameType->currentText();
|
||||
drawAirframe(frameType);
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::drawAirframe(QString frameType)
|
||||
{
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType;
|
||||
|
||||
QString elementId;
|
||||
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||
elementId = "tri";
|
||||
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
elementId = "quad-x";
|
||||
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
elementId = "quad-plus";
|
||||
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
||||
elementId = "quad-hexa";
|
||||
} else if (frameType == "HexaX" || frameType == "Hexacopter X") {
|
||||
elementId = "quad-hexa-H";
|
||||
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
||||
elementId = "hexa-coax";
|
||||
} else if (frameType == "Octo" || frameType == "Octocopter") {
|
||||
elementId = "quad-octo";
|
||||
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
||||
elementId = "quad-octo-v";
|
||||
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
||||
elementId = "octo-coax-P";
|
||||
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
elementId = "octo-coax-X";
|
||||
}
|
||||
|
||||
invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1;
|
||||
if (invertMotors <= 0) {
|
||||
elementId += "_reverse";
|
||||
}
|
||||
|
||||
if (elementId != "" && elementId != quad->elementId()) {
|
||||
quad->setElementId(elementId);
|
||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function: setupQuadMotor
|
||||
@ -1106,7 +1074,7 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
|
||||
//Iterate through all instances of multiMotorChannelBox
|
||||
for (int i=0; i<numMotors; i++) {
|
||||
//Fine widgets with text "multiMotorChannelBox.x", where x is an integer
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(uiowner, "multiMotorChannelBox" + QString::number(i+1));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i+1));
|
||||
if (combobox){
|
||||
if (combobox->currentText() == "None") {
|
||||
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
|
@ -46,9 +46,8 @@ class ConfigMultiRotorWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
static QStringList getChannelDescriptions();
|
||||
static const QString CHANNELBOXNAME;
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
ConfigMultiRotorWidget(QWidget *parent = 0);
|
||||
~ConfigMultiRotorWidget();
|
||||
@ -56,20 +55,16 @@ public:
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
Ui_MultiRotorConfigWidget *m_aircraft;
|
||||
|
||||
QWidget *uiowner;
|
||||
QGraphicsSvgItem *quad;
|
||||
float invertMotors;
|
||||
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
bool setupQuad(bool pLayout);
|
||||
bool setupHexa(bool pLayout);
|
||||
@ -78,13 +73,12 @@ private:
|
||||
void setupMotors(QList<QString> motorList);
|
||||
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
|
||||
|
||||
float invertMotors;
|
||||
|
||||
void setYawMixLevel(int);
|
||||
|
||||
void drawAirframe(QString multiRotorType);
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual bool throwConfigError(int numMotors);
|
||||
|
||||
void reverseMultirotorMotor();
|
||||
|
@ -138,7 +138,7 @@ void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index)
|
||||
|
||||
/**
|
||||
Helper function:
|
||||
enables/disables the named comboboxes within supplied uiowner
|
||||
enables/disables the named comboboxes within supplied owner
|
||||
*/
|
||||
void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
|
||||
{
|
||||
|
@ -145,6 +145,7 @@ public:
|
||||
static void SetConfigData(GUIConfigDataUnion configData);
|
||||
|
||||
static void resetField(UAVObjectField *field);
|
||||
|
||||
static void setComboCurrentIndex(QComboBox *box, int index);
|
||||
static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable);
|
||||
|
||||
@ -170,9 +171,6 @@ public:
|
||||
double getCurveMin(QList<double> *curve);
|
||||
double getCurveMax(QList<double> *curve);
|
||||
|
||||
public slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
protected:
|
||||
QStringList channelNames;
|
||||
QStringList mixerTypes;
|
||||
@ -184,6 +182,9 @@ private:
|
||||
|
||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
|
||||
};
|
||||
|
||||
#endif // GUIVEHICLECONFIG_H
|
||||
|
@ -44,6 +44,62 @@
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/generalsettings.h>
|
||||
|
||||
/**
|
||||
Static function to get currently assigned channelDescriptions
|
||||
for all known vehicle types; instantiates the appropriate object
|
||||
then asks it to supply channel descs
|
||||
*/
|
||||
QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
QStringList channelDesc;
|
||||
switch (systemSettingsData.AirframeType) {
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
// fixed wing
|
||||
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
// helicp
|
||||
channelDesc = ConfigCcpmWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_VTOL:
|
||||
case SystemSettings::AIRFRAMETYPE_TRI:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADX:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOV:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTO:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||
// multirotor
|
||||
channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
// ground
|
||||
channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
|
||||
break;
|
||||
default:
|
||||
channelDesc = ConfigCustomWidget::getChannelDescriptions();
|
||||
break;
|
||||
}
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
{
|
||||
m_aircraft = new Ui_AircraftWidget();
|
||||
@ -115,7 +171,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
}
|
||||
|
||||
// Connect aircraft type selection dropbox to callback function
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), m_aircraft->airframesWidget, SLOT(setCurrentIndex(int)));
|
||||
|
||||
// Connect the three feed forward test checkboxes
|
||||
connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||
@ -132,7 +188,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
disableMouseWheelEvents();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
@ -141,76 +196,207 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
Static function to get currently assigned channelDescriptions
|
||||
for all known vehicle types; instantiates the appropriate object
|
||||
then asks it to supply channel descs
|
||||
*/
|
||||
QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
QStringList channelDesc;
|
||||
switch (systemSettingsData.AirframeType) {
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
// fixed wing
|
||||
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
// helicp
|
||||
channelDesc = ConfigCcpmWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_VTOL:
|
||||
case SystemSettings::AIRFRAMETYPE_TRI:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADX:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOV:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTO:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||
// multirotor
|
||||
channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
|
||||
break;
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
// ground
|
||||
channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
|
||||
break;
|
||||
default:
|
||||
channelDesc = ConfigCustomWidget::getChannelDescriptions();
|
||||
break;
|
||||
}
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Slot for switching the airframe type. We do it explicitely
|
||||
rather than a signal in the UI, because we want to force a fitInView of the quad shapes.
|
||||
This is because this method (fitinview) only works when the widget is shown.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||
//void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||
//{
|
||||
// m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
//}
|
||||
|
||||
/**
|
||||
\brief Sets up the mixer depending on Airframe type. Accepts either system settings or
|
||||
combo box entry from airframe type, as those do not overlap.
|
||||
*/
|
||||
//void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
//{
|
||||
// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin";
|
||||
// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType;
|
||||
//
|
||||
// bool dirty = isDirty();
|
||||
//
|
||||
// QString category = frameCategory2(frameType);
|
||||
// if (category == "FixedWing") {
|
||||
// m_fixedwing->setupUI(frameType);
|
||||
// } else if (category == "Multirotor") {
|
||||
// m_multirotor->setupUI(frameType);
|
||||
// } else if (category == "Helicopter") {
|
||||
// m_heli->setupUI(frameType);
|
||||
// } else if (category == "Ground") {
|
||||
// m_groundvehicle->setupUI(frameType);
|
||||
// } else if (category == "Custom") {
|
||||
// m_custom->setupUI(frameType);
|
||||
// }
|
||||
//
|
||||
// setDirty(dirty);
|
||||
//
|
||||
// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end";
|
||||
//}
|
||||
|
||||
/**
|
||||
Refreshes the current value of the SystemSettings which holds the aircraft type
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
|
||||
{
|
||||
m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
Q_UNUSED(o);
|
||||
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin";
|
||||
|
||||
if (!allObjectsUpdated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/// Feed Forward Testing
|
||||
/////////////////////////////////////////////////////////
|
||||
bool dirty = isDirty();
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty;
|
||||
|
||||
// Get the Airframe type from the system settings:
|
||||
UAVDataObject *system = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(system);
|
||||
|
||||
UAVObjectField *field = system->getField(QString("AirframeType"));
|
||||
Q_ASSERT(field);
|
||||
|
||||
// At this stage, we will need to have some hardcoded settings in this code, this
|
||||
// is not ideal, but there you go.
|
||||
QString frameType = field->getValue().toString();
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType;
|
||||
//setupAirframeUI(frameType);
|
||||
|
||||
QString category = "FixedWing";//frameCategory(frameType);
|
||||
if (category == "FixedWing") {
|
||||
// Retrieve fixed wing settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_fixedwing->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Multirotor") {
|
||||
// Retrieve multirotor settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_multirotor->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Helicopter") {
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
|
||||
m_heli->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Ground") {
|
||||
// Retrieve ground vehicle settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
|
||||
m_groundvehicle->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Custom") {
|
||||
// Retrieve custom settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
|
||||
m_custom->refreshWidgetsValues(frameType);
|
||||
}
|
||||
|
||||
updateFeedForwardUI();
|
||||
|
||||
setDirty(dirty);
|
||||
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end";
|
||||
}
|
||||
|
||||
//QString ConfigVehicleTypeWidget::frameCategory1(QString frameType)
|
||||
//{
|
||||
// QString category;
|
||||
// if (frameType.startsWith("FixedWing")) {
|
||||
// category = "FixedWing";
|
||||
// } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa"
|
||||
// || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV"
|
||||
// || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") {
|
||||
// category = "Multirotor";
|
||||
// } else if (frameType == "HeliCP") {
|
||||
// category = "Helicopter";
|
||||
// } else if (frameType.startsWith("GroundVehicle")) {
|
||||
// category = "Ground";
|
||||
// } else {
|
||||
// category = "Custom";
|
||||
// }
|
||||
// return category;
|
||||
//}
|
||||
|
||||
|
||||
QString ConfigVehicleTypeWidget::frameCategory(QString frameType)
|
||||
{
|
||||
QString category;
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
|
||||
|| frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") {
|
||||
category = "FixedWing";
|
||||
} else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X"
|
||||
|| frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter"
|
||||
|| frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax"
|
||||
|| frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV"
|
||||
|| frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +"
|
||||
|| frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
category = "Multirotor";
|
||||
} else if (frameType == "HeliCP") {
|
||||
category = "Helicopter";
|
||||
} else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
|
||||
|| frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
|
||||
|| frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||
category = "Ground";
|
||||
} else {
|
||||
category = "Custom";
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
Sends the config to the board (airframe type)
|
||||
|
||||
We do all the tasks common to all airframes, or family of airframes, and
|
||||
we call additional methods for specific frames, so that we do not have a code
|
||||
that is too heavy.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
||||
// Update feed forward settings
|
||||
vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0);
|
||||
vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value());
|
||||
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
|
||||
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
|
||||
|
||||
// Sets airframe type default to "Custom"
|
||||
QString airframeType = "Custom";
|
||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
||||
airframeType = m_multirotor->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
||||
airframeType = m_heli->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Ground") {
|
||||
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else {
|
||||
airframeType = m_custom->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
|
||||
// set the airframe type
|
||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(system);
|
||||
|
||||
QPointer<UAVObjectField> field = system->getField(QString("AirframeType"));
|
||||
if (field) {
|
||||
field->setValue(airframeType);
|
||||
}
|
||||
|
||||
updateFeedForwardUI();
|
||||
}
|
||||
|
||||
/**
|
||||
Reset the contents of a field
|
||||
*/
|
||||
//void ConfigVehicleTypeWidget::resetField(UAVObjectField *field)
|
||||
//{
|
||||
// for (unsigned int i = 0; i < field->getNumElements(); i++) {
|
||||
// field->setValue(0, i);
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
Enables and runs feed forward testing
|
||||
@ -271,150 +457,6 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
}
|
||||
}
|
||||
|
||||
/**************************
|
||||
* Aircraft settings
|
||||
**************************/
|
||||
|
||||
/**
|
||||
Refreshes the current value of the SystemSettings which holds the aircraft type
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
|
||||
{
|
||||
Q_UNUSED(o);
|
||||
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin";
|
||||
|
||||
if (!allObjectsUpdated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool dirty = isDirty();
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty;
|
||||
|
||||
// Get the Airframe type from the system settings:
|
||||
UAVDataObject *system = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(system);
|
||||
|
||||
UAVObjectField *field = system->getField(QString("AirframeType"));
|
||||
Q_ASSERT(field);
|
||||
|
||||
// At this stage, we will need to have some hardcoded settings in this code, this
|
||||
// is not ideal, but there you go.
|
||||
QString frameType = field->getValue().toString();
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType;
|
||||
setupAirframeUI(frameType);
|
||||
|
||||
QString category = frameCategory1(frameType);
|
||||
if (category == "FixedWing") {
|
||||
// Retrieve fixed wing settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_fixedwing->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Multirotor") {
|
||||
// Retrieve multirotor settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_multirotor->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Helicopter") {
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
|
||||
m_heli->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Ground") {
|
||||
// Retrieve ground vehicle settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
|
||||
m_groundvehicle->refreshWidgetsValues(frameType);
|
||||
} else if (category == "Custom") {
|
||||
// Retrieve custom settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
|
||||
m_custom->refreshWidgetsValues(frameType);
|
||||
}
|
||||
|
||||
updateFeedForwardUI();
|
||||
setDirty(dirty);
|
||||
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end";
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Sets up the mixer depending on Airframe type. Accepts either system settings or
|
||||
combo box entry from airframe type, as those do not overlap.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
{
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin";
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType;
|
||||
bool dirty = isDirty();
|
||||
|
||||
QString category = frameCategory2(frameType);
|
||||
if (category == "FixedWing") {
|
||||
m_fixedwing->setupUI(frameType);
|
||||
} else if (category == "Multirotor") {
|
||||
m_multirotor->setupUI(frameType);
|
||||
} else if (category == "Helicopter") {
|
||||
m_heli->setupUI(frameType);
|
||||
} else if (category == "Ground") {
|
||||
m_groundvehicle->setupUI(frameType);
|
||||
} else if (category == "Custom") {
|
||||
m_custom->setupUI(frameType);
|
||||
}
|
||||
|
||||
setDirty(dirty);
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end";
|
||||
}
|
||||
|
||||
QString ConfigVehicleTypeWidget::frameCategory1(QString frameType)
|
||||
{
|
||||
QString category;
|
||||
if (frameType.startsWith("FixedWing")) {
|
||||
category = "FixedWing";
|
||||
} else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa"
|
||||
|| frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV"
|
||||
|| frameType == "OctoCoaxP" || frameType == "OctoCoaxX") {
|
||||
category = "Multirotor";
|
||||
} else if (frameType == "HeliCP") {
|
||||
category = "Helicopter";
|
||||
} else if (frameType.startsWith("GroundVehicle")) {
|
||||
category = "Ground";
|
||||
} else {
|
||||
category = "Custom";
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
|
||||
QString ConfigVehicleTypeWidget::frameCategory2(QString frameType)
|
||||
{
|
||||
QString category;
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
|
||||
|| frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") {
|
||||
category = "FixedWing";
|
||||
} else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X"
|
||||
|| frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter"
|
||||
|| frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax"
|
||||
|| frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV"
|
||||
|| frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +"
|
||||
|| frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
category = "Multirotor";
|
||||
} else if (frameType == "HeliCP") {
|
||||
category = "Helicopter";
|
||||
} else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
|
||||
|| frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
|
||||
|| frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||
category = "Ground";
|
||||
} else {
|
||||
category = "Custom";
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the contents of a field
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
||||
{
|
||||
for (unsigned int i = 0; i < field->getNumElements(); i++) {
|
||||
field->setValue(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Updates the custom airframe settings based on the current airframe.
|
||||
|
||||
@ -435,56 +477,6 @@ void ConfigVehicleTypeWidget::updateFeedForwardUI()
|
||||
m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer,"MaxAccel"));
|
||||
}
|
||||
|
||||
/**
|
||||
Sends the config to the board (airframe type)
|
||||
|
||||
We do all the tasks common to all airframes, or family of airframes, and
|
||||
we call additional methods for specific frames, so that we do not have a code
|
||||
that is too heavy.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
||||
// Update feed forward settings
|
||||
vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0);
|
||||
vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value());
|
||||
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
|
||||
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
|
||||
|
||||
// Sets airframe type default to "Custom"
|
||||
QString airframeType = "Custom";
|
||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
||||
airframeType = m_multirotor->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
||||
airframeType = m_heli->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Ground") {
|
||||
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else {
|
||||
airframeType = m_custom->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
|
||||
// set the airframe type
|
||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(system);
|
||||
|
||||
QPointer<UAVObjectField> field = system->getField(QString("AirframeType"));
|
||||
if (field) {
|
||||
field->setValue(airframeType);
|
||||
}
|
||||
|
||||
updateFeedForwardUI();
|
||||
}
|
||||
|
||||
/**
|
||||
Opens the wiki from the user's default browser
|
||||
*/
|
||||
|
@ -43,10 +43,15 @@ class ConfigVehicleTypeWidget: public ConfigTaskWidget
|
||||
|
||||
public:
|
||||
static QStringList getChannelDescriptions();
|
||||
static void setComboCurrentIndex(QComboBox *box, int index);
|
||||
|
||||
ConfigVehicleTypeWidget(QWidget *parent = 0);
|
||||
~ConfigVehicleTypeWidget();
|
||||
|
||||
public slots:
|
||||
virtual void refreshWidgetsValues(UAVObject *o = NULL);
|
||||
virtual void updateObjectsFromWidgets();
|
||||
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
|
||||
@ -57,10 +62,8 @@ private:
|
||||
VehicleConfig *m_custom;
|
||||
|
||||
void updateFeedForwardUI();
|
||||
void resetField(UAVObjectField *field);
|
||||
|
||||
QString frameCategory1(QString frameType);
|
||||
QString frameCategory2(QString frameType);
|
||||
QString frameCategory(QString frameType);
|
||||
|
||||
QStringList channelNames;
|
||||
QStringList mixerTypes;
|
||||
@ -71,16 +74,6 @@ private:
|
||||
UAVObject::Metadata accInitialData;
|
||||
|
||||
private slots:
|
||||
|
||||
virtual void refreshWidgetsValues(UAVObject *o = NULL);
|
||||
virtual void updateObjectsFromWidgets();
|
||||
|
||||
void setComboCurrentIndex(QComboBox *box, int index);
|
||||
|
||||
void setupAirframeUI(QString type);
|
||||
// TODO ?
|
||||
void switchAirframeType(int index);
|
||||
|
||||
void enableFFTest();
|
||||
void openHelp();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user