1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-1222 Renamed some pages. Added support for both esc and servo types.

This commit is contained in:
m_thread 2014-08-22 01:40:05 +02:00
parent a7ab68f539
commit a893f6ff2b
12 changed files with 146 additions and 112 deletions

View File

@ -1,11 +1,11 @@
/**
******************************************************************************
*
* @file outputpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @file escpage.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup
* @{
* @addtogroup OutputPage
* @addtogroup EscPage
* @{
* @brief
*****************************************************************************/
@ -25,29 +25,29 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "outputpage.h"
#include "ui_outputpage.h"
#include "escpage.h"
#include "ui_escpage.h"
#include "setupwizard.h"
OutputPage::OutputPage(SetupWizard *wizard, QWidget *parent) :
EscPage::EscPage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::OutputPage)
ui(new Ui::EscPage)
{
ui->setupUi(this);
}
OutputPage::~OutputPage()
EscPage::~EscPage()
{
delete ui;
}
bool OutputPage::validatePage()
bool EscPage::validatePage()
{
if (ui->rapidESCButton->isChecked()) {
getWizard()->setActuatorType(SetupWizard::ESC_RAPID);
getWizard()->setEscType(SetupWizard::ESC_RAPID);
} else {
getWizard()->setActuatorType(SetupWizard::ESC_LEGACY);
getWizard()->setEscType(SetupWizard::ESC_LEGACY);
}
return true;

View File

@ -1,11 +1,11 @@
/**
******************************************************************************
*
* @file outputpage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @file escpage.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup
* @{
* @addtogroup OutputPage
* @addtogroup EscPage
* @{
* @brief
*****************************************************************************/
@ -25,25 +25,25 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef OUTPUTPAGE_H
#define OUTPUTPAGE_H
#ifndef ESCPAGE_H
#define ESCPAGE_H
#include "abstractwizardpage.h"
namespace Ui {
class OutputPage;
class EscPage;
}
class OutputPage : public AbstractWizardPage {
class EscPage : public AbstractWizardPage {
Q_OBJECT
public:
explicit OutputPage(SetupWizard *wizard, QWidget *parent = 0);
~OutputPage();
explicit EscPage(SetupWizard *wizard, QWidget *parent = 0);
~EscPage();
bool validatePage();
private:
Ui::OutputPage *ui;
Ui::EscPage *ui;
};
#endif // OUTPUTPAGE_H
#endif // ESCPAGE_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OutputPage</class>
<widget class="QWizardPage" name="OutputPage">
<class>EscPage</class>
<widget class="QWizardPage" name="EscPage">
<property name="geometry">
<rect>
<x>0</x>

View File

@ -120,7 +120,7 @@ void OutputCalibrationPage::setupVehicle()
// The channel number to configure for each step.
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 3 << 3;
setupActuatorMinMaxAndNeutral(0, 1, 3);
setupActuatorMinMaxAndNeutral(0, 2, 3);
getWizard()->setActuatorSettings(m_actuatorSettings);
break;

View File

@ -25,28 +25,28 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "outputfixedwingpage.h"
#include "ui_outputfixedwingpage.h"
#include "servopage.h"
#include "ui_servopage.h"
#include "setupwizard.h"
OutputFixedwingPage::OutputFixedwingPage(SetupWizard *wizard, QWidget *parent) :
ServoPage::ServoPage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::OutputFixedwingPage)
ui(new Ui::ServoPage)
{
ui->setupUi(this);
}
OutputFixedwingPage::~OutputFixedwingPage()
ServoPage::~ServoPage()
{
delete ui;
}
bool OutputFixedwingPage::validatePage()
bool ServoPage::validatePage()
{
if (ui->ServoTypeButton->isChecked()) {
getWizard()->setActuatorType(SetupWizard::SERVO_DIGITAL);
getWizard()->setServoType(SetupWizard::SERVO_DIGITAL);
} else {
getWizard()->setActuatorType(SetupWizard::SERVO_ANALOG);
getWizard()->setServoType(SetupWizard::SERVO_ANALOG);
}
return true;

View File

@ -31,19 +31,19 @@
#include "abstractwizardpage.h"
namespace Ui {
class OutputFixedwingPage;
class ServoPage;
}
class OutputFixedwingPage : public AbstractWizardPage {
class ServoPage : public AbstractWizardPage {
Q_OBJECT
public:
explicit OutputFixedwingPage(SetupWizard *wizard, QWidget *parent = 0);
~OutputFixedwingPage();
explicit ServoPage(SetupWizard *wizard, QWidget *parent = 0);
~ServoPage();
bool validatePage();
private:
Ui::OutputFixedwingPage *ui;
Ui::ServoPage *ui;
};
#endif // OUTPUTFIXEDWINGPAGE_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OutputFixedwingPage</class>
<widget class="QWizardPage" name="OutputFixedwingPage">
<class>ServoPage</class>
<widget class="QWizardPage" name="ServoPage">
<property name="geometry">
<rect>
<x>0</x>

View File

@ -35,8 +35,8 @@
#include "pages/helipage.h"
#include "pages/surfacepage.h"
#include "pages/inputpage.h"
#include "pages/outputpage.h"
#include "pages/outputfixedwingpage.h"
#include "pages/escpage.h"
#include "pages/servopage.h"
#include "pages/biascalibrationpage.h"
#include "pages/summarypage.h"
#include "pages/savepage.h"
@ -54,7 +54,8 @@
SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent), VehicleConfigurationSource(),
m_controllerType(CONTROLLER_UNKNOWN),
m_vehicleType(VEHICLE_UNKNOWN), m_inputType(INPUT_UNKNOWN), m_escType(ESC_UNKNOWN),
m_calibrationPerformed(false), m_restartNeeded(false), m_connectionManager(0)
m_servoType(SERVO_UNKNOWN), m_calibrationPerformed(false), m_restartNeeded(false),
m_connectionManager(0)
{
setWindowTitle(tr("OpenPilot Setup Wizard"));
setOption(QWizard::IndependentPages, false);
@ -112,10 +113,10 @@ int SetupWizard::nextId() const
}
}
case PAGE_MULTI:
return PAGE_OUTPUT;
return PAGE_ESC;
case PAGE_FIXEDWING:
return PAGE_OUTPUT_FIXEDWING;
return PAGE_SERVO;
case PAGE_INPUT:
if (isRestartNeeded()) {
@ -127,10 +128,14 @@ int SetupWizard::nextId() const
case PAGE_REBOOT:
return PAGE_VEHICLES;
case PAGE_OUTPUT:
return PAGE_SUMMARY;
case PAGE_ESC:
if (getVehicleSubType() == MULTI_ROTOR_TRI_Y) {
return PAGE_SERVO;
} else {
return PAGE_SUMMARY;
}
case PAGE_OUTPUT_FIXEDWING:
case PAGE_SERVO:
return PAGE_SUMMARY;
case PAGE_BIAS_CALIBRATION:
@ -306,25 +311,33 @@ QString SetupWizard::getSummaryText()
}
summary.append("<br>");
summary.append("<b>").append(tr("Actuator type: ")).append("</b>");
switch (getActuatorType()) {
summary.append("<b>").append(tr("Speed Controller (ESC) type: ")).append("</b>");
switch (getEscType()) {
case ESC_LEGACY:
summary.append(tr("Legacy ESC (50 Hz)"));
break;
case ESC_RAPID:
summary.append(tr("Rapid ESC (400 Hz)"));
break;
case SERVO_ANALOG:
summary.append(tr("Analog Servos (50 Hz)"));
break;
case SERVO_DIGITAL:
summary.append(tr("Digital Servos (333 Hz)"));
break;
default:
summary.append(tr("Unknown"));
}
if (getVehicleSubType() == MULTI_ROTOR_TRI_Y || getVehicleType() == VEHICLE_FIXEDWING) {
summary.append("<br>");
summary.append("<b>").append(tr("Servo type: ")).append("</b>");
switch (getServoType()) {
case SERVO_ANALOG:
summary.append(tr("Analog Servos (50 Hz)"));
break;
case SERVO_DIGITAL:
summary.append(tr("Digital Servos (333 Hz)"));
break;
default:
summary.append(tr("Unknown"));
}
}
/*
summary.append("<br>");
summary.append("<b>").append(tr("Reboot required: ")).append("</b>");
@ -344,8 +357,8 @@ void SetupWizard::createPages()
setPage(PAGE_HELI, new HeliPage(this));
setPage(PAGE_SURFACE, new SurfacePage(this));
setPage(PAGE_INPUT, new InputPage(this));
setPage(PAGE_OUTPUT, new OutputPage(this));
setPage(PAGE_OUTPUT_FIXEDWING, new OutputFixedwingPage(this));
setPage(PAGE_ESC, new EscPage(this));
setPage(PAGE_SERVO, new ServoPage(this));
setPage(PAGE_BIAS_CALIBRATION, new BiasCalibrationPage(this));
// setPage(PAGE_REVO_CALIBRATION, new RevoCalibrationPage(this));
setPage(PAGE_OUTPUT_CALIBRATION, new OutputCalibrationPage(this));

View File

@ -78,15 +78,24 @@ public:
return m_inputType;
}
void setActuatorType(SetupWizard::ACTUATOR_TYPE type)
void setEscType(SetupWizard::ESC_TYPE type)
{
m_escType = type;
}
SetupWizard::ACTUATOR_TYPE getActuatorType() const
SetupWizard::ESC_TYPE getEscType() const
{
return m_escType;
}
void setServoType(SetupWizard::SERVO_TYPE type)
{
m_servoType = type;
}
SetupWizard::SERVO_TYPE getServoType() const
{
return m_servoType;
}
void setGPSSetting(SetupWizard::GPS_SETTING setting)
{
m_gpsSetting = setting;
@ -156,8 +165,8 @@ private slots:
void pageChanged(int currId);
private:
enum { PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING,
PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_OUTPUT, PAGE_OUTPUT_FIXEDWING,
PAGE_BIAS_CALIBRATION,PAGE_REVO_CALIBRATION, PAGE_OUTPUT_CALIBRATION,
PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_ESC, PAGE_SERVO,
PAGE_BIAS_CALIBRATION, PAGE_REVO_CALIBRATION, PAGE_OUTPUT_CALIBRATION,
PAGE_SAVE, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_AIRFRAMESTAB_FIXEDWING,
PAGE_REBOOT, PAGE_END, PAGE_UPDATE };
void createPages();
@ -168,7 +177,8 @@ private:
VEHICLE_TYPE m_vehicleType;
VEHICLE_SUB_TYPE m_vehicleSubType;
INPUT_TYPE m_inputType;
ACTUATOR_TYPE m_escType;
ESC_TYPE m_escType;
SERVO_TYPE m_servoType;
GPS_SETTING m_gpsSetting;
RADIO_SETTING m_radioSetting;

View File

@ -22,7 +22,6 @@ HEADERS += setupwizardplugin.h \
pages/helipage.h \
pages/surfacepage.h \
pages/abstractwizardpage.h \
pages/outputpage.h \
pages/inputpage.h \
pages/summarypage.h \
vehicleconfigurationsource.h \
@ -36,8 +35,9 @@ HEADERS += setupwizardplugin.h \
pages/revocalibrationpage.h \
biascalibrationutil.h \
pages/biascalibrationpage.h \
pages/outputfixedwingpage.h \
pages/airframestabfixedwingpage.h
pages/airframestabfixedwingpage.h \
pages/escpage.h \
pages/servopage.h
SOURCES += setupwizardplugin.cpp \
setupwizard.cpp \
@ -51,7 +51,6 @@ SOURCES += setupwizardplugin.cpp \
pages/helipage.cpp \
pages/surfacepage.cpp \
pages/abstractwizardpage.cpp \
pages/outputpage.cpp \
pages/inputpage.cpp \
pages/summarypage.cpp \
vehicleconfigurationsource.cpp \
@ -65,8 +64,9 @@ SOURCES += setupwizardplugin.cpp \
pages/revocalibrationpage.cpp \
biascalibrationutil.cpp \
pages/biascalibrationpage.cpp \
pages/outputfixedwingpage.cpp \
pages/airframestabfixedwingpage.cpp
pages/airframestabfixedwingpage.cpp \
pages/escpage.cpp \
pages/servopage.cpp
OTHER_FILES += SetupWizard.pluginspec
@ -80,7 +80,6 @@ FORMS += \
pages/fixedwingpage.ui \
pages/helipage.ui \
pages/surfacepage.ui \
pages/outputpage.ui \
pages/inputpage.ui \
pages/summarypage.ui \
connectiondiagram.ui \
@ -90,8 +89,9 @@ FORMS += \
pages/autoupdatepage.ui \
pages/revocalibrationpage.ui \
pages/biascalibrationpage.ui \
pages/outputfixedwingpage.ui \
pages/airframestabfixedwingpage.ui
pages/airframestabfixedwingpage.ui \
pages/escpage.ui \
pages/servopage.ui
RESOURCES += \
wizardResources.qrc

View File

@ -253,6 +253,30 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
{
ActuatorSettings *actSettings = ActuatorSettings::GetInstance(m_uavoManager);
qint16 escFrequence = LEGACY_ESC_FREQUENCE;
switch (m_configSource->getEscType()) {
case VehicleConfigurationSource::ESC_LEGACY:
escFrequence = LEGACY_ESC_FREQUENCE;
break;
case VehicleConfigurationSource::ESC_RAPID:
escFrequence = RAPID_ESC_FREQUENCE;
break;
default:
break;
}
qint16 servoFrequence = ANALOG_SERVO_FREQUENCE;
switch (m_configSource->getServoType()) {
case VehicleConfigurationSource::SERVO_ANALOG:
servoFrequence = ANALOG_SERVO_FREQUENCE;
break;
case VehicleConfigurationSource::SERVO_DIGITAL:
servoFrequence = DIGITAL_SERVO_FREQUENCE;
break;
default:
break;
}
switch (m_configSource->getVehicleType()) {
case VehicleConfigurationSource::VEHICLE_MULTI:
{
@ -273,31 +297,28 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
data.ChannelUpdateFreq[i] = LEGACY_ESC_FREQUENCE;
}
qint16 updateFrequence = LEGACY_ESC_FREQUENCE;
switch (m_configSource->getActuatorType()) {
case VehicleConfigurationSource::ESC_LEGACY:
updateFrequence = LEGACY_ESC_FREQUENCE;
break;
case VehicleConfigurationSource::ESC_RAPID:
updateFrequence = RAPID_ESC_FREQUENCE;
break;
default:
break;
}
switch (m_configSource->getVehicleSubType()) {
case VehicleConfigurationSource::MULTI_ROTOR_TRI_Y:
data.ChannelUpdateFreq[0] = updateFrequence;
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
data.ChannelUpdateFreq[1] = updateFrequence;
// Servo always on channel 4
data.ChannelUpdateFreq[0] = escFrequence;
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_CC ||
m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_CC3D) {
data.ChannelUpdateFreq[1] = servoFrequence;
} else if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
data.ChannelUpdateFreq[1] = escFrequence;
data.ChannelUpdateFreq[2] = servoFrequence;
} else if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_NANO) {
data.ChannelUpdateFreq[1] = escFrequence;
data.ChannelUpdateFreq[2] = escFrequence;
data.ChannelUpdateFreq[3] = servoFrequence;
}
break;
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS:
data.ChannelUpdateFreq[0] = updateFrequence;
data.ChannelUpdateFreq[1] = updateFrequence;
data.ChannelUpdateFreq[0] = escFrequence;
data.ChannelUpdateFreq[1] = escFrequence;
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
data.ChannelUpdateFreq[2] = updateFrequence;
data.ChannelUpdateFreq[2] = escFrequence;
}
break;
case VehicleConfigurationSource::MULTI_ROTOR_HEXA:
@ -309,10 +330,10 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X:
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS:
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V:
data.ChannelUpdateFreq[0] = updateFrequence;
data.ChannelUpdateFreq[1] = updateFrequence;
data.ChannelUpdateFreq[2] = updateFrequence;
data.ChannelUpdateFreq[3] = updateFrequence;
data.ChannelUpdateFreq[0] = escFrequence;
data.ChannelUpdateFreq[1] = escFrequence;
data.ChannelUpdateFreq[2] = escFrequence;
data.ChannelUpdateFreq[3] = escFrequence;
break;
default:
break;
@ -335,27 +356,15 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
data.ChannelMax[i] = actuatorSettings[i].channelMax;
}
qint16 updateFrequence = ANALOG_SERVO_FREQUENCE;
switch (m_configSource->getActuatorType()) {
case VehicleConfigurationSource::SERVO_ANALOG:
updateFrequence = ANALOG_SERVO_FREQUENCE;
break;
case VehicleConfigurationSource::SERVO_DIGITAL:
updateFrequence = DIGITAL_SERVO_FREQUENCE;
break;
default:
break;
}
for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) {
data.ChannelUpdateFreq[i] = updateFrequence;
data.ChannelUpdateFreq[i] = servoFrequence;
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
if (i == 1) {
data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE;
data.ChannelUpdateFreq[i] = escFrequence;
}
} else if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_NANO) {
if (i == 2) {
data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE;
data.ChannelUpdateFreq[i] = escFrequence;
}
}
}

View File

@ -61,7 +61,8 @@ public:
MULTI_ROTOR_HEXA, MULTI_ROTOR_HEXA_H, MULTI_ROTOR_HEXA_X, MULTI_ROTOR_HEXA_COAX_Y, MULTI_ROTOR_OCTO,
MULTI_ROTOR_OCTO_X, MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS,
FIXED_WING_AILERON, FIXED_WING_VTAIL, FIXED_WING_ELEVON, HELI_CCPM };
enum ACTUATOR_TYPE { ESC_RAPID, ESC_LEGACY, SERVO_ANALOG, SERVO_DIGITAL, ESC_UNKNOWN };
enum ESC_TYPE { ESC_RAPID, ESC_LEGACY, ESC_UNKNOWN };
enum SERVO_TYPE { SERVO_ANALOG, SERVO_DIGITAL, SERVO_UNKNOWN };
enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSMX10, INPUT_DSMX11, INPUT_DSM2, INPUT_UNKNOWN };
enum GPS_SETTING { GPS_UBX, GPS_NMEA, GPS_DISABLED };
@ -71,7 +72,8 @@ public:
virtual VehicleConfigurationSource::VEHICLE_TYPE getVehicleType() const = 0;
virtual VehicleConfigurationSource::VEHICLE_SUB_TYPE getVehicleSubType() const = 0;
virtual VehicleConfigurationSource::INPUT_TYPE getInputType() const = 0;
virtual VehicleConfigurationSource::ACTUATOR_TYPE getActuatorType() const = 0;
virtual VehicleConfigurationSource::ESC_TYPE getEscType() const = 0;
virtual VehicleConfigurationSource::SERVO_TYPE getServoType() const = 0;
virtual VehicleConfigurationSource::GPS_SETTING getGPSSetting() const = 0;
virtual VehicleConfigurationSource::RADIO_SETTING getRadioSetting() const = 0;