mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-39 Added condition for multirotor type. If PWM input option is enable only up to Hex is selectable, otherwise Octo is selectable to.
Added initial configuration code that applies the users choices in the UAVOs. Changed order of pages so that Input page comes before vehicle page.
This commit is contained in:
parent
25d13e4c35
commit
2b541219bf
@ -35,6 +35,7 @@ FlashPage::FlashPage(SetupWizard *wizard, QWidget *parent) :
|
||||
ui(new Ui::FlashPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->applyButton, SIGNAL(clicked()), wizard, SLOT(writeConfiguration()));
|
||||
}
|
||||
|
||||
FlashPage::~FlashPage()
|
||||
|
@ -45,9 +45,9 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>240</y>
|
||||
<y>230</y>
|
||||
<width>561</width>
|
||||
<height>141</height>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -62,6 +62,19 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<widget class="QPushButton" name="applyButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>30</y>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -57,16 +57,23 @@ MultiPage::~MultiPage()
|
||||
|
||||
void MultiPage::initializePage()
|
||||
{
|
||||
updateAvailableTypes();
|
||||
updateImageAndDescription();
|
||||
}
|
||||
|
||||
bool MultiPage::validatePage()
|
||||
{
|
||||
SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE) ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt();
|
||||
getWizard()->setVehicleSubType(type);
|
||||
}
|
||||
|
||||
void MultiPage::setupMultiTypesCombo()
|
||||
{
|
||||
ui->typeCombo->addItem("Tricopter", SetupWizard::MULTI_ROTOR_TRI_Y);
|
||||
ui->typeCombo->addItem("Quadcopter X", SetupWizard::MULTI_ROTOR_QUAD_X);
|
||||
ui->typeCombo->addItem("Quadcopter +", SetupWizard::MULTI_ROTOR_QUAD_PLUS);
|
||||
ui->typeCombo->addItem("Hexacopter", SetupWizard::MULTI_ROTOR_HEXA);
|
||||
ui->typeCombo->addItem("Hexacopter Coax", SetupWizard::MULTI_ROTOR_HEXA_COAX_Y);
|
||||
ui->typeCombo->addItem("Hexacopter Coax (Y6)", SetupWizard::MULTI_ROTOR_HEXA_COAX_Y);
|
||||
ui->typeCombo->addItem("Hexacopter H", SetupWizard::MULTI_ROTOR_HEXA_H);
|
||||
ui->typeCombo->addItem("Octocopter", SetupWizard::MULTI_ROTOR_OCTO);
|
||||
ui->typeCombo->addItem("Octocopter Coax X", SetupWizard::MULTI_ROTOR_OCTO_COAX_X);
|
||||
@ -74,9 +81,18 @@ void MultiPage::setupMultiTypesCombo()
|
||||
ui->typeCombo->addItem("Octocopter V", SetupWizard::MULTI_ROTOR_OCTO_V);
|
||||
}
|
||||
|
||||
void MultiPage::updateAvailableTypes()
|
||||
{
|
||||
QVariant enable = (getWizard()->getInputType() == SetupWizard::INPUT_PWM) ? QVariant(0) : QVariant(1 | 32);
|
||||
ui->typeCombo->model()->setData(ui->typeCombo->model()->index(6, 0), enable, Qt::UserRole - 1);
|
||||
ui->typeCombo->model()->setData(ui->typeCombo->model()->index(7, 0), enable, Qt::UserRole - 1);
|
||||
ui->typeCombo->model()->setData(ui->typeCombo->model()->index(8, 0), enable, Qt::UserRole - 1);
|
||||
ui->typeCombo->model()->setData(ui->typeCombo->model()->index(9, 0), enable, Qt::UserRole - 1);
|
||||
}
|
||||
|
||||
void MultiPage::updateImageAndDescription()
|
||||
{
|
||||
SetupWizard::MULTI_ROTOR_SUB_TYPE type = (SetupWizard::MULTI_ROTOR_SUB_TYPE) ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt();
|
||||
SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE) ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt();
|
||||
QString elementId = "";
|
||||
QString description = "Descriptive text with information about ";
|
||||
description.append(ui->typeCombo->currentText());
|
||||
|
@ -46,11 +46,14 @@ public:
|
||||
~MultiPage();
|
||||
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
|
||||
|
||||
private:
|
||||
Ui::MultiPage *ui;
|
||||
void setupMultiTypesCombo();
|
||||
QGraphicsSvgItem *multiPic;
|
||||
void updateAvailableTypes();
|
||||
|
||||
private slots:
|
||||
void updateImageAndDescription();
|
||||
|
@ -40,6 +40,11 @@
|
||||
#include "pages/summarypage.h"
|
||||
#include "pages/flashpage.h"
|
||||
#include "pages/notyetimplementedpage.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "hwsettings.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "attitudesettings.h"
|
||||
|
||||
|
||||
SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent),
|
||||
m_controllerSelectionMode(CONTROLLER_SELECTION_UNKNOWN), m_controllerType(CONTROLLER_UNKNOWN),
|
||||
@ -47,6 +52,7 @@ SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent),
|
||||
m_levellingPerformed(false), m_connectionManager(0)
|
||||
{
|
||||
setWindowTitle("OpenPilot Setup Wizard");
|
||||
setOption(QWizard::IndependentPages, false);
|
||||
createPages();
|
||||
}
|
||||
|
||||
@ -60,7 +66,7 @@ int SetupWizard::nextId() const
|
||||
{
|
||||
case CONTROLLER_CC:
|
||||
case CONTROLLER_CC3D:
|
||||
return PAGE_VEHICLES;
|
||||
return PAGE_INPUT;
|
||||
case CONTROLLER_REVO:
|
||||
case CONTROLLER_PIPX:
|
||||
default:
|
||||
@ -83,9 +89,9 @@ int SetupWizard::nextId() const
|
||||
}
|
||||
}
|
||||
case PAGE_MULTI:
|
||||
return PAGE_INPUT;
|
||||
case PAGE_INPUT:
|
||||
return PAGE_OUTPUT;
|
||||
case PAGE_INPUT:
|
||||
return PAGE_VEHICLES;
|
||||
case PAGE_OUTPUT:
|
||||
{
|
||||
if(getControllerSelectionMode() == CONTROLLER_SELECTION_AUTOMATIC) {
|
||||
@ -196,6 +202,197 @@ QString SetupWizard::getSummaryText()
|
||||
return summary;
|
||||
}
|
||||
|
||||
void SetupWizard::applyConfiguration()
|
||||
{
|
||||
UAVObjectManager* uavoMgr = getUAVObjectManager();
|
||||
applyHardwareConfiguration(uavoMgr);
|
||||
applyVehicleConfiguration(uavoMgr);
|
||||
applyOutputConfiguration(uavoMgr);
|
||||
applyLevellingConfiguration(uavoMgr);
|
||||
}
|
||||
|
||||
UAVObjectManager* SetupWizard::getUAVObjectManager()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * uavObjectManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(uavObjectManager);
|
||||
return uavObjectManager;
|
||||
}
|
||||
|
||||
void SetupWizard::applyHardwareConfiguration(UAVObjectManager* uavoMgr)
|
||||
{
|
||||
HwSettings* hwSettings = HwSettings::GetInstance(uavoMgr);
|
||||
|
||||
switch(getControllerType())
|
||||
{
|
||||
case CONTROLLER_CC:
|
||||
case CONTROLLER_CC3D:
|
||||
// Reset all ports
|
||||
hwSettings->setCC_RcvrPort(HwSettings::CC_RCVRPORT_DISABLED);
|
||||
hwSettings->setCC_FlexiPort(HwSettings::CC_FLEXIPORT_DISABLED);
|
||||
hwSettings->setCC_MainPort(HwSettings::CC_MAINPORT_DISABLED);
|
||||
switch(getInputType())
|
||||
{
|
||||
case INPUT_PWM:
|
||||
hwSettings->setCC_RcvrPort(HwSettings::CC_RCVRPORT_PWM);
|
||||
break;
|
||||
case INPUT_PPM:
|
||||
hwSettings->setCC_RcvrPort(HwSettings::CC_RCVRPORT_PPM);
|
||||
break;
|
||||
case INPUT_SBUS:
|
||||
hwSettings->setCC_MainPort(HwSettings::CC_MAINPORT_SBUS);
|
||||
break;
|
||||
case INPUT_DSM:
|
||||
// TODO: Handle all of the DSM types ?? Which is most common?
|
||||
hwSettings->setCC_MainPort(HwSettings::CC_MAINPORT_DSM2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CONTROLLER_REVO:
|
||||
// TODO: Implement Revo settings
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::applyVehicleConfiguration(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
|
||||
switch(getVehicleType())
|
||||
{
|
||||
case VEHICLE_MULTI:
|
||||
{
|
||||
switch(getVehicleSubType())
|
||||
{
|
||||
case SetupWizard::MULTI_ROTOR_TRI_Y:
|
||||
setupTriCopter(uavoMgr);
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_X:
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_PLUS:
|
||||
setupQuadCopter(uavoMgr);
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_HEXA:
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y:
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_H:
|
||||
setupHexaCopter(uavoMgr);
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_OCTO:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_COAX_X:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_V:
|
||||
setupOctoCopter(uavoMgr);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VEHICLE_FIXEDWING:
|
||||
case VEHICLE_HELI:
|
||||
case VEHICLE_SURFACE:
|
||||
// TODO: Implement settings for other vehicle types?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::applyOutputConfiguration(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
ActuatorSettings* actSettings = ActuatorSettings::GetInstance(uavoMgr);
|
||||
switch(getVehicleType())
|
||||
{
|
||||
case VEHICLE_MULTI:
|
||||
{
|
||||
actSettings->setChannelUpdateFreq(0, DEFAULT_ESC_FREQUENCE);
|
||||
actSettings->setChannelUpdateFreq(1, DEFAULT_ESC_FREQUENCE);
|
||||
actSettings->setChannelUpdateFreq(2, DEFAULT_ESC_FREQUENCE);
|
||||
actSettings->setChannelUpdateFreq(3, DEFAULT_ESC_FREQUENCE);
|
||||
|
||||
qint16 updateFrequence = DEFAULT_ESC_FREQUENCE;
|
||||
switch(getESCType())
|
||||
{
|
||||
case ESC_DEFAULT:
|
||||
updateFrequence = DEFAULT_ESC_FREQUENCE;
|
||||
break;
|
||||
case ESC_RAPID:
|
||||
updateFrequence = RAPID_ESC_FREQUENCE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(getVehicleSubType())
|
||||
{
|
||||
case SetupWizard::MULTI_ROTOR_TRI_Y:
|
||||
actSettings->setChannelUpdateFreq(0, updateFrequence);
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_X:
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_PLUS:
|
||||
actSettings->setChannelUpdateFreq(0, updateFrequence);
|
||||
actSettings->setChannelUpdateFreq(1, updateFrequence);
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_HEXA:
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y:
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_H:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_COAX_X:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_COAX_PLUS:
|
||||
case SetupWizard::MULTI_ROTOR_OCTO_V:
|
||||
actSettings->setChannelUpdateFreq(0, updateFrequence);
|
||||
actSettings->setChannelUpdateFreq(1, updateFrequence);
|
||||
actSettings->setChannelUpdateFreq(2, updateFrequence);
|
||||
actSettings->setChannelUpdateFreq(3, updateFrequence);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VEHICLE_FIXEDWING:
|
||||
case VEHICLE_HELI:
|
||||
case VEHICLE_SURFACE:
|
||||
// TODO: Implement settings for other vehicle types?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::applyLevellingConfiguration(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
if(isLevellingPerformed())
|
||||
{
|
||||
accelGyroBias bias = getLevellingBias();
|
||||
AttitudeSettings::DataFields attitudeSettingsData = AttitudeSettings::GetInstance(uavoMgr)->getData();
|
||||
attitudeSettingsData.AccelBias[0] += bias.m_accelerometerXBias;
|
||||
attitudeSettingsData.AccelBias[1] += bias.m_accelerometerYBias;
|
||||
attitudeSettingsData.AccelBias[2] += bias.m_accelerometerZBias;
|
||||
attitudeSettingsData.GyroBias[0] = -bias.m_gyroXBias;
|
||||
attitudeSettingsData.GyroBias[1] = -bias.m_gyroYBias;
|
||||
attitudeSettingsData.GyroBias[2] = -bias.m_gyroZBias;
|
||||
AttitudeSettings::GetInstance(uavoMgr)->setData(attitudeSettingsData);
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::setupTriCopter(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SetupWizard::setupQuadCopter(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
}
|
||||
|
||||
void SetupWizard::setupHexaCopter(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
}
|
||||
|
||||
void SetupWizard::setupOctoCopter(UAVObjectManager *uavoMgr)
|
||||
{
|
||||
}
|
||||
|
||||
void SetupWizard::exportConfiguration()
|
||||
{
|
||||
applyConfiguration();
|
||||
// Call export configuration function...
|
||||
}
|
||||
|
||||
void SetupWizard::writeConfiguration()
|
||||
{
|
||||
applyConfiguration();
|
||||
// Call Save UAVOs to controller
|
||||
}
|
||||
|
||||
void SetupWizard::createPages()
|
||||
{
|
||||
setPage(PAGE_START, new StartPage(this));
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "levellingutil.h"
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/connectionmanager.h>
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
|
||||
class SetupWizard : public QWizard
|
||||
{
|
||||
@ -43,9 +45,10 @@ public:
|
||||
enum CONTROLLER_SELECTION_MODE {CONTROLLER_SELECTION_AUTOMATIC, CONTROLLER_SELECTION_MANUAL, CONTROLLER_SELECTION_UNKNOWN};
|
||||
enum CONTROLLER_TYPE {CONTROLLER_UNKNOWN, CONTROLLER_CC, CONTROLLER_CC3D, CONTROLLER_REVO, CONTROLLER_PIPX};
|
||||
enum VEHICLE_TYPE {VEHICLE_UNKNOWN, VEHICLE_MULTI, VEHICLE_FIXEDWING, VEHICLE_HELI, VEHICLE_SURFACE};
|
||||
enum MULTI_ROTOR_SUB_TYPE {MULTI_ROTOR_UNKNOWN, MULTI_ROTOR_TRI_Y, MULTI_ROTOR_QUAD_X, MULTI_ROTOR_QUAD_PLUS,
|
||||
enum VEHICLE_SUB_TYPE {MULTI_ROTOR_UNKNOWN, MULTI_ROTOR_TRI_Y, MULTI_ROTOR_QUAD_X, MULTI_ROTOR_QUAD_PLUS,
|
||||
MULTI_ROTOR_HEXA, MULTI_ROTOR_HEXA_H, MULTI_ROTOR_HEXA_COAX_Y, MULTI_ROTOR_OCTO,
|
||||
MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS};
|
||||
MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS, FIXED_WING_AILERON,
|
||||
FIXED_WING_VTAIL, HELI_CCPM};
|
||||
enum ESC_TYPE {ESC_DEFAULT, ESC_RAPID, ESC_UNKNOWN};
|
||||
enum INPUT_TYPE {INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSM, INPUT_UNKNOWN};
|
||||
|
||||
@ -58,6 +61,9 @@ public:
|
||||
void setVehicleType(SetupWizard::VEHICLE_TYPE type) { m_vehicleType = type; }
|
||||
SetupWizard::VEHICLE_TYPE getVehicleType() const { return m_vehicleType; }
|
||||
|
||||
void setVehicleSubType(SetupWizard::VEHICLE_SUB_TYPE type) { m_vehicleSubType = type; }
|
||||
SetupWizard::VEHICLE_SUB_TYPE getVehicleSubType() const { return m_vehicleSubType; }
|
||||
|
||||
void setInputType(SetupWizard::INPUT_TYPE type) { m_inputType = type; }
|
||||
SetupWizard::INPUT_TYPE getInputType() const { return m_inputType; }
|
||||
|
||||
@ -78,8 +84,14 @@ public:
|
||||
}
|
||||
return m_connectionManager;
|
||||
}
|
||||
public slots:
|
||||
void exportConfiguration();
|
||||
void writeConfiguration();
|
||||
|
||||
private:
|
||||
static const qint16 DEFAULT_ESC_FREQUENCE = 50;
|
||||
static const qint16 RAPID_ESC_FREQUENCE = 50;
|
||||
|
||||
enum {PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING,
|
||||
PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_OUTPUT, PAGE_LEVELLING,
|
||||
PAGE_FLASH, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_END};
|
||||
@ -88,6 +100,7 @@ private:
|
||||
CONTROLLER_SELECTION_MODE m_controllerSelectionMode;
|
||||
CONTROLLER_TYPE m_controllerType;
|
||||
VEHICLE_TYPE m_vehicleType;
|
||||
VEHICLE_SUB_TYPE m_vehicleSubType;
|
||||
INPUT_TYPE m_inputType;
|
||||
ESC_TYPE m_escType;
|
||||
bool m_levellingPerformed;
|
||||
@ -95,6 +108,18 @@ private:
|
||||
|
||||
Core::ConnectionManager *m_connectionManager;
|
||||
|
||||
UAVObjectManager *getUAVObjectManager();
|
||||
|
||||
void applyConfiguration();
|
||||
void applyHardwareConfiguration(UAVObjectManager *uavoMgr);
|
||||
void applyVehicleConfiguration(UAVObjectManager *uavoMgr);
|
||||
void applyOutputConfiguration(UAVObjectManager *uavoMgr);
|
||||
void applyLevellingConfiguration(UAVObjectManager *uavoMgr);
|
||||
|
||||
void setupTriCopter(UAVObjectManager *uavoMgr);
|
||||
void setupQuadCopter(UAVObjectManager *uavoMgr);
|
||||
void setupHexaCopter(UAVObjectManager *uavoMgr);
|
||||
void setupOctoCopter(UAVObjectManager *uavoMgr);
|
||||
};
|
||||
|
||||
#endif // SETUPWIZARD_H
|
||||
|
Loading…
Reference in New Issue
Block a user