mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-907 step 2: moved vehicle specific code to respective vehicle widget
This commit is contained in:
parent
b190b898f1
commit
3ab96ed3cc
37
ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui
Normal file
37
ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CcpmConfigWidget</class>
|
||||
<widget class="QWidget" name="CcpmConfigWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>880</width>
|
||||
<height>608</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<property name="margin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ConfigCcpmWidget" name="widget_3" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ConfigCcpmWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cfg_vehicletypes/configccpmwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../coreplugin/core.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -36,34 +36,38 @@
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
#define Pi 3.14159265358979323846
|
||||
#include <math.h>
|
||||
|
||||
#define Pi 3.14159265358979323846
|
||||
|
||||
ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget())
|
||||
{
|
||||
int i;
|
||||
SwashLvlConfigurationInProgress=0;
|
||||
SwashLvlState=0;
|
||||
SwashLvlServoInterlock=0;
|
||||
updatingFromHardware=FALSE;
|
||||
updatingToHardware=FALSE;
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
m_ccpm = new Ui_ccpmWidget();
|
||||
m_ccpm->setupUi(this);
|
||||
//Ui_CcpmConfigWidget *m_aircraft = m_aircraft;
|
||||
|
||||
SwashLvlConfigurationInProgress = 0;
|
||||
SwashLvlState = 0;
|
||||
SwashLvlServoInterlock = 0;
|
||||
updatingFromHardware = FALSE;
|
||||
updatingToHardware = FALSE;
|
||||
|
||||
//m_aircraft = new Ui_ccpmWidget();
|
||||
//m_aircraft->setupUi(this);
|
||||
|
||||
// Initialization of the swashplaye widget
|
||||
m_ccpm->SwashplateImage->setScene(new QGraphicsScene(this));
|
||||
m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this));
|
||||
|
||||
m_ccpm->SwashLvlSwashplateImage->setScene(m_ccpm->SwashplateImage->scene());
|
||||
m_ccpm->SwashLvlSwashplateImage->setSceneRect(-50,-50,500,500);
|
||||
//m_ccpm->SwashLvlSwashplateImage->scale(.85,.85);
|
||||
m_aircraft->SwashLvlSwashplateImage->setScene(m_aircraft->SwashplateImage->scene());
|
||||
m_aircraft->SwashLvlSwashplateImage->setSceneRect(-50,-50,500,500);
|
||||
//m_aircraft->SwashLvlSwashplateImage->scale(.85,.85);
|
||||
|
||||
//m_ccpm->SwashplateImage->setSceneRect(SwashplateImg->boundingRect());
|
||||
m_ccpm->SwashplateImage->setSceneRect(-50,-30,500,500);
|
||||
//m_ccpm->SwashplateImage->scale(.85,.85);
|
||||
//m_aircraft->SwashplateImage->setSceneRect(SwashplateImg->boundingRect());
|
||||
m_aircraft->SwashplateImage->setSceneRect(-50,-30,500,500);
|
||||
//m_aircraft->SwashplateImage->scale(.85,.85);
|
||||
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
renderer->load(QString(":/configgadget/images/ccpm_setup.svg"));
|
||||
@ -74,7 +78,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
SwashplateImg->setElementId("Swashplate");
|
||||
SwashplateImg->setObjectName("Swashplate");
|
||||
//SwashplateImg->setScale(0.75);
|
||||
m_ccpm->SwashplateImage->scene()->addItem(SwashplateImg);
|
||||
m_aircraft->SwashplateImage->scene()->addItem(SwashplateImg);
|
||||
|
||||
QFont serifFont("Times", 24, QFont::Bold);
|
||||
QPen pen; // creates a default pen
|
||||
@ -101,14 +105,13 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
QList<QString> ServoNames;
|
||||
ServoNames << "ServoW" << "ServoX" << "ServoY" << "ServoZ" ;
|
||||
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
ServoLines[i] = m_ccpm->SwashLvlSwashplateImage->scene()->addLine(0,0,100*i,i*i*100,pen);
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
ServoLines[i] = m_aircraft->SwashLvlSwashplateImage->scene()->addLine(0,0,100*i,i*i*100,pen);
|
||||
|
||||
Servos[i] = new QGraphicsSvgItem();
|
||||
Servos[i]->setSharedRenderer(renderer);
|
||||
Servos[i]->setElementId(ServoNames.at(i));
|
||||
m_ccpm->SwashplateImage->scene()->addItem(Servos[i]);
|
||||
m_aircraft->SwashplateImage->scene()->addItem(Servos[i]);
|
||||
|
||||
ServosText[i] = new QGraphicsTextItem();
|
||||
ServosText[i]->setDefaultTextColor(Qt::yellow);
|
||||
@ -118,13 +121,13 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
ServosTextCircles[i] = new QGraphicsEllipseItem(1,1,30,30);
|
||||
ServosTextCircles[i]->setBrush(brush);
|
||||
ServosTextCircles[i]->setPen(pen2);
|
||||
m_ccpm->SwashplateImage->scene()->addItem(ServosTextCircles[i]);
|
||||
m_ccpm->SwashplateImage->scene()->addItem(ServosText[i]);
|
||||
m_aircraft->SwashplateImage->scene()->addItem(ServosTextCircles[i]);
|
||||
m_aircraft->SwashplateImage->scene()->addItem(ServosText[i]);
|
||||
|
||||
|
||||
|
||||
SwashLvlSpinBoxes[i] = new QSpinBox(m_ccpm->SwashLvlSwashplateImage); // use QGraphicsView
|
||||
m_ccpm->SwashLvlSwashplateImage->scene()->addWidget(SwashLvlSpinBoxes[i]);
|
||||
SwashLvlSpinBoxes[i] = new QSpinBox(m_aircraft->SwashLvlSwashplateImage); // use QGraphicsView
|
||||
m_aircraft->SwashLvlSwashplateImage->scene()->addWidget(SwashLvlSpinBoxes[i]);
|
||||
SwashLvlSpinBoxes[i]->setMaximum(10000);
|
||||
SwashLvlSpinBoxes[i]->setMinimum(0);
|
||||
SwashLvlSpinBoxes[i]->setValue(0);
|
||||
@ -133,25 +136,25 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
|
||||
//initialize our two mixer curves
|
||||
// mixercurve defaults to mixercurve_throttle
|
||||
m_ccpm->ThrottleCurve->initLinearCurve(5, 1.0, 0.0);
|
||||
m_aircraft->ThrottleCurve->initLinearCurve(5, 1.0, 0.0);
|
||||
|
||||
// tell mixercurve this is a pitch curve
|
||||
m_ccpm->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||
m_ccpm->PitchCurve->initLinearCurve(5, 1.0, -1.0);
|
||||
m_aircraft->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||
m_aircraft->PitchCurve->initLinearCurve(5, 1.0, -1.0);
|
||||
|
||||
//initialize channel names
|
||||
m_ccpm->ccpmEngineChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmEngineChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmTailChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmTailChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoWChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmServoWChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoXChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmServoXChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->addItems(channelNames);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmEngineChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmEngineChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmTailChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmTailChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoWChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmServoWChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoXChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmServoXChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoYChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->addItems(channelNames);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
|
||||
QStringList Types;
|
||||
Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") << QString::fromUtf8("CCPM 4 Servo 90º") <<
|
||||
@ -159,49 +162,47 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
QString::fromUtf8("FP 2 Servo 90º") <<
|
||||
QString::fromUtf8("Coax 2 Servo 90º") <<
|
||||
QString::fromUtf8("Custom - User Angles") << QString::fromUtf8("Custom - Advanced Settings");
|
||||
m_ccpm->ccpmType->addItems(Types);
|
||||
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - 1);
|
||||
m_aircraft->ccpmType->addItems(Types);
|
||||
m_aircraft->ccpmType->setCurrentIndex(m_aircraft->ccpmType->count() - 1);
|
||||
|
||||
refreshWidgetsValues(QString("HeliCP"));
|
||||
|
||||
UpdateType();
|
||||
|
||||
connect(m_ccpm->ccpmAngleW, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmAngleX, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmAngleY, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmAngleZ, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmCorrectionAngle, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmServoWChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmServoXChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmServoYChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmServoZChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_ccpm->ccpmEngineChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmTailChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmRevoSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmREVOspinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmCollectiveSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_ccpm->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
|
||||
connect(m_ccpm->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
|
||||
connect(m_ccpm->TabObject, SIGNAL(currentChanged ( QWidget * )), this, SLOT(UpdateType()));
|
||||
|
||||
connect(m_ccpm->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed()));
|
||||
connect(m_ccpm->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed()));
|
||||
connect(m_ccpm->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed()));
|
||||
connect(m_ccpm->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed()));
|
||||
|
||||
connect(m_ccpm->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities()));
|
||||
connect(m_ccpm->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
|
||||
connect(m_ccpm->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
|
||||
connect(m_aircraft->ccpmAngleW, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmAngleX, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmAngleY, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmAngleZ, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmCorrectionAngle, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmServoWChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmServoXChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmServoYChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmServoZChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate()));
|
||||
connect(m_aircraft->ccpmEngineChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmTailChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmRevoSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmREVOspinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmCollectiveSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
|
||||
connect(m_aircraft->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
|
||||
connect(m_aircraft->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
|
||||
connect(m_aircraft->TabObject, SIGNAL(currentChanged ( QWidget * )), this, SLOT(UpdateType()));
|
||||
|
||||
connect(m_aircraft->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed()));
|
||||
connect(m_aircraft->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed()));
|
||||
connect(m_aircraft->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed()));
|
||||
connect(m_aircraft->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed()));
|
||||
|
||||
connect(m_aircraft->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities()));
|
||||
connect(m_aircraft->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
|
||||
connect(m_aircraft->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities()));
|
||||
|
||||
ccpmSwashplateRedraw();
|
||||
ccpmSwashplateRedraw();
|
||||
}
|
||||
|
||||
ConfigCcpmWidget::~ConfigCcpmWidget()
|
||||
{
|
||||
// Do nothing
|
||||
delete m_aircraft;
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::setupUI(QString frameType)
|
||||
@ -291,139 +292,139 @@ void ConfigCcpmWidget::UpdateType()
|
||||
|
||||
SetUIComponentVisibilities();
|
||||
|
||||
TypeInt = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
|
||||
TypeText = m_ccpm->ccpmType->currentText();
|
||||
SingleServoIndex = m_ccpm->ccpmSingleServo->currentIndex();
|
||||
TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1;
|
||||
TypeText = m_aircraft->ccpmType->currentText();
|
||||
SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex();
|
||||
|
||||
//set visibility of user settings
|
||||
m_ccpm->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0);
|
||||
m_ccpm->ccpmAdvancedSettingsTable->clearFocus();;
|
||||
m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0);
|
||||
m_aircraft->ccpmAdvancedSettingsTable->clearFocus();;
|
||||
|
||||
m_ccpm->ccpmAngleW->setEnabled(TypeInt==1);
|
||||
m_ccpm->ccpmAngleX->setEnabled(TypeInt==1);
|
||||
m_ccpm->ccpmAngleY->setEnabled(TypeInt==1);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(TypeInt==1);
|
||||
m_ccpm->ccpmCorrectionAngle->setEnabled(TypeInt!=0);
|
||||
m_aircraft->ccpmAngleW->setEnabled(TypeInt==1);
|
||||
m_aircraft->ccpmAngleX->setEnabled(TypeInt==1);
|
||||
m_aircraft->ccpmAngleY->setEnabled(TypeInt==1);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(TypeInt==1);
|
||||
m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt!=0);
|
||||
|
||||
m_ccpm->ccpmServoWChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmServoXChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmSingleServo->setEnabled(TypeInt>1);
|
||||
m_aircraft->ccpmServoWChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmServoXChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmServoYChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmSingleServo->setEnabled(TypeInt>1);
|
||||
|
||||
m_ccpm->ccpmEngineChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmTailChannel->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmCollectiveSlider->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmCollectivespinBox->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmRevoSlider->setEnabled(TypeInt>0);
|
||||
m_ccpm->ccpmREVOspinBox->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmEngineChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmTailChannel->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmRevoSlider->setEnabled(TypeInt>0);
|
||||
m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt>0);
|
||||
|
||||
AdjustmentAngle=SingleServoIndex*90;
|
||||
|
||||
m_ccpm->PitchCurve->setVisible(1);
|
||||
m_aircraft->PitchCurve->setVisible(1);
|
||||
|
||||
NumServosDefined=4;
|
||||
//set values for pre defined heli types
|
||||
if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_ccpm->ccpmAngleY->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleY->setEnabled(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_aircraft->ccpmAngleY->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleY->setEnabled(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoYChannel->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
NumServosDefined=2;
|
||||
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
NumServosDefined=3;
|
||||
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360));
|
||||
m_ccpm->ccpmSingleServo->setEnabled(0);
|
||||
m_ccpm->ccpmSingleServo->setCurrentIndex(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
|
||||
m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360));
|
||||
m_aircraft->ccpmSingleServo->setEnabled(0);
|
||||
m_aircraft->ccpmSingleServo->setCurrentIndex(0);
|
||||
NumServosDefined=4;
|
||||
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360));
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360));
|
||||
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360));
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
NumServosDefined=3;
|
||||
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360));
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360));
|
||||
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360));
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
NumServosDefined=3;
|
||||
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_ccpm->ccpmAngleY->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleY->setEnabled(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_aircraft->ccpmAngleY->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleY->setEnabled(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoYChannel->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
|
||||
m_ccpm->ccpmCollectivespinBox->setEnabled(0);
|
||||
m_ccpm->ccpmCollectiveSlider->setEnabled(0);
|
||||
m_ccpm->ccpmCollectivespinBox->setValue(0);
|
||||
m_ccpm->ccpmCollectiveSlider->setValue(0);
|
||||
m_ccpm->PitchCurve->setVisible(0);
|
||||
m_aircraft->ccpmCollectivespinBox->setEnabled(0);
|
||||
m_aircraft->ccpmCollectiveSlider->setEnabled(0);
|
||||
m_aircraft->ccpmCollectivespinBox->setValue(0);
|
||||
m_aircraft->ccpmCollectiveSlider->setValue(0);
|
||||
m_aircraft->PitchCurve->setVisible(0);
|
||||
NumServosDefined=2;
|
||||
}
|
||||
else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_ccpm->ccpmAngleY->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleY->setEnabled(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
|
||||
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
|
||||
m_aircraft->ccpmAngleY->setValue(0);
|
||||
m_aircraft->ccpmAngleZ->setValue(0);
|
||||
m_aircraft->ccpmAngleY->setEnabled(0);
|
||||
m_aircraft->ccpmAngleZ->setEnabled(0);
|
||||
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_aircraft->ccpmServoYChannel->setEnabled(0);
|
||||
m_aircraft->ccpmServoZChannel->setEnabled(0);
|
||||
|
||||
m_ccpm->ccpmCollectivespinBox->setEnabled(0);
|
||||
m_ccpm->ccpmCollectiveSlider->setEnabled(0);
|
||||
m_ccpm->ccpmCollectivespinBox->setValue(0);
|
||||
m_ccpm->ccpmCollectiveSlider->setValue(0);
|
||||
m_ccpm->PitchCurve->setVisible(0);
|
||||
m_aircraft->ccpmCollectivespinBox->setEnabled(0);
|
||||
m_aircraft->ccpmCollectiveSlider->setEnabled(0);
|
||||
m_aircraft->ccpmCollectivespinBox->setValue(0);
|
||||
m_aircraft->ccpmCollectiveSlider->setValue(0);
|
||||
m_aircraft->PitchCurve->setVisible(0);
|
||||
NumServosDefined=2;
|
||||
|
||||
}
|
||||
@ -431,39 +432,39 @@ void ConfigCcpmWidget::UpdateType()
|
||||
//Set the text of the motor boxes
|
||||
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("CW motor");
|
||||
m_ccpm->ccpmTailLabel->setText("CCW motor");
|
||||
m_aircraft->ccpmEngineLabel->setText("CW motor");
|
||||
m_aircraft->ccpmTailLabel->setText("CCW motor");
|
||||
}
|
||||
else{
|
||||
m_ccpm->ccpmEngineLabel->setText("Engine");
|
||||
m_ccpm->ccpmTailLabel->setText("Tail rotor");
|
||||
m_aircraft->ccpmEngineLabel->setText("Engine");
|
||||
m_aircraft->ccpmTailLabel->setText("Tail rotor");
|
||||
}
|
||||
|
||||
//set the visibility of the swashplate servo selection boxes
|
||||
m_ccpm->ccpmServoWLabel->setVisible(NumServosDefined>=1);
|
||||
m_ccpm->ccpmServoXLabel->setVisible(NumServosDefined>=2);
|
||||
m_ccpm->ccpmServoYLabel->setVisible(NumServosDefined>=3);
|
||||
m_ccpm->ccpmServoZLabel->setVisible(NumServosDefined>=4);
|
||||
m_ccpm->ccpmServoWChannel->setVisible(NumServosDefined>=1);
|
||||
m_ccpm->ccpmServoXChannel->setVisible(NumServosDefined>=2);
|
||||
m_ccpm->ccpmServoYChannel->setVisible(NumServosDefined>=3);
|
||||
m_ccpm->ccpmServoZChannel->setVisible(NumServosDefined>=4);
|
||||
m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined>=1);
|
||||
m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined>=2);
|
||||
m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined>=3);
|
||||
m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined>=4);
|
||||
m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined>=1);
|
||||
m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined>=2);
|
||||
m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined>=3);
|
||||
m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined>=4);
|
||||
|
||||
//set the visibility of the swashplate angle selection boxes
|
||||
m_ccpm->ccpmServoWLabel_2->setVisible(NumServosDefined>=1);
|
||||
m_ccpm->ccpmServoXLabel_2->setVisible(NumServosDefined>=2);
|
||||
m_ccpm->ccpmServoYLabel_2->setVisible(NumServosDefined>=3);
|
||||
m_ccpm->ccpmServoZLabel_2->setVisible(NumServosDefined>=4);
|
||||
m_ccpm->ccpmAngleW->setVisible(NumServosDefined>=1);
|
||||
m_ccpm->ccpmAngleX->setVisible(NumServosDefined>=2);
|
||||
m_ccpm->ccpmAngleY->setVisible(NumServosDefined>=3);
|
||||
m_ccpm->ccpmAngleZ->setVisible(NumServosDefined>=4);
|
||||
m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined>=1);
|
||||
m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined>=2);
|
||||
m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined>=3);
|
||||
m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined>=4);
|
||||
m_aircraft->ccpmAngleW->setVisible(NumServosDefined>=1);
|
||||
m_aircraft->ccpmAngleX->setVisible(NumServosDefined>=2);
|
||||
m_aircraft->ccpmAngleY->setVisible(NumServosDefined>=3);
|
||||
m_aircraft->ccpmAngleZ->setVisible(NumServosDefined>=4);
|
||||
|
||||
|
||||
m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
for (int i=0;i<6;i++) {
|
||||
m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()-
|
||||
m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()-
|
||||
m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
}
|
||||
|
||||
//update UI
|
||||
@ -482,25 +483,25 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw()
|
||||
double scale,xscale,yscale;
|
||||
|
||||
|
||||
size = m_ccpm->SwashplateImage->rect();
|
||||
size = m_aircraft->SwashplateImage->rect();
|
||||
xscale=size.width();
|
||||
yscale=size.height();
|
||||
scale=xscale;
|
||||
if (yscale<scale)scale=yscale;
|
||||
scale/=460.00;
|
||||
m_ccpm->SwashplateImage->resetTransform ();
|
||||
m_ccpm->SwashplateImage->scale(scale,scale);
|
||||
m_aircraft->SwashplateImage->resetTransform ();
|
||||
m_aircraft->SwashplateImage->scale(scale,scale);
|
||||
|
||||
size = m_ccpm->SwashLvlSwashplateImage->rect();
|
||||
size = m_aircraft->SwashLvlSwashplateImage->rect();
|
||||
xscale=size.width();
|
||||
yscale=size.height();
|
||||
scale=xscale;
|
||||
if (yscale<scale)scale=yscale;
|
||||
scale/=590.00;
|
||||
m_ccpm->SwashLvlSwashplateImage->resetTransform ();
|
||||
m_ccpm->SwashLvlSwashplateImage->scale(scale,scale);
|
||||
m_aircraft->SwashLvlSwashplateImage->resetTransform ();
|
||||
m_aircraft->SwashLvlSwashplateImage->scale(scale,scale);
|
||||
|
||||
CorrectionAngle=m_ccpm->ccpmCorrectionAngle->value();
|
||||
CorrectionAngle=m_aircraft->ccpmCorrectionAngle->value();
|
||||
|
||||
CenterX=200;
|
||||
CenterY=200;
|
||||
@ -509,18 +510,18 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw()
|
||||
|
||||
SwashplateImg->setPos(CenterX-bounds.width()/2,CenterY-bounds.height()/2);
|
||||
|
||||
defined[0]=(m_ccpm->ccpmServoWChannel->isEnabled());
|
||||
defined[1]=(m_ccpm->ccpmServoXChannel->isEnabled());
|
||||
defined[2]=(m_ccpm->ccpmServoYChannel->isEnabled());
|
||||
defined[3]=(m_ccpm->ccpmServoZChannel->isEnabled());
|
||||
used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
angle[0]=(CorrectionAngle+180+m_ccpm->ccpmAngleW->value())*Pi/180.00;
|
||||
angle[1]=(CorrectionAngle+180+m_ccpm->ccpmAngleX->value())*Pi/180.00;
|
||||
angle[2]=(CorrectionAngle+180+m_ccpm->ccpmAngleY->value())*Pi/180.00;
|
||||
angle[3]=(CorrectionAngle+180+m_ccpm->ccpmAngleZ->value())*Pi/180.00;
|
||||
defined[0]=(m_aircraft->ccpmServoWChannel->isEnabled());
|
||||
defined[1]=(m_aircraft->ccpmServoXChannel->isEnabled());
|
||||
defined[2]=(m_aircraft->ccpmServoYChannel->isEnabled());
|
||||
defined[3]=(m_aircraft->ccpmServoZChannel->isEnabled());
|
||||
used[0]=((m_aircraft->ccpmServoWChannel->currentIndex()>0)&&(m_aircraft->ccpmServoWChannel->isEnabled()));
|
||||
used[1]=((m_aircraft->ccpmServoXChannel->currentIndex()>0)&&(m_aircraft->ccpmServoXChannel->isEnabled()));
|
||||
used[2]=((m_aircraft->ccpmServoYChannel->currentIndex()>0)&&(m_aircraft->ccpmServoYChannel->isEnabled()));
|
||||
used[3]=((m_aircraft->ccpmServoZChannel->currentIndex()>0)&&(m_aircraft->ccpmServoZChannel->isEnabled()));
|
||||
angle[0]=(CorrectionAngle+180+m_aircraft->ccpmAngleW->value())*Pi/180.00;
|
||||
angle[1]=(CorrectionAngle+180+m_aircraft->ccpmAngleX->value())*Pi/180.00;
|
||||
angle[2]=(CorrectionAngle+180+m_aircraft->ccpmAngleY->value())*Pi/180.00;
|
||||
angle[3]=(CorrectionAngle+180+m_aircraft->ccpmAngleZ->value())*Pi/180.00;
|
||||
|
||||
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
@ -559,7 +560,7 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw()
|
||||
radius = (215.00+w+h);
|
||||
x=CenterX-(radius*sin(angle[i]))-w;
|
||||
y=CenterY+(radius*cos(angle[i]))-h;
|
||||
SwashLvlSpinBoxes[i]->move(m_ccpm->SwashLvlSwashplateImage->mapFromScene (x, y));
|
||||
SwashLvlSpinBoxes[i]->move(m_aircraft->SwashLvlSwashplateImage->mapFromScene (x, y));
|
||||
SwashLvlSpinBoxes[i]->setVisible(used[i]!=0);
|
||||
|
||||
radius=220;
|
||||
@ -569,9 +570,9 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw()
|
||||
ServoLines[i]->setVisible(defined[i]!=0);
|
||||
}
|
||||
|
||||
//m_ccpm->SwashplateImage->centerOn (CenterX, CenterY);
|
||||
//m_aircraft->SwashplateImage->centerOn (CenterX, CenterY);
|
||||
|
||||
//m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio);
|
||||
//m_aircraft->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::ccpmSwashplateUpdate()
|
||||
@ -620,24 +621,24 @@ void ConfigCcpmWidget::UpdateMixer()
|
||||
if (config.heli.SwashplateType>0)
|
||||
{//not advanced settings
|
||||
//get the channel data from the ui
|
||||
MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex();
|
||||
MixerChannelData[1] = m_ccpm->ccpmTailChannel->currentIndex();
|
||||
MixerChannelData[2] = m_ccpm->ccpmServoWChannel->currentIndex();
|
||||
MixerChannelData[3] = m_ccpm->ccpmServoXChannel->currentIndex();
|
||||
MixerChannelData[4] = m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
MixerChannelData[5] = m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex();
|
||||
MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex();
|
||||
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
|
||||
MixerChannelData[3] = m_aircraft->ccpmServoXChannel->currentIndex();
|
||||
MixerChannelData[4] = m_aircraft->ccpmServoYChannel->currentIndex();
|
||||
MixerChannelData[5] = m_aircraft->ccpmServoZChannel->currentIndex();
|
||||
|
||||
//get the angle data from the ui
|
||||
ThisAngle[2] = m_ccpm->ccpmAngleW->value();
|
||||
ThisAngle[3] = m_ccpm->ccpmAngleX->value();
|
||||
ThisAngle[4] = m_ccpm->ccpmAngleY->value();
|
||||
ThisAngle[5] = m_ccpm->ccpmAngleZ->value();
|
||||
ThisAngle[2] = m_aircraft->ccpmAngleW->value();
|
||||
ThisAngle[3] = m_aircraft->ccpmAngleX->value();
|
||||
ThisAngle[4] = m_aircraft->ccpmAngleY->value();
|
||||
ThisAngle[5] = m_aircraft->ccpmAngleZ->value();
|
||||
|
||||
//get the angle data from the ui
|
||||
ThisEnable[2] = m_ccpm->ccpmServoWChannel->isEnabled();
|
||||
ThisEnable[3] = m_ccpm->ccpmServoXChannel->isEnabled();
|
||||
ThisEnable[4] = m_ccpm->ccpmServoYChannel->isEnabled();
|
||||
ThisEnable[5] = m_ccpm->ccpmServoZChannel->isEnabled();
|
||||
ThisEnable[2] = m_aircraft->ccpmServoWChannel->isEnabled();
|
||||
ThisEnable[3] = m_aircraft->ccpmServoXChannel->isEnabled();
|
||||
ThisEnable[4] = m_aircraft->ccpmServoYChannel->isEnabled();
|
||||
ThisEnable[5] = m_aircraft->ccpmServoZChannel->isEnabled();
|
||||
|
||||
ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] ));
|
||||
ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] ));
|
||||
@ -650,52 +651,52 @@ void ConfigCcpmWidget::UpdateMixer()
|
||||
{
|
||||
if ((MixerChannelData[i]>0) && ((ThisEnable[i])||(i<2)))
|
||||
{
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] ));
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] ));
|
||||
|
||||
//Generate the mixer vector
|
||||
if (i==0)
|
||||
{//main motor-engine
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
|
||||
|
||||
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw
|
||||
else
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
|
||||
|
||||
}
|
||||
if (i==1)
|
||||
{//tailrotor --or-- counter-clockwise motor
|
||||
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
|
||||
{
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
|
||||
}
|
||||
else{
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
|
||||
}
|
||||
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
|
||||
|
||||
}
|
||||
if (i>1)
|
||||
{//Swashplate
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
|
||||
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j=0;j<6;j++) m_ccpm->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-"));
|
||||
for (j=0;j<6;j++) m_aircraft->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -704,7 +705,7 @@ void ConfigCcpmWidget::UpdateMixer()
|
||||
{//advanced settings
|
||||
for (i=0;i<6;i++)
|
||||
{
|
||||
Channel =m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->text();
|
||||
Channel =m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->text();
|
||||
if (Channel == "-") Channel = QString("9");
|
||||
MixerChannelData[i]= Channel.toInt();
|
||||
}
|
||||
@ -726,48 +727,48 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
config.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
|
||||
config.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex();
|
||||
config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1;
|
||||
config.heli.FirstServoIndex = m_aircraft->ccpmSingleServo->currentIndex();
|
||||
|
||||
//ccpm mixing options
|
||||
config.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked();
|
||||
config.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked();
|
||||
config.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked();
|
||||
config.heli.ccpmCollectivePassthroughState = m_aircraft->ccpmCollectivePassthrough->isChecked();
|
||||
config.heli.ccpmLinkCyclicState = m_aircraft->ccpmLinkCyclic->isChecked();
|
||||
config.heli.ccpmLinkRollState = m_aircraft->ccpmLinkRoll->isChecked();
|
||||
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
|
||||
useCyclic = config.heli.ccpmLinkRollState;
|
||||
|
||||
//correction angle
|
||||
config.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value();
|
||||
config.heli.CorrectionAngle = m_aircraft->ccpmCorrectionAngle->value();
|
||||
|
||||
//update sliders
|
||||
if (useCCPM)
|
||||
{
|
||||
config.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value();
|
||||
config.heli.SliderValue0 = m_aircraft->ccpmCollectiveSlider->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value();
|
||||
config.heli.SliderValue0 = m_aircraft->ccpmCollectiveScale->value();
|
||||
}
|
||||
if (useCyclic)
|
||||
{
|
||||
config.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value();
|
||||
config.heli.SliderValue1 = m_aircraft->ccpmCyclicScale->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value();
|
||||
config.heli.SliderValue1 = m_aircraft->ccpmPitchScale->value();
|
||||
}
|
||||
config.heli.SliderValue2 = m_ccpm->ccpmRollScale->value();
|
||||
config.heli.SliderValue2 = m_aircraft->ccpmRollScale->value();
|
||||
|
||||
//servo assignments
|
||||
config.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex();
|
||||
config.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex();
|
||||
config.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
config.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
config.heli.ServoIndexW = m_aircraft->ccpmServoWChannel->currentIndex();
|
||||
config.heli.ServoIndexX = m_aircraft->ccpmServoXChannel->currentIndex();
|
||||
config.heli.ServoIndexY = m_aircraft->ccpmServoYChannel->currentIndex();
|
||||
config.heli.ServoIndexZ = m_aircraft->ccpmServoZChannel->currentIndex();
|
||||
|
||||
//throttle
|
||||
config.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex();
|
||||
config.heli.Throttle = m_aircraft->ccpmEngineChannel->currentIndex();
|
||||
//tail
|
||||
config.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex();
|
||||
config.heli.Tail = m_aircraft->ccpmTailChannel->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
|
||||
@ -791,39 +792,39 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
setComboCurrentIndex( m_ccpm->ccpmType, m_ccpm->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
setComboCurrentIndex(m_ccpm->ccpmSingleServo, config.heli.FirstServoIndex);
|
||||
setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex);
|
||||
|
||||
//ccpm mixing options
|
||||
m_ccpm->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState);
|
||||
m_ccpm->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState);
|
||||
m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState);
|
||||
m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState);
|
||||
m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState);
|
||||
|
||||
//correction angle
|
||||
m_ccpm->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle);
|
||||
m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle);
|
||||
|
||||
//update sliders
|
||||
m_ccpm->ccpmCollectiveScale->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCyclicScale->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScale->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmRollScale->setValue(config.heli.SliderValue2);
|
||||
m_ccpm->ccpmRollScaleBox->setValue(config.heli.SliderValue2);
|
||||
m_ccpm->ccpmCollectiveSlider->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectivespinBox->setValue(config.heli.SliderValue0);
|
||||
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_ccpm->ccpmServoWChannel, config.heli.ServoIndexW);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoXChannel,config.heli.ServoIndexX);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoYChannel,config.heli.ServoIndexY);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoZChannel,config.heli.ServoIndexZ);
|
||||
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_ccpm->ccpmEngineChannel, config.heli.Throttle);
|
||||
setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle);
|
||||
//tail
|
||||
setComboCurrentIndex( m_ccpm->ccpmTailChannel, config.heli.Tail);
|
||||
setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail);
|
||||
|
||||
getMixer();
|
||||
}
|
||||
@ -831,30 +832,30 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro
|
||||
|
||||
void ConfigCcpmWidget::SetUIComponentVisibilities()
|
||||
{
|
||||
m_ccpm->ccpmRevoMixingBox->setVisible(0);
|
||||
m_aircraft->ccpmRevoMixingBox->setVisible(0);
|
||||
|
||||
m_ccpm->ccpmPitchMixingBox->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked() &&
|
||||
m_ccpm->ccpmLinkCyclic->isChecked());
|
||||
m_aircraft->ccpmPitchMixingBox->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked() &&
|
||||
m_aircraft->ccpmLinkCyclic->isChecked());
|
||||
|
||||
m_ccpm->ccpmCollectiveScalingBox->setVisible(m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked());
|
||||
m_aircraft->ccpmCollectiveScalingBox->setVisible(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked());
|
||||
|
||||
m_ccpm->ccpmLinkCyclic->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked());
|
||||
m_aircraft->ccpmLinkCyclic->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked());
|
||||
|
||||
m_ccpm->ccpmCyclicScalingBox->setVisible((m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked()) &&
|
||||
m_ccpm->ccpmLinkRoll->isChecked());
|
||||
m_aircraft->ccpmCyclicScalingBox->setVisible((m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) &&
|
||||
m_aircraft->ccpmLinkRoll->isChecked());
|
||||
|
||||
if (!m_ccpm->ccpmCollectivePassthrough->checkState() && m_ccpm->ccpmLinkCyclic->isChecked())
|
||||
if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked())
|
||||
{
|
||||
m_ccpm->ccpmPitchScalingBox->setVisible(0);
|
||||
m_ccpm->ccpmRollScalingBox->setVisible(0);
|
||||
m_ccpm->ccpmLinkRoll->setVisible(0);
|
||||
m_aircraft->ccpmPitchScalingBox->setVisible(0);
|
||||
m_aircraft->ccpmRollScalingBox->setVisible(0);
|
||||
m_aircraft->ccpmLinkRoll->setVisible(0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmPitchScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked());
|
||||
m_ccpm->ccpmRollScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked());
|
||||
m_ccpm->ccpmLinkRoll->setVisible(1);
|
||||
m_aircraft->ccpmPitchScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked());
|
||||
m_aircraft->ccpmRollScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked());
|
||||
m_aircraft->ccpmLinkRoll->setVisible(1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -877,20 +878,20 @@ void ConfigCcpmWidget::getMixer()
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
m_ccpm->ThrottleCurve->setCurve(&curveValues);
|
||||
m_aircraft->ThrottleCurve->setCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_ccpm->ThrottleCurve->ResetCurve();
|
||||
m_aircraft->ThrottleCurve->ResetCurve();
|
||||
}
|
||||
|
||||
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
m_ccpm->PitchCurve->setCurve(&curveValues);
|
||||
m_aircraft->PitchCurve->setCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_ccpm->PitchCurve->ResetCurve();
|
||||
m_aircraft->PitchCurve->ResetCurve();
|
||||
}
|
||||
|
||||
updatingFromHardware=FALSE;
|
||||
@ -963,13 +964,13 @@ void ConfigCcpmWidget::setMixer()
|
||||
|
||||
//Configure the vector
|
||||
for (j=0;j<5;j++)
|
||||
mixers[MixerChannelData[i] - 1][j] = m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt();
|
||||
mixers[MixerChannelData[i] - 1][j] = m_aircraft->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt();
|
||||
}
|
||||
}
|
||||
|
||||
//get the user data for the curve into the mixer settings
|
||||
QList<double> curve1 = m_ccpm->ThrottleCurve->getCurve();
|
||||
QList<double> curve2 = m_ccpm->PitchCurve->getCurve();
|
||||
QList<double> curve1 = m_aircraft->ThrottleCurve->getCurve();
|
||||
QList<double> curve2 = m_aircraft->PitchCurve->getCurve();
|
||||
for (i=0;i<5;i++) {
|
||||
mixerSettingsData.ThrottleCurve1[i] = curve1.at(i);
|
||||
mixerSettingsData.ThrottleCurve2[i] = curve2.at(i);
|
||||
@ -978,7 +979,7 @@ void ConfigCcpmWidget::setMixer()
|
||||
//mapping of collective input to curve 2...
|
||||
//MixerSettings.Curve2Source = Throttle,Roll,Pitch,Yaw,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5
|
||||
//check if we are using throttle or directly from a channel...
|
||||
if (m_ccpm->ccpmCollectivePassthrough->isChecked())
|
||||
if (m_aircraft->ccpmCollectivePassthrough->isChecked())
|
||||
mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_COLLECTIVE;
|
||||
else
|
||||
mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_THROTTLE;
|
||||
@ -1008,10 +1009,10 @@ void ConfigCcpmWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
// Make the custom table columns autostretch:
|
||||
m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
for (int i=0;i<6;i++) {
|
||||
m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()-
|
||||
m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()-
|
||||
m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
}
|
||||
ccpmSwashplateRedraw();
|
||||
|
||||
@ -1019,10 +1020,10 @@ void ConfigCcpmWidget::resizeEvent(QResizeEvent* event)
|
||||
void ConfigCcpmWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents();
|
||||
for (int i=0;i<6;i++) {
|
||||
m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()-
|
||||
m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()-
|
||||
m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
|
||||
}
|
||||
ccpmSwashplateRedraw();
|
||||
}
|
||||
@ -1053,15 +1054,15 @@ void ConfigCcpmWidget::SwashLvlStartButtonPressed()
|
||||
//remove Flight control of ActuatorCommand
|
||||
enableSwashplateLevellingControl(true);
|
||||
|
||||
m_ccpm->SwashLvlStartButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlNextButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlCancelButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlFinishButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlStartButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlNextButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlCancelButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlFinishButton->setEnabled(false);
|
||||
//clear status check boxes
|
||||
m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
|
||||
|
||||
|
||||
//download the current settings to the OP hw
|
||||
@ -1086,15 +1087,15 @@ void ConfigCcpmWidget::SwashLvlStartButtonPressed()
|
||||
MaxField = obj->getField(QString("ChannelMax"));
|
||||
|
||||
//channel assignments
|
||||
oldSwashLvlConfiguration.ServoChannels[0]=m_ccpm->ccpmServoWChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[1]=m_ccpm->ccpmServoXChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[2]=m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[3]=m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[0]=m_aircraft->ccpmServoWChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[1]=m_aircraft->ccpmServoXChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[2]=m_aircraft->ccpmServoYChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[3]=m_aircraft->ccpmServoZChannel->currentIndex();
|
||||
//if servos are used
|
||||
oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[0]=((m_aircraft->ccpmServoWChannel->currentIndex()>0)&&(m_aircraft->ccpmServoWChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[1]=((m_aircraft->ccpmServoXChannel->currentIndex()>0)&&(m_aircraft->ccpmServoXChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[2]=((m_aircraft->ccpmServoYChannel->currentIndex()>0)&&(m_aircraft->ccpmServoYChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[3]=((m_aircraft->ccpmServoZChannel->currentIndex()>0)&&(m_aircraft->ccpmServoZChannel->isEnabled()));
|
||||
//min,neutral,max values for the servos
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
@ -1115,111 +1116,107 @@ void ConfigCcpmWidget::SwashLvlStartButtonPressed()
|
||||
//restore Flight control of ActuatorCommand
|
||||
enableSwashplateLevellingControl(false);
|
||||
|
||||
m_ccpm->SwashLvlStartButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlNextButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlCancelButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlFinishButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlStartButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlNextButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlCancelButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlFinishButton->setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
// should never be reached
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::SwashLvlNextButtonPressed()
|
||||
{
|
||||
//ShowDisclaimer(2);
|
||||
SwashLvlState++;
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
|
||||
switch (SwashLvlState)
|
||||
{
|
||||
switch (SwashLvlState) {
|
||||
case 0:
|
||||
break;
|
||||
case 1: //Neutral levelling
|
||||
m_ccpm->SwashLvlStepList->setCurrentRow(0);
|
||||
m_aircraft->SwashLvlStepList->setCurrentRow(0);
|
||||
//set spin boxes and swashplate servos to Neutral values
|
||||
setSwashplateLevel(50);
|
||||
//disable position slider
|
||||
m_ccpm->SwashLvlPositionSlider->setEnabled(false);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setEnabled(false);
|
||||
m_aircraft->SwashLvlPositionSlider->setEnabled(false);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setEnabled(false);
|
||||
//set position slider to 50%
|
||||
m_ccpm->SwashLvlPositionSlider->setValue(50);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setValue(50);
|
||||
m_aircraft->SwashLvlPositionSlider->setValue(50);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setValue(50);
|
||||
//connect spinbox signals to slots and ebnable them
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
connect(SwashLvlSpinBoxes[i], SIGNAL(valueChanged(int)), this, SLOT(SwashLvlSpinBoxChanged(int)));
|
||||
SwashLvlSpinBoxes[i]->setEnabled(true);
|
||||
}
|
||||
//issue user instructions
|
||||
m_ccpm->SwashLvlStepInstruction->setHtml("<h2>Neutral levelling</h2><p>Using adjustment of:<ul><li>servo horns<li>link lengths and<li>Neutral timing spinboxes to the right</ul><br>ensure that the swashplate is in the center of desired travel range and is level.");
|
||||
m_aircraft->SwashLvlStepInstruction->setHtml(
|
||||
"<h2>Neutral levelling</h2><p>Using adjustment of:<ul><li>servo horns<li>link lengths and<li>Neutral timing spinboxes to the right</ul><br>ensure that the swashplate is in the center of desired travel range and is level.");
|
||||
break;
|
||||
case 2: //Max levelling
|
||||
//check Neutral status as complete
|
||||
m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Checked);
|
||||
m_ccpm->SwashLvlStepList->setCurrentRow(1);
|
||||
m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Checked);
|
||||
m_aircraft->SwashLvlStepList->setCurrentRow(1);
|
||||
//set spin boxes and swashplate servos to Max values
|
||||
setSwashplateLevel(100);
|
||||
//set position slider to 100%
|
||||
m_ccpm->SwashLvlPositionSlider->setValue(100);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setValue(100);
|
||||
m_aircraft->SwashLvlPositionSlider->setValue(100);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setValue(100);
|
||||
//issue user instructions
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>Max levelling</h2><p>Using adjustment of:<ul><li>Max timing spinboxes to the right ONLY</ul><br>ensure that the swashplate is at the top of desired travel range and is level.");
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>Max levelling</h2><p>Using adjustment of:<ul><li>Max timing spinboxes to the right ONLY</ul><br>ensure that the swashplate is at the top of desired travel range and is level.");
|
||||
break;
|
||||
case 3: //Min levelling
|
||||
//check Max status as complete
|
||||
m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Checked);
|
||||
m_ccpm->SwashLvlStepList->setCurrentRow(2);
|
||||
m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Checked);
|
||||
m_aircraft->SwashLvlStepList->setCurrentRow(2);
|
||||
//set spin boxes and swashplate servos to Min values
|
||||
setSwashplateLevel(0);
|
||||
//set position slider to 0%
|
||||
m_ccpm->SwashLvlPositionSlider->setValue(0);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setValue(0);
|
||||
m_aircraft->SwashLvlPositionSlider->setValue(0);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setValue(0);
|
||||
//issue user instructions
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>Min levelling</h2><p>Using adjustment of:<ul><li>Min timing spinboxes to the right ONLY</ul><br>ensure that the swashplate is at the bottom of desired travel range and is level.");
|
||||
break;
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>Min levelling</h2><p>Using adjustment of:<ul><li>Min timing spinboxes to the right ONLY</ul><br>ensure that the swashplate is at the bottom of desired travel range and is level.");
|
||||
break;
|
||||
case 4: //levelling verification
|
||||
//check Min status as complete
|
||||
m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Checked);
|
||||
m_ccpm->SwashLvlStepList->setCurrentRow(3);
|
||||
m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Checked);
|
||||
m_aircraft->SwashLvlStepList->setCurrentRow(3);
|
||||
//enable position slider
|
||||
m_ccpm->SwashLvlPositionSlider->setEnabled(true);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setEnabled(true);
|
||||
m_aircraft->SwashLvlPositionSlider->setEnabled(true);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setEnabled(true);
|
||||
//make heli respond to slider movement
|
||||
connect(m_ccpm->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
|
||||
connect(m_aircraft->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
|
||||
//disable spin boxes
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
SwashLvlSpinBoxes[i]->setEnabled(false);
|
||||
}
|
||||
|
||||
//issue user instructions
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>levelling verification</h2><p>Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel.");
|
||||
break;
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>levelling verification</h2><p>Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel.");
|
||||
break;
|
||||
case 5: //levelling complete
|
||||
//check verify status as complete
|
||||
m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Checked);
|
||||
m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Checked);
|
||||
//issue user instructions
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>levelling complete</h2><p>Press the Finish button to save these settings to the SD card<p>Press the cancel button to return to the pre-levelling settings");
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>levelling complete</h2><p>Press the Finish button to save these settings to the SD card<p>Press the cancel button to return to the pre-levelling settings");
|
||||
//disable position slider
|
||||
m_ccpm->SwashLvlPositionSlider->setEnabled(false);
|
||||
m_ccpm->SwashLvlPositionSpinBox->setEnabled(false);
|
||||
m_aircraft->SwashLvlPositionSlider->setEnabled(false);
|
||||
m_aircraft->SwashLvlPositionSpinBox->setEnabled(false);
|
||||
//disconnect levelling slots from signals
|
||||
disconnect(m_ccpm->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
disconnect(m_aircraft->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
disconnect(SwashLvlSpinBoxes[i], SIGNAL(valueChanged(int)), this, SLOT(SwashLvlSpinBoxChanged(int)));
|
||||
}
|
||||
|
||||
m_ccpm->SwashLvlStartButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlNextButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlCancelButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlFinishButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlStartButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlNextButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlCancelButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlFinishButton->setEnabled(true);
|
||||
|
||||
default:
|
||||
//restore collective/cyclic setting
|
||||
@ -1230,24 +1227,24 @@ void ConfigCcpmWidget::SwashLvlNextButtonPressed()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigCcpmWidget::SwashLvlCancelButtonPressed()
|
||||
{
|
||||
int i;
|
||||
SwashLvlState=0;
|
||||
SwashLvlState = 0;
|
||||
|
||||
UAVObjectField* MinField;
|
||||
UAVObjectField* NeutralField;
|
||||
UAVObjectField* MaxField;
|
||||
UAVObjectField *MinField;
|
||||
UAVObjectField *NeutralField;
|
||||
UAVObjectField *MaxField;
|
||||
|
||||
m_ccpm->SwashLvlStartButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlNextButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlCancelButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlFinishButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlStartButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlNextButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlCancelButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlFinishButton->setEnabled(false);
|
||||
|
||||
m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
|
||||
m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
|
||||
m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
|
||||
|
||||
//restore old Actuator Settings
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
@ -1259,110 +1256,110 @@ void ConfigCcpmWidget::SwashLvlCancelButtonPressed()
|
||||
NeutralField = obj->getField(QString("ChannelNeutral"));
|
||||
MaxField = obj->getField(QString("ChannelMax"));
|
||||
|
||||
//min,neutral,max values for the servos
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
MinField->setValue(oldSwashLvlConfiguration.Min[i],oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i],oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
MaxField->setValue(oldSwashLvlConfiguration.Max[i],oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
// min,neutral,max values for the servos
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
MinField->setValue(oldSwashLvlConfiguration.Min[i], oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i], oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
MaxField->setValue(oldSwashLvlConfiguration.Max[i], oldSwashLvlConfiguration.ServoChannels[i]);
|
||||
}
|
||||
|
||||
obj->updated();
|
||||
|
||||
|
||||
//restore Flight control of ActuatorCommand
|
||||
// restore Flight control of ActuatorCommand
|
||||
enableSwashplateLevellingControl(false);
|
||||
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>Levelling Cancelled</h2><p>Previous settings have been restored.");
|
||||
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>Levelling Cancelled</h2><p>Previous settings have been restored.");
|
||||
}
|
||||
|
||||
|
||||
void ConfigCcpmWidget::SwashLvlFinishButtonPressed()
|
||||
{
|
||||
int i;
|
||||
UAVObjectField *MinField;
|
||||
UAVObjectField *NeutralField;
|
||||
UAVObjectField *MaxField;
|
||||
|
||||
UAVObjectField* MinField;
|
||||
UAVObjectField* NeutralField;
|
||||
UAVObjectField* MaxField;
|
||||
m_aircraft->SwashLvlStartButton->setEnabled(true);
|
||||
m_aircraft->SwashLvlNextButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlCancelButton->setEnabled(false);
|
||||
m_aircraft->SwashLvlFinishButton->setEnabled(false);
|
||||
|
||||
m_ccpm->SwashLvlStartButton->setEnabled(true);
|
||||
m_ccpm->SwashLvlNextButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlCancelButton->setEnabled(false);
|
||||
m_ccpm->SwashLvlFinishButton->setEnabled(false);
|
||||
|
||||
//save new Actuator Settings to memory and SD card
|
||||
// save new Actuator Settings to memory and SD card
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings")));
|
||||
Q_ASSERT(obj);
|
||||
//update settings to match our changes.
|
||||
|
||||
// update settings to match our changes.
|
||||
MinField = obj->getField(QString("ChannelMin"));
|
||||
NeutralField = obj->getField(QString("ChannelNeutral"));
|
||||
MaxField = obj->getField(QString("ChannelMax"));
|
||||
|
||||
//min,neutral,max values for the servos
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
MinField->setValue(newSwashLvlConfiguration.Min[i],newSwashLvlConfiguration.ServoChannels[i]);
|
||||
NeutralField->setValue(newSwashLvlConfiguration.Neutral[i],newSwashLvlConfiguration.ServoChannels[i]);
|
||||
MaxField->setValue(newSwashLvlConfiguration.Max[i],newSwashLvlConfiguration.ServoChannels[i]);
|
||||
// min,neutral,max values for the servos
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
MinField->setValue(newSwashLvlConfiguration.Min[i], newSwashLvlConfiguration.ServoChannels[i]);
|
||||
NeutralField->setValue(newSwashLvlConfiguration.Neutral[i], newSwashLvlConfiguration.ServoChannels[i]);
|
||||
MaxField->setValue(newSwashLvlConfiguration.Max[i], newSwashLvlConfiguration.ServoChannels[i]);
|
||||
}
|
||||
|
||||
obj->updated();
|
||||
saveObjectToSD(obj);
|
||||
|
||||
//restore Flight control of ActuatorCommand
|
||||
// restore Flight control of ActuatorCommand
|
||||
enableSwashplateLevellingControl(false);
|
||||
|
||||
m_ccpm->SwashLvlStepInstruction->setText("<h2>Levelling Completed</h2><p>New settings have been saved to the SD card");
|
||||
m_aircraft->SwashLvlStepInstruction->setText(
|
||||
"<h2>Levelling Completed</h2><p>New settings have been saved to the SD card");
|
||||
|
||||
ShowDisclaimer(0);
|
||||
//ShowDisclaimer(2);
|
||||
|
||||
}
|
||||
|
||||
int ConfigCcpmWidget::ShowDisclaimer(int messageID)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("<font color=red><h1>Warning!!!</h2></font>");
|
||||
int ret;
|
||||
switch (messageID) {
|
||||
case 0:
|
||||
// Basic disclaimer
|
||||
msgBox.setInformativeText("<h2>This code has many configurations.</h2><p>Please double check all settings before attempting flight!");
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
ret = msgBox.exec();
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
// Not Tested disclaimer
|
||||
msgBox.setInformativeText("<h2>The CCPM mixer code needs more testing!</h2><p><font color=red>Use it at your own risk!</font><p>Do you wish to continue?");
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
ret = msgBox.exec();
|
||||
switch (ret)
|
||||
{
|
||||
case QMessageBox::Cancel: return -1;
|
||||
case QMessageBox::Yes: return 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// DO NOT use
|
||||
msgBox.setInformativeText("<h2>The CCPM swashplate levelling code is NOT complete!</h2><p><font color=red>DO NOT use it for flight!</font>");
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
ret = msgBox.exec();
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("<font color=red><h1>Warning!!!</h2></font>");
|
||||
int ret;
|
||||
switch (messageID) {
|
||||
case 0:
|
||||
// Basic disclaimer
|
||||
msgBox.setInformativeText(
|
||||
"<h2>This code has many configurations.</h2><p>Please double check all settings before attempting flight!");
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
ret = msgBox.exec();
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
// Not Tested disclaimer
|
||||
msgBox.setInformativeText(
|
||||
"<h2>The CCPM mixer code needs more testing!</h2><p><font color=red>Use it at your own risk!</font><p>Do you wish to continue?");
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
ret = msgBox.exec();
|
||||
switch (ret) {
|
||||
case QMessageBox::Cancel:
|
||||
return -1;
|
||||
case QMessageBox::Yes:
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
// should never be reached
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// DO NOT use
|
||||
msgBox.setInformativeText(
|
||||
"<h2>The CCPM swashplate levelling code is NOT complete!</h2><p><font color=red>DO NOT use it for flight!</font>");
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
ret = msgBox.exec();
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
// should never be reached
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1378,33 +1375,30 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state)
|
||||
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorCommand")));
|
||||
UAVObject::Metadata mdata = obj->getMetadata();
|
||||
if (state)
|
||||
{
|
||||
if (state) {
|
||||
SwashLvlaccInitialData = mdata;
|
||||
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY);
|
||||
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
||||
UAVObject::SetGcsTelemetryAcked(mdata, false);
|
||||
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
||||
mdata.gcsTelemetryUpdatePeriod = 100;
|
||||
SwashLvlConfigurationInProgress=1;
|
||||
m_ccpm->TabObject->setTabEnabled(0,0);
|
||||
m_ccpm->TabObject->setTabEnabled(2,0);
|
||||
m_ccpm->TabObject->setTabEnabled(3,0);
|
||||
m_ccpm->ccpmType->setEnabled(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
mdata = SwashLvlaccInitialData; // Restore metadata
|
||||
SwashLvlConfigurationInProgress=0;
|
||||
SwashLvlConfigurationInProgress = 1;
|
||||
m_aircraft->TabObject->setTabEnabled(0, 0);
|
||||
m_aircraft->TabObject->setTabEnabled(2, 0);
|
||||
m_aircraft->TabObject->setTabEnabled(3, 0);
|
||||
m_aircraft->ccpmType->setEnabled(0);
|
||||
} else {
|
||||
// Restore metadata
|
||||
mdata = SwashLvlaccInitialData;
|
||||
SwashLvlConfigurationInProgress = 0;
|
||||
|
||||
m_ccpm->TabObject->setTabEnabled(0,1);
|
||||
m_ccpm->TabObject->setTabEnabled(2,1);
|
||||
m_ccpm->TabObject->setTabEnabled(3,1);
|
||||
m_ccpm->ccpmType->setEnabled(1);
|
||||
m_aircraft->TabObject->setTabEnabled(0, 1);
|
||||
m_aircraft->TabObject->setTabEnabled(2, 1);
|
||||
m_aircraft->TabObject->setTabEnabled(3, 1);
|
||||
m_aircraft->ccpmType->setEnabled(1);
|
||||
|
||||
}
|
||||
obj->setMetadata(mdata);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1413,26 +1407,34 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state)
|
||||
*/
|
||||
void ConfigCcpmWidget::setSwashplateLevel(int percent)
|
||||
{
|
||||
if (percent<0)return;// -1;
|
||||
if (percent>100)return;// -1;
|
||||
if (SwashLvlConfigurationInProgress!=1)return;// -1;
|
||||
int i;
|
||||
double value;
|
||||
double level = ((double)percent /50.00) - 1.00;
|
||||
if (percent < 0) {
|
||||
return; // -1;
|
||||
}
|
||||
if (percent > 100) {
|
||||
return; // -1;
|
||||
}
|
||||
if (SwashLvlConfigurationInProgress != 1) {
|
||||
return; // -1;
|
||||
}
|
||||
|
||||
SwashLvlServoInterlock=1;
|
||||
double level = ((double) percent / 50.00) - 1.00;
|
||||
|
||||
ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
|
||||
SwashLvlServoInterlock = 1;
|
||||
|
||||
ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
|
||||
ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData();
|
||||
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++) {
|
||||
if (level==0)
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
double value;
|
||||
if (level == 0) {
|
||||
value = newSwashLvlConfiguration.Neutral[i];
|
||||
else if (level > 0)
|
||||
value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i])*level + newSwashLvlConfiguration.Neutral[i];
|
||||
else if (level < 0)
|
||||
value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i])*level + newSwashLvlConfiguration.Neutral[i];
|
||||
|
||||
} else if (level > 0) {
|
||||
value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i]) * level
|
||||
+ newSwashLvlConfiguration.Neutral[i];
|
||||
} else if (level < 0) {
|
||||
value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i]) * level
|
||||
+ newSwashLvlConfiguration.Neutral[i];
|
||||
}
|
||||
actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value;
|
||||
SwashLvlSpinBoxes[i]->setValue(value);
|
||||
}
|
||||
@ -1440,38 +1442,42 @@ void ConfigCcpmWidget::setSwashplateLevel(int percent)
|
||||
actuatorCommand->setData(actuatorCommandData);
|
||||
actuatorCommand->updated();
|
||||
|
||||
SwashLvlServoInterlock=0;
|
||||
|
||||
return;
|
||||
SwashLvlServoInterlock = 0;
|
||||
}
|
||||
|
||||
|
||||
void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
int i;
|
||||
if (SwashLvlServoInterlock==1)return;
|
||||
|
||||
ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
|
||||
if (SwashLvlServoInterlock == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
|
||||
ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData();
|
||||
|
||||
for (i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
|
||||
value = SwashLvlSpinBoxes[i]->value();
|
||||
|
||||
switch (SwashLvlState)
|
||||
{
|
||||
case 1: //Neutral levelling
|
||||
newSwashLvlConfiguration.Neutral[i]=value;
|
||||
switch (SwashLvlState) {
|
||||
case 1:
|
||||
// Neutral levelling
|
||||
newSwashLvlConfiguration.Neutral[i] = value;
|
||||
break;
|
||||
case 2: //Max levelling
|
||||
case 2:
|
||||
// Max levelling
|
||||
newSwashLvlConfiguration.Max[i] = value;
|
||||
break;
|
||||
case 3: //Min levelling
|
||||
newSwashLvlConfiguration.Min[i]= value;
|
||||
case 3:
|
||||
// Min levelling
|
||||
newSwashLvlConfiguration.Min[i] = value;
|
||||
break;
|
||||
case 4: //levelling verification
|
||||
case 4:
|
||||
// levelling verification
|
||||
break;
|
||||
case 5: //levelling complete
|
||||
case 5:
|
||||
// levelling complete
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1480,7 +1486,6 @@ void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
|
||||
actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value;
|
||||
}
|
||||
|
||||
|
||||
actuatorCommand->setData(actuatorCommandData);
|
||||
actuatorCommand->updated();
|
||||
|
||||
@ -1496,63 +1501,45 @@ bool ConfigCcpmWidget::throwConfigError(QString airframeType)
|
||||
|
||||
bool error = false;
|
||||
|
||||
if((m_ccpm->ccpmServoWChannel->currentIndex()==0) && (m_ccpm->ccpmServoWChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText("<font color=red>" + m_ccpm->ccpmServoWLabel->text() + "</font>");
|
||||
if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isEnabled())) {
|
||||
m_aircraft->ccpmServoWLabel->setText("<font color=red>" + m_aircraft->ccpmServoWLabel->text() + "</font>");
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText(QTextEdit(m_ccpm->ccpmServoWLabel->text()).toPlainText());
|
||||
} else {
|
||||
m_aircraft->ccpmServoWLabel->setText(QTextEdit(m_aircraft->ccpmServoWLabel->text()).toPlainText());
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmServoXChannel->currentIndex()==0) && (m_ccpm->ccpmServoXChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText("<font color=red>" + m_ccpm->ccpmServoXLabel->text() + "</font>");
|
||||
if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isEnabled())) {
|
||||
m_aircraft->ccpmServoXLabel->setText("<font color=red>" + m_aircraft->ccpmServoXLabel->text() + "</font>");
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText(QTextEdit(m_ccpm->ccpmServoXLabel->text()).toPlainText());
|
||||
} else {
|
||||
m_aircraft->ccpmServoXLabel->setText(QTextEdit(m_aircraft->ccpmServoXLabel->text()).toPlainText());
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmServoYChannel->currentIndex()==0) && (m_ccpm->ccpmServoYChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText("<font color=red>" + m_ccpm->ccpmServoYLabel->text() + "</font>");
|
||||
if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isEnabled())) {
|
||||
m_aircraft->ccpmServoYLabel->setText("<font color=red>" + m_aircraft->ccpmServoYLabel->text() + "</font>");
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText(QTextEdit(m_ccpm->ccpmServoYLabel->text()).toPlainText());
|
||||
} else {
|
||||
m_aircraft->ccpmServoYLabel->setText(QTextEdit(m_aircraft->ccpmServoYLabel->text()).toPlainText());
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmServoZChannel->currentIndex()==0) && (m_ccpm->ccpmServoZChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText("<font color=red>" + m_ccpm->ccpmServoZLabel->text()+ "</font>");
|
||||
if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isEnabled())) {
|
||||
m_aircraft->ccpmServoZLabel->setText("<font color=red>" + m_aircraft->ccpmServoZLabel->text() + "</font>");
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText(QTextEdit(m_ccpm->ccpmServoZLabel->text()).toPlainText());
|
||||
} else {
|
||||
m_aircraft->ccpmServoZLabel->setText(QTextEdit(m_aircraft->ccpmServoZLabel->text()).toPlainText());
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmEngineChannel->currentIndex()==0) && (m_ccpm->ccpmEngineChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("<font color=red>" + m_ccpm->ccpmEngineLabel->text() + "</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText(QTextEdit(m_ccpm->ccpmEngineLabel->text()).toPlainText());
|
||||
if ((m_aircraft->ccpmEngineChannel->currentIndex() == 0) && (m_aircraft->ccpmEngineChannel->isEnabled())) {
|
||||
m_aircraft->ccpmEngineLabel->setText("<font color=red>" + m_aircraft->ccpmEngineLabel->text() + "</font>");
|
||||
} else {
|
||||
m_aircraft->ccpmEngineLabel->setText(QTextEdit(m_aircraft->ccpmEngineLabel->text()).toPlainText());
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmTailChannel->currentIndex()==0) && (m_ccpm->ccpmTailChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText("<font color=red>" + m_ccpm->ccpmTailLabel->text() + "</font>");
|
||||
if ((m_aircraft->ccpmTailChannel->currentIndex() == 0) && (m_aircraft->ccpmTailChannel->isEnabled())) {
|
||||
m_aircraft->ccpmTailLabel->setText("<font color=red>" + m_aircraft->ccpmTailLabel->text() + "</font>");
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText(QTextEdit(m_ccpm->ccpmTailLabel->text()).toPlainText());
|
||||
} else {
|
||||
m_aircraft->ccpmTailLabel->setText(QTextEdit(m_aircraft->ccpmTailLabel->text()).toPlainText());
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define CONFIGccpmWIDGET_H
|
||||
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include "ui_ccpm.h"
|
||||
#include "ui_airframe_ccpm.h"
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
@ -52,7 +52,6 @@ typedef struct {
|
||||
int Min[CCPM_MAX_SWASH_SERVOS];
|
||||
} SwashplateServoSettingsStruct;
|
||||
|
||||
|
||||
class ConfigCcpmWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -64,7 +63,9 @@ public:
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
|
||||
private:
|
||||
Ui_ccpmWidget *m_ccpm;
|
||||
//Ui_ccpmWidget *m_ccpm;
|
||||
Ui_CcpmConfigWidget *m_aircraft;
|
||||
|
||||
QGraphicsSvgItem *SwashplateImg;
|
||||
QGraphicsSvgItem *CurveImg;
|
||||
QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
|
||||
@ -90,7 +91,7 @@ private:
|
||||
bool updatingFromHardware;
|
||||
bool updatingToHardware;
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual void ResetActuators(GUIConfigDataUnion *configData);
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
QString updateConfigObjects();
|
||||
|
@ -0,0 +1,293 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configmultirotorwidget.cpp
|
||||
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief ccpm configuration panel
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "configcustomwidget.h"
|
||||
#include "mixersettings.h"
|
||||
//#include "systemsettings.h"
|
||||
//#include "actuatorsettings.h"
|
||||
//#include "actuatorcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
//const QString ConfigCustomWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
|
||||
|
||||
ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget())
|
||||
{
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
// Put combo boxes in line one of the custom mixer table:
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
UAVObjectField* field = mixer->getField(QString("Mixer1Type"));
|
||||
QStringList list = field->getOptions();
|
||||
for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
QComboBox* qb = new QComboBox(m_aircraft->customMixerTable);
|
||||
qb->addItems(list);
|
||||
m_aircraft->customMixerTable->setCellWidget(0, i, qb);
|
||||
}
|
||||
|
||||
SpinBoxDelegate *sbd = new SpinBoxDelegate();
|
||||
for (int i = 1; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigCustomWidget::~ConfigCustomWidget()
|
||||
{
|
||||
delete m_aircraft;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
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";
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
*/
|
||||
void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QList<double> curveValues;
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
// yes, use the curve we just read from mixersettings
|
||||
m_aircraft->customThrottle1Curve->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
if (MixerSettings *mxr = qobject_cast<MixerSettings *>(mixer)) {
|
||||
MixerSettings::DataFields mixerSettingsData = mxr->getData();
|
||||
if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
|
||||
m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
||||
else {
|
||||
m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup all Throttle2 curves for all types of airframes
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
m_aircraft->customThrottle2Curve->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_aircraft->customThrottle2Curve->getMin());
|
||||
}
|
||||
|
||||
// Update the mixer table:
|
||||
for (int channel = 0; channel < m_aircraft->customMixerTable->columnCount(); channel++) {
|
||||
UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
|
||||
if (field) {
|
||||
QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel);
|
||||
if (q) {
|
||||
QString s = field->getValue().toString();
|
||||
setComboCurrentIndex(q, q->findText(s));
|
||||
}
|
||||
|
||||
m_aircraft->customMixerTable->item(1, channel)->setText(
|
||||
QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
|
||||
m_aircraft->customMixerTable->item(2, channel)->setText(
|
||||
QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
|
||||
m_aircraft->customMixerTable->item(3, channel)->setText(
|
||||
QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL)));
|
||||
m_aircraft->customMixerTable->item(4, channel)->setText(
|
||||
QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH)));
|
||||
m_aircraft->customMixerTable->item(5, channel)->setText(
|
||||
QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
bool ConfigCustomWidget::throwConfigError(int numMotors)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
WHAT DOES THIS DO???
|
||||
*/
|
||||
void ConfigCustomWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Resize the GUI contents when the user changes the window size
|
||||
*/
|
||||
void ConfigCustomWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
// Make the custom table columns autostretch:
|
||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper delegate for the custom mixer editor table.
|
||||
Taken straight from Qt examples, thanks!
|
||||
*/
|
||||
SpinBoxDelegate::SpinBoxDelegate(QObject *parent) :
|
||||
QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QSpinBox *editor = new QSpinBox(parent);
|
||||
editor->setMinimum(-127);
|
||||
editor->setMaximum(127);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->interpretText();
|
||||
int value = spinBox->value();
|
||||
|
||||
model->setData(index, value, Qt::EditRole);
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file configairframetwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief Airframe configuration panel
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CONFIGCUSTOMWIDGET_H
|
||||
#define CONFIGCUSTOMWIDGET_H
|
||||
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include "ui_airframe_custom.h"
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
class Ui_Widget;
|
||||
|
||||
class ConfigCustomWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigCustomWidget(QWidget *parent = 0);
|
||||
~ConfigCustomWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
|
||||
private:
|
||||
Ui_CustomConfigWidget *m_aircraft;
|
||||
|
||||
//virtual void ResetActuators(GUIConfigDataUnion *configData);
|
||||
static QStringList getChannelDescriptions();
|
||||
// static const QString CHANNELBOXNAME;
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual bool throwConfigError(int numMotors);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
signals:
|
||||
void configurationChanged();
|
||||
|
||||
};
|
||||
|
||||
class SpinBoxDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpinBoxDelegate(QObject *parent = 0);
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
#endif // CONFIGCUSTOMWIDGET_H
|
@ -41,20 +41,24 @@
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
/**
|
||||
Constructor
|
||||
*/
|
||||
ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
|
||||
ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget())
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
QStringList fixedWingTypes;
|
||||
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||
m_aircraft->fixedWingType->addItems(fixedWingTypes);
|
||||
|
||||
// Set default model to "Elevator aileron rudder"
|
||||
m_aircraft->fixedWingType->setCurrentIndex(0);
|
||||
|
||||
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
|
||||
}
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
ConfigFixedWingWidget::~ConfigFixedWingWidget()
|
||||
{
|
||||
// Do nothing
|
||||
delete m_aircraft;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +69,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
|
||||
// Setup the UI
|
||||
//setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
||||
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
|
||||
@ -210,6 +213,30 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QList<double> curveValues;
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
// yes, use the curve we just read from mixersettings
|
||||
m_aircraft->fixedWingThrottle->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
fixedGUISettingsStruct fixed = config.fixedwing;
|
||||
|
||||
@ -222,26 +249,32 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
||||
setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
|
||||
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
|
||||
|
||||
UAVDataObject* mixer= dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
//UAVDataObject* mixer= dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
//Q_ASSERT(mixer);
|
||||
|
||||
int channel;
|
||||
if (frameType == "FixedWingElevon") {
|
||||
if (frameType == "FixedWingElevon") {
|
||||
// If the airframe is elevon, restore the slider setting
|
||||
// Find the channel number for Elevon1 (FixedWingRoll1)
|
||||
channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||
if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)*100);
|
||||
m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
|
||||
}
|
||||
}
|
||||
if (frameType == "FixedWingVtail") {
|
||||
channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
||||
if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)*100);
|
||||
m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
|
||||
channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
|
||||
if (channel > -1) {
|
||||
// If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
m_aircraft->elevonSlider1->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
|
||||
m_aircraft->elevonSlider2->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (frameType == "FixedWingVtail") {
|
||||
channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
|
||||
if (channel > -1) {
|
||||
// If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
m_aircraft->elevonSlider1->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) * 100);
|
||||
m_aircraft->elevonSlider2->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ConfigFixedWingWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft = 0, QWidget *parent = 0);
|
||||
ConfigFixedWingWidget(QWidget *parent = 0);
|
||||
~ConfigFixedWingWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
@ -67,10 +67,8 @@ private slots:
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual bool throwConfigError(QString airframeType);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGFIXEDWINGWIDGET_H
|
||||
|
@ -41,29 +41,42 @@
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
|
||||
ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget())
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
QStringList groundVehicleTypes;
|
||||
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
|
||||
m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
|
||||
|
||||
// Set default model to "Turnable (car)"
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(0);
|
||||
|
||||
setupUI(m_aircraft->groundVehicleType->currentText());
|
||||
|
||||
connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
|
||||
}
|
||||
|
||||
ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
|
||||
{
|
||||
// Do nothing
|
||||
delete m_aircraft;
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to setup the UI
|
||||
TODO move to constructor or make private
|
||||
*/
|
||||
void ConfigGroundVehicleWidget::setupUI(QString frameType)
|
||||
{
|
||||
m_aircraft->differentialSteeringMixBox->setHidden(true);
|
||||
//STILL NEEDS WORK
|
||||
|
||||
// Setup the UI
|
||||
//setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
|
||||
|
||||
m_aircraft->gvEngineChannelBox->setEnabled(false);
|
||||
m_aircraft->gvEngineLabel->setEnabled(false);
|
||||
|
||||
|
||||
m_aircraft->gvAileron1ChannelBox->setEnabled(false);
|
||||
m_aircraft->gvAileron1Label->setEnabled(false);
|
||||
@ -71,7 +84,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
|
||||
m_aircraft->gvAileron2ChannelBox->setEnabled(false);
|
||||
m_aircraft->gvAileron2Label->setEnabled(false);
|
||||
|
||||
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank
|
||||
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") {
|
||||
// Tank
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)"));
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||
m_aircraft->gvMotor1Label->setEnabled(true);
|
||||
@ -96,7 +110,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
|
||||
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
|
||||
|
||||
}
|
||||
else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle
|
||||
else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") {
|
||||
// Motorcycle
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle"));
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(false);
|
||||
m_aircraft->gvMotor1Label->setEnabled(false);
|
||||
@ -120,7 +135,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
|
||||
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
|
||||
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
|
||||
}
|
||||
else {//Car
|
||||
else {
|
||||
// Car
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
|
||||
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||
@ -159,28 +175,28 @@ QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
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");
|
||||
|
||||
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
|
||||
*/
|
||||
@ -195,33 +211,68 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
|
||||
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() );
|
||||
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);
|
||||
}
|
||||
// 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
|
||||
*/
|
||||
void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
UAVDataObject* obj;
|
||||
// UAVObjectField *field;
|
||||
qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType;
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QList<double> curveValues;
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
// yes, use the curve we just read from mixersettings
|
||||
m_aircraft->groundVehicleThrottle1->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
// Setup all Throttle2 curves for all types of airframes
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//UAVDataObject *obj;
|
||||
//UAVObjectField *field;
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
@ -237,16 +288,18 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
// If the vehicle type is "differential", restore the slider setting
|
||||
|
||||
// Find the channel number for Motor1
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
|
||||
if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
|
||||
m_aircraft->differentialSteeringSlider1->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_ROLL)*100);
|
||||
m_aircraft->differentialSteeringSlider2->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
|
||||
}
|
||||
//obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
//Q_ASSERT(obj);
|
||||
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
|
||||
if (channel > -1) {
|
||||
// If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||
m_aircraft->differentialSteeringSlider1->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
|
||||
m_aircraft->differentialSteeringSlider2->setValue(
|
||||
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
|
||||
}
|
||||
}
|
||||
if (frameType == "GroundVehicleMotorcycle") {
|
||||
else if (frameType == "GroundVehicleMotorcycle") {
|
||||
//CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
|
||||
// obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
// Q_ASSERT(obj);
|
||||
@ -311,8 +364,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Setup differentially steered ground vehicle.
|
||||
|
||||
@ -355,11 +406,8 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
|
||||
m_aircraft->gvStatusLabel->setText("Mixer generated");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Setup steerable ground vehicle.
|
||||
|
||||
@ -505,4 +553,3 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ConfigGroundVehicleWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft = 0, QWidget *parent = 0);
|
||||
ConfigGroundVehicleWidget(QWidget *parent = 0);
|
||||
~ConfigGroundVehicleWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
@ -71,5 +71,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGGROUNDVEHICLEWIDGET_H
|
||||
|
@ -43,14 +43,50 @@
|
||||
|
||||
const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
|
||||
|
||||
ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1)
|
||||
ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
|
||||
VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1)
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
// Setup the Multirotor picture in the Quad settings interface
|
||||
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
|
||||
|
||||
quad = new QGraphicsSvgItem();
|
||||
quad->setSharedRenderer(renderer);
|
||||
quad->setElementId("quad-x");
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
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());
|
||||
|
||||
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);
|
||||
|
||||
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()
|
||||
{
|
||||
// Do nothing
|
||||
delete m_aircraft;
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
@ -59,11 +95,12 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
Q_ASSERT(uiowner);
|
||||
Q_ASSERT(quad);
|
||||
|
||||
qDebug() << "ConfigMultiRotorWidget::setupUI - begin";
|
||||
qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType;
|
||||
|
||||
// set aircraftType to Multirotor, disable triyaw channel
|
||||
// set aircraftType to Multirotor
|
||||
//setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
|
||||
|
||||
// disable triyaw channel
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
|
||||
// disable all motor channel boxes
|
||||
@ -77,9 +114,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
}
|
||||
|
||||
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
@ -89,9 +126,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
m_aircraft->triYawChannelBox->setEnabled(true);
|
||||
}
|
||||
else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
|
||||
|
||||
// init mixer levels
|
||||
@ -100,9 +137,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setYawMixLevel(50);
|
||||
}
|
||||
else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
@ -110,9 +147,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setYawMixLevel(50);
|
||||
}
|
||||
else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
@ -120,31 +157,31 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setYawMixLevel(33);
|
||||
}
|
||||
else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType,
|
||||
m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
setYawMixLevel(33);
|
||||
|
||||
}
|
||||
else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType,
|
||||
m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
// Enable all necessary motor channel boxes...
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
setYawMixLevel(66);
|
||||
|
||||
}
|
||||
else if (frameType == "Octo" || frameType == "Octocopter") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
@ -152,31 +189,30 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
setYawMixLevel(25);
|
||||
}
|
||||
else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType,
|
||||
m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(25);
|
||||
m_aircraft->mrPitchMixLevel->setValue(25);
|
||||
setYawMixLevel(25);
|
||||
|
||||
}
|
||||
else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
setYawMixLevel(50);
|
||||
|
||||
}
|
||||
else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
// Enable all necessary motor channel boxes
|
||||
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
|
||||
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
@ -186,15 +222,14 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
|
||||
// Draw the appropriate airframe
|
||||
drawAirframe(frameType);
|
||||
qDebug() << "ConfigMultiRotorWidget::setupUI - end";
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::drawAirframe(QString frameType)
|
||||
{
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - begin";
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type:" << frameType;
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType;
|
||||
|
||||
invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1;
|
||||
invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1;
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - invert motors" << invertMotors;
|
||||
|
||||
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||
if (invertMotors > 0) {
|
||||
@ -203,13 +238,11 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType)
|
||||
quad->setElementId("tri_reverse");
|
||||
}
|
||||
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - 1";
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-x");
|
||||
} else {
|
||||
quad->setElementId("quad-x_reverse");
|
||||
}
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - 2";
|
||||
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
if (invertMotors > 0) {
|
||||
quad->setElementId("quad-plus");
|
||||
@ -259,7 +292,8 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType)
|
||||
quad->setElementId("octo-coax-X_reverse");
|
||||
}
|
||||
}
|
||||
qDebug() << "ConfigMultiRotorWidget::drawAirframe - end";
|
||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
|
||||
@ -316,12 +350,12 @@ void ConfigMultiRotorWidget::setYawMixLevel(int value)
|
||||
if(value<0)
|
||||
{
|
||||
m_aircraft->mrYawMixLevel->setValue((-1)*value);
|
||||
m_aircraft->MultirotorRevMixercheckBox->setChecked(true);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aircraft->mrYawMixLevel->setValue(value);
|
||||
m_aircraft->MultirotorRevMixercheckBox->setChecked(false);
|
||||
m_aircraft->MultirotorRevMixerCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
}
|
||||
@ -337,11 +371,11 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
QString airframeType;
|
||||
QList<QString> motorList;
|
||||
|
||||
UAVDataObject* mixerObj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixerObj);
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
// Curve is also common to all quads:
|
||||
setThrottleCurve(mixerObj, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
|
||||
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
|
||||
|
||||
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
||||
airframeType = "QuadP";
|
||||
@ -368,17 +402,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
|
||||
@ -394,17 +428,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
|
||||
@ -420,17 +454,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
// Motor 1 to 8:
|
||||
// IMPORTANT: Assumes evenly spaced engines
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
|
||||
@ -445,17 +479,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
|
||||
@ -470,17 +504,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
setupMotors(motorList);
|
||||
// Motor 1 to 8:
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
m_aircraft->mrStatusLabel->setText("Configuration OK");
|
||||
|
||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
|
||||
@ -505,24 +539,24 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
double mixer [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}
|
||||
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(mixer);
|
||||
setupMultiRotorMixer(mixerMatrix);
|
||||
|
||||
//tell the mixer about tricopter yaw channel
|
||||
// tell the mixer about tricopter yaw channel
|
||||
|
||||
int channel = m_aircraft->triYawChannelBox->currentIndex()-1;
|
||||
if (channel > -1){
|
||||
setMixerType(mixerObj, channel, VehicleConfig::MIXERTYPE_SERVO);
|
||||
setMixerVectorValue(mixerObj, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
|
||||
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"));
|
||||
@ -532,21 +566,45 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
|
||||
void ConfigMultiRotorWidget::reverseMultirotorMotor(){
|
||||
QString frameType = m_aircraft->multirotorFrameType->currentText();
|
||||
drawAirframe(frameType);
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
*/
|
||||
void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QList<double> curveValues;
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
// yes, use the curve we just read from mixersettings
|
||||
m_aircraft->multiThrottleCurve->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int channel;
|
||||
double value;
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
multiGUISettingsStruct multi = config.multi;
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
// UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
// Q_ASSERT(mixer);
|
||||
|
||||
if (frameType == "QuadP")
|
||||
{
|
||||
@ -1022,7 +1080,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
||||
// and enable only the relevant channels:
|
||||
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
|
||||
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
|
||||
invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1:1;
|
||||
invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1:1;
|
||||
double yFactor =invertMotors * (double)m_aircraft->mrYawMixLevel->value()/100;
|
||||
for (int i=0 ; i<8; i++) {
|
||||
if(mmList.at(i)->isEnabled())
|
||||
@ -1070,4 +1128,23 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
WHAT DOES THIS DO???
|
||||
*/
|
||||
void ConfigMultiRotorWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// Thit fitInView method should only be called now, once the
|
||||
// widget is shown, otherwise it cannot compute its values and
|
||||
// the result is usually a ahrsbargraph that is way too small.
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
Resize the GUI contents when the user changes the window size
|
||||
*/
|
||||
void ConfigMultiRotorWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class ConfigMultiRotorWidget: public VehicleConfig
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft = 0, QWidget *parent = 0);
|
||||
ConfigMultiRotorWidget(QWidget *parent = 0);
|
||||
~ConfigMultiRotorWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
@ -66,7 +66,7 @@ private:
|
||||
|
||||
float invertMotors;
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual void ResetActuators(GUIConfigDataUnion *configData);
|
||||
static QStringList getChannelDescriptions();
|
||||
static const QString CHANNELBOXNAME;
|
||||
void setYawMixLevel(int);
|
||||
@ -79,13 +79,15 @@ private slots:
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual bool throwConfigError(int numMotors);
|
||||
|
||||
void reverseMultirotorMotor();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
signals:
|
||||
void configurationChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGMULTIROTORWIDGET_H
|
||||
|
@ -104,7 +104,22 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) {
|
||||
guiConfig->setValue(configData.UAVObject[i], i);
|
||||
}
|
||||
|
||||
void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
|
||||
|
||||
void VehicleConfig::setupUI(QString frameType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString VehicleConfig::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
void VehicleConfig::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
}
|
||||
|
||||
void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData)
|
||||
{
|
||||
}
|
||||
|
||||
@ -113,27 +128,30 @@ void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
|
||||
Sets the current index on supplied combobox to index
|
||||
if it is within bounds 0 <= index < combobox.count()
|
||||
*/
|
||||
void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index)
|
||||
void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index)
|
||||
{
|
||||
Q_ASSERT(box);
|
||||
|
||||
if (index >= 0 && index < box->count())
|
||||
if (index >= 0 && index < box->count()) {
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function:
|
||||
enables/disables the named comboboxes within supplied uiowner
|
||||
*/
|
||||
void VehicleConfig::enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable)
|
||||
void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
|
||||
{
|
||||
for (int i = 1; i <= boxCount; i++) {
|
||||
QComboBox* box = qFindChild<QComboBox*>(owner, QString("%0%1").arg(boxName).arg(i));
|
||||
if (box)
|
||||
if (box) {
|
||||
box->setEnabled(enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
QString VehicleConfig::getMixerType(UAVDataObject* mixer, int channel)
|
||||
|
||||
QString VehicleConfig::getMixerType(UAVDataObject *mixer, int channel)
|
||||
{
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
@ -246,28 +264,22 @@ void VehicleConfig::setMixerValue(UAVDataObject* mixer, QString elementName, dou
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VehicleConfig::setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double> curve)
|
||||
void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double> curve)
|
||||
{
|
||||
QPointer<UAVObjectField> field;
|
||||
|
||||
switch (curveType)
|
||||
{
|
||||
case MIXER_THROTTLECURVE1:
|
||||
{
|
||||
field = mixer->getField("ThrottleCurve1");
|
||||
break;
|
||||
}
|
||||
case MIXER_THROTTLECURVE2:
|
||||
{
|
||||
field = mixer->getField("ThrottleCurve2");
|
||||
break;
|
||||
}
|
||||
switch (curveType) {
|
||||
case MIXER_THROTTLECURVE1:
|
||||
field = mixer->getField("ThrottleCurve1");
|
||||
break;
|
||||
case MIXER_THROTTLECURVE2:
|
||||
field = mixer->getField("ThrottleCurve2");
|
||||
break;
|
||||
}
|
||||
|
||||
if (field && field->getNumElements() == curve.length()) {
|
||||
for (int i=0;i<curve.length();i++) {
|
||||
field->setValue(curve.at(i),i);
|
||||
for (int i = 0; i < curve.length(); i++) {
|
||||
field->setValue(curve.at(i), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,23 +291,18 @@ void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveEle
|
||||
|
||||
QPointer<UAVObjectField> field;
|
||||
|
||||
switch (curveType)
|
||||
{
|
||||
case MIXER_THROTTLECURVE1:
|
||||
{
|
||||
field = mixer->getField("ThrottleCurve1");
|
||||
break;
|
||||
}
|
||||
case MIXER_THROTTLECURVE2:
|
||||
{
|
||||
field = mixer->getField("ThrottleCurve2");
|
||||
break;
|
||||
}
|
||||
switch (curveType) {
|
||||
case MIXER_THROTTLECURVE1:
|
||||
field = mixer->getField("ThrottleCurve1");
|
||||
break;
|
||||
case MIXER_THROTTLECURVE2:
|
||||
field = mixer->getField("ThrottleCurve2");
|
||||
break;
|
||||
}
|
||||
|
||||
if (field) {
|
||||
curve->clear();
|
||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||
for (unsigned int i = 0; i < field->getNumElements(); i++) {
|
||||
curve->append(field->getValue(i).toDouble());
|
||||
}
|
||||
}
|
||||
@ -306,7 +313,7 @@ bool VehicleConfig::isValidThrottleCurve(QList<double>* curve)
|
||||
Q_ASSERT(curve);
|
||||
|
||||
if (curve) {
|
||||
for (int i=0; i < curve->count(); i++) {
|
||||
for (int i = 0; i < curve->count(); i++) {
|
||||
if (curve->at(i) != 0)
|
||||
return true;
|
||||
}
|
||||
@ -314,21 +321,21 @@ bool VehicleConfig::isValidThrottleCurve(QList<double>* curve)
|
||||
return false;
|
||||
}
|
||||
|
||||
double VehicleConfig::getCurveMin(QList<double>* curve)
|
||||
double VehicleConfig::getCurveMin(QList<double> *curve)
|
||||
{
|
||||
double min = 0;
|
||||
for (int i=0; i<curve->count(); i++)
|
||||
for (int i = 0; i < curve->count(); i++) {
|
||||
min = std::min(min, curve->at(i));
|
||||
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
double VehicleConfig::getCurveMax(QList<double>* curve)
|
||||
double VehicleConfig::getCurveMax(QList<double> *curve)
|
||||
{
|
||||
double max = 0;
|
||||
for (int i=0; i<curve->count(); i++)
|
||||
for (int i = 0; i < curve->count(); i++) {
|
||||
max = std::max(max, curve->at(i));
|
||||
|
||||
}
|
||||
return max;
|
||||
}
|
||||
/**
|
||||
@ -336,8 +343,8 @@ double VehicleConfig::getCurveMax(QList<double>* curve)
|
||||
*/
|
||||
void VehicleConfig::resetField(UAVObjectField * field)
|
||||
{
|
||||
for (unsigned int i=0;i<field->getNumElements();i++) {
|
||||
field->setValue(0,i);
|
||||
for (unsigned int i = 0; i < field->getNumElements(); i++) {
|
||||
field->setValue(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,25 +140,33 @@ public:
|
||||
MIXERVECTOR_YAW = 4
|
||||
} MixerVectorElem;
|
||||
|
||||
// TODO remove 1st capital
|
||||
static GUIConfigDataUnion GetConfigData();
|
||||
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);
|
||||
double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName);
|
||||
void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value);
|
||||
void resetMixerVector(UAVDataObject* mixer, int channel);
|
||||
void resetMotorAndServoMixers(UAVDataObject* mixer);
|
||||
QString getMixerType(UAVDataObject* mixer, int channel);
|
||||
void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType);
|
||||
double getMixerValue(UAVDataObject* mixer, QString elementName);
|
||||
void setMixerValue(UAVDataObject* mixer, QString elementName, double value);
|
||||
void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double> curve);
|
||||
void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList<double>* curve);
|
||||
bool isValidThrottleCurve(QList<double>* curve);
|
||||
double getCurveMin(QList<double>* curve);
|
||||
double getCurveMax(QList<double>* curve);
|
||||
virtual void ResetActuators(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);
|
||||
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion *configData);
|
||||
|
||||
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName);
|
||||
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value);
|
||||
void resetMixerVector(UAVDataObject *mixer, int channel);
|
||||
void resetMotorAndServoMixers(UAVDataObject *mixer);
|
||||
QString getMixerType(UAVDataObject *mixer, int channel);
|
||||
void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType);
|
||||
double getMixerValue(UAVDataObject *mixer, QString elementName);
|
||||
void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
|
||||
void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double> curve);
|
||||
void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double>* curve);
|
||||
bool isValidThrottleCurve(QList<double> *curve);
|
||||
double getCurveMin(QList<double> *curve);
|
||||
double getCurveMax(QList<double> *curve);
|
||||
|
||||
QStringList channelNames;
|
||||
QStringList mixerTypes;
|
||||
@ -168,7 +176,7 @@ public:
|
||||
static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
|
||||
|
||||
private:
|
||||
static UAVObjectManager* getUAVObjectManager();
|
||||
static UAVObjectManager *getUAVObjectManager();
|
||||
|
||||
private slots:
|
||||
|
||||
|
@ -32,6 +32,7 @@ HEADERS += configplugin.h \
|
||||
cfg_vehicletypes/configmultirotorwidget.h \
|
||||
cfg_vehicletypes/configfixedwingwidget.h \
|
||||
cfg_vehicletypes/configgroundvehiclewidget.h \
|
||||
cfg_vehicletypes/configcustomwidget.h \
|
||||
configrevowidget.h \
|
||||
config_global.h \
|
||||
mixercurve.h \
|
||||
@ -65,6 +66,7 @@ SOURCES += configplugin.cpp \
|
||||
cfg_vehicletypes/configmultirotorwidget.cpp \
|
||||
cfg_vehicletypes/configfixedwingwidget.cpp \
|
||||
cfg_vehicletypes/configgroundvehiclewidget.cpp \
|
||||
cfg_vehicletypes/configcustomwidget.cpp \
|
||||
outputchannelform.cpp \
|
||||
mixercurve.cpp \
|
||||
dblspindelegate.cpp \
|
||||
@ -77,7 +79,6 @@ FORMS += airframe.ui \
|
||||
airframe_multirotor.ui \
|
||||
airframe_custom.ui \
|
||||
cc_hw_settings.ui \
|
||||
ccpm.ui \
|
||||
stabilization.ui \
|
||||
input.ui \
|
||||
output.ui \
|
||||
|
@ -26,70 +26,29 @@
|
||||
*/
|
||||
#include "configvehicletypewidget.h"
|
||||
#include "systemsettings.h"
|
||||
#include "mixersettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
|
||||
#include "cfg_vehicletypes/configccpmwidget.h"
|
||||
#include "cfg_vehicletypes/configfixedwingwidget.h"
|
||||
#include "cfg_vehicletypes/configgroundvehiclewidget.h"
|
||||
#include "cfg_vehicletypes/configmultirotorwidget.h"
|
||||
#include "cfg_vehicletypes/configcustomwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <math.h>
|
||||
//#include <QtGui/QTextEdit>
|
||||
//#include <QtGui/QVBoxLayout>
|
||||
//#include <QtGui/QPushButton>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QEventLoop>
|
||||
//#include <QEventLoop>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/generalsettings.h>
|
||||
|
||||
/**
|
||||
Helper delegate for the custom mixer editor table.
|
||||
Taken straight from Qt examples, thanks!
|
||||
*/
|
||||
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
|
||||
: QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &/* option */,
|
||||
const QModelIndex &/* index */) const
|
||||
{
|
||||
QSpinBox *editor = new QSpinBox(parent);
|
||||
editor->setMinimum(-127);
|
||||
editor->setMaximum(127);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::setEditorData(QWidget *editor,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||
spinBox->interpretText();
|
||||
int value = spinBox->value();
|
||||
|
||||
model->setData(index, value, Qt::EditRole);
|
||||
}
|
||||
|
||||
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
//#include <math.h>
|
||||
|
||||
ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
{
|
||||
@ -102,7 +61,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
m_aircraft->saveAircraftToRAM->setVisible(false);
|
||||
}
|
||||
|
||||
addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
|
||||
addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD);
|
||||
|
||||
addUAVObject("SystemSettings");
|
||||
addUAVObject("MixerSettings");
|
||||
@ -120,76 +79,90 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
// *****************************************************************************************************************
|
||||
|
||||
// create and setup a FixedWing config widget
|
||||
QWidget *fixedwingConfigWidget = new QWidget();
|
||||
m_fixedwingUi = new Ui_FixedWingConfigWidget();
|
||||
m_fixedwingUi->setupUi(fixedwingConfigWidget);
|
||||
m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget);
|
||||
qDebug() << "create fixedwing ui";
|
||||
m_fixedwing = new ConfigFixedWingWidget();
|
||||
m_aircraft->airframesWidget->addWidget(m_fixedwing);
|
||||
|
||||
m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi);
|
||||
m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() );
|
||||
|
||||
QStringList fixedWingTypes;
|
||||
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||
m_fixedwingUi->fixedWingType->addItems(fixedWingTypes);
|
||||
m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
|
||||
|
||||
connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
// QWidget *fixedwingConfigWidget = new QWidget();
|
||||
// m_fixedwingUi = new Ui_FixedWingConfigWidget();
|
||||
// m_fixedwingUi->setupUi(fixedwingConfigWidget);
|
||||
// m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget);
|
||||
|
||||
// m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi);
|
||||
// m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() );
|
||||
|
||||
// QStringList fixedWingTypes;
|
||||
// fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||
// m_fixedwingUi->fixedWingType->addItems(fixedWingTypes);
|
||||
// m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
|
||||
//
|
||||
// connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
|
||||
// *****************************************************************************************************************
|
||||
// MULTIROTOR
|
||||
// *****************************************************************************************************************
|
||||
|
||||
// create and setup a MultiRotor config widget
|
||||
qDebug() << "create multirotor ui";
|
||||
QWidget *multirotorConfigWidget = new QWidget();
|
||||
m_multirotorUi = new Ui_MultiRotorConfigWidget();
|
||||
m_multirotorUi->setupUi(multirotorConfigWidget);
|
||||
m_aircraft->airframesWidget->addWidget(multirotorConfigWidget);
|
||||
m_multirotor = new ConfigMultiRotorWidget();
|
||||
m_aircraft->airframesWidget->addWidget(m_multirotor);
|
||||
|
||||
// Setup the Multirotor picture in the Quad settings interface
|
||||
m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
|
||||
quad = new QGraphicsSvgItem();
|
||||
quad->setSharedRenderer(renderer);
|
||||
quad->setElementId("quad-x");
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
scene->addItem(quad);
|
||||
scene->setSceneRect(quad->boundingRect());
|
||||
m_multirotorUi->quadShape->setScene(scene);
|
||||
|
||||
m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi);
|
||||
m_multirotor->quad = quad;
|
||||
m_multirotor->uiowner = this;
|
||||
m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText());
|
||||
|
||||
QStringList multiRotorTypes;
|
||||
multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" <<
|
||||
"Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
|
||||
"Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
|
||||
m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes);
|
||||
m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X"
|
||||
// qDebug() << "create multirotor ui";
|
||||
// QWidget *multirotorConfigWidget = new QWidget();
|
||||
// m_multirotorUi = new Ui_MultiRotorConfigWidget();
|
||||
// m_multirotorUi->setupUi(multirotorConfigWidget);
|
||||
// m_aircraft->airframesWidget->addWidget(multirotorConfigWidget);
|
||||
|
||||
connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
|
||||
// Connect the multirotor motor reverse checkbox
|
||||
connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
|
||||
|
||||
m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
// // Setup the Multirotor picture in the Quad settings interface
|
||||
// m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
// m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
// QSvgRenderer *renderer = new QSvgRenderer();
|
||||
// renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
|
||||
// quad = new QGraphicsSvgItem();
|
||||
// quad->setSharedRenderer(renderer);
|
||||
// quad->setElementId("quad-x");
|
||||
// QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
// scene->addItem(quad);
|
||||
// scene->setSceneRect(quad->boundingRect());
|
||||
// m_multirotorUi->quadShape->setScene(scene);
|
||||
//
|
||||
// m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi);
|
||||
// m_multirotor->quad = quad;
|
||||
// m_multirotor->uiowner = this;
|
||||
// m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText());
|
||||
//
|
||||
// QStringList multiRotorTypes;
|
||||
// multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" <<
|
||||
// "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
|
||||
// "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
|
||||
// m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes);
|
||||
// m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X"
|
||||
//
|
||||
// connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
//
|
||||
// // Connect the multirotor motor reverse checkbox
|
||||
// connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
|
||||
//
|
||||
// m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
|
||||
// *****************************************************************************************************************
|
||||
// HELICOPTER
|
||||
// *****************************************************************************************************************
|
||||
|
||||
// create and setup a Helicopter config widget
|
||||
QWidget *ccpmConfigWidget = new QWidget();
|
||||
m_ccpmUi = new Ui_CcpmConfigWidget();
|
||||
m_ccpmUi->setupUi(ccpmConfigWidget);
|
||||
m_aircraft->airframesWidget->addWidget(ccpmConfigWidget);
|
||||
// QWidget *ccpmConfigWidget = new QWidget();
|
||||
// m_ccpmUi = new Ui_CcpmConfigWidget();
|
||||
// m_ccpmUi->setupUi(ccpmConfigWidget);
|
||||
// m_aircraft->airframesWidget->addWidget(ccpmConfigWidget);
|
||||
|
||||
m_heli = m_ccpmUi->widget_3;
|
||||
m_heli->setupUI(QString("HeliCP"));
|
||||
m_heli = new ConfigCcpmWidget();
|
||||
m_aircraft->airframesWidget->addWidget(m_heli);
|
||||
|
||||
//m_heli = m_ccpmUi->widget_3;
|
||||
//m_heli->setupUI(QString("HeliCP"));
|
||||
|
||||
|
||||
//mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
@ -199,45 +172,49 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
// *****************************************************************************************************************
|
||||
|
||||
// create and setup a GroundVehicle config widget
|
||||
qDebug() << "create ground ui";
|
||||
QWidget *groundConfigWidget = new QWidget();
|
||||
m_groundUi = new Ui_GroundConfigWidget();
|
||||
m_groundUi->setupUi(groundConfigWidget);
|
||||
m_aircraft->airframesWidget->addWidget(groundConfigWidget);
|
||||
// QWidget *groundConfigWidget = new QWidget();
|
||||
// m_groundUi = new Ui_GroundConfigWidget();
|
||||
// m_groundUi->setupUi(groundConfigWidget);
|
||||
// m_aircraft->airframesWidget->addWidget(groundConfigWidget);
|
||||
|
||||
m_groundvehicle = new ConfigGroundVehicleWidget(m_groundUi);
|
||||
m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText());
|
||||
m_groundvehicle = new ConfigGroundVehicleWidget();
|
||||
//m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText());
|
||||
m_aircraft->airframesWidget->addWidget(m_groundvehicle);
|
||||
|
||||
QStringList groundVehicleTypes;
|
||||
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
|
||||
m_groundUi->groundVehicleType->addItems(groundVehicleTypes);
|
||||
m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
|
||||
// QStringList groundVehicleTypes;
|
||||
// groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
|
||||
// m_groundUi->groundVehicleType->addItems(groundVehicleTypes);
|
||||
// m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
|
||||
|
||||
connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
// connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
|
||||
// *****************************************************************************************************************
|
||||
// CUSTOM
|
||||
// *****************************************************************************************************************
|
||||
|
||||
QWidget *customConfigWidget = new QWidget();
|
||||
m_customUi = new Ui_CustomConfigWidget();
|
||||
m_customUi->setupUi(customConfigWidget);
|
||||
m_aircraft->airframesWidget->addWidget(customConfigWidget);
|
||||
m_custom = new ConfigCustomWidget();
|
||||
m_aircraft->airframesWidget->addWidget(m_custom);
|
||||
|
||||
// Put combo boxes in line one of the custom mixer table:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("Mixer1Type"));
|
||||
QStringList list = field->getOptions();
|
||||
for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
QComboBox* qb = new QComboBox(m_customUi->customMixerTable);
|
||||
qb->addItems(list);
|
||||
m_customUi->customMixerTable->setCellWidget(0,i,qb);
|
||||
}
|
||||
|
||||
SpinBoxDelegate *sbd = new SpinBoxDelegate();
|
||||
for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
m_customUi->customMixerTable->setItemDelegateForRow(i, sbd);
|
||||
}
|
||||
// QWidget *customConfigWidget = new QWidget();
|
||||
// m_customUi = new Ui_CustomConfigWidget();
|
||||
// m_customUi->setupUi(customConfigWidget);
|
||||
// m_aircraft->airframesWidget->addWidget(customConfigWidget);
|
||||
|
||||
// // Put combo boxes in line one of the custom mixer table:
|
||||
// UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
// UAVObjectField* field = obj->getField(QString("Mixer1Type"));
|
||||
// QStringList list = field->getOptions();
|
||||
// for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
// QComboBox* qb = new QComboBox(m_customUi->customMixerTable);
|
||||
// qb->addItems(list);
|
||||
// m_customUi->customMixerTable->setCellWidget(0,i,qb);
|
||||
// }
|
||||
//
|
||||
// SpinBoxDelegate *sbd = new SpinBoxDelegate();
|
||||
// for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
// m_customUi->customMixerTable->setItemDelegateForRow(i, sbd);
|
||||
// }
|
||||
|
||||
// *****************************************************************************************************************
|
||||
|
||||
@ -249,9 +226,9 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
// Generate lists of mixerTypeNames, mixerVectorNames, channelNames
|
||||
channelNames << "None";
|
||||
for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
||||
mixerTypes << QString("Mixer%1Type").arg(i+1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i+1);
|
||||
channelNames << QString("Channel%1").arg(i+1);
|
||||
mixerTypes << QString("Mixer%1Type").arg(i + 1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i + 1);
|
||||
channelNames << QString("Channel%1").arg(i + 1);
|
||||
}
|
||||
|
||||
// NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
|
||||
@ -298,73 +275,52 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
||||
*/
|
||||
QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
UAVObjectManager *objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr);
|
||||
SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
switch (systemSettingsData.AirframeType)
|
||||
{
|
||||
QStringList channelDesc;
|
||||
switch (systemSettingsData.AirframeType) {
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
// fixed wing
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
{
|
||||
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
|
||||
}
|
||||
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
|
||||
break;
|
||||
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
// helicp
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
{
|
||||
channelDesc = ConfigCcpmWidget::getChannelDescriptions();
|
||||
}
|
||||
channelDesc = ConfigCcpmWidget::getChannelDescriptions();
|
||||
break;
|
||||
|
||||
//multirotor
|
||||
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:
|
||||
{
|
||||
channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
|
||||
}
|
||||
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
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
{
|
||||
channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
|
||||
}
|
||||
channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++)
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
default:
|
||||
channelDesc = ConfigCustomWidget::getChannelDescriptions();
|
||||
break;
|
||||
}
|
||||
|
||||
// for (i=0; i < channelDesc.count(); i++)
|
||||
// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]);
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
@ -376,83 +332,83 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||
{
|
||||
//m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
|
||||
//m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
// m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
// for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
// m_customUi->customMixerTable->setColumnWidth(i,
|
||||
// (m_customUi->customMixerTable->width() - m_customUi->customMixerTable->verticalHeader()->width()) / 10);
|
||||
// }
|
||||
|
||||
m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||
m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
|
||||
m_customUi->customMixerTable->verticalHeader()->width())/ 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
WHAT DOES THIS DO???
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// Thit fitInView method should only be called now, once the
|
||||
// widget is shown, otherwise it cannot compute its values and
|
||||
// the result is usually a ahrsbargraph that is way too small.
|
||||
m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||
m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
|
||||
m_customUi->customMixerTable->verticalHeader()->width())/ 10);
|
||||
}
|
||||
}
|
||||
//void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
|
||||
//{
|
||||
// Q_UNUSED(event)
|
||||
// // Thit fitInView method should only be called now, once the
|
||||
// // widget is shown, otherwise it cannot compute its values and
|
||||
// // the result is usually a ahrsbargraph that is way too small.
|
||||
// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
//// m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
//// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||
//// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
|
||||
//// m_customUi->customMixerTable->verticalHeader()->width())/ 10);
|
||||
//// }
|
||||
//}
|
||||
|
||||
/**
|
||||
Resize the GUI contents when the user changes the window size
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
// Make the custom table columns autostretch:
|
||||
m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||
m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
|
||||
m_customUi->customMixerTable->verticalHeader()->width())/ 10);
|
||||
}
|
||||
//void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent *event)
|
||||
//{
|
||||
// Q_UNUSED(event);
|
||||
// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
// // Make the custom table columns autostretch:
|
||||
// m_customUi->customMixerTable->resizeColumnsToContents();
|
||||
// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||
// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
|
||||
// m_customUi->customMixerTable->verticalHeader()->width())/ 10);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
}
|
||||
//void ConfigVehicleTypeWidget::toggleAileron2(int index)
|
||||
//{
|
||||
// if (index) {
|
||||
// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true);
|
||||
// m_fixedwingUi->fwAileron2Label->setEnabled(true);
|
||||
// } else {
|
||||
// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false);
|
||||
// m_fixedwingUi->fwAileron2Label->setEnabled(false);
|
||||
// }
|
||||
//}
|
||||
|
||||
//void ConfigVehicleTypeWidget::toggleElevator2(int index)
|
||||
//{
|
||||
// if (index) {
|
||||
// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true);
|
||||
// m_fixedwingUi->fwElevator2Label->setEnabled(true);
|
||||
// } else {
|
||||
// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false);
|
||||
// m_fixedwingUi->fwElevator2Label->setEnabled(false);
|
||||
// }
|
||||
//}
|
||||
|
||||
void ConfigVehicleTypeWidget::toggleAileron2(int index)
|
||||
{
|
||||
if (index) {
|
||||
m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true);
|
||||
m_fixedwingUi->fwAileron2Label->setEnabled(true);
|
||||
} else {
|
||||
m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false);
|
||||
m_fixedwingUi->fwAileron2Label->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigVehicleTypeWidget::toggleElevator2(int index)
|
||||
{
|
||||
if (index) {
|
||||
m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true);
|
||||
m_fixedwingUi->fwElevator2Label->setEnabled(true);
|
||||
} else {
|
||||
m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false);
|
||||
m_fixedwingUi->fwElevator2Label->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigVehicleTypeWidget::toggleRudder2(int index)
|
||||
{
|
||||
if (index) {
|
||||
m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true);
|
||||
m_fixedwingUi->fwRudder2Label->setEnabled(true);
|
||||
} else {
|
||||
m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false);
|
||||
m_fixedwingUi->fwRudder2Label->setEnabled(false);
|
||||
}
|
||||
}
|
||||
//void ConfigVehicleTypeWidget::toggleRudder2(int index)
|
||||
//{
|
||||
// if (index) {
|
||||
// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true);
|
||||
// m_fixedwingUi->fwRudder2Label->setEnabled(true);
|
||||
// } else {
|
||||
// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false);
|
||||
// m_fixedwingUi->fwRudder2Label->setEnabled(false);
|
||||
// }
|
||||
//}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/// Feed Forward Testing
|
||||
@ -522,81 +478,84 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
/**
|
||||
Refreshes the current value of the SystemSettings which holds the aircraft type
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o)
|
||||
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
|
||||
{
|
||||
Q_UNUSED(o);
|
||||
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin";
|
||||
|
||||
if(!allObjectsUpdated())
|
||||
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")));
|
||||
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);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
||||
QList<double> curveValues;
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
// UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
// Q_ASSERT(mixer);
|
||||
//
|
||||
// QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
//
|
||||
// QList<double> curveValues;
|
||||
// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
// yes, use the curve we just read from mixersettings
|
||||
m_multirotorUi->multiThrottleCurve->initCurve(&curveValues);
|
||||
m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues);
|
||||
m_groundUi->groundVehicleThrottle1->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
|
||||
m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
|
||||
m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
// if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
// // yes, use the curve we just read from mixersettings
|
||||
// //m_multirotorUi->multiThrottleCurve->initCurve(&curveValues);
|
||||
// //m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues);
|
||||
// //m_groundUi->groundVehicleThrottle1->initCurve(&curveValues);
|
||||
// }
|
||||
// else {
|
||||
// // no, init a straight curve
|
||||
// //m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
|
||||
// //m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
|
||||
// //m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
|
||||
// }
|
||||
|
||||
// Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
//
|
||||
// if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
// m_groundUi->groundVehicleThrottle2->initCurve(&curveValues);
|
||||
// }
|
||||
// else {
|
||||
// m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
||||
// }
|
||||
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
m_groundUi->groundVehicleThrottle2->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
// Load the Settings for fixed wing frames:
|
||||
if (frameType.startsWith("FixedWing")) {
|
||||
// Retrieve fixed wing settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_fixedwing->refreshWidgetsValues(frameType);
|
||||
} else if (frameType == "Tri" ||
|
||||
frameType == "QuadX" || frameType == "QuadP" ||
|
||||
frameType == "Hexa" || frameType == "HexaCoax" || frameType == "HexaX" ||
|
||||
frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) {
|
||||
|
||||
// Retrieve multirotor settings
|
||||
m_multirotor->refreshWidgetsValues(frameType);
|
||||
} else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa"
|
||||
|| frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV"
|
||||
|| frameType == "OctoCoaxP" || frameType == "OctoCoaxX") {
|
||||
// Retrieve multirotor settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_multirotor->refreshWidgetsValues(frameType);
|
||||
} else if (frameType == "HeliCP") {
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
|
||||
m_heli->refreshWidgetsValues(frameType);
|
||||
} else if (frameType.startsWith("GroundVehicle")) {
|
||||
// Retrieve ground vehicle settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
|
||||
m_groundvehicle->refreshWidgetsValues(frameType);
|
||||
} else if (frameType == "Custom") {
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
|
||||
m_custom->refreshWidgetsValues(frameType);
|
||||
}
|
||||
|
||||
updateCustomAirframeUI();
|
||||
@ -614,36 +573,31 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin";
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType;
|
||||
bool dirty = isDirty();
|
||||
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
|
||||
|| frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") {
|
||||
m_fixedwing->setupUI(frameType);
|
||||
}
|
||||
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" ) {
|
||||
|
||||
//Call multi-rotor setup UI
|
||||
m_multirotor->setupUI(frameType);
|
||||
}
|
||||
else if (frameType == "HeliCP") {
|
||||
} 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") {
|
||||
|
||||
m_multirotor->setupUI(frameType);
|
||||
} else if (frameType == "HeliCP") {
|
||||
m_heli->setupUI(frameType);
|
||||
}
|
||||
else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" ||
|
||||
frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" ||
|
||||
frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||
} else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
|
||||
|| frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
|
||||
|| frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||
m_groundvehicle->setupUI(frameType);
|
||||
} else {
|
||||
m_custom->setupUI(frameType);
|
||||
}
|
||||
|
||||
|
||||
//SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST???
|
||||
m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
//m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
|
||||
//m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
|
||||
setDirty(dirty);
|
||||
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end";
|
||||
@ -655,8 +609,8 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
||||
{
|
||||
for (unsigned int i=0;i<field->getNumElements();i++) {
|
||||
field->setValue(0,i);
|
||||
for (unsigned int i = 0; i < field->getNumElements(); i++) {
|
||||
field->setValue(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,6 +619,7 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
||||
|
||||
Note: does NOT ask for an object refresh itself!
|
||||
*/
|
||||
// TODO rename to FF
|
||||
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
{
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
@ -672,61 +627,61 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
||||
QList<double> curveValues;
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
m_customUi->customThrottle1Curve->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
// no, init a straight curve
|
||||
m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
if (MixerSettings* mxr = qobject_cast<MixerSettings *>(mixer)) {
|
||||
MixerSettings::DataFields mixerSettingsData = mxr->getData();
|
||||
if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
|
||||
m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
||||
else {
|
||||
m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup all Throttle2 curves for all types of airframes
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
m_customUi->customThrottle2Curve->initCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin());
|
||||
}
|
||||
|
||||
// Update the mixer table:
|
||||
for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) {
|
||||
UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
|
||||
if (field)
|
||||
{
|
||||
QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
|
||||
if (q)
|
||||
{
|
||||
QString s = field->getValue().toString();
|
||||
setComboCurrentIndex(q, q->findText(s));
|
||||
}
|
||||
|
||||
m_customUi->customMixerTable->item(1,channel)->setText(
|
||||
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
|
||||
m_customUi->customMixerTable->item(2,channel)->setText(
|
||||
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
|
||||
m_customUi->customMixerTable->item(3,channel)->setText(
|
||||
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
|
||||
m_customUi->customMixerTable->item(4,channel)->setText(
|
||||
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
|
||||
m_customUi->customMixerTable->item(5,channel)->setText(
|
||||
QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)));
|
||||
}
|
||||
}
|
||||
// QList<double> curveValues;
|
||||
// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
//
|
||||
// // is at least one of the curve values != 0?
|
||||
// if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
// m_customUi->customThrottle1Curve->initCurve(&curveValues);
|
||||
// }
|
||||
// else {
|
||||
// // no, init a straight curve
|
||||
// m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
|
||||
// }
|
||||
//
|
||||
// if (MixerSettings* mxr = qobject_cast<MixerSettings *>(mixer)) {
|
||||
// MixerSettings::DataFields mixerSettingsData = mxr->getData();
|
||||
// if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
|
||||
// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
||||
// else {
|
||||
// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Setup all Throttle2 curves for all types of airframes
|
||||
// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
//
|
||||
// if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
// m_customUi->customThrottle2Curve->initCurve(&curveValues);
|
||||
// }
|
||||
// else {
|
||||
// m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin());
|
||||
// }
|
||||
//
|
||||
// // Update the mixer table:
|
||||
// for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) {
|
||||
// UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
|
||||
// if (field)
|
||||
// {
|
||||
// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
|
||||
// if (q)
|
||||
// {
|
||||
// QString s = field->getValue().toString();
|
||||
// setComboCurrentIndex(q, q->findText(s));
|
||||
// }
|
||||
//
|
||||
// m_customUi->customMixerTable->item(1,channel)->setText(
|
||||
// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
|
||||
// m_customUi->customMixerTable->item(2,channel)->setText(
|
||||
// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
|
||||
// m_customUi->customMixerTable->item(3,channel)->setText(
|
||||
// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
|
||||
// m_customUi->customMixerTable->item(4,channel)->setText(
|
||||
// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
|
||||
// m_customUi->customMixerTable->item(5,channel)->setText(
|
||||
// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Update feed forward settings
|
||||
m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer,"FeedForward") * 100);
|
||||
@ -745,7 +700,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
@ -756,7 +711,8 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
|
||||
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
|
||||
|
||||
QString airframeType = "Custom"; //Sets airframe type default to "Custom"
|
||||
// Sets airframe type default to "Custom"
|
||||
QString airframeType = "Custom";
|
||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
@ -770,57 +726,59 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else {
|
||||
vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve());
|
||||
vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve());
|
||||
|
||||
// Update the table:
|
||||
for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) {
|
||||
QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
|
||||
if(q->currentText()=="Disabled")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
|
||||
else if(q->currentText()=="Motor")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
|
||||
else if(q->currentText()=="Servo")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
|
||||
else if(q->currentText()=="CameraRoll")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL);
|
||||
else if(q->currentText()=="CameraPitch")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH);
|
||||
else if(q->currentText()=="CameraYaw")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW);
|
||||
else if(q->currentText()=="Accessory0")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0);
|
||||
else if(q->currentText()=="Accessory1")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1);
|
||||
else if(q->currentText()=="Accessory2")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2);
|
||||
else if(q->currentText()=="Accessory3")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3);
|
||||
else if(q->currentText()=="Accessory4")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4);
|
||||
else if(q->currentText()=="Accessory5")
|
||||
vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5);
|
||||
|
||||
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
|
||||
m_customUi->customMixerTable->item(1,channel)->text().toDouble());
|
||||
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
|
||||
m_customUi->customMixerTable->item(2,channel)->text().toDouble());
|
||||
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
|
||||
m_customUi->customMixerTable->item(3,channel)->text().toDouble());
|
||||
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
|
||||
m_customUi->customMixerTable->item(4,channel)->text().toDouble());
|
||||
vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
|
||||
m_customUi->customMixerTable->item(5,channel)->text().toDouble());
|
||||
}
|
||||
airframeType = m_custom->updateConfigObjectsFromWidgets();
|
||||
// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve());
|
||||
// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve());
|
||||
//
|
||||
// // Update the table:
|
||||
// for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) {
|
||||
// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
|
||||
// if(q->currentText()=="Disabled")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
|
||||
// else if(q->currentText()=="Motor")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
|
||||
// else if(q->currentText()=="Servo")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
|
||||
// else if(q->currentText()=="CameraRoll")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL);
|
||||
// else if(q->currentText()=="CameraPitch")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH);
|
||||
// else if(q->currentText()=="CameraYaw")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW);
|
||||
// else if(q->currentText()=="Accessory0")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0);
|
||||
// else if(q->currentText()=="Accessory1")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1);
|
||||
// else if(q->currentText()=="Accessory2")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2);
|
||||
// else if(q->currentText()=="Accessory3")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3);
|
||||
// else if(q->currentText()=="Accessory4")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4);
|
||||
// else if(q->currentText()=="Accessory5")
|
||||
// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5);
|
||||
//
|
||||
// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
|
||||
// m_customUi->customMixerTable->item(1,channel)->text().toDouble());
|
||||
// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
|
||||
// m_customUi->customMixerTable->item(2,channel)->text().toDouble());
|
||||
// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
|
||||
// m_customUi->customMixerTable->item(3,channel)->text().toDouble());
|
||||
// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
|
||||
// m_customUi->customMixerTable->item(4,channel)->text().toDouble());
|
||||
// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
|
||||
// m_customUi->customMixerTable->item(5,channel)->text().toDouble());
|
||||
// }
|
||||
}
|
||||
|
||||
// set the airframe type
|
||||
UAVDataObject* system = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(system);
|
||||
|
||||
QPointer<UAVObjectField> field = system->getField(QString("AirframeType"));
|
||||
if (field)
|
||||
if (field) {
|
||||
field->setValue(airframeType);
|
||||
}
|
||||
|
||||
updateCustomAirframeUI();
|
||||
}
|
||||
@ -830,7 +788,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::openHelp()
|
||||
{
|
||||
|
||||
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/44Cf", QUrl::StrictMode) );
|
||||
}
|
||||
|
||||
@ -841,16 +798,11 @@ void ConfigVehicleTypeWidget::openHelp()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index)
|
||||
{
|
||||
if (index >= 0 && index < box->count())
|
||||
if (index >= 0 && index < box->count()) {
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigVehicleTypeWidget::reverseMultirotorMotor(){
|
||||
QString frameType = m_multirotorUi->multirotorFrameType->currentText();
|
||||
m_multirotor->drawAirframe(frameType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
WHAT DOES THIS DO???
|
||||
*/
|
||||
|
@ -28,29 +28,14 @@
|
||||
#define CONFIGVEHICLETYPEWIDGET_H
|
||||
|
||||
#include "ui_airframe.h"
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include "cfg_vehicletypes/configccpmwidget.h"
|
||||
#include "cfg_vehicletypes/configfixedwingwidget.h"
|
||||
#include "cfg_vehicletypes/configgroundvehiclewidget.h"
|
||||
#include "cfg_vehicletypes/configmultirotorwidget.h"
|
||||
#include "uavobject.h"
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
|
||||
#include "ui_airframe_ccpm.h"
|
||||
#include "ui_airframe_fixedwing.h"
|
||||
#include "ui_airframe_ground.h"
|
||||
#include "ui_airframe_multirotor.h"
|
||||
#include "ui_airframe_custom.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
class Ui_Widget;
|
||||
#include <QComboBox>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
class ConfigVehicleTypeWidget: public ConfigTaskWidget
|
||||
{
|
||||
@ -65,16 +50,11 @@ public:
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
|
||||
Ui_CcpmConfigWidget *m_ccpmUi;
|
||||
Ui_FixedWingConfigWidget *m_fixedwingUi;
|
||||
Ui_MultiRotorConfigWidget *m_multirotorUi;
|
||||
Ui_GroundConfigWidget *m_groundUi;
|
||||
Ui_CustomConfigWidget *m_customUi;
|
||||
|
||||
ConfigCcpmWidget *m_heli;
|
||||
ConfigFixedWingWidget *m_fixedwing;
|
||||
ConfigMultiRotorWidget *m_multirotor;
|
||||
ConfigGroundVehicleWidget *m_groundvehicle;
|
||||
VehicleConfig *m_heli;
|
||||
VehicleConfig *m_fixedwing;
|
||||
VehicleConfig *m_multirotor;
|
||||
VehicleConfig *m_groundvehicle;
|
||||
VehicleConfig *m_custom;
|
||||
|
||||
void updateCustomAirframeUI();
|
||||
void addToDirtyMonitor();
|
||||
@ -86,7 +66,6 @@ private:
|
||||
QStringList mixerTypes;
|
||||
QStringList mixerVectors;
|
||||
|
||||
QGraphicsSvgItem *quad;
|
||||
bool ffTuningInProgress;
|
||||
bool ffTuningPhase;
|
||||
UAVObject::Metadata accInitialData;
|
||||
@ -100,36 +79,14 @@ private slots:
|
||||
|
||||
void setupAirframeUI(QString type);
|
||||
|
||||
void toggleAileron2(int index);
|
||||
void toggleElevator2(int index);
|
||||
void toggleRudder2(int index);
|
||||
// void toggleAileron2(int index);
|
||||
// void toggleElevator2(int index);
|
||||
// void toggleRudder2(int index);
|
||||
void switchAirframeType(int index);
|
||||
|
||||
void enableFFTest();
|
||||
void openHelp();
|
||||
void reverseMultirotorMotor();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class SpinBoxDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpinBoxDelegate(QObject *parent = 0);
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
#endif // CONFIGVEHICLETYPEWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user