mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Refactor configwidgets for multirotor,fixedwing,heli,ground;
VehicleConfig subclasses ConfigTaskWidget and adds guiconfigdata bit storage; Align channelbox items so 'None' is first;
This commit is contained in:
parent
ed54716436
commit
64688be0a1
@ -44,21 +44,17 @@
|
||||
#define Pi 3.14159265358979323846
|
||||
|
||||
|
||||
ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent)
|
||||
{
|
||||
int i;
|
||||
|
||||
m_ccpm = new Ui_ccpmWidget();
|
||||
m_ccpm->setupUi(this);
|
||||
SwashLvlConfigurationInProgress=0;
|
||||
SwashLvlState=0;
|
||||
SwashLvlServoInterlock=0;
|
||||
updatingFromHardware=FALSE;
|
||||
updatingToHardware=FALSE;
|
||||
|
||||
// Now connect the widget to the ManualControlCommand / Channel UAVObject
|
||||
//ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
//UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
m_ccpm = new Ui_ccpmWidget();
|
||||
m_ccpm->setupUi(this);
|
||||
|
||||
// Initialization of the swashplaye widget
|
||||
m_ccpm->SwashplateImage->setScene(new QGraphicsScene(this));
|
||||
@ -148,20 +144,20 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
Q_ASSERT(curve2source);
|
||||
|
||||
QStringList channels;
|
||||
channels << "Channel1" << "Channel2" << "Channel3" << "Channel4" <<
|
||||
"Channel5" << "Channel6" << "Channel7" << "Channel8" << "None";
|
||||
channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" <<
|
||||
"Channel5" << "Channel6" << "Channel7" << "Channel8";
|
||||
m_ccpm->ccpmEngineChannel->addItems(channels);
|
||||
m_ccpm->ccpmEngineChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmEngineChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmTailChannel->addItems(channels);
|
||||
m_ccpm->ccpmTailChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmTailChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoWChannel->addItems(channels);
|
||||
m_ccpm->ccpmServoWChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoWChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoXChannel->addItems(channels);
|
||||
m_ccpm->ccpmServoXChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoXChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->addItems(channels);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->addItems(channels);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
|
||||
QStringList Types;
|
||||
Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") <<
|
||||
@ -170,12 +166,14 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
QString::fromUtf8("Custom - User Angles") << QString::fromUtf8("Custom - Advanced Settings");
|
||||
m_ccpm->ccpmType->addItems(Types);
|
||||
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - 1);
|
||||
requestccpmUpdate();
|
||||
|
||||
UpdateCurveSettings();
|
||||
|
||||
//disable changing number of points in curves until UAVObjects have more than 5
|
||||
m_ccpm->NumCurvePoints->setEnabled(0);
|
||||
|
||||
refreshWidgetsValues(QString("HeliCP"));
|
||||
|
||||
UpdateType();
|
||||
|
||||
//connect(m_ccpm->saveccpmToSD, SIGNAL(clicked()), this, SLOT(saveccpmUpdate()));
|
||||
@ -229,13 +227,91 @@ ConfigccpmWidget::~ConfigccpmWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::setupUI(QString frameType)
|
||||
{
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
configData->heli.Throttle = 0;
|
||||
configData->heli.Tail = 0;
|
||||
configData->heli.ServoIndexW = 0;
|
||||
configData->heli.ServoIndexX = 0;
|
||||
configData->heli.ServoIndexY = 0;
|
||||
configData->heli.ServoIndexZ = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigccpmWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigccpmWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
heliGUISettingsStruct heli = configData.heli;
|
||||
|
||||
if (heli.Throttle > 0)
|
||||
channelDesc[heli.Throttle - 1] = QString("Throttle");
|
||||
if (heli.Tail > 0)
|
||||
channelDesc[heli.Tail - 1] = QString("Tail");
|
||||
|
||||
switch(heli.FirstServoIndex)
|
||||
{
|
||||
case 0: //front
|
||||
if (heli.ServoIndexW > 0)
|
||||
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
|
||||
if (heli.ServoIndexX > 0)
|
||||
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
|
||||
if (heli.ServoIndexY > 0)
|
||||
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
|
||||
break;
|
||||
|
||||
case 1: //right
|
||||
if (heli.ServoIndexW > 0)
|
||||
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
|
||||
if (heli.ServoIndexX > 0)
|
||||
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
|
||||
if (heli.ServoIndexY > 0)
|
||||
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
|
||||
break;
|
||||
|
||||
case 2: //rear
|
||||
if (heli.ServoIndexW > 0)
|
||||
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
|
||||
if (heli.ServoIndexX > 0)
|
||||
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
|
||||
if (heli.ServoIndexY > 0)
|
||||
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
|
||||
break;
|
||||
|
||||
case 3: //left
|
||||
if (heli.ServoIndexW > 0)
|
||||
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
|
||||
if (heli.ServoIndexX > 0)
|
||||
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
|
||||
if (heli.ServoIndexY > 0)
|
||||
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
|
||||
break;
|
||||
|
||||
}
|
||||
if (heli.ServoIndexZ > 0)
|
||||
channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::UpdateType()
|
||||
{
|
||||
int TypeInt,SingleServoIndex,NumServosDefined;
|
||||
QString TypeText;
|
||||
double AdjustmentAngle=0;
|
||||
|
||||
UpdateCCPMOptionsFromUI();
|
||||
SetUIComponentVisibilities();
|
||||
|
||||
TypeInt = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
|
||||
@ -283,8 +359,8 @@ void ConfigccpmWidget::UpdateType()
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleY->setEnabled(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
//m_ccpm->ccpmCorrectionAngle->setValue(0);
|
||||
@ -298,7 +374,7 @@ void ConfigccpmWidget::UpdateType()
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
//m_ccpm->ccpmCorrectionAngle->setValue(0);
|
||||
NumServosDefined=3;
|
||||
@ -323,7 +399,7 @@ void ConfigccpmWidget::UpdateType()
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
//m_ccpm->ccpmCorrectionAngle->setValue(0);
|
||||
NumServosDefined=3;
|
||||
@ -336,7 +412,7 @@ void ConfigccpmWidget::UpdateType()
|
||||
m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360));
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
//m_ccpm->ccpmCorrectionAngle->setValue(0);
|
||||
NumServosDefined=3;
|
||||
@ -350,8 +426,8 @@ void ConfigccpmWidget::UpdateType()
|
||||
m_ccpm->ccpmAngleZ->setValue(0);
|
||||
m_ccpm->ccpmAngleY->setEnabled(0);
|
||||
m_ccpm->ccpmAngleZ->setEnabled(0);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(8);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
|
||||
m_ccpm->ccpmServoYChannel->setEnabled(0);
|
||||
m_ccpm->ccpmServoZChannel->setEnabled(0);
|
||||
//m_ccpm->ccpmCorrectionAngle->setValue(0);
|
||||
@ -735,10 +811,10 @@ void ConfigccpmWidget::ccpmSwashplateRedraw()
|
||||
defined[1]=(m_ccpm->ccpmServoXChannel->isEnabled());
|
||||
defined[2]=(m_ccpm->ccpmServoYChannel->isEnabled());
|
||||
defined[3]=(m_ccpm->ccpmServoZChannel->isEnabled());
|
||||
used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()<8)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()<8)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()<8)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()<8)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
angle[0]=(CorrectionAngle+180+m_ccpm->ccpmAngleW->value())*Pi/180.00;
|
||||
angle[1]=(CorrectionAngle+180+m_ccpm->ccpmAngleX->value())*Pi/180.00;
|
||||
angle[2]=(CorrectionAngle+180+m_ccpm->ccpmAngleY->value())*Pi/180.00;
|
||||
@ -803,61 +879,6 @@ void ConfigccpmWidget::ccpmSwashplateUpdate()
|
||||
UpdateMixer();
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::ccpmChannelCheck()
|
||||
{
|
||||
if((m_ccpm->ccpmServoWChannel->currentIndex()==8)&&(m_ccpm->ccpmServoWChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText("<font color=red>Servo W</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText("<font color=black>Servo W</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoXChannel->currentIndex()==8)&&(m_ccpm->ccpmServoXChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText("<font color=red>Servo X</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText("<font color=black>Servo X</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoYChannel->currentIndex()==8)&&(m_ccpm->ccpmServoYChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText("<font color=red>Servo Y</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText("<font color=black>Servo Y</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoZChannel->currentIndex()==8)&&(m_ccpm->ccpmServoZChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText("<font color=red>Servo Z</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText("<font color=black>Servo Z</font>");
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmEngineChannel->currentIndex()==8)&&(m_ccpm->ccpmEngineChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("<font color=red>Engine</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("<font color=black>Engine</font>");
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmTailChannel->currentIndex()==8)&&(m_ccpm->ccpmTailChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText("<font color=red>Tail Rotor</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText("<font color=black>Tail Rotor</font>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::UpdateMixer()
|
||||
{
|
||||
bool useCCPM;
|
||||
@ -866,13 +887,16 @@ void ConfigccpmWidget::UpdateMixer()
|
||||
float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6];
|
||||
QString Channel;
|
||||
|
||||
ccpmChannelCheck();
|
||||
UpdateCCPMOptionsFromUI();
|
||||
throwConfigError(QString("HeliCP"));
|
||||
|
||||
useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState);
|
||||
useCyclic = GUIConfigData.heli.ccpmLinkRollState;
|
||||
updateConfigObjectsFromWidgets();
|
||||
|
||||
CollectiveConstant = (float)GUIConfigData.heli.SliderValue0 / 100.00;
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
|
||||
useCyclic = config.heli.ccpmLinkRollState;
|
||||
|
||||
CollectiveConstant = (float)config.heli.SliderValue0 / 100.00;
|
||||
|
||||
if (useCCPM)
|
||||
{//cyclic = 1 - collective
|
||||
@ -881,18 +905,18 @@ void ConfigccpmWidget::UpdateMixer()
|
||||
}
|
||||
else
|
||||
{
|
||||
PitchConstant = (float)GUIConfigData.heli.SliderValue1 / 100.00;;
|
||||
PitchConstant = (float)config.heli.SliderValue1 / 100.00;;
|
||||
if (useCyclic)
|
||||
{
|
||||
RollConstant = PitchConstant;
|
||||
}
|
||||
else
|
||||
{
|
||||
RollConstant = (float)GUIConfigData.heli.SliderValue2 / 100.00;;
|
||||
RollConstant = (float)config.heli.SliderValue2 / 100.00;;
|
||||
}
|
||||
}
|
||||
|
||||
if (GUIConfigData.heli.SwashplateType>0)
|
||||
if (config.heli.SwashplateType>0)
|
||||
{//not advanced settings
|
||||
//get the channel data from the ui
|
||||
MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex();
|
||||
@ -914,18 +938,18 @@ void ConfigccpmWidget::UpdateMixer()
|
||||
ThisEnable[4] = m_ccpm->ccpmServoYChannel->isEnabled();
|
||||
ThisEnable[5] = m_ccpm->ccpmServoZChannel->isEnabled();
|
||||
|
||||
ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2]+1 ));
|
||||
ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3]+1 ));
|
||||
ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4]+1 ));
|
||||
ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5]+1 ));
|
||||
ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] ));
|
||||
ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] ));
|
||||
ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4] ));
|
||||
ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5] ));
|
||||
|
||||
|
||||
//go through the user data and update the mixer matrix
|
||||
for (i=0;i<6;i++)
|
||||
{
|
||||
if ((MixerChannelData[i]<8)&&((ThisEnable[i])||(i<2)))
|
||||
if ((MixerChannelData[i]>0)&&((ThisEnable[i])||(i<2)))
|
||||
{
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i]+1 ));
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] ));
|
||||
//config the vector
|
||||
if (i==0)
|
||||
{//motor-engine
|
||||
@ -947,8 +971,8 @@ void ConfigccpmWidget::UpdateMixer()
|
||||
{//Swashplate
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
|
||||
m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
|
||||
|
||||
}
|
||||
@ -970,131 +994,132 @@ void ConfigccpmWidget::UpdateMixer()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**************************
|
||||
* ccpm settings
|
||||
**************************/
|
||||
/*
|
||||
Get the state of the UI check boxes and change the visibility of sliders
|
||||
typedef struct {
|
||||
uint SwasplateType:3;
|
||||
uint FirstServoIndex:2;
|
||||
uint CorrectionAngle:9;
|
||||
uint ccpmCollectivePassthroughState:1;
|
||||
uint ccpmLinkCyclicState:1;
|
||||
uint ccpmLinkRollState:1;
|
||||
uint CollectiveChannel:3;
|
||||
uint padding:12;
|
||||
} __attribute__((packed)) heliGUISettingsStruct;
|
||||
|
||||
*/
|
||||
void ConfigccpmWidget::UpdateCCPMOptionsFromUI()
|
||||
QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI()
|
||||
{
|
||||
QString airframeType = "HeliCP";
|
||||
|
||||
bool useCCPM;
|
||||
bool useCyclic;
|
||||
|
||||
if (updatingFromHardware) return;
|
||||
if (updatingFromHardware) return airframeType;
|
||||
|
||||
updatingFromHardware = TRUE;
|
||||
|
||||
//get the user options
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
GUIConfigData.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
|
||||
GUIConfigData.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex();
|
||||
config.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1;
|
||||
config.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex();
|
||||
|
||||
//ccpm mixing options
|
||||
GUIConfigData.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked();
|
||||
GUIConfigData.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked();
|
||||
GUIConfigData.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked();
|
||||
useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState);
|
||||
useCyclic = GUIConfigData.heli.ccpmLinkRollState;
|
||||
config.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked();
|
||||
config.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked();
|
||||
config.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked();
|
||||
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
|
||||
useCyclic = config.heli.ccpmLinkRollState;
|
||||
|
||||
//correction angle
|
||||
GUIConfigData.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value();
|
||||
config.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value();
|
||||
|
||||
//update sliders
|
||||
if (useCCPM)
|
||||
{
|
||||
GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value();
|
||||
config.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value();
|
||||
config.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value();
|
||||
}
|
||||
if (useCyclic)
|
||||
{
|
||||
GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value();
|
||||
config.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value();
|
||||
config.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value();
|
||||
}
|
||||
GUIConfigData.heli.SliderValue2 = m_ccpm->ccpmRollScale->value();
|
||||
config.heli.SliderValue2 = m_ccpm->ccpmRollScale->value();
|
||||
|
||||
//servo assignments
|
||||
GUIConfigData.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex();
|
||||
GUIConfigData.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex();
|
||||
GUIConfigData.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
GUIConfigData.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
config.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex();
|
||||
config.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex();
|
||||
config.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
config.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
|
||||
//throttle
|
||||
GUIConfigData.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex();
|
||||
config.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex();
|
||||
//tail
|
||||
GUIConfigData.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex();
|
||||
config.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
|
||||
//setMixer();
|
||||
|
||||
updatingFromHardware = FALSE;
|
||||
return airframeType;
|
||||
}
|
||||
void ConfigccpmWidget::UpdateCCPMUIFromOptions()
|
||||
|
||||
void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions()
|
||||
{
|
||||
Q_UNUSED(frameType);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//swashplate config
|
||||
m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - (GUIConfigData.heli.SwashplateType +1));
|
||||
m_ccpm->ccpmSingleServo->setCurrentIndex(GUIConfigData.heli.FirstServoIndex);
|
||||
setComboCurrentIndex( m_ccpm->ccpmType, m_ccpm->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
setComboCurrentIndex(m_ccpm->ccpmSingleServo, config.heli.FirstServoIndex);
|
||||
|
||||
//ccpm mixing options
|
||||
m_ccpm->ccpmCollectivePassthrough->setChecked(GUIConfigData.heli.ccpmCollectivePassthroughState);
|
||||
m_ccpm->ccpmLinkCyclic->setChecked(GUIConfigData.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmLinkRoll->setChecked(GUIConfigData.heli.ccpmLinkRollState);
|
||||
m_ccpm->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState);
|
||||
m_ccpm->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState);
|
||||
|
||||
//correction angle
|
||||
m_ccpm->ccpmCorrectionAngle->setValue(GUIConfigData.heli.CorrectionAngle);
|
||||
m_ccpm->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle);
|
||||
|
||||
//update sliders
|
||||
m_ccpm->ccpmCollectiveScale->setValue(GUIConfigData.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectiveScaleBox->setValue(GUIConfigData.heli.SliderValue0);
|
||||
m_ccpm->ccpmCyclicScale->setValue(GUIConfigData.heli.SliderValue1);
|
||||
m_ccpm->ccpmCyclicScaleBox->setValue(GUIConfigData.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScale->setValue(GUIConfigData.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScaleBox->setValue(GUIConfigData.heli.SliderValue1);
|
||||
m_ccpm->ccpmRollScale->setValue(GUIConfigData.heli.SliderValue2);
|
||||
m_ccpm->ccpmRollScaleBox->setValue(GUIConfigData.heli.SliderValue2);
|
||||
m_ccpm->ccpmCollectiveSlider->setValue(GUIConfigData.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectivespinBox->setValue(GUIConfigData.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectiveScale->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCyclicScale->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScale->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmPitchScaleBox->setValue(config.heli.SliderValue1);
|
||||
m_ccpm->ccpmRollScale->setValue(config.heli.SliderValue2);
|
||||
m_ccpm->ccpmRollScaleBox->setValue(config.heli.SliderValue2);
|
||||
m_ccpm->ccpmCollectiveSlider->setValue(config.heli.SliderValue0);
|
||||
m_ccpm->ccpmCollectivespinBox->setValue(config.heli.SliderValue0);
|
||||
|
||||
//servo assignments
|
||||
m_ccpm->ccpmServoWChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexW);
|
||||
m_ccpm->ccpmServoXChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexX);
|
||||
m_ccpm->ccpmServoYChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexY);
|
||||
m_ccpm->ccpmServoZChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexZ);
|
||||
setComboCurrentIndex(m_ccpm->ccpmServoWChannel, config.heli.ServoIndexW);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoXChannel,config.heli.ServoIndexX);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoYChannel,config.heli.ServoIndexY);
|
||||
setComboCurrentIndex( m_ccpm->ccpmServoZChannel,config.heli.ServoIndexZ);
|
||||
|
||||
//throttle
|
||||
m_ccpm->ccpmEngineChannel->setCurrentIndex(GUIConfigData.heli.Throttle);
|
||||
setComboCurrentIndex( m_ccpm->ccpmEngineChannel, config.heli.Throttle);
|
||||
//tail
|
||||
m_ccpm->ccpmTailChannel->setCurrentIndex((GUIConfigData.heli.Tail));
|
||||
setComboCurrentIndex( m_ccpm->ccpmTailChannel, config.heli.Tail);
|
||||
|
||||
//getMixer();
|
||||
}
|
||||
|
||||
|
||||
void ConfigccpmWidget::SetUIComponentVisibilities()
|
||||
{
|
||||
UpdateCCPMOptionsFromUI();
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//set which sliders are user...
|
||||
m_ccpm->ccpmRevoMixingBox->setVisible(0);
|
||||
|
||||
m_ccpm->ccpmPitchMixingBox->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmCollectiveScalingBox->setVisible(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmPitchMixingBox->setVisible(!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState);
|
||||
m_ccpm->ccpmCollectiveScalingBox->setVisible(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
|
||||
|
||||
m_ccpm->ccpmLinkCyclic->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState);
|
||||
m_ccpm->ccpmLinkCyclic->setVisible(!config.heli.ccpmCollectivePassthroughState);
|
||||
|
||||
m_ccpm->ccpmCyclicScalingBox->setVisible((GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState) && GUIConfigData.heli.ccpmLinkRollState);
|
||||
if (!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState)
|
||||
m_ccpm->ccpmCyclicScalingBox->setVisible((config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState) && config.heli.ccpmLinkRollState);
|
||||
if (!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState)
|
||||
{
|
||||
m_ccpm->ccpmPitchScalingBox->setVisible(0);
|
||||
m_ccpm->ccpmRollScalingBox->setVisible(0);
|
||||
@ -1103,8 +1128,8 @@ void ConfigccpmWidget::SetUIComponentVisibilities()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmPitchScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState);
|
||||
m_ccpm->ccpmRollScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState);
|
||||
m_ccpm->ccpmPitchScalingBox->setVisible(!config.heli.ccpmLinkRollState);
|
||||
m_ccpm->ccpmRollScalingBox->setVisible(!config.heli.ccpmLinkRollState);
|
||||
m_ccpm->ccpmLinkRoll->setVisible(1);
|
||||
}
|
||||
|
||||
@ -1112,116 +1137,18 @@ void ConfigccpmWidget::SetUIComponentVisibilities()
|
||||
/**
|
||||
Request the current value of the SystemSettings which holds the ccpm type
|
||||
*/
|
||||
void ConfigccpmWidget::requestccpmUpdate()
|
||||
void ConfigccpmWidget::getMixer()
|
||||
{
|
||||
#define MaxAngleError 2
|
||||
int MixerDataFromHeli[8][5];
|
||||
quint8 MixerOutputType[8];
|
||||
int EngineChannel,TailRotorChannel,ServoChannels[4],ServoAngles[4],SortAngles[4],ServoCurve2[4];
|
||||
int NumServos=0;
|
||||
|
||||
if (SwashLvlConfigurationInProgress)return;
|
||||
if (updatingToHardware)return;
|
||||
updatingFromHardware=TRUE;
|
||||
|
||||
unsigned int i,j;
|
||||
|
||||
// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
// Q_ASSERT(systemSettings);
|
||||
// SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
// Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
|
||||
// (sizeof(GUIConfigData.UAVObject) / sizeof(GUIConfigData.UAVObject[0])));
|
||||
|
||||
// for(i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++)
|
||||
// GUIConfigData.UAVObject[i]=systemSettingsData.GUIConfigData[i];
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
|
||||
UpdateCCPMUIFromOptions();
|
||||
int i;
|
||||
|
||||
// Get existing mixer settings
|
||||
MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
||||
MixerSettings::DataFields mixerSettingsData = mixerSettings->getData();
|
||||
|
||||
//go through the user data and update the mixer matrix
|
||||
for (j=0;j<5;j++)
|
||||
{
|
||||
MixerDataFromHeli[0][j] = mixerSettingsData.Mixer1Vector[j];
|
||||
MixerDataFromHeli[1][j] = mixerSettingsData.Mixer2Vector[j];
|
||||
MixerDataFromHeli[2][j] = mixerSettingsData.Mixer3Vector[j];
|
||||
MixerDataFromHeli[3][j] = mixerSettingsData.Mixer4Vector[j];
|
||||
MixerDataFromHeli[4][j] = mixerSettingsData.Mixer5Vector[j];
|
||||
MixerDataFromHeli[5][j] = mixerSettingsData.Mixer6Vector[j];
|
||||
MixerDataFromHeli[6][j] = mixerSettingsData.Mixer7Vector[j];
|
||||
MixerDataFromHeli[7][j] = mixerSettingsData.Mixer8Vector[j];
|
||||
}
|
||||
|
||||
MixerOutputType[0] = mixerSettingsData.Mixer1Type;
|
||||
MixerOutputType[1] = mixerSettingsData.Mixer2Type;
|
||||
MixerOutputType[2] = mixerSettingsData.Mixer3Type;
|
||||
MixerOutputType[3] = mixerSettingsData.Mixer4Type;
|
||||
MixerOutputType[4] = mixerSettingsData.Mixer5Type;
|
||||
MixerOutputType[5] = mixerSettingsData.Mixer6Type;
|
||||
MixerOutputType[6] = mixerSettingsData.Mixer7Type;
|
||||
MixerOutputType[7] = mixerSettingsData.Mixer8Type;
|
||||
|
||||
EngineChannel =-1;
|
||||
TailRotorChannel =-1;
|
||||
for (j=0;j<5;j++)
|
||||
{
|
||||
ServoChannels[j]=8;
|
||||
ServoCurve2[j]=0;
|
||||
ServoAngles[j]=0;
|
||||
SortAngles[j]=j;
|
||||
}
|
||||
|
||||
NumServos=0;
|
||||
//process the data from Heli and try to figure out the settings...
|
||||
for (i=0;i<8;i++)
|
||||
{
|
||||
//check if this is the engine... Throttle only
|
||||
if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_MOTOR)&&
|
||||
(MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1
|
||||
(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
|
||||
(MixerDataFromHeli[i][2]==0)&&//Roll
|
||||
(MixerDataFromHeli[i][3]==0)&&//Pitch
|
||||
(MixerDataFromHeli[i][4]==0))//Yaw
|
||||
{
|
||||
EngineChannel = i;
|
||||
//m_ccpm->ccpmEngineChannel->setCurrentIndex(i);
|
||||
|
||||
}
|
||||
//check if this is the tail rotor... REVO and YAW
|
||||
if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&&
|
||||
//(MixerDataFromHeli[i][0]!=0)&&//ThrottleCurve1
|
||||
(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
|
||||
(MixerDataFromHeli[i][2]==0)&&//Roll
|
||||
(MixerDataFromHeli[i][3]==0)&&//Pitch
|
||||
(MixerDataFromHeli[i][4]!=0))//Yaw
|
||||
{
|
||||
TailRotorChannel = i;
|
||||
//m_ccpm->ccpmTailChannel->setCurrentIndex(i);
|
||||
m_ccpm->ccpmRevoSlider->setValue((MixerDataFromHeli[i][0]*100)/127);
|
||||
m_ccpm->ccpmREVOspinBox->setValue((MixerDataFromHeli[i][0]*100)/127);
|
||||
}
|
||||
//check if this is a swashplate servo... Throttle is zero
|
||||
if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&&
|
||||
(MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1
|
||||
//(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2
|
||||
//(MixerDataFromHeli[i][2]==0)&&//Roll
|
||||
//(MixerDataFromHeli[i][3]==0)&&//Pitch
|
||||
(MixerDataFromHeli[i][4]==0))//Yaw
|
||||
{
|
||||
ServoChannels[NumServos] = i;//record the channel for this servo
|
||||
ServoCurve2[NumServos]=MixerDataFromHeli[i][1];//record the ThrottleCurve2 contribution to this servo
|
||||
ServoAngles[NumServos]=NumServos*45;//make this 0 for the final version
|
||||
|
||||
NumServos++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//get the settings for the curve from the mixer settings
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
@ -1232,7 +1159,7 @@ void ConfigccpmWidget::requestccpmUpdate()
|
||||
}
|
||||
|
||||
updatingFromHardware=FALSE;
|
||||
UpdateCCPMUIFromOptions();
|
||||
|
||||
ccpmSwashplateUpdate();
|
||||
}
|
||||
|
||||
@ -1240,27 +1167,12 @@ void ConfigccpmWidget::requestccpmUpdate()
|
||||
/**
|
||||
Sends the config to the board (ccpm type)
|
||||
*/
|
||||
void ConfigccpmWidget::sendccpmUpdate()
|
||||
void ConfigccpmWidget::setMixer()
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if (SwashLvlConfigurationInProgress)return;
|
||||
updatingToHardware=TRUE;
|
||||
//ShowDisclaimer(1);
|
||||
|
||||
UpdateCCPMOptionsFromUI();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
|
||||
// Store the data required to reconstruct
|
||||
// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
// Q_ASSERT(systemSettings);
|
||||
// SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
// for (i=0; i<SystemSettings::GUICONFIGDATA_NUMELEM; i++)
|
||||
// systemSettingsData.GUIConfigData[i] = GUIConfigData.UAVObject[i];
|
||||
|
||||
// systemSettings->setData(systemSettingsData);
|
||||
// systemSettings->updated();
|
||||
|
||||
MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(mixerSettings);
|
||||
@ -1316,7 +1228,7 @@ void ConfigccpmWidget::sendccpmUpdate()
|
||||
//mapping of collective input to curve 2...
|
||||
//MixerSettings.Curve2Source = Throttle,Roll,Pitch,Yaw,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5
|
||||
//check if we are using throttle or directly from a channel...
|
||||
if (GUIConfigData.heli.ccpmCollectivePassthroughState)
|
||||
if (GetConfigData().heli.ccpmCollectivePassthroughState)
|
||||
mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_COLLECTIVE;
|
||||
else
|
||||
mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_THROTTLE;
|
||||
@ -1335,7 +1247,8 @@ void ConfigccpmWidget::saveccpmUpdate()
|
||||
if (SwashLvlConfigurationInProgress)return;
|
||||
ShowDisclaimer(0);
|
||||
// Send update so that the latest value is saved
|
||||
sendccpmUpdate();
|
||||
//sendccpmUpdate();
|
||||
setMixer();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
saveObjectToSD(obj);
|
||||
@ -1402,7 +1315,8 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed()
|
||||
|
||||
|
||||
//download the current settings to the OP hw
|
||||
sendccpmUpdate();
|
||||
//sendccpmUpdate();
|
||||
setMixer();
|
||||
|
||||
//change control mode to gcs control / disarmed
|
||||
//set throttle to 0
|
||||
@ -1427,10 +1341,10 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed()
|
||||
oldSwashLvlConfiguration.ServoChannels[2]=m_ccpm->ccpmServoYChannel->currentIndex();
|
||||
oldSwashLvlConfiguration.ServoChannels[3]=m_ccpm->ccpmServoZChannel->currentIndex();
|
||||
//if servos are used
|
||||
oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()<8)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()<8)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()<8)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()<8)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled()));
|
||||
oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled()));
|
||||
//min,neutral,max values for the servos
|
||||
for (i=0;i<CCPM_MAX_SWASH_SERVOS;i++)
|
||||
{
|
||||
@ -1822,3 +1736,63 @@ void ConfigccpmWidget::SwashLvlSpinBoxChanged(int value)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
void ConfigccpmWidget::throwConfigError(QString airframeType)
|
||||
{
|
||||
Q_UNUSED(airframeType);
|
||||
|
||||
if((m_ccpm->ccpmServoWChannel->currentIndex()==0)&&(m_ccpm->ccpmServoWChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText("<font color=red>Servo W</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoWLabel->setText("<font color=black>Servo W</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoXChannel->currentIndex()==0)&&(m_ccpm->ccpmServoXChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText("<font color=red>Servo X</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoXLabel->setText("<font color=black>Servo X</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoYChannel->currentIndex()==0)&&(m_ccpm->ccpmServoYChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText("<font color=red>Servo Y</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoYLabel->setText("<font color=black>Servo Y</font>");
|
||||
}
|
||||
if((m_ccpm->ccpmServoZChannel->currentIndex()==0)&&(m_ccpm->ccpmServoZChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText("<font color=red>Servo Z</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmServoZLabel->setText("<font color=black>Servo Z</font>");
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmEngineChannel->currentIndex()==0)&&(m_ccpm->ccpmEngineChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("<font color=red>Engine</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmEngineLabel->setText("<font color=black>Engine</font>");
|
||||
}
|
||||
|
||||
if((m_ccpm->ccpmTailChannel->currentIndex()==0)&&(m_ccpm->ccpmTailChannel->isEnabled()))
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText("<font color=red>Tail Rotor</font>");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ccpm->ccpmTailLabel->setText("<font color=black>Tail Rotor</font>");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "ui_ccpm.h"
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "guiconfigdata.h"
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
@ -50,33 +50,9 @@ typedef struct {
|
||||
int Neutral[CCPM_MAX_SWASH_SERVOS];
|
||||
int Min[CCPM_MAX_SWASH_SERVOS];
|
||||
} SwashplateServoSettingsStruct;
|
||||
//typedef struct {
|
||||
// uint SwasplateType:3;
|
||||
// uint FirstServoIndex:2;
|
||||
// uint CorrectionAngle:9;
|
||||
// uint ccpmCollectivePassthroughState:1;
|
||||
// uint ccpmLinkCyclicState:1;
|
||||
// uint ccpmLinkRollState:1;
|
||||
// uint SliderValue0:7;
|
||||
// uint SliderValue1:7;
|
||||
// uint SliderValue2:7;//41bits
|
||||
// uint ServoIndexW:4;
|
||||
// uint ServoIndexX:4;
|
||||
// uint ServoIndexY:4;
|
||||
// uint ServoIndexZ:4;//57bits
|
||||
// uint Throttle:4;
|
||||
// uint Tail:4; //65bits
|
||||
// quint32 padding1:31; //96bits
|
||||
// quint32 padding2; //128bits
|
||||
//} __attribute__((packed)) heliGUISettingsStruct;
|
||||
|
||||
//typedef union
|
||||
//{
|
||||
// uint UAVObject[4];//32bits * 4
|
||||
// heliGUISettingsStruct heli;//128bits
|
||||
//} GUIConfigDataUnion;
|
||||
|
||||
class ConfigccpmWidget: public ConfigTaskWidget
|
||||
class ConfigccpmWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -90,14 +66,6 @@ private:
|
||||
Ui_ccpmWidget *m_ccpm;
|
||||
QGraphicsSvgItem *SwashplateImg;
|
||||
QGraphicsSvgItem *CurveImg;
|
||||
//QGraphicsSvgItem *ServoW;
|
||||
//QGraphicsSvgItem *ServoX;
|
||||
//QGraphicsSvgItem *ServoY;
|
||||
//QGraphicsSvgItem *ServoZ;
|
||||
//QGraphicsTextItem *ServoWText;
|
||||
//QGraphicsTextItem *ServoXText;
|
||||
//QGraphicsTextItem *ServoYText;
|
||||
//QGraphicsTextItem *ServoZText;
|
||||
QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
|
||||
QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS];
|
||||
QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS];
|
||||
@ -112,9 +80,6 @@ private:
|
||||
SwashplateServoSettingsStruct oldSwashLvlConfiguration;
|
||||
SwashplateServoSettingsStruct newSwashLvlConfiguration;
|
||||
|
||||
GUIConfigDataManager GUIManager;
|
||||
GUIConfigDataUnion GUIConfigData;
|
||||
|
||||
int MixerChannelData[6];
|
||||
int ShowDisclaimer(int messageID);
|
||||
virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget
|
||||
@ -122,7 +87,15 @@ private:
|
||||
bool updatingFromHardware;
|
||||
bool updatingToHardware;
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual QStringList getChannelDescriptions();
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual void throwConfigError(QString airframeType);
|
||||
|
||||
void ccpmSwashplateUpdate();
|
||||
void ccpmSwashplateRedraw();
|
||||
void UpdateCurveSettings();
|
||||
@ -139,11 +112,10 @@ private:
|
||||
void SwashLvlCancelButtonPressed();
|
||||
void SwashLvlFinishButtonPressed();
|
||||
|
||||
void UpdateCCPMOptionsFromUI();
|
||||
void UpdateCCPMUIFromOptions();
|
||||
//void UpdateCCPMOptionsFromUI();
|
||||
//void UpdateCCPMUIFromOptions();
|
||||
|
||||
void SetUIComponentVisibilities();
|
||||
void ccpmChannelCheck();
|
||||
|
||||
void enableSwashplateLevellingControl(bool state);
|
||||
void setSwashplateLevel(int percent);
|
||||
@ -151,8 +123,8 @@ private:
|
||||
virtual void refreshValues() {}; // Not used
|
||||
|
||||
public slots:
|
||||
void requestccpmUpdate();
|
||||
void sendccpmUpdate();
|
||||
void getMixer();
|
||||
void setMixer();
|
||||
void saveccpmUpdate();
|
||||
|
||||
protected:
|
||||
|
@ -24,7 +24,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
//#include "configfixedwingwidget.h"
|
||||
#include "configfixedwingwidget.h"
|
||||
#include "configvehicletypewidget.h"
|
||||
#include "mixersettings.h"
|
||||
|
||||
@ -40,18 +40,38 @@
|
||||
|
||||
#include "mixersettings.h"
|
||||
#include "systemsettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "actuatorcommand.h"
|
||||
|
||||
|
||||
/**
|
||||
Helper function to setup the UI
|
||||
Constructor
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType)
|
||||
ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
}
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
ConfigFixedWingWidget::~ConfigFixedWingWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Virtual function to setup the UI
|
||||
*/
|
||||
void ConfigFixedWingWidget::setupUI(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
|
||||
// Setup the UI
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
||||
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
|
||||
m_aircraft->fwRudder1Label->setEnabled(true);
|
||||
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
|
||||
@ -72,8 +92,8 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType)
|
||||
m_aircraft->elevonMixBox->setHidden(true);
|
||||
|
||||
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevon"));
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon"));
|
||||
m_aircraft->fwAileron1Label->setText("Elevon 1");
|
||||
m_aircraft->fwAileron2Label->setText("Elevon 2");
|
||||
m_aircraft->fwElevator1ChannelBox->setEnabled(false);
|
||||
@ -91,8 +111,8 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType)
|
||||
m_aircraft->elevonLabel2->setText("Pitch");
|
||||
|
||||
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Vtail"));
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail"));
|
||||
m_aircraft->fwRudder1ChannelBox->setEnabled(false);
|
||||
m_aircraft->fwRudder1Label->setEnabled(false);
|
||||
m_aircraft->fwRudder2ChannelBox->setEnabled(false);
|
||||
@ -111,12 +131,53 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType)
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
configData->fixedwing.FixedWingPitch1 = 0;
|
||||
configData->fixedwing.FixedWingPitch2 = 0;
|
||||
configData->fixedwing.FixedWingRoll1 = 0;
|
||||
configData->fixedwing.FixedWingRoll2 = 0;
|
||||
configData->fixedwing.FixedWingYaw1 = 0;
|
||||
configData->fixedwing.FixedWingYaw2 = 0;
|
||||
configData->fixedwing.FixedWingThrottle = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigFixedWingWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigFixedWingWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.fixedwing.FixedWingPitch1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingPitch1-1] = QString("FixedWingPitch1");
|
||||
if (configData.fixedwing.FixedWingPitch2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingPitch2-1] = QString("FixedWingPitch2");
|
||||
if (configData.fixedwing.FixedWingRoll1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingRoll1-1] = QString("FixedWingRoll1");
|
||||
if (configData.fixedwing.FixedWingRoll2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingRoll2-1] = QString("FixedWingRoll2");
|
||||
if (configData.fixedwing.FixedWingYaw1 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingYaw1-1] = QString("FixedWingYaw1");
|
||||
if (configData.fixedwing.FixedWingYaw2 > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingYaw2-1] = QString("FixedWingYaw2");
|
||||
if (configData.fixedwing.FixedWingThrottle > 0)
|
||||
channelDesc[configData.fixedwing.FixedWingThrottle-1] = QString("FixedWingThrottle");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
Virtual function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets()
|
||||
QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = "FixedWing";
|
||||
|
||||
@ -145,20 +206,19 @@ QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets()
|
||||
setupFrameVtail( airframeType );
|
||||
}
|
||||
|
||||
// Now reflect those settings in the "Custom" panel as well
|
||||
updateCustomAirframeUI();
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
Virtual function to refresh the UI widget values
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType)
|
||||
void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
fixedGUISettingsStruct fixed = GUIConfigData.fixed;
|
||||
Q_ASSERT(m_aircraft);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
fixedGUISettingsStruct fixed = config.fixedwing;
|
||||
|
||||
// Then retrieve how channels are setup
|
||||
setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle);
|
||||
@ -210,11 +270,11 @@ void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType)
|
||||
|
||||
Returns False if impossible to create the mixer.
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType)
|
||||
bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
|
||||
{
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwFixedWingChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - At least Pitch and either Roll or Yaw
|
||||
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||
@ -228,17 +288,17 @@ bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType)
|
||||
|
||||
// Now setup the channels:
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(config);
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -331,11 +391,11 @@ bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType)
|
||||
/**
|
||||
Setup Elevon
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType)
|
||||
bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
|
||||
{
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwFixedWingChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - At least Aileron1 and Aileron 2, and engine
|
||||
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||
@ -346,16 +406,16 @@ bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType)
|
||||
return false;
|
||||
}
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(config);
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -443,11 +503,11 @@ bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType)
|
||||
/**
|
||||
Setup VTail
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType)
|
||||
bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
|
||||
{
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwFixedWingChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - At least Pitch1 and Pitch2, and engine
|
||||
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||
@ -458,16 +518,16 @@ bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType)
|
||||
return false;
|
||||
}
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(config);
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -545,7 +605,7 @@ bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType)
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::throwFixedWingChannelConfigError(QString airframeType)
|
||||
void ConfigFixedWingWidget::throwConfigError(QString airframeType)
|
||||
{
|
||||
//Initialize configuration error flag
|
||||
bool error=false;
|
||||
|
@ -0,0 +1,74 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 CONFIGFIXEDWINGWIDGET_H
|
||||
#define CONFIGFIXEDWINGWIDGET_H
|
||||
|
||||
#include "ui_airframe.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 ConfigFixedWingWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigFixedWingWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
|
||||
~ConfigFixedWingWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
|
||||
bool setupFrameFixedWing(QString airframeType);
|
||||
bool setupFrameElevon(QString airframeType);
|
||||
bool setupFrameVtail(QString airframeType);
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual QStringList getChannelDescriptions();
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual void throwConfigError(QString airframeType);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGFIXEDWINGWIDGET_H
|
@ -24,7 +24,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
//#include "configgroundvehiclewidget.h"
|
||||
#include "configgroundvehiclewidget.h"
|
||||
#include "configvehicletypewidget.h"
|
||||
#include "mixersettings.h"
|
||||
|
||||
@ -40,18 +40,35 @@
|
||||
|
||||
#include "mixersettings.h"
|
||||
#include "systemsettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "actuatorcommand.h"
|
||||
|
||||
|
||||
/**
|
||||
Helper function to setup the UI
|
||||
Constructor
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||
ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
}
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
Virtual function to setup the UI
|
||||
*/
|
||||
void ConfigGroundVehicleWidget::setupUI(QString frameType)
|
||||
{
|
||||
m_aircraft->differentialSteeringMixBox->setHidden(true);
|
||||
//STILL NEEDS WORK
|
||||
// Setup the UI
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Ground"));
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
|
||||
|
||||
m_aircraft->gvEngineChannelBox->setEnabled(false);
|
||||
m_aircraft->gvEngineLabel->setEnabled(false);
|
||||
@ -64,7 +81,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||
m_aircraft->gvAileron2Label->setEnabled(false);
|
||||
|
||||
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Differential (tank)"));
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)"));
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||
m_aircraft->gvMotor1Label->setEnabled(true);
|
||||
|
||||
@ -89,7 +106,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||
|
||||
}
|
||||
else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Motorcycle"));
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle"));
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(false);
|
||||
m_aircraft->gvMotor1Label->setEnabled(false);
|
||||
|
||||
@ -113,7 +130,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
|
||||
}
|
||||
else {//Car
|
||||
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
|
||||
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
|
||||
|
||||
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||
m_aircraft->gvMotor1Label->setEnabled(true);
|
||||
@ -137,12 +154,46 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
configData->ground.GroundVehicleSteering1 = 0;
|
||||
configData->ground.GroundVehicleSteering2 = 0;
|
||||
configData->ground.GroundVehicleThrottle1 = 0;
|
||||
configData->ground.GroundVehicleThrottle2 = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
if (configData.ground.GroundVehicleSteering1 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1");
|
||||
if (configData.ground.GroundVehicleSteering2 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2");
|
||||
if (configData.ground.GroundVehicleThrottle1 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1");
|
||||
if (configData.ground.GroundVehicleThrottle2 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
Virtual function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigVehicleTypeWidget::updateGroundVehicleObjectsFromWidgets()
|
||||
QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType = "GroundVehicleCar";
|
||||
|
||||
@ -177,31 +228,27 @@ QString ConfigVehicleTypeWidget::updateGroundVehicleObjectsFromWidgets()
|
||||
setupGroundVehicleMotorcycle(airframeType);
|
||||
}
|
||||
|
||||
// Now reflect those settings in the "Custom" panel as well
|
||||
updateCustomAirframeUI();
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
Virtual function to refresh the UI widget values
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameType)
|
||||
void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField *field;
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
|
||||
//THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
|
||||
// Retrieve channel setup values
|
||||
setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, GUIConfigData.ground.GroundVehicleThrottle1);
|
||||
setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, GUIConfigData.ground.GroundVehicleThrottle2);
|
||||
setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, GUIConfigData.ground.GroundVehicleSteering1);
|
||||
setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, GUIConfigData.ground.GroundVehicleSteering2);
|
||||
setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1);
|
||||
setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2);
|
||||
setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1);
|
||||
setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2);
|
||||
|
||||
if (frameType == "GroundVehicleDifferential") {
|
||||
//CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE
|
||||
@ -237,17 +284,15 @@ void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameTyp
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Setup balancing ground vehicle.
|
||||
|
||||
Returns False if impossible to create the mixer.
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType){
|
||||
bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType){
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwGroundVehicleChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - Motor, steering, and balance
|
||||
if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" ||
|
||||
@ -259,13 +304,13 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType)
|
||||
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(config);
|
||||
|
||||
UAVObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -356,10 +401,10 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType)
|
||||
|
||||
Returns False if impossible to create the mixer.
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeType){
|
||||
bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType){
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwGroundVehicleChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - Left and right steering
|
||||
if ( m_aircraft->gvMotor2ChannelBox->currentText() == "None" ||
|
||||
@ -370,13 +415,13 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeTyp
|
||||
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData((GUIConfigData));
|
||||
SetConfigData((config));
|
||||
|
||||
UAVObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -457,11 +502,11 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeTyp
|
||||
|
||||
Returns False if impossible to create the mixer.
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType)
|
||||
bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
|
||||
{
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwGroundVehicleChannelConfigError(airframeType);
|
||||
throwConfigError(airframeType);
|
||||
|
||||
// - At least one motor and one steering servo
|
||||
if ((m_aircraft->gvMotor1ChannelBox->currentText() == "None" &&
|
||||
@ -490,15 +535,15 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType)
|
||||
// }
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
ResetActuators(&config);
|
||||
|
||||
GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
GUIConfigData.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex();
|
||||
GUIConfigData.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex();
|
||||
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(config);
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField* field;
|
||||
@ -599,7 +644,7 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType)
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::throwGroundVehicleChannelConfigError(QString airframeType)
|
||||
void ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
|
||||
{
|
||||
//Initialize configuration error flag
|
||||
bool error=false;
|
||||
|
@ -0,0 +1,74 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 CONFIGGROUNDVEHICLEWIDGET_H
|
||||
#define CONFIGGROUNDVEHICLEWIDGET_H
|
||||
|
||||
#include "ui_airframe.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 ConfigGroundVehicleWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
|
||||
~ConfigGroundVehicleWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
|
||||
bool setupGroundVehicleCar(QString airframeType);
|
||||
bool setupGroundVehicleDifferential(QString airframeType);
|
||||
bool setupGroundVehicleMotorcycle(QString airframeType);
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual QStringList getChannelDescriptions();
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual void throwConfigError(QString airframeType);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGGROUNDVEHICLEWIDGET_H
|
@ -24,8 +24,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
//#include "configmultirotorwidget.h"
|
||||
#include "configvehicletypewidget.h"
|
||||
#include "configmultirotorwidget.h"
|
||||
#include "mixersettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
@ -34,201 +33,206 @@
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "mixersettings.h"
|
||||
#include "systemsettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "actuatorcommand.h"
|
||||
#include "guiconfigdata.h"
|
||||
|
||||
//#define Pi 3.14159265358979323846
|
||||
|
||||
|
||||
/**
|
||||
Helper function to setup the UI
|
||||
Constructor
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType)
|
||||
ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
|
||||
{
|
||||
m_aircraft = aircraft;
|
||||
}
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void ConfigMultiRotorWidget::setupUI(QString frameType)
|
||||
{
|
||||
Q_ASSERT(m_aircraft);
|
||||
Q_ASSERT(quad);
|
||||
|
||||
// set aircraftType to Multirotor, disable triyaw channel
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
|
||||
// disable all motor channel boxes
|
||||
for (int i=1; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||
quad->setElementId("tri");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=3; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=4; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(true);
|
||||
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
}
|
||||
else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||
quad->setElementId("quad-X");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=4; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=5; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
m_aircraft->mrYawMixLevel->setValue(50);
|
||||
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||
}
|
||||
else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||
quad->setElementId("quad-plus");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=4; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=5; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
m_aircraft->mrYawMixLevel->setValue(50);
|
||||
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||
}
|
||||
else if (frameType == "Hexa" || frameType == "Hexacopter")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||
quad->setElementId("quad-hexa");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=6; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=7; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||
m_aircraft->mrYawMixLevel->setValue(33);
|
||||
} else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||
}
|
||||
else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||
quad->setElementId("quad-hexa-H");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=6; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=7; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
m_aircraft->mrYawMixLevel->setValue(33);
|
||||
|
||||
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||
}
|
||||
else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||
quad->setElementId("hexa-coax");
|
||||
|
||||
//Enable all necessary motor channel boxes...
|
||||
for (int i=1; i <=6; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
//and grey out all unused motor channel boxes
|
||||
for (int i=7; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
combobox->setEnabled(false);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
m_aircraft->mrYawMixLevel->setValue(66);
|
||||
|
||||
} else if (frameType == "Octo" || frameType == "Octocopter") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||
}
|
||||
else if (frameType == "Octo" || frameType == "Octocopter")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||
quad->setElementId("quad-octo");
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
for (int i=1; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(33);
|
||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||
m_aircraft->mrYawMixLevel->setValue(25);
|
||||
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||
}
|
||||
else if (frameType == "OctoV" || frameType == "Octocopter V")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||
quad->setElementId("quad-octo-v");
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
for (int i=1; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(25);
|
||||
m_aircraft->mrPitchMixLevel->setValue(25);
|
||||
m_aircraft->mrYawMixLevel->setValue(25);
|
||||
|
||||
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||
}
|
||||
else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||
quad->setElementId("octo-coax-P");
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
for (int i=1; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(100);
|
||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||
m_aircraft->mrYawMixLevel->setValue(50);
|
||||
|
||||
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||
}
|
||||
else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X")
|
||||
{
|
||||
setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||
quad->setElementId("octo-coax-X");
|
||||
|
||||
//Enable all necessary motor channel boxes
|
||||
for (int i=1; i <=8; i++) {
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i));
|
||||
if (combobox)
|
||||
combobox->setEnabled(true);
|
||||
}
|
||||
|
||||
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||
m_aircraft->mrRollMixLevel->setValue(50);
|
||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||
m_aircraft->mrYawMixLevel->setValue(50);
|
||||
@ -236,12 +240,61 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType)
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
configData->multi.VTOLMotorN = 0;
|
||||
configData->multi.VTOLMotorNE = 0;
|
||||
configData->multi.VTOLMotorE = 0;
|
||||
configData->multi.VTOLMotorSE = 0;
|
||||
configData->multi.VTOLMotorS = 0;
|
||||
configData->multi.VTOLMotorSW = 0;
|
||||
configData->multi.VTOLMotorW = 0;
|
||||
configData->multi.VTOLMotorNW = 0;
|
||||
configData->multi.TRIYaw = 0;
|
||||
}
|
||||
|
||||
QStringList ConfigMultiRotorWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
multiGUISettingsStruct multi = configData.multi;
|
||||
|
||||
if (multi.VTOLMotorN > 0 && multi.VTOLMotorN < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN");
|
||||
if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE");
|
||||
if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW");
|
||||
if (multi.VTOLMotorS > 0 && multi.VTOLMotorS < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS");
|
||||
if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE");
|
||||
if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW");
|
||||
if (multi.VTOLMotorW > 0 && multi.VTOLMotorW < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW");
|
||||
if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < ConfigMultiRotorWidget::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Helper function to update the UI widget objects
|
||||
*/
|
||||
QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
{
|
||||
QString airframeType;
|
||||
QList<QString> motorList;
|
||||
@ -280,7 +333,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "HexaCoax";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(6);
|
||||
throwConfigError(6);
|
||||
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
@ -314,7 +367,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "Octo";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(8);
|
||||
throwConfigError(8);
|
||||
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
@ -349,7 +402,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "OctoV";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(8);
|
||||
throwConfigError(8);
|
||||
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
@ -385,7 +438,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "OctoCoaxP";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(8);
|
||||
throwConfigError(8);
|
||||
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
@ -420,7 +473,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "OctoCoaxX";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(8);
|
||||
throwConfigError(8);
|
||||
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
@ -455,7 +508,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
airframeType = "Tri";
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(3);
|
||||
throwConfigError(3);
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||
m_aircraft->multiMotorChannelBox3->currentText() == "None" ) {
|
||||
@ -469,9 +522,9 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
||||
setupMotors(motorList);
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIConfigData.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
|
||||
SetConfigData(config);
|
||||
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
@ -500,8 +553,6 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||
|
||||
}
|
||||
// Now reflect those settings in the "Custom" panel as well
|
||||
updateCustomAirframeUI();
|
||||
|
||||
return airframeType;
|
||||
}
|
||||
@ -511,14 +562,10 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||
/**
|
||||
Helper function to refresh the UI widget values
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType)
|
||||
void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Retrieve settings
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
multiGUISettingsStruct multi = GUIConfigData.multi;
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
multiGUISettingsStruct multi = config.multi;
|
||||
|
||||
UAVDataObject* obj;
|
||||
UAVObjectField *field;
|
||||
@ -794,9 +841,10 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType)
|
||||
/**
|
||||
Helper function: setupQuadMotor
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw)
|
||||
void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw)
|
||||
{
|
||||
qDebug()<<QString("Setup quad motor channel=%0 pitch=%1 roll=%2 yaw=%3").arg(channel).arg(pitch).arg(roll).arg(yaw);
|
||||
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
UAVObjectField *field = obj->getField(mixerTypes.at(channel));
|
||||
@ -822,15 +870,15 @@ void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double r
|
||||
/**
|
||||
Helper function: setup motors. Takes a list of channel names in input.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupMotors(QList<QString> motorList)
|
||||
void ConfigMultiRotorWidget::setupMotors(QList<QString> motorList)
|
||||
{
|
||||
QList<QComboBox*> mmList;
|
||||
mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
|
||||
<< m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
||||
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
||||
|
||||
GUIConfigData = GUIManager.GetConfigData();
|
||||
GUIManager.ResetActuators(&GUIConfigData);
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
ResetActuators(&configData);
|
||||
|
||||
int index;
|
||||
foreach (QString motor, motorList) {
|
||||
@ -840,23 +888,23 @@ void ConfigVehicleTypeWidget::setupMotors(QList<QString> motorList)
|
||||
//qDebug()<<QString("Setup motor: %0 = %1").arg(motor).arg(index);
|
||||
|
||||
if (motor == QString("VTOLMotorN"))
|
||||
GUIConfigData.multi.VTOLMotorN = index;
|
||||
configData.multi.VTOLMotorN = index;
|
||||
else if (motor == QString("VTOLMotorNE"))
|
||||
GUIConfigData.multi.VTOLMotorNE = index;
|
||||
configData.multi.VTOLMotorNE = index;
|
||||
else if (motor == QString("VTOLMotorE"))
|
||||
GUIConfigData.multi.VTOLMotorE = index;
|
||||
configData.multi.VTOLMotorE = index;
|
||||
else if (motor == QString("VTOLMotorSE"))
|
||||
GUIConfigData.multi.VTOLMotorSE = index;
|
||||
configData.multi.VTOLMotorSE = index;
|
||||
else if (motor == QString( "VTOLMotorS"))
|
||||
GUIConfigData.multi.VTOLMotorS = index;
|
||||
configData.multi.VTOLMotorS = index;
|
||||
else if (motor == QString( "VTOLMotorSW"))
|
||||
GUIConfigData.multi.VTOLMotorSW = index;
|
||||
configData.multi.VTOLMotorSW = index;
|
||||
else if (motor == QString( "VTOLMotorW"))
|
||||
GUIConfigData.multi.VTOLMotorW = index;
|
||||
configData.multi.VTOLMotorW = index;
|
||||
else if (motor == QString( "VTOLMotorNW"))
|
||||
GUIConfigData.multi.VTOLMotorNW = index;
|
||||
configData.multi.VTOLMotorNW = index;
|
||||
}
|
||||
GUIManager.SetConfigData(GUIConfigData);
|
||||
SetConfigData(configData);
|
||||
|
||||
}
|
||||
|
||||
@ -865,12 +913,12 @@ void ConfigVehicleTypeWidget::setupMotors(QList<QString> motorList)
|
||||
/**
|
||||
Set up a Quad-X or Quad-P mixer
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupQuad(bool pLayout)
|
||||
bool ConfigMultiRotorWidget::setupQuad(bool pLayout)
|
||||
{
|
||||
// Check coherence:
|
||||
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(4);
|
||||
throwConfigError(4);
|
||||
|
||||
// - Four engines have to be defined
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
@ -941,11 +989,11 @@ bool ConfigVehicleTypeWidget::setupQuad(bool pLayout)
|
||||
/**
|
||||
Set up a Hexa-X or Hexa-P mixer
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupHexa(bool pLayout)
|
||||
bool ConfigMultiRotorWidget::setupHexa(bool pLayout)
|
||||
{
|
||||
// Check coherence:
|
||||
//Show any config errors in GUI
|
||||
throwMultiRotorChannelConfigError(6);
|
||||
throwConfigError(6);
|
||||
|
||||
// - Four engines have to be defined
|
||||
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||
@ -1022,7 +1070,7 @@ bool ConfigVehicleTypeWidget::setupHexa(bool pLayout)
|
||||
/**
|
||||
This function sets up the multirotor mixer values.
|
||||
*/
|
||||
bool ConfigVehicleTypeWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
||||
bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
||||
{
|
||||
qDebug()<<"Mixer factors";
|
||||
qDebug()<<mixerFactors[0][0]<<" "<<mixerFactors[0][1]<<" "<<mixerFactors[0][2];
|
||||
@ -1069,7 +1117,7 @@ bool ConfigVehicleTypeWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
||||
/**
|
||||
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors)
|
||||
void ConfigMultiRotorWidget::throwConfigError(int numMotors)
|
||||
{
|
||||
//Initialize configuration error flag
|
||||
bool error=false;
|
||||
@ -1079,7 +1127,8 @@ void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors)
|
||||
//Fine widgets with text "multiMotorChannelBox.x", where x is an integer
|
||||
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i+1));
|
||||
if (combobox){ //if QLabel exists
|
||||
QLabel *label = qFindChild<QLabel*>(this, "MotorOutputLabel" + QString::number(i+1));
|
||||
// QLabel *label = qFindChild<QLabel*>(this, "MotorOutputLabel" + QString::number(i+1));
|
||||
|
||||
if (combobox->currentText() == "None") {
|
||||
|
||||
// label->setText("<font color='red'>" + label->text() + "</font>");
|
||||
@ -1106,3 +1155,5 @@ void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors)
|
||||
m_aircraft->mrStatusLabel->setText(QString("<font color='red'>ERROR: Assign all %1 motor channels</font>").arg(numMotors));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 CONFIGMULTIROTORWIDGET_H
|
||||
#define CONFIGMULTIROTORWIDGET_H
|
||||
|
||||
#include "ui_airframe.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 ConfigMultiRotorWidget: public VehicleConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
|
||||
~ConfigMultiRotorWidget();
|
||||
|
||||
friend class ConfigVehicleTypeWidget;
|
||||
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
|
||||
QGraphicsSvgItem *quad;
|
||||
|
||||
bool setupQuad(bool pLayout);
|
||||
bool setupHexa(bool pLayout);
|
||||
bool setupOcto();
|
||||
bool setupMultiRotorMixer(double mixerFactors[8][3]);
|
||||
void setupMotors(QList<QString> motorList);
|
||||
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual QStringList getChannelDescriptions();
|
||||
|
||||
private slots:
|
||||
virtual void setupUI(QString airframeType);
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
void throwConfigError(int numMotors);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CONFIGMULTIROTORWIDGET_H
|
@ -1,328 +0,0 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file guiconfigdata.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief bit storage of config ui settings
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "guiconfigdata.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
#include "systemsettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
GUIConfigDataManager::GUIConfigDataManager()
|
||||
{
|
||||
}
|
||||
|
||||
GUIConfigDataManager::~GUIConfigDataManager()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
GUIConfigDataUnion GUIConfigDataManager::GetConfigData() {
|
||||
|
||||
int i;
|
||||
GUIConfigDataUnion configData;
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
// copy systemsettings -> local configData
|
||||
for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
|
||||
configData.UAVObject[i]=systemSettingsData.GUIConfigData[i];
|
||||
|
||||
// sanity check
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
|
||||
(sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
return configData;
|
||||
}
|
||||
|
||||
void GUIConfigDataManager::SetConfigData(GUIConfigDataUnion configData) {
|
||||
|
||||
int i;
|
||||
|
||||
// sanity check
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
|
||||
(sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
// copy parameter configData -> systemsettings
|
||||
for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
|
||||
systemSettingsData.GUIConfigData[i] = configData.UAVObject[i];
|
||||
|
||||
systemSettings->setData(systemSettingsData);
|
||||
systemSettings->updated();
|
||||
}
|
||||
|
||||
void GUIConfigDataManager::ResetActuators()
|
||||
{
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
// reset the actuators by airframe type
|
||||
ResetActuators(&configData);
|
||||
|
||||
// set the gui config data
|
||||
SetConfigData(configData);
|
||||
|
||||
}
|
||||
|
||||
void GUIConfigDataManager::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
// get systemsettings for airframe type
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
switch (systemSettingsData.AirframeType)
|
||||
{
|
||||
// fixed wing
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
{
|
||||
configData->fixed.FixedWingPitch1 = 0;
|
||||
configData->fixed.FixedWingPitch2 = 0;
|
||||
configData->fixed.FixedWingRoll1 = 0;
|
||||
configData->fixed.FixedWingRoll2 = 0;
|
||||
configData->fixed.FixedWingYaw1 = 0;
|
||||
configData->fixed.FixedWingYaw2 = 0;
|
||||
configData->fixed.FixedWingThrottle = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
// helicp
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
{
|
||||
configData->heli.Throttle = 0;
|
||||
configData->heli.Tail = 0;
|
||||
configData->heli.ServoIndexW = 0;
|
||||
configData->heli.ServoIndexX = 0;
|
||||
configData->heli.ServoIndexY = 0;
|
||||
configData->heli.ServoIndexZ = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
//multirotor
|
||||
case SystemSettings::AIRFRAMETYPE_VTOL:
|
||||
case SystemSettings::AIRFRAMETYPE_TRI:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADX:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOV:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTO:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||
{
|
||||
configData->multi.VTOLMotorN = 0;
|
||||
configData->multi.VTOLMotorNE = 0;
|
||||
configData->multi.VTOLMotorE = 0;
|
||||
configData->multi.VTOLMotorSE = 0;
|
||||
configData->multi.VTOLMotorS = 0;
|
||||
configData->multi.VTOLMotorSW = 0;
|
||||
configData->multi.VTOLMotorW = 0;
|
||||
configData->multi.VTOLMotorNW = 0;
|
||||
configData->multi.TRIYaw = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
// ground
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
{
|
||||
configData->ground.GroundVehicleSteering1 = 0;
|
||||
configData->ground.GroundVehicleSteering2 = 0;
|
||||
configData->ground.GroundVehicleThrottle1 = 0;
|
||||
configData->ground.GroundVehicleThrottle2 = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QStringList GUIConfigDataManager::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (i=0; i < (int)(GUIConfigDataManager::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
|
||||
// get systemsettings for airframe type
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
switch (systemSettingsData.AirframeType)
|
||||
{
|
||||
// fixed wing
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
{
|
||||
if (configData.fixed.FixedWingPitch1 > 0)
|
||||
channelDesc[configData.fixed.FixedWingPitch1-1] = QString("FixedWingPitch1");
|
||||
if (configData.fixed.FixedWingPitch2 > 0)
|
||||
channelDesc[configData.fixed.FixedWingPitch2-1] = QString("FixedWingPitch2");
|
||||
if (configData.fixed.FixedWingRoll1 > 0)
|
||||
channelDesc[configData.fixed.FixedWingRoll1-1] = QString("FixedWingRoll1");
|
||||
if (configData.fixed.FixedWingRoll2 > 0)
|
||||
channelDesc[configData.fixed.FixedWingRoll2-1] = QString("FixedWingRoll2");
|
||||
if (configData.fixed.FixedWingYaw1 > 0)
|
||||
channelDesc[configData.fixed.FixedWingYaw1-1] = QString("FixedWingYaw1");
|
||||
if (configData.fixed.FixedWingYaw2 > 0)
|
||||
channelDesc[configData.fixed.FixedWingYaw2-1] = QString("FixedWingYaw2");
|
||||
if (configData.fixed.FixedWingThrottle > 0)
|
||||
channelDesc[configData.fixed.FixedWingThrottle-1] = QString("FixedWingThrottle");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
break;
|
||||
|
||||
// helicp
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
{
|
||||
channelDesc[configData.heli.Throttle] = QString("Throttle");
|
||||
channelDesc[configData.heli.Tail] = QString("Tail");
|
||||
|
||||
switch(configData.heli.FirstServoIndex)
|
||||
{
|
||||
case 0: //front
|
||||
channelDesc[configData.heli.ServoIndexW] = QString("Elevator");
|
||||
channelDesc[configData.heli.ServoIndexX] = QString("Roll1");
|
||||
channelDesc[configData.heli.ServoIndexY] = QString("Roll2");
|
||||
break;
|
||||
|
||||
case 1: //right
|
||||
channelDesc[configData.heli.ServoIndexW] = QString("ServoW");
|
||||
channelDesc[configData.heli.ServoIndexX] = QString("ServoX");
|
||||
channelDesc[configData.heli.ServoIndexY] = QString("ServoY");
|
||||
break;
|
||||
|
||||
case 2: //rear
|
||||
channelDesc[configData.heli.ServoIndexW] = QString("Elevator");
|
||||
channelDesc[configData.heli.ServoIndexX] = QString("Roll1");
|
||||
channelDesc[configData.heli.ServoIndexY] = QString("Roll2");
|
||||
break;
|
||||
|
||||
case 3: //left
|
||||
channelDesc[configData.heli.ServoIndexW] = QString("ServoW");
|
||||
channelDesc[configData.heli.ServoIndexX] = QString("ServoX");
|
||||
channelDesc[configData.heli.ServoIndexY] = QString("ServoY");
|
||||
break;
|
||||
|
||||
}
|
||||
if (configData.heli.ServoIndexZ < 8)
|
||||
channelDesc[configData.heli.ServoIndexZ] = QString("ServoZ");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
break;
|
||||
|
||||
//multirotor
|
||||
case SystemSettings::AIRFRAMETYPE_VTOL:
|
||||
case SystemSettings::AIRFRAMETYPE_TRI:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADX:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOV:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTO:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||
{
|
||||
multiGUISettingsStruct multi = configData.multi;
|
||||
|
||||
if (multi.VTOLMotorN > 0 && multi.VTOLMotorN < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN");
|
||||
if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE");
|
||||
if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW");
|
||||
if (multi.VTOLMotorS > 0 && multi.VTOLMotorS < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS");
|
||||
if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE");
|
||||
if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW");
|
||||
if (multi.VTOLMotorW > 0 && multi.VTOLMotorW < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW");
|
||||
if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < GUIConfigDataManager::CHANNEL_NUMELEM)
|
||||
channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
break;
|
||||
|
||||
// ground
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
{
|
||||
if (configData.ground.GroundVehicleSteering1 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1");
|
||||
if (configData.ground.GroundVehicleSteering2 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2");
|
||||
if (configData.ground.GroundVehicleThrottle1 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1");
|
||||
if (configData.ground.GroundVehicleThrottle2 > 0)
|
||||
channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2");
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
/**
|
||||
* Util function to get a pointer to the object manager
|
||||
* @return pointer to the UAVObjectManager
|
||||
*/
|
||||
UAVObjectManager* GUIConfigDataManager::getObjectManager() {
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
return objMngr;
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file vehicleconfig.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup ConfigPlugin Config Plugin
|
||||
* @{
|
||||
* @brief bit storage of config ui settings
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
#include "systemsettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
{
|
||||
for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
|
||||
mixerTypes << QString("Mixer%1Type").arg(i+1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i+1);
|
||||
}
|
||||
}
|
||||
|
||||
VehicleConfig::~VehicleConfig()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
GUIConfigDataUnion VehicleConfig::GetConfigData() {
|
||||
|
||||
int i;
|
||||
GUIConfigDataUnion configData;
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
// copy systemsettings -> local configData
|
||||
for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
|
||||
configData.UAVObject[i]=systemSettingsData.GUIConfigData[i];
|
||||
|
||||
// sanity check
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
|
||||
(sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
return configData;
|
||||
}
|
||||
|
||||
void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) {
|
||||
|
||||
int i;
|
||||
|
||||
// sanity check
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
|
||||
(sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
// copy parameter configData -> systemsettings
|
||||
for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
|
||||
systemSettingsData.GUIConfigData[i] = configData.UAVObject[i];
|
||||
|
||||
systemSettings->setData(systemSettingsData);
|
||||
systemSettings->updated();
|
||||
|
||||
//emit ConfigurationChanged();
|
||||
}
|
||||
|
||||
void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
|
||||
{
|
||||
}
|
||||
QStringList VehicleConfig::getChannelDescriptions()
|
||||
{
|
||||
QStringList channelDesc;
|
||||
|
||||
// init a channel_numelem list of channel desc defaults
|
||||
for (int i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++)
|
||||
{
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function:
|
||||
Sets the current index on supplied combobox to index
|
||||
if it is within bounds 0 <= index < combobox.count()
|
||||
*/
|
||||
void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index)
|
||||
{
|
||||
Q_ASSERT(box);
|
||||
|
||||
if (index >= 0 && index < box->count())
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the contents of a field
|
||||
*/
|
||||
void VehicleConfig::resetField(UAVObjectField * field)
|
||||
{
|
||||
for (unsigned int i=0;i<field->getNumElements();i++) {
|
||||
field->setValue(0,i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Util function to get a pointer to the object manager
|
||||
* @return pointer to the UAVObjectManager
|
||||
*/
|
||||
UAVObjectManager* VehicleConfig::getUAVObjectManager() {
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
return objMngr;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file guiconfigdata.h
|
||||
* @file vehicleconfig.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
@ -24,14 +24,15 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef GUICONFIGDATA_H
|
||||
#define GUICONFIGDATA_H
|
||||
|
||||
#ifndef GUIVEHICLECONFIG_H
|
||||
#define GUIVEHICLECONFIG_H
|
||||
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint VTOLMotorN:4;
|
||||
uint VTOLMotorS:4;
|
||||
@ -96,39 +97,46 @@ typedef union
|
||||
{
|
||||
uint UAVObject[4]; //32bits * 4
|
||||
heliGUISettingsStruct heli; //128bits
|
||||
fixedGUISettingsStruct fixed;
|
||||
fixedGUISettingsStruct fixedwing;
|
||||
multiGUISettingsStruct multi;
|
||||
groundGUISettingsStruct ground;
|
||||
} GUIConfigDataUnion;
|
||||
|
||||
class GUIConfigDataManager: public QObject
|
||||
|
||||
class VehicleConfig: public ConfigTaskWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GUIConfigDataManager();
|
||||
~GUIConfigDataManager();
|
||||
VehicleConfig(QWidget *parent = 0);
|
||||
~VehicleConfig();
|
||||
|
||||
GUIConfigDataUnion GetConfigData();
|
||||
void SetConfigData(GUIConfigDataUnion configData);
|
||||
QStringList getChannelDescriptions();
|
||||
void ResetActuators();
|
||||
void ResetActuators(GUIConfigDataUnion* configData);
|
||||
static GUIConfigDataUnion GetConfigData();
|
||||
static void SetConfigData(GUIConfigDataUnion configData);
|
||||
static void resetField(UAVObjectField * field);
|
||||
static void setComboCurrentIndex(QComboBox* box, int index);
|
||||
|
||||
virtual void ResetActuators(GUIConfigDataUnion* configData);
|
||||
virtual QStringList getChannelDescriptions();
|
||||
|
||||
QStringList mixerTypes;
|
||||
QStringList mixerVectors;
|
||||
|
||||
static const quint32 CHANNEL_NUMELEM = 10;
|
||||
|
||||
friend class ConfigTaskWidget;
|
||||
|
||||
private:
|
||||
UAVObjectManager* getObjectManager();
|
||||
|
||||
static UAVObjectManager* getUAVObjectManager();
|
||||
|
||||
private slots:
|
||||
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
//void ConfigurationChanged();
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // GUICONFIGDATA_H
|
||||
#endif // GUIVEHICLECONFIG_H
|
@ -32,7 +32,10 @@ HEADERS += configplugin.h \
|
||||
configtxpidwidget.h \
|
||||
outputchannelform.h \
|
||||
config_global.h \
|
||||
cfg_vehicletypes/guiconfigdata.h
|
||||
cfg_vehicletypes/configmultirotorwidget.h \
|
||||
cfg_vehicletypes/configgroundvehiclewidget.h \
|
||||
cfg_vehicletypes/configfixedwingwidget.h \
|
||||
cfg_vehicletypes/vehicleconfig.h
|
||||
SOURCES += configplugin.cpp \
|
||||
configgadgetconfiguration.cpp \
|
||||
configgadgetwidget.cpp \
|
||||
@ -62,7 +65,7 @@ SOURCES += configplugin.cpp \
|
||||
cfg_vehicletypes/configfixedwingwidget.cpp \
|
||||
cfg_vehicletypes/configccpmwidget.cpp \
|
||||
outputchannelform.cpp \
|
||||
cfg_vehicletypes/guiconfigdata.cpp
|
||||
cfg_vehicletypes/vehicleconfig.cpp
|
||||
FORMS += airframe.ui \
|
||||
cc_hw_settings.ui \
|
||||
pro_hw_settings.ui \
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "configoutputwidget.h"
|
||||
#include "outputchannelform.h"
|
||||
#include "configvehicletypewidget.h"
|
||||
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
@ -250,8 +251,8 @@ void ConfigOutputWidget::refreshWidgetsValues()
|
||||
Q_ASSERT(actuatorSettings);
|
||||
ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData();
|
||||
|
||||
// get helicp channel descriptions based on mixer settings
|
||||
QStringList ChannelDesc = GUIManager.getChannelDescriptions();
|
||||
// get channel descriptions
|
||||
QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions();
|
||||
|
||||
// Initialize output forms
|
||||
QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>();
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavobjectutilmanager.h"
|
||||
#include "cfg_vehicletypes/guiconfigdata.h"
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
|
||||
@ -63,8 +63,6 @@ private:
|
||||
|
||||
UAVObject::Metadata accInitialData;
|
||||
|
||||
GUIConfigDataManager GUIManager;
|
||||
|
||||
bool firstUpdate;
|
||||
|
||||
bool wasItMe;
|
||||
|
@ -103,7 +103,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
addUAVObject("MixerSettings");
|
||||
addUAVObject("ActuatorSettings");
|
||||
|
||||
|
||||
ffTuningInProgress = false;
|
||||
ffTuningPhase = false;
|
||||
|
||||
@ -119,7 +118,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
QStringList airframeTypes;
|
||||
airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom";
|
||||
m_aircraft->aircraftType->addItems(airframeTypes);
|
||||
m_aircraft->aircraftType->setCurrentIndex(1);
|
||||
m_aircraft->aircraftType->setCurrentIndex(0);
|
||||
|
||||
QStringList fixedWingTypes;
|
||||
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||
@ -138,20 +137,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
m_aircraft->multirotorFrameType->addItems(multiRotorTypes);
|
||||
m_aircraft->multirotorFrameType->setCurrentIndex(1); //Set default model to "Quad +"
|
||||
|
||||
// Now load all the channel assignements
|
||||
//OLD STYLE: DO IT MANUALLY
|
||||
// m_aircraft->triYawChannelBox->addItems(channels);
|
||||
// m_aircraft->gvMotor1ChannelBox->addItems(channels);
|
||||
// m_aircraft->gvMotor2ChannelBox->addItems(channels);
|
||||
// m_aircraft->gvSteering1ChannelBox->addItems(channels);
|
||||
// m_aircraft->gvSteering2ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwElevator1ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwElevator2ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwEngineChannelBox->addItems(channels);
|
||||
// m_aircraft->fwRudder1ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwRudder2ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwAileron1ChannelBox->addItems(channels);
|
||||
// m_aircraft->fwAileron2ChannelBox->addItems(channels);
|
||||
|
||||
//NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
|
||||
// The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name
|
||||
@ -188,6 +173,19 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
|
||||
}
|
||||
|
||||
m_multirotor = new ConfigMultiRotorWidget(m_aircraft, this);
|
||||
m_multirotor->quad = quad;
|
||||
m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText());
|
||||
|
||||
m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft, this);
|
||||
m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() );
|
||||
|
||||
m_fixedwing = new ConfigFixedWingWidget(m_aircraft, this);
|
||||
m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() );
|
||||
|
||||
m_heli = m_aircraft->widget_3;// new ConfigccpmWidget(this);
|
||||
m_heli->setupUI(QString("HeliCP"));
|
||||
|
||||
//Connect aircraft type selection dropbox to callback function
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
||||
|
||||
@ -195,6 +193,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
//mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||
|
||||
//Connect throttle curve reset pushbuttons to reset functions
|
||||
connect(m_aircraft->fwThrottleReset, SIGNAL(clicked()), this, SLOT(resetFwMixer()));
|
||||
@ -220,18 +219,12 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||
connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||
|
||||
//WHAT DOES THIS DO?
|
||||
enableControls(false);
|
||||
refreshWidgetsValues();
|
||||
|
||||
// Connect the help pushbutton
|
||||
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
addToDirtyMonitor();
|
||||
|
||||
//Initialize GUI tabs //MOVING THIS FROM THE END OF THIS FUNCTION CAN CAUSE RUNTIME ERRORS DUE TO setupMultiRotorUI. WHY?
|
||||
setupMultiRotorUI( m_aircraft->multirotorFrameType->currentText() );
|
||||
setupGroundVehicleUI( m_aircraft->groundVehicleType->currentText() );
|
||||
setupFixedWingUI( m_aircraft->fixedWingType->currentText() );
|
||||
enableControls(false);
|
||||
refreshWidgetsValues();
|
||||
addToDirtyMonitor();
|
||||
|
||||
disbleMouseWheelEvents();
|
||||
}
|
||||
@ -245,12 +238,90 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
||||
{
|
||||
int i;
|
||||
QStringList channelDesc;
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr);
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
switch (systemSettingsData.AirframeType)
|
||||
{
|
||||
// fixed wing
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||
{
|
||||
ConfigFixedWingWidget* fixedwing = new ConfigFixedWingWidget();
|
||||
channelDesc = fixedwing->getChannelDescriptions();
|
||||
}
|
||||
break;
|
||||
|
||||
// helicp
|
||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||
{
|
||||
ConfigccpmWidget* heli = new ConfigccpmWidget();
|
||||
channelDesc = heli->getChannelDescriptions();
|
||||
}
|
||||
break;
|
||||
|
||||
//multirotor
|
||||
case SystemSettings::AIRFRAMETYPE_VTOL:
|
||||
case SystemSettings::AIRFRAMETYPE_TRI:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADX:
|
||||
case SystemSettings::AIRFRAMETYPE_QUADP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOV:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
|
||||
case SystemSettings::AIRFRAMETYPE_OCTO:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||
{
|
||||
ConfigMultiRotorWidget* multi = new ConfigMultiRotorWidget();
|
||||
channelDesc = multi->getChannelDescriptions();
|
||||
}
|
||||
break;
|
||||
|
||||
// ground
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||
{
|
||||
ConfigGroundVehicleWidget* ground = new ConfigGroundVehicleWidget();
|
||||
channelDesc = ground->getChannelDescriptions();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++)
|
||||
channelDesc.append(QString("-"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// for (i=0; i < channelDesc.count(); i++)
|
||||
// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]);
|
||||
|
||||
return channelDesc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Slot for switching the airframe type. We do it explicitely
|
||||
rather than a signal in the UI, because we want to force a fitInView of the quad shapes.
|
||||
This is because this method (fitinview) only works when the widget is shown.
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::switchAirframeType(int index){
|
||||
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||
{
|
||||
m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
@ -609,7 +680,7 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues()
|
||||
if (frameType.startsWith("FixedWing")) {
|
||||
|
||||
// Retrieve fixed wing settings
|
||||
refreshFixedWingWidgetsValues(frameType);
|
||||
m_fixedwing->refreshWidgetsValues(frameType);
|
||||
|
||||
} else if (frameType == "Tri" ||
|
||||
frameType == "QuadX" || frameType == "QuadP" ||
|
||||
@ -617,17 +688,18 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues()
|
||||
frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) {
|
||||
|
||||
// Retrieve multirotor settings
|
||||
refreshMultiRotorWidgetsValues(frameType);
|
||||
m_multirotor->refreshWidgetsValues(frameType);
|
||||
} else if (frameType == "HeliCP") {
|
||||
m_aircraft->widget_3->requestccpmUpdate();
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Helicopter"));//"Helicopter"
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
|
||||
m_heli->refreshWidgetsValues(frameType);
|
||||
|
||||
} else if (frameType.startsWith("GroundVehicle")) {
|
||||
|
||||
// Retrieve ground vehicle settings
|
||||
refreshGroundVehicleWidgetsValues(frameType);
|
||||
m_groundvehicle->refreshWidgetsValues(frameType);
|
||||
|
||||
} else if (frameType == "Custom") {
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Custom"));
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
|
||||
}
|
||||
|
||||
|
||||
@ -641,13 +713,13 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
{
|
||||
|
||||
bool dirty=isDirty();
|
||||
if(frameType == "FixedWing" || frameType == "Elevator aileron rudder" ||
|
||||
frameType == "FixedWingElevon" || frameType == "Elevon" ||
|
||||
frameType == "FixedWingVtail" || frameType == "Vtail"){
|
||||
setupFixedWingUI(frameType);
|
||||
} else if (frameType == "Tri" || frameType == "Tricopter Y" ||
|
||||
m_fixedwing->setupUI(frameType);
|
||||
}
|
||||
else if (frameType == "Tri" || frameType == "Tricopter Y" ||
|
||||
frameType == "QuadX" || frameType == "Quad X" ||
|
||||
frameType == "QuadP" || frameType == "Quad +" ||
|
||||
frameType == "Hexa" || frameType == "Hexacopter" ||
|
||||
@ -658,12 +730,15 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||
frameType == "OctoCoaxP" || frameType == "Octo Coax +" ) {
|
||||
|
||||
//Call multi-rotor setup UI
|
||||
setupMultiRotorUI(frameType);
|
||||
m_multirotor->setupUI(frameType);
|
||||
}
|
||||
else if (frameType == "HeliCP") {
|
||||
m_heli->setupUI(frameType);
|
||||
}
|
||||
else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" ||
|
||||
frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" ||
|
||||
frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||
setupGroundVehicleUI(frameType);
|
||||
m_groundvehicle->setupUI(frameType);
|
||||
}
|
||||
|
||||
//SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST???
|
||||
@ -684,26 +759,6 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset actuator values
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::resetActuators()
|
||||
{
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||
Q_ASSERT(obj);
|
||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||
// Reset all assignements first:
|
||||
foreach (UAVObjectField* field, fieldList) {
|
||||
// NOTE: we assume that all options in ActuatorSettings are a channel assignement
|
||||
// except for the options called "ChannelBoxXXX"
|
||||
if (field->getUnits().contains("channel")) {
|
||||
field->setValue(field->getOptions().last());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Updates the custom airframe settings based on the current airframe.
|
||||
|
||||
@ -711,9 +766,14 @@ void ConfigVehicleTypeWidget::resetActuators()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
{
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||
QList<double> curveValues;
|
||||
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
|
||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||
if (field)
|
||||
{
|
||||
// If the 1st element of the curve is <= -10, then the curve
|
||||
// is a straight line (that's how the mixer works on the mainboard):
|
||||
if (field->getValue(0).toInt() <= -10) {
|
||||
@ -731,9 +791,13 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
else
|
||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
||||
}
|
||||
}
|
||||
|
||||
curveValues.clear();
|
||||
|
||||
field = obj->getField(QString("ThrottleCurve2"));
|
||||
curveValues.clear();
|
||||
if (field)
|
||||
{
|
||||
// If the 1st element of the curve is <= -10, then the curve
|
||||
// is a straight line (that's how the mixer works on the mainboard):
|
||||
if (field->getValue(0).toInt() <= -10) {
|
||||
@ -744,15 +808,23 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
}
|
||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the table:
|
||||
for (int i=0; i<8; i++) {
|
||||
field = obj->getField(mixerTypes.at(i));
|
||||
if (field)
|
||||
{
|
||||
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
||||
if (q)
|
||||
{
|
||||
QString s = field->getValue().toString();
|
||||
q->setCurrentIndex(q->findText(s));
|
||||
//bool en = (s != "Disabled");
|
||||
setComboCurrentIndex(q, q->findText(s));
|
||||
}
|
||||
|
||||
field = obj->getField(mixerVectors.at(i));
|
||||
if (field)
|
||||
{
|
||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||
m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString());
|
||||
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||
@ -765,6 +837,8 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -776,20 +850,19 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
qDebug()<<"updateObjectsFromWidgets";
|
||||
QString airframeType = "Custom"; //Sets airframe type default to "Custom"
|
||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||
airframeType = updateFixedWingObjectsFromWidgets();
|
||||
} else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
||||
//update the mixer
|
||||
airframeType = updateMultiRotorObjectsFromWidgets();
|
||||
} else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
||||
airframeType = "HeliCP";
|
||||
m_aircraft->widget_3->sendccpmUpdate();
|
||||
} else if (m_aircraft->aircraftType->currentText() == "Ground") {
|
||||
airframeType = updateGroundVehicleObjectsFromWidgets();
|
||||
} else {
|
||||
airframeType = "Custom";
|
||||
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
||||
airframeType = m_multirotor->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
||||
airframeType = m_heli->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
else if (m_aircraft->aircraftType->currentText() == "Ground") {
|
||||
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
|
||||
}
|
||||
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||
@ -826,13 +899,12 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||
field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//WHAT DOES THIS DO?
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("AirframeType"));
|
||||
// set the airframe type
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
field = obj->getField(QString("AirframeType"));
|
||||
field->setValue(airframeType);
|
||||
|
||||
updateCustomAirframeUI();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -893,44 +965,44 @@ void ConfigVehicleTypeWidget::addToDirtyMonitor()
|
||||
addWidget(m_aircraft->fwRudder2ChannelBox);
|
||||
addWidget(m_aircraft->elevonSlider1);
|
||||
addWidget(m_aircraft->elevonSlider2);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmType);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmTailChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmEngineChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoWChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoXChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoYChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmSingleServo);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoZChannel);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleW);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleX);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCorrectionAngle);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleZ);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleY);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivePassthrough);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkRoll);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkCyclic);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRevoSlider);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmREVOspinBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveSlider);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivespinBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScale);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScaleBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCyclicScale);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScale);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScaleBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScale);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScaleBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSlider);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSpinBox);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveType);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->NumCurvePoints);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue1);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue2);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue3);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveToGenerate);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveSettings);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ThrottleCurve);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->PitchCurve);
|
||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAdvancedSettingsTable);
|
||||
addWidget(m_heli->m_ccpm->ccpmType);
|
||||
addWidget(m_heli->m_ccpm->ccpmTailChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmEngineChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmServoWChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmServoXChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmServoYChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmSingleServo);
|
||||
addWidget(m_heli->m_ccpm->ccpmServoZChannel);
|
||||
addWidget(m_heli->m_ccpm->ccpmAngleW);
|
||||
addWidget(m_heli->m_ccpm->ccpmAngleX);
|
||||
addWidget(m_heli->m_ccpm->ccpmCorrectionAngle);
|
||||
addWidget(m_heli->m_ccpm->ccpmAngleZ);
|
||||
addWidget(m_heli->m_ccpm->ccpmAngleY);
|
||||
addWidget(m_heli->m_ccpm->ccpmCollectivePassthrough);
|
||||
addWidget(m_heli->m_ccpm->ccpmLinkRoll);
|
||||
addWidget(m_heli->m_ccpm->ccpmLinkCyclic);
|
||||
addWidget(m_heli->m_ccpm->ccpmRevoSlider);
|
||||
addWidget(m_heli->m_ccpm->ccpmREVOspinBox);
|
||||
addWidget(m_heli->m_ccpm->ccpmCollectiveSlider);
|
||||
addWidget(m_heli->m_ccpm->ccpmCollectivespinBox);
|
||||
addWidget(m_heli->m_ccpm->ccpmCollectiveScale);
|
||||
addWidget(m_heli->m_ccpm->ccpmCollectiveScaleBox);
|
||||
addWidget(m_heli->m_ccpm->ccpmCyclicScale);
|
||||
addWidget(m_heli->m_ccpm->ccpmPitchScale);
|
||||
addWidget(m_heli->m_ccpm->ccpmPitchScaleBox);
|
||||
addWidget(m_heli->m_ccpm->ccpmRollScale);
|
||||
addWidget(m_heli->m_ccpm->ccpmRollScaleBox);
|
||||
addWidget(m_heli->m_ccpm->SwashLvlPositionSlider);
|
||||
addWidget(m_heli->m_ccpm->SwashLvlPositionSpinBox);
|
||||
addWidget(m_heli->m_ccpm->CurveType);
|
||||
addWidget(m_heli->m_ccpm->NumCurvePoints);
|
||||
addWidget(m_heli->m_ccpm->CurveValue1);
|
||||
addWidget(m_heli->m_ccpm->CurveValue2);
|
||||
addWidget(m_heli->m_ccpm->CurveValue3);
|
||||
addWidget(m_heli->m_ccpm->CurveToGenerate);
|
||||
addWidget(m_heli->m_ccpm->CurveSettings);
|
||||
addWidget(m_heli->m_ccpm->ThrottleCurve);
|
||||
addWidget(m_heli->m_ccpm->PitchCurve);
|
||||
addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,12 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
#include "cfg_vehicletypes/guiconfigdata.h"
|
||||
|
||||
#include "cfg_vehicletypes/configccpmwidget.h"
|
||||
#include "cfg_vehicletypes/configfixedwingwidget.h"
|
||||
#include "cfg_vehicletypes/configmultirotorwidget.h"
|
||||
#include "cfg_vehicletypes/configgroundvehiclewidget.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
@ -48,27 +53,24 @@ public:
|
||||
ConfigVehicleTypeWidget(QWidget *parent = 0);
|
||||
~ConfigVehicleTypeWidget();
|
||||
|
||||
static QStringList getChannelDescriptions();
|
||||
|
||||
private:
|
||||
Ui_AircraftWidget *m_aircraft;
|
||||
bool setupFrameFixedWing(QString airframeType);
|
||||
bool setupFrameElevon(QString airframeType);
|
||||
bool setupFrameVtail(QString airframeType);
|
||||
bool setupQuad(bool pLayout);
|
||||
bool setupHexa(bool pLayout);
|
||||
bool setupOcto();
|
||||
bool setupGroundVehicleCar(QString airframeType);
|
||||
bool setupGroundVehicleDifferential(QString airframeType);
|
||||
bool setupGroundVehicleMotorcycle(QString airframeType);
|
||||
|
||||
ConfigccpmWidget *m_heli;
|
||||
ConfigFixedWingWidget *m_fixedwing;
|
||||
ConfigMultiRotorWidget *m_multirotor;
|
||||
ConfigGroundVehicleWidget *m_groundvehicle;
|
||||
|
||||
void updateCustomAirframeUI();
|
||||
bool setupMultiRotorMixer(double mixerFactors[8][3]);
|
||||
void setupMotors(QList<QString> motorList);
|
||||
void addToDirtyMonitor();
|
||||
void resetField(UAVObjectField * field);
|
||||
void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue);
|
||||
void resetActuators();
|
||||
|
||||
//void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector);
|
||||
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
|
||||
void setComboCurrentIndex(QComboBox* box, int index);
|
||||
|
||||
|
||||
QStringList mixerTypes;
|
||||
QStringList mixerVectors;
|
||||
QGraphicsSvgItem *quad;
|
||||
@ -76,29 +78,15 @@ private:
|
||||
bool ffTuningPhase;
|
||||
UAVObject::Metadata accInitialData;
|
||||
|
||||
GUIConfigDataManager GUIManager;
|
||||
GUIConfigDataUnion GUIConfigData;
|
||||
|
||||
private slots:
|
||||
virtual void refreshWidgetsValues();
|
||||
void refreshFixedWingWidgetsValues(QString frameType);
|
||||
void refreshMultiRotorWidgetsValues(QString frameType);
|
||||
void refreshGroundVehicleWidgetsValues(QString frameType);
|
||||
|
||||
void updateObjectsFromWidgets();
|
||||
QString updateFixedWingObjectsFromWidgets();
|
||||
QString updateMultiRotorObjectsFromWidgets();
|
||||
QString updateGroundVehicleObjectsFromWidgets();
|
||||
// void saveAircraftUpdate();
|
||||
virtual void refreshWidgetsValues();
|
||||
virtual void updateObjectsFromWidgets();
|
||||
|
||||
void setComboCurrentIndex(QComboBox* box, int index);
|
||||
|
||||
|
||||
void setupAirframeUI(QString type);
|
||||
void setupFixedWingUI(QString frameType);
|
||||
void setupMultiRotorUI(QString frameType);
|
||||
void setupGroundVehicleUI(QString frameType);
|
||||
|
||||
void throwMultiRotorChannelConfigError(int numMotors);
|
||||
void throwFixedWingChannelConfigError(QString airframeType);
|
||||
void throwGroundVehicleChannelConfigError(QString airframeType);
|
||||
|
||||
void toggleAileron2(int index);
|
||||
void toggleElevator2(int index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user