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