mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-907 step 3: more vehicle config code cleanups
This commit is contained in:
parent
782913590b
commit
81da5303f2
@ -51,7 +51,7 @@ QStringList ConfigCcpmWidget::getChannelDescriptions()
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
GUIConfigDataUnion configData = getConfigData();
|
||||
heliGUISettingsStruct heli = configData.heli;
|
||||
|
||||
if (heli.Throttle > 0) {
|
||||
@ -293,7 +293,7 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType)
|
||||
|
||||
setupUI(frameType);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
|
||||
// swashplate config
|
||||
setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1));
|
||||
@ -626,7 +626,7 @@ void ConfigCcpmWidget::UpdateMixer()
|
||||
if (throwConfigError(QString("HeliCP")))
|
||||
return;
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
|
||||
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
|
||||
useCyclic = config.heli.ccpmLinkRollState;
|
||||
@ -767,7 +767,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
updatingFromHardware = TRUE;
|
||||
|
||||
//get the user options
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
|
||||
//swashplate config
|
||||
config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
|
||||
@ -807,7 +807,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
//tail
|
||||
config.heli.Tail = m_aircraft->ccpmTailChannel->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
updatingFromHardware = FALSE;
|
||||
return airframeType;
|
||||
@ -849,28 +849,25 @@ void ConfigCcpmWidget::getMixer()
|
||||
if (SwashLvlConfigurationInProgress)return;
|
||||
if (updatingToHardware)return;
|
||||
|
||||
updatingFromHardware=TRUE;
|
||||
updatingFromHardware = TRUE;
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
||||
QList<double> curveValues;
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
m_aircraft->ThrottleCurve->setCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
m_aircraft->ThrottleCurve->ResetCurve();
|
||||
}
|
||||
|
||||
|
||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||
// is at least one of the curve values != 0?
|
||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||
if (isValidThrottleCurve(&curveValues)) {
|
||||
m_aircraft->PitchCurve->setCurve(&curveValues);
|
||||
}
|
||||
else {
|
||||
|
@ -49,7 +49,7 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions()
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
GUIConfigDataUnion configData = getConfigData();
|
||||
|
||||
if (configData.fixedwing.FixedWingPitch1 > 0) {
|
||||
channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1");
|
||||
@ -80,6 +80,8 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
|
||||
{
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
populateChannelComboBoxes();
|
||||
|
||||
QStringList fixedWingTypes;
|
||||
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||
m_aircraft->fixedWingType->addItems(fixedWingTypes);
|
||||
@ -199,7 +201,7 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
|
||||
m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
fixedGUISettingsStruct fixed = config.fixedwing;
|
||||
|
||||
// Then retrieve how channels are setup
|
||||
@ -283,7 +285,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
|
||||
}
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
@ -293,7 +295,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
|
||||
config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
@ -353,7 +355,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
|
||||
return false;
|
||||
}
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
|
||||
@ -362,7 +364,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
|
||||
config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
@ -423,7 +425,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
|
||||
return false;
|
||||
}
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
|
||||
@ -432,7 +434,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
|
||||
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
|
||||
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
@ -50,7 +50,7 @@ QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
GUIConfigDataUnion configData = getConfigData();
|
||||
|
||||
if (configData.ground.GroundVehicleSteering1 > 0) {
|
||||
channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1");
|
||||
@ -72,6 +72,8 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
|
||||
{
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
populateChannelComboBoxes();
|
||||
|
||||
QStringList groundVehicleTypes;
|
||||
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
|
||||
m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
|
||||
@ -224,7 +226,7 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
|
||||
} else {
|
||||
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
||||
}
|
||||
GUIConfigDataUnion config = 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
|
||||
@ -310,13 +312,13 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
|
||||
}
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
@ -360,13 +362,13 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
|
||||
}
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
|
||||
|
||||
SetConfigData((config));
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
@ -404,7 +406,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
|
||||
}
|
||||
|
||||
// Now setup the channels:
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
resetActuators(&config);
|
||||
|
||||
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
|
||||
@ -412,7 +414,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
|
||||
config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex();
|
||||
config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex();
|
||||
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
@ -52,7 +52,7 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions()
|
||||
}
|
||||
|
||||
// get the gui config data
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
GUIConfigDataUnion configData = getConfigData();
|
||||
multiGUISettingsStruct multi = configData.multi;
|
||||
|
||||
if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
|
||||
@ -90,9 +90,12 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
|
||||
{
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
populateChannelComboBoxes();
|
||||
|
||||
// Setup the Multirotor picture in the Quad settings interface
|
||||
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
|
||||
|
||||
@ -284,7 +287,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
|
||||
m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
|
||||
}
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
multiGUISettingsStruct multi = config.multi;
|
||||
|
||||
if (frameType == "QuadP") {
|
||||
@ -670,9 +673,9 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
|
||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
||||
setupMotors(motorList);
|
||||
|
||||
GUIConfigDataUnion config = GetConfigData();
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
|
||||
SetConfigData(config);
|
||||
setConfigData(config);
|
||||
|
||||
// Motor 1 to 6, Y6 Layout:
|
||||
// pitch roll yaw
|
||||
@ -787,11 +790,10 @@ void ConfigMultiRotorWidget::setupMotors(QList<QString> motorList)
|
||||
<< m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
||||
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
||||
|
||||
GUIConfigDataUnion configData = GetConfigData();
|
||||
GUIConfigDataUnion configData = getConfigData();
|
||||
resetActuators(&configData);
|
||||
|
||||
foreach (QString motor, motorList)
|
||||
{
|
||||
foreach (QString motor, motorList) {
|
||||
int index = mmList.takeFirst()->currentIndex();
|
||||
if (motor == QString("VTOLMotorN")) {
|
||||
configData.multi.VTOLMotorN = index;
|
||||
@ -811,7 +813,7 @@ void ConfigMultiRotorWidget::setupMotors(QList<QString> motorList)
|
||||
configData.multi.VTOLMotorNW = index;
|
||||
}
|
||||
}
|
||||
SetConfigData(configData);
|
||||
setConfigData(configData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,14 +38,13 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
|
||||
// Generate lists of mixerTypeNames, mixerVectorNames, channelNames
|
||||
channelNames << "None";
|
||||
for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) {
|
||||
mixerTypes << QString("Mixer%1Type").arg(i+1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i+1);
|
||||
channelNames << QString("Channel%1").arg(i+1);
|
||||
mixerTypes << QString("Mixer%1Type").arg(i + 1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i + 1);
|
||||
channelNames << QString("Channel%1").arg(i + 1);
|
||||
}
|
||||
|
||||
mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch"
|
||||
<< "CameraYaw" << "Accessory0" << "Accessory1" << "Accessory2"
|
||||
<< "Accessory3" << "Accessory4" << "Accessory5";
|
||||
mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch" << "CameraYaw"
|
||||
<< "Accessory0" << "Accessory1" << "Accessory2" << "Accessory3" << "Accessory4" << "Accessory5";
|
||||
|
||||
// This is needed because new style tries to compact things as much as possible in grid
|
||||
// and on OSX the widget sizes of PushButtons is reported incorrectly:
|
||||
@ -60,45 +59,43 @@ VehicleConfig::~VehicleConfig()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
GUIConfigDataUnion VehicleConfig::GetConfigData()
|
||||
GUIConfigDataUnion VehicleConfig::getConfigData()
|
||||
{
|
||||
int i;
|
||||
GUIConfigDataUnion configData;
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
|
||||
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];
|
||||
GUIConfigDataUnion configData;
|
||||
for (int 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])));
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
return configData;
|
||||
}
|
||||
|
||||
void VehicleConfig::SetConfigData(GUIConfigDataUnion configData)
|
||||
void VehicleConfig::setConfigData(GUIConfigDataUnion configData)
|
||||
{
|
||||
// sanity check
|
||||
Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
|
||||
|
||||
// get an instance of systemsettings
|
||||
SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
|
||||
SystemSettings *systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
|
||||
Q_ASSERT(systemSettings);
|
||||
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
|
||||
|
||||
UAVObjectField* guiConfig = systemSettings->getField("GUIConfigData");
|
||||
UAVObjectField *guiConfig = systemSettings->getField("GUIConfigData");
|
||||
Q_ASSERT(guiConfig);
|
||||
if (!guiConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
// copy parameter configData -> systemsettings
|
||||
for (int i = 0; i < (int) (SystemSettings::GUICONFIGDATA_NUMELEM); i++) {
|
||||
for (int i = 0; i < (int) SystemSettings::GUICONFIGDATA_NUMELEM; i++) {
|
||||
guiConfig->setValue(configData.UAVObject[i], i);
|
||||
}
|
||||
}
|
||||
@ -120,6 +117,17 @@ void VehicleConfig::resetActuators(GUIConfigDataUnion *configData)
|
||||
{
|
||||
}
|
||||
|
||||
// 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
|
||||
// FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
|
||||
void VehicleConfig::populateChannelComboBoxes()
|
||||
{
|
||||
QList<QComboBox *> l = findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+"));
|
||||
foreach(QComboBox *combobox, l) {
|
||||
combobox->addItems(channelNames);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper function:
|
||||
Sets the current index on supplied combobox to index
|
||||
|
@ -24,8 +24,8 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef GUIVEHICLECONFIG_H
|
||||
#define GUIVEHICLECONFIG_H
|
||||
#ifndef VEHICLECONFIG_H
|
||||
#define VEHICLECONFIG_H
|
||||
|
||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
@ -95,10 +95,10 @@ typedef struct {
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint UAVObject[4]; // 32 bits * 4
|
||||
heliGUISettingsStruct heli; // 128 bits
|
||||
fixedGUISettingsStruct fixedwing;
|
||||
multiGUISettingsStruct multi;
|
||||
uint UAVObject[4]; // 32 bits * 4
|
||||
heliGUISettingsStruct heli; // 128 bits
|
||||
fixedGUISettingsStruct fixedwing;
|
||||
multiGUISettingsStruct multi;
|
||||
groundGUISettingsStruct ground;
|
||||
} GUIConfigDataUnion;
|
||||
|
||||
@ -140,9 +140,8 @@ public:
|
||||
|
||||
static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
|
||||
|
||||
// TODO remove 1st capital
|
||||
static GUIConfigDataUnion GetConfigData();
|
||||
static void SetConfigData(GUIConfigDataUnion configData);
|
||||
static GUIConfigDataUnion getConfigData();
|
||||
static void setConfigData(GUIConfigDataUnion configData);
|
||||
|
||||
static void resetField(UAVObjectField *field);
|
||||
|
||||
@ -153,23 +152,11 @@ public:
|
||||
VehicleConfig(QWidget *parent = 0);
|
||||
~VehicleConfig();
|
||||
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
virtual void refreshWidgetsValues(QString frameType);
|
||||
virtual QString updateConfigObjectsFromWidgets();
|
||||
|
||||
// TODO move to separate class
|
||||
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName);
|
||||
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value);
|
||||
void resetMixerVector(UAVDataObject *mixer, int channel);
|
||||
void resetMotorAndServoMixers(UAVDataObject *mixer);
|
||||
QString getMixerType(UAVDataObject *mixer, int channel);
|
||||
void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType);
|
||||
double getMixerValue(UAVDataObject *mixer, QString elementName);
|
||||
void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
|
||||
void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double> curve);
|
||||
void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double>* curve);
|
||||
bool isValidThrottleCurve(QList<double> *curve);
|
||||
double getCurveMin(QList<double> *curve);
|
||||
double getCurveMax(QList<double> *curve);
|
||||
double getMixerValue(UAVDataObject *mixer, QString elementName);
|
||||
void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
|
||||
|
||||
protected:
|
||||
QStringList channelNames;
|
||||
@ -177,6 +164,20 @@ protected:
|
||||
QStringList mixerVectors;
|
||||
QStringList mixerTypeDescriptions;
|
||||
|
||||
void populateChannelComboBoxes();
|
||||
|
||||
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName);
|
||||
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value);
|
||||
void resetMixerVector(UAVDataObject *mixer, int channel);
|
||||
void resetMotorAndServoMixers(UAVDataObject *mixer);
|
||||
QString getMixerType(UAVDataObject *mixer, int channel);
|
||||
void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType);
|
||||
void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double> curve);
|
||||
void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList<double>* curve);
|
||||
bool isValidThrottleCurve(QList<double> *curve);
|
||||
double getCurveMin(QList<double> *curve);
|
||||
double getCurveMax(QList<double> *curve);
|
||||
|
||||
private:
|
||||
static UAVObjectManager *getUAVObjectManager();
|
||||
|
||||
@ -187,4 +188,4 @@ private slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // GUIVEHICLECONFIG_H
|
||||
#endif // VEHICLECONFIG_H
|
||||
|
@ -154,24 +154,8 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
// Force the tab index to match
|
||||
m_aircraft->airframesWidget->setCurrentIndex(1);
|
||||
|
||||
// Generate lists of mixerTypeNames, mixerVectorNames, channelNames
|
||||
channelNames << "None";
|
||||
for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
||||
mixerTypes << QString("Mixer%1Type").arg(i + 1);
|
||||
mixerVectors << QString("Mixer%1Vector").arg(i + 1);
|
||||
channelNames << QString("Channel%1").arg(i + 1);
|
||||
}
|
||||
|
||||
// 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
|
||||
// FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
|
||||
QList<QComboBox *> l = findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+"));
|
||||
foreach(QComboBox *combobox, l) {
|
||||
combobox->addItems(channelNames);
|
||||
}
|
||||
|
||||
// Connect aircraft type selection dropbox to callback function
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), m_aircraft->airframesWidget, SLOT(setCurrentIndex(int)));
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
||||
|
||||
// Connect the three feed forward test checkboxes
|
||||
connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||
@ -196,15 +180,10 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
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)
|
||||
//{
|
||||
// m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
//}
|
||||
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||
{
|
||||
m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
/**
|
||||
Refreshes the current value of the SystemSettings which holds the aircraft type
|
||||
@ -233,9 +212,8 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
|
||||
// is not ideal, but there you go.
|
||||
QString frameType = field->getValue().toString();
|
||||
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType;
|
||||
//setupAirframeUI(frameType);
|
||||
|
||||
QString category = "FixedWing";//frameCategory(frameType);
|
||||
QString category = frameCategory(frameType);
|
||||
if (category == "FixedWing") {
|
||||
// Retrieve fixed wing settings
|
||||
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
@ -378,13 +356,12 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
// - Check if all three checkboxes are checked
|
||||
// - Every other timer event: toggle engine from 45% to 55%
|
||||
// - Every other time event: send FF settings to flight FW
|
||||
if (m_aircraft->ffTestBox1->isChecked() &&
|
||||
m_aircraft->ffTestBox2->isChecked() &&
|
||||
m_aircraft->ffTestBox3->isChecked()) {
|
||||
if (!ffTuningInProgress)
|
||||
{
|
||||
if (m_aircraft->ffTestBox1->isChecked() && m_aircraft->ffTestBox2->isChecked()
|
||||
&& m_aircraft->ffTestBox3->isChecked()) {
|
||||
if (!ffTuningInProgress) {
|
||||
// Initiate tuning:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(
|
||||
QString("ManualControlCommand")));
|
||||
UAVObject::Metadata mdata = obj->getMetadata();
|
||||
accInitialData = mdata;
|
||||
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY);
|
||||
@ -404,9 +381,10 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
|
||||
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
|
||||
mixer->updated();
|
||||
} else {
|
||||
} else {
|
||||
// Toggle motor state
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(
|
||||
QString("ManualControlCommand")));
|
||||
double value = obj->getField("Throttle")->getDouble();
|
||||
double target = (value < 0.5) ? 0.55 : 0.45;
|
||||
obj->getField("Throttle")->setValue(target);
|
||||
@ -420,7 +398,8 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
// Disarm!
|
||||
if (ffTuningInProgress) {
|
||||
ffTuningInProgress = false;
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(
|
||||
QString("ManualControlCommand")));
|
||||
UAVObject::Metadata mdata = obj->getMetadata();
|
||||
mdata = accInitialData; // Restore metadata
|
||||
obj->setMetadata(mdata);
|
||||
@ -435,7 +414,7 @@ void ConfigVehicleTypeWidget::enableFFTest()
|
||||
*/
|
||||
void ConfigVehicleTypeWidget::updateFeedForwardUI()
|
||||
{
|
||||
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
QPointer<VehicleConfig> vconfig = new VehicleConfig();
|
||||
|
@ -65,15 +65,12 @@ private:
|
||||
|
||||
QString frameCategory(QString frameType);
|
||||
|
||||
QStringList channelNames;
|
||||
QStringList mixerTypes;
|
||||
QStringList mixerVectors;
|
||||
|
||||
bool ffTuningInProgress;
|
||||
bool ffTuningPhase;
|
||||
UAVObject::Metadata accInitialData;
|
||||
|
||||
private slots:
|
||||
void switchAirframeType(int index);
|
||||
void enableFFTest();
|
||||
void openHelp();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user