1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

Minor refactroring of a type in a class, change ESC_TYPE and geter /

serter to be actuator type as we are dealing with servos. Add servos to
enum, remove hard coded min / max for now.
This commit is contained in:
Fredrik Larson 2014-08-17 22:55:11 +10:00
parent 3fc991fe2c
commit ea1e95db7b
9 changed files with 59 additions and 28 deletions

View File

@ -45,9 +45,9 @@ OutputPage::~OutputPage()
bool OutputPage::validatePage()
{
if (ui->rapidESCButton->isChecked()) {
getWizard()->setESCType(SetupWizard::ESC_RAPID);
getWizard()->setActuatorType(SetupWizard::ESC_RAPID);
} else {
getWizard()->setESCType(SetupWizard::ESC_LEGACY);
getWizard()->setActuatorType(SetupWizard::ESC_LEGACY);
}
return true;

View File

@ -44,10 +44,10 @@ OutputPageFixedwing::~OutputPageFixedwing()
bool OutputPageFixedwing::validatePage()
{
if (ui->rapidESCButton->isChecked()) {
getWizard()->setESCType(SetupWizard::ESC_RAPID);
if (ui->ServoTypeButton->isChecked()) {
getWizard()->setActuatorType(SetupWizard::SERVO_DIGITAL);
} else {
getWizard()->setESCType(SetupWizard::ESC_LEGACY);
getWizard()->setActuatorType(SetupWizard::SERVO_LEGACY);
}
return true;

View File

@ -39,7 +39,7 @@ class OutputPageFixedwing : public AbstractWizardPage {
public:
explicit OutputPageFixedwing(SetupWizard *wizard, QWidget *parent = 0);
~OutputPage();
~OutputPageFixedwing();
bool validatePage();
private:

View File

@ -99,7 +99,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QToolButton" name="rapidESCButton">
<widget class="QToolButton" name="ServoTypeButton">
<property name="font">
<font>
<pointsize>10</pointsize>

View File

@ -291,14 +291,21 @@ QString SetupWizard::getSummaryText()
}
summary.append("<br>");
summary.append("<b>").append(tr("ESC type: ")).append("</b>");
switch (getESCType()) {
summary.append("<b>").append(tr("Actuator type: ")).append("</b>");
switch (getActuatorType()) {
case ESC_LEGACY:
summary.append(tr("Legacy ESC (50 Hz)"));
break;
case ESC_RAPID:
summary.append(tr("Rapid ESC (400 Hz)"));
break;
case SERVO_LEGACY:
summary.append(tr("Legacy Servos (50 Hz)"));
break;
case SERVO_DIGITAL:
summary.append(tr("Digital Servos (333 Hz)"));
break;
default:
summary.append(tr("Unknown"));
}

View File

@ -78,11 +78,11 @@ public:
return m_inputType;
}
void setESCType(SetupWizard::ESC_TYPE type)
void setActuatorType(SetupWizard::ACTUATOR_TYPE type)
{
m_escType = type;
}
SetupWizard::ESC_TYPE getESCType() const
SetupWizard::ACTUATOR_TYPE getActuatorType() const
{
return m_escType;
}
@ -168,7 +168,7 @@ private:
VEHICLE_TYPE m_vehicleType;
VEHICLE_SUB_TYPE m_vehicleSubType;
INPUT_TYPE m_inputType;
ESC_TYPE m_escType;
ACTUATOR_TYPE m_escType;
GPS_SETTING m_gpsSetting;
RADIO_SETTING m_radioSetting;

View File

@ -42,6 +42,8 @@
const qint16 VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE = 50;
const qint16 VehicleConfigurationHelper::RAPID_ESC_FREQUENCE = 400;
const qint16 VehicleConfigurationHelper::LEGACY_SERVO_FREQUENCE = 50;
const qint16 VehicleConfigurationHelper::DIGITAL_SERVO_FREQUENCE = 333;
VehicleConfigurationHelper::VehicleConfigurationHelper(VehicleConfigurationSource *configSource)
: m_configSource(configSource), m_uavoManager(0),
@ -68,7 +70,7 @@ bool VehicleConfigurationHelper::setupVehicle(bool save)
applyHardwareConfiguration();
applyVehicleConfiguration();
applyActuatorConfiguration();
applyFlighModeConfiguration();
applyFlightModeConfiguration();
if (save) {
applySensorBiasConfiguration();
@ -237,8 +239,10 @@ void VehicleConfigurationHelper::applyVehicleConfiguration()
break;
}
case VehicleConfigurationSource::VEHICLE_HELI:
// TODO: Implement settings for Helis
break;
case VehicleConfigurationSource::VEHICLE_SURFACE:
// TODO: Implement settings for other vehicle types?
// TODO: Implement settings for Surface
break;
default:
break;
@ -270,7 +274,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
}
qint16 updateFrequence = LEGACY_ESC_FREQUENCE;
switch (m_configSource->getESCType()) {
switch (m_configSource->getActuatorType()) {
case VehicleConfigurationSource::ESC_LEGACY:
updateFrequence = LEGACY_ESC_FREQUENCE;
break;
@ -322,18 +326,31 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
{
ActuatorSettings::DataFields data = actSettings->getData();
qDebug() << "Override center, min and max pulses for fixed wing servos\n";
// move all but first chan to 1500 center pluse
QList<actuatorChannelSettings> actuatorSettings = m_configSource->getActuatorSettings();
for (quint16 i = 1; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) {
data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM;
data.ChannelAddr[i] = i;
data.ChannelMin[i] = 554; // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach,
// 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU
data.ChannelNeutral[i] = 1500;
data.ChannelMax[i] = 2400; // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg
data.ChannelMin[i] = actuatorSettings[i].channelMin;
data.ChannelNeutral[i] = actuatorSettings[i].channelNeutral;
data.ChannelMax[i] = actuatorSettings[i].channelMax;
}
qDebug() << "Save Fixed Wing Actuator Data\n";
for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) {
data.ChannelUpdateFreq[i] = LEGACY_SERVO_FREQUENCE;
}
qint16 updateFrequence = LEGACY_SERVO_FREQUENCE;
switch (m_configSource->getActuatorType()) {
case VehicleConfigurationSource::SERVO_LEGACY:
updateFrequence = LEGACY_SERVO_FREQUENCE;
break;
case VehicleConfigurationSource::SERVO_DIGITAL:
updateFrequence = DIGITAL_SERVO_FREQUENCE;
break;
default:
break;
}
actSettings->setData(data);
addModifiedObject(actSettings, tr("Writing actuator settings"));
@ -389,15 +406,19 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
}
case VehicleConfigurationSource::VEHICLE_HELI:
case VehicleConfigurationSource::VEHICLE_SURFACE:
// TODO: Implement settings for other vehicle types?
// TODO: Implement settings for Heli vehicle types
break;
case VehicleConfigurationSource::VEHICLE_SURFACE:
// TODO: Implement settings for ground vehicle types
break;
default:
break;
}
}
void VehicleConfigurationHelper::applyFlighModeConfiguration()
void VehicleConfigurationHelper::applyFlightModeConfiguration()
{
FlightModeSettings *modeSettings = FlightModeSettings::GetInstance(m_uavoManager);
ManualControlSettings *controlSettings = ManualControlSettings::GetInstance(m_uavoManager);

View File

@ -59,6 +59,9 @@ public:
bool setupHardwareSettings(bool save = true);
static const qint16 LEGACY_ESC_FREQUENCE;
static const qint16 RAPID_ESC_FREQUENCE;
static const qint16 LEGACY_SERVO_FREQUENCE;
static const qint16 DIGITAL_SERVO_FREQUENCE;
signals:
void saveProgress(int total, int current, QString description);
@ -79,7 +82,7 @@ private:
void applyHardwareConfiguration();
void applyVehicleConfiguration();
void applyActuatorConfiguration();
void applyFlighModeConfiguration();
void applyFlightModeConfiguration();
void applySensorBiasConfiguration();
void applyStabilizationConfiguration();
void applyManualControlDefaults();

View File

@ -61,7 +61,7 @@ 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 ESC_TYPE { ESC_RAPID, ESC_LEGACY, ESC_UNKNOWN };
enum ACTUATOR_TYPE { ESC_RAPID, ESC_LEGACY, SERVO_LEGACY, SERVO_DIGITAL, ESC_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 +71,7 @@ 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::ESC_TYPE getESCType() const = 0;
virtual VehicleConfigurationSource::ACTUATOR_TYPE getActuatorType() const = 0;
virtual VehicleConfigurationSource::GPS_SETTING getGPSSetting() const = 0;
virtual VehicleConfigurationSource::RADIO_SETTING getRadioSetting() const = 0;