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

Remove some redundant "elevon" stuff for now. Will come back later when proper "elevon + rudder" artwork exists. Currently no different from vtail anyway...

Enabled proper channel mixing settings inside the FixedWing wizard Output configuration screen. Attempt to set GUIConfigDataUnion to fixedwing
This commit is contained in:
Kevin Finisterre 2013-12-18 12:57:35 -05:00
parent 6e5e7e4dd3
commit 9e417f5ee5
7 changed files with 78 additions and 224 deletions

View File

@ -86,7 +86,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
populateChannelComboBoxes();
QStringList fixedWingTypes;
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
fixedWingTypes << "Elevator aileron rudder" << "Vtail";
m_aircraft->fixedWingType->addItems(fixedWingTypes);
// Set default model to "Elevator aileron rudder"
@ -134,23 +134,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonSlider1->setEnabled(false);
m_aircraft->elevonSlider2->setEnabled(false);
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
plane->setElementId("vtail");
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);
m_aircraft->fwElevator2ChannelBox->setEnabled(false);
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
m_aircraft->fwElevator1Label->setText("Elevator 1");
m_aircraft->fwElevator2Label->setText("Elevator 2");
m_aircraft->elevonLabel1->setText("Roll");
m_aircraft->elevonLabel2->setText("Pitch");
m_aircraft->elevonSlider1->setEnabled(true);
m_aircraft->elevonSlider2->setEnabled(true);
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
plane->setElementId("vtail");
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail"));
@ -192,7 +175,7 @@ void ConfigFixedWingWidget::setupEnabledControls(QString frameType)
}
}
if (frameType == "Vtail" || frameType == "Elevon") {
if (frameType == "Vtail" || frameType == "vtail") {
enableComboBoxes(this, CHANNELBOXNAME, 3, true);
} else if (frameType == "aileron" || frameType == "Elevator aileron rudder") {
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
@ -263,18 +246,9 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
if (frameType == "FixedWingElevon") {
// If the airframe is elevon, restore the slider setting
if (frameType == "FixedWingVtail") {
// If the airframe is vtail, restore the slider setting
// Find the channel number for Elevon1 (FixedWingRoll1)
int channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// If for some reason the actuators were incoherent, we might fail here, hence the check.
m_aircraft->elevonSlider1->setValue(
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
m_aircraft->elevonSlider2->setValue(
getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
}
} else if (frameType == "FixedWingVtail") {
int channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
if (channel > -1) {
// If for some reason the actuators were incoherent, we might fail here, hence the check.
@ -308,10 +282,7 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder") {
airframeType = "FixedWing";
setupFrameFixedWing(airframeType);
} else if (m_aircraft->fixedWingType->currentText() == "Elevon") {
airframeType = "FixedWingElevon";
setupFrameElevon(airframeType);
} else { // "Vtail"
} else if (m_aircraft->fixedWingType->currentText() == "vtail") {
airframeType = "FixedWingVtail";
setupFrameVtail(airframeType);
}
@ -404,76 +375,6 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
return true;
}
/**
Setup Elevon
*/
bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
{
// Check coherence:
// Show any config errors in GUI
if (throwConfigError(airframeType)) {
return false;
}
GUIConfigDataUnion config = getConfigData();
resetActuators(&config);
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();
setConfigData(config);
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
// Save the curve:
// ... and compute the matrix:
// In order to make code a bit nicer, we assume:
// - Channel dropdowns start with 'None', then 0 to 7
// 1. Assign the servo/motor/none for each channel
double value;
// motor
int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
// rudders
channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
// ailerons
channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
value = (double)(m_aircraft->elevonSlider2->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value);
value = (double)(m_aircraft->elevonSlider1->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, value);
channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
value = (double)(m_aircraft->elevonSlider2->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value);
value = (double)(m_aircraft->elevonSlider1->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value);
}
m_aircraft->fwStatusLabel->setText("Mixer generated");
return true;
}
/**
Setup VTail
*/
@ -592,27 +493,6 @@ bool ConfigFixedWingWidget::throwConfigError(QString airframeType)
m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
}
} else if (airframeType == "FixedWingElevon") {
if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true;
} else {
m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
}
if (m_aircraft->fwAileron1ChannelBox->currentText() == "None") {
m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true;
} else {
m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
}
if (m_aircraft->fwAileron2ChannelBox->currentText() == "None") {
m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true;
} else {
m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole); // Reset color palettes
}
} else if (airframeType == "FixedWingVtail") {
if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes

View File

@ -67,7 +67,6 @@ private:
virtual void resetActuators(GUIConfigDataUnion *configData);
bool setupFrameFixedWing(QString airframeType);
bool setupFrameElevon(QString airframeType);
bool setupFrameVtail(QString airframeType);
void updateAirframe(QString multiRotorType);

View File

@ -68,9 +68,11 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
QStringList channelDesc;
switch (systemSettingsData.AirframeType) {
case SystemSettings::AIRFRAMETYPE_FIXEDWING:
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
break;
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
// do nothing for elevon support for the time being.
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
// fixed wing
channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
break;
case SystemSettings::AIRFRAMETYPE_HELICP:
@ -268,8 +270,7 @@ QString ConfigVehicleTypeWidget::frameCategory(QString frameType)
{
QString category;
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
|| frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") {
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingVtail" || frameType == "Vtail") {
category = "Fixed Wing";
} else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X"
|| frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter"

View File

@ -83,10 +83,10 @@ void FixedWingPage::resizeEvent(QResizeEvent *event)
void FixedWingPage::setupFixedWingTypesCombo()
{
ui->typeCombo->addItem(tr("Aileron, Elevator, Rudder"), SetupWizard::FIXED_WING_AILERON);
m_descriptions << tr("A description for aileron driven fixed wing stuff goes here... ");
m_descriptions << tr("This setup currently expects a traditional 4 channel setup including two ailerons (not connected by Y adapter), an elevator and a rudder. ");
ui->typeCombo->addItem(tr("V-Tail, or Elevon"), SetupWizard::FIXED_WING_VTAIL);
m_descriptions << tr("A description for vtail driven fixed wing stuff goes here... ");
ui->typeCombo->addItem(tr("V-Tail"), SetupWizard::FIXED_WING_VTAIL);
m_descriptions << tr("This setup currently expects a flying-wing setup, an elevon plus rudder setup is not yet supported. Setup should include only two elevons, and should explicitly not include a rudder.");
}
void FixedWingPage::updateAvailableTypes()

View File

@ -147,10 +147,29 @@ void OutputCalibrationPage::setupVehicle()
ui->vehicleView->setScene(m_vehicleScene);
}
qDebug() << "no clue what a wizard index is!";
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1;
m_vehicleElementIds << "fixed-aileron" << "aileron";
m_vehicleHighlightElementIndexes << 0 << 1;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4;
// see Servo city for an example. 1500 usec is center on MS85mg for example. - http://www.servocity.com/html/hs-85mg__mighty_micro.html
// make sure Aileron servo one does not go to an extreme value
m_actuatorSettings[1].channelMin = 1500;
m_actuatorSettings[1].channelNeutral = 1500;
m_actuatorSettings[1].channelMax = 1500;
// make sure Aileron servo two does not go to an extreme value
m_actuatorSettings[2].channelMin = 1500;
m_actuatorSettings[2].channelNeutral = 1500;
m_actuatorSettings[2].channelMax = 1500;
// make sure Elevator servo one does not go to an extreme value
m_actuatorSettings[3].channelMin = 1500;
m_actuatorSettings[4].channelNeutral = 1500;
m_actuatorSettings[3].channelMax = 1500;
// make sure Rudder servo one does not go to an extreme value
m_actuatorSettings[4].channelMin = 1500;
m_actuatorSettings[4].channelNeutral = 1500;
m_actuatorSettings[4].channelMax = 1500;
getWizard()->setActuatorSettings(m_actuatorSettings);
break;
case SetupWizard::FIXED_WING_VTAIL:
@ -160,10 +179,20 @@ void OutputCalibrationPage::setupVehicle()
ui->vehicleView->setScene(m_vehicleScene);
}
qDebug() << "no clue what a wizard index is!";
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
m_wizardIndexes << 0 << 1 << 1 << 1;
m_vehicleElementIds << "fixed-vtail" << "vtail";
m_vehicleHighlightElementIndexes << 0 << 1;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
m_channelIndex << 0 << 0 << 1 << 2;
// make sure elevon servo one does not go to an extreme value
m_actuatorSettings[1].channelMin = 1500;
m_actuatorSettings[1].channelNeutral = 1500;
m_actuatorSettings[1].channelMax = 1500;
// make sure elevon servo two does not go to an extreme value
m_actuatorSettings[2].channelMin = 1500;
m_actuatorSettings[2].channelNeutral = 1500;
m_actuatorSettings[2].channelMax = 1500;
getWizard()->setActuatorSettings(m_actuatorSettings);
break;
default:

View File

@ -219,9 +219,6 @@ void VehicleConfigurationHelper::applyVehicleConfiguration()
case VehicleConfigurationSource::FIXED_WING_AILERON:
setupAileron();
break;
/* case VehicleConfigurationSource::FIXED_WING_ELEVON:
setupElevon();
break; */
case VehicleConfigurationSource::FIXED_WING_VTAIL:
setupVtail();
break;
@ -1304,7 +1301,6 @@ void VehicleConfigurationHelper::setupOctoCopter()
applyMultiGUISettings(frame, guiSettings);
}
// This is all wrong... I just copied the Tricopter stuff
void VehicleConfigurationHelper::setupVtail()
{
@ -1314,41 +1310,32 @@ void VehicleConfigurationHelper::setupVtail()
channels[0].type = MIXER_TYPE_MOTOR;
channels[0].throttle1 = 100;
channels[0].throttle2 = 0;
channels[0].roll = 100;
channels[0].pitch = 50;
channels[0].roll = 0;
channels[0].pitch = 0;
channels[0].yaw = 0;
channels[1].type = MIXER_TYPE_MOTOR;
channels[1].throttle1 = 100;
channels[1].type = MIXER_TYPE_SERVO;
channels[1].throttle1 = 0;
channels[1].throttle2 = 0;
channels[1].roll = -100;
channels[1].pitch = 50;
channels[1].yaw = 0;
channels[2].type = MIXER_TYPE_MOTOR;
channels[2].throttle1 = 100;
channels[2].type = MIXER_TYPE_SERVO;
channels[2].throttle1 = 0;
channels[2].throttle2 = 0;
channels[2].roll = 0;
channels[2].pitch = -100;
channels[2].roll = 100;
channels[2].pitch = -50;
channels[2].yaw = 0;
channels[3].type = MIXER_TYPE_SERVO;
channels[3].throttle1 = 0;
channels[3].throttle2 = 0;
channels[3].roll = 0;
channels[3].pitch = 0;
channels[3].yaw = 100;
guiSettings.multi.VTOLMotorNW = 1;
guiSettings.multi.VTOLMotorNE = 2;
guiSettings.multi.VTOLMotorS = 3;
guiSettings.multi.TRIYaw = 4;
guiSettings.fixedwing.FixedWingThrottle = 1;
guiSettings.fixedwing.FixedWingRoll1 = 2;
guiSettings.fixedwing.FixedWingRoll2 = 3;
applyMixerConfiguration(channels);
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings);
}
// This is all wrong... I just copied the Tricopter stuff
void VehicleConfigurationHelper::setupAileron()
{
// Typical vehicle setup
@ -1362,24 +1349,31 @@ void VehicleConfigurationHelper::setupAileron()
channels[0].type = MIXER_TYPE_MOTOR;
channels[0].throttle1 = 100;
channels[0].throttle2 = 0;
channels[0].roll = 100;
channels[0].pitch = 50;
channels[0].roll = 0;
channels[0].pitch = 0;
channels[0].yaw = 0;
channels[1].type = MIXER_TYPE_MOTOR;
channels[1].throttle1 = 100;
channels[1].type = MIXER_TYPE_SERVO;
channels[1].throttle1 = 0;
channels[1].throttle2 = 0;
channels[1].roll = -100;
channels[1].pitch = 50;
channels[1].pitch = 0;
channels[1].yaw = 0;
channels[2].type = MIXER_TYPE_MOTOR;
channels[2].throttle1 = 100;
channels[2].type = MIXER_TYPE_SERVO;
channels[2].throttle1 = 0;
channels[2].throttle2 = 0;
channels[2].roll = 0;
channels[2].pitch = -100;
channels[2].roll = 100;
channels[2].pitch = 0;
channels[2].yaw = 0;
channels[3].type = MIXER_TYPE_SERVO;
channels[3].throttle1 = 0;
channels[3].throttle2 = 0;
channels[3].roll = 0;
channels[3].pitch = 100;
channels[3].yaw = 0;
channels[3].type = MIXER_TYPE_SERVO;
channels[3].throttle1 = 0;
channels[3].throttle2 = 0;
@ -1387,60 +1381,12 @@ void VehicleConfigurationHelper::setupAileron()
channels[3].pitch = 0;
channels[3].yaw = 100;
guiSettings.multi.VTOLMotorNW = 1;
guiSettings.multi.VTOLMotorNE = 2;
guiSettings.multi.VTOLMotorS = 3;
guiSettings.multi.TRIYaw = 4;
guiSettings.fixedwing.FixedWingThrottle = 1;
guiSettings.fixedwing.FixedWingRoll1 = 2;
guiSettings.fixedwing.FixedWingRoll2 = 3;
guiSettings.fixedwing.FixedWingPitch1 = 4;
guiSettings.fixedwing.FixedWingYaw1 = 5;
applyMixerConfiguration(channels);
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings);
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGAILERON, guiSettings);
}
// This is all wrong... I just copied the Tricopter stuff
void VehicleConfigurationHelper::setupElevon()
{
// Typical vehicle setup
// 1. Setup mixer data
// 2. Setup GUI data
// 3. Apply changes
mixerChannelSettings channels[10];
GUIConfigDataUnion guiSettings = getGUIConfigData();
channels[0].type = MIXER_TYPE_MOTOR;
channels[0].throttle1 = 100;
channels[0].throttle2 = 0;
channels[0].roll = 100;
channels[0].pitch = 50;
channels[0].yaw = 0;
channels[1].type = MIXER_TYPE_MOTOR;
channels[1].throttle1 = 100;
channels[1].throttle2 = 0;
channels[1].roll = -100;
channels[1].pitch = 50;
channels[1].yaw = 0;
channels[2].type = MIXER_TYPE_MOTOR;
channels[2].throttle1 = 100;
channels[2].throttle2 = 0;
channels[2].roll = 0;
channels[2].pitch = -100;
channels[2].yaw = 0;
channels[3].type = MIXER_TYPE_SERVO;
channels[3].throttle1 = 0;
channels[3].throttle2 = 0;
channels[3].roll = 0;
channels[3].pitch = 0;
channels[3].yaw = 100;
guiSettings.multi.VTOLMotorNW = 1;
guiSettings.multi.VTOLMotorNE = 2;
guiSettings.multi.VTOLMotorS = 3;
guiSettings.multi.TRIYaw = 4;
applyMixerConfiguration(channels);
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON, guiSettings);
}

View File

@ -105,7 +105,6 @@ private:
void setupOctoCopter();
void setupVtail();
void setupAileron();
void setupElevon();
private slots:
void uAVOTransactionCompleted(UAVObject *object, bool success);