31 #include <QStringList>
35 #include <QVBoxLayout>
36 #include <QPushButton>
38 #include <QDesktopServices>
41 #include <QMessageBox>
43 #include "systemsettings.h"
44 #include "mixersettings.h"
45 #include "actuatorcommand.h"
46 #include "actuatorsettings.h"
54 : QItemDelegate(parent)
59 const QModelIndex & )
const
61 QSpinBox *editor =
new QSpinBox(parent);
70 int value = index.model()->data(index, Qt::EditRole).toInt();
72 QSpinBox *spinBox =
static_cast<QSpinBox *
>(editor);
73 spinBox->setValue(value);
77 const QModelIndex &index)
const
79 QSpinBox *spinBox =
static_cast<QSpinBox *
>(editor);
80 spinBox->interpretText();
81 int value = spinBox->value();
83 model->setData(index, value, Qt::EditRole);
87 const QModelIndex & )
const
89 editor->setGeometry(option.rect);
100 m_aircraft =
new Ui_AircraftWidget();
101 m_aircraft->setupUi(
this);
107 m_aircraft->customThrottle2Curve->getCBCurveSource());
110 channelNames <<
"None";
111 for (
int i = 0;
i < (int)ActuatorSettings::CHANNELMIN_NUMELEM;
i++) {
113 mixerTypes << QString(
"Mixer%1Type").arg(
i + 1);
114 mixerVectors << QString(
"Mixer%1Vector").arg(
i + 1);
115 channelNames << QString(
"Channel%1").arg(
i + 1);
119 m_aircraft->aircraftType->addItem(
"Fixed Wing", AIRFRAME_FIXED_WING);
120 m_aircraft->aircraftType->addItem(
"Multirotor", AIRFRAME_MULTIROTOR);
121 m_aircraft->aircraftType->addItem(
"Helicopter", AIRFRAME_HELICOPTER);
122 m_aircraft->aircraftType->addItem(
"Ground", AIRFRAME_GROUND);
123 m_aircraft->aircraftType->addItem(
"Custom", AIRFRAME_CUSTOM);
125 m_aircraft->aircraftType->setCurrentIndex(1);
126 m_aircraft->airframesWidget->setCurrentIndex(1);
129 m_aircraft->fixedWingType->addItem(
"Elevator aileron rudder",
130 SystemSettings::AIRFRAMETYPE_FIXEDWING);
131 m_aircraft->fixedWingType->addItem(
"Elevon", SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON);
132 m_aircraft->fixedWingType->addItem(
"Vtail", SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL);
133 m_aircraft->fixedWingType->setCurrentIndex(0);
136 m_aircraft->groundVehicleType->addItem(
"Turnable (car)",
137 SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR);
138 m_aircraft->groundVehicleType->addItem(
"Differential (tank)",
139 SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL);
140 m_aircraft->groundVehicleType->addItem(
"Motorcycle",
141 SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE);
142 m_aircraft->groundVehicleType->setCurrentIndex(0);
145 m_aircraft->multirotorFrameType->addItem(
"Tricopter Y", SystemSettings::AIRFRAMETYPE_TRI);
146 m_aircraft->multirotorFrameType->addItem(
"Quad X", SystemSettings::AIRFRAMETYPE_QUADX);
147 m_aircraft->multirotorFrameType->addItem(
"Quad +", SystemSettings::AIRFRAMETYPE_QUADP);
148 m_aircraft->multirotorFrameType->addItem(
"Hexacopter", SystemSettings::AIRFRAMETYPE_HEXA);
149 m_aircraft->multirotorFrameType->addItem(
"Hexacopter X", SystemSettings::AIRFRAMETYPE_HEXAX);
150 m_aircraft->multirotorFrameType->addItem(
"Hexacopter Y6",
151 SystemSettings::AIRFRAMETYPE_HEXACOAX);
152 m_aircraft->multirotorFrameType->addItem(
"Octocopter", SystemSettings::AIRFRAMETYPE_OCTO);
153 m_aircraft->multirotorFrameType->addItem(
"Octocopter V", SystemSettings::AIRFRAMETYPE_OCTOV);
154 m_aircraft->multirotorFrameType->addItem(
"Octocopter Coax +",
155 SystemSettings::AIRFRAMETYPE_OCTOCOAXP);
156 m_aircraft->multirotorFrameType->addItem(
"Octocopter Coax X",
157 SystemSettings::AIRFRAMETYPE_OCTOCOAXX);
158 m_aircraft->multirotorFrameType->setCurrentIndex(2);
164 foreach (QComboBox *combobox,
165 this->findChildren<QComboBox *>(QRegExp(
"\\S+ChannelBo\\S+")))
171 combobox->addItems(channelNames);
175 m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
176 m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
177 QSvgRenderer *renderer =
new QSvgRenderer();
178 renderer->load(QString(
":/configgadget/images/multirotor-shapes.svg"));
179 quad =
new QGraphicsSvgItem();
180 quad->setSharedRenderer(renderer);
181 quad->setElementId(
"quad-x");
182 QGraphicsScene *scene =
new QGraphicsScene(
this);
183 scene->addItem(quad);
184 scene->setSceneRect(quad->boundingRect());
185 m_aircraft->quadShape->setScene(scene);
192 for (
int i = 0;
i < (int)(ActuatorCommand::CHANNEL_NUMELEM);
i++) {
193 QComboBox *qb =
new QComboBox(m_aircraft->customMixerTable);
195 m_aircraft->customMixerTable->setCellWidget(0,
i, qb);
199 for (
int i = 1;
i < (int)(ActuatorCommand::CHANNEL_NUMELEM);
i++) {
200 m_aircraft->customMixerTable->setItemDelegateForRow(
i, sbd);
205 m_multirotor->quad = quad;
206 m_multirotor->uiowner =
this;
207 m_multirotor->setupUI(SystemSettings::AIRFRAMETYPE_QUADX);
211 m_groundvehicle->setupUI(SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR);
215 m_fixedwing->setupUI(SystemSettings::AIRFRAMETYPE_FIXEDWING);
218 m_heli = m_aircraft->helicopterLayout;
219 m_heli->setupUI(SystemSettings::AIRFRAMETYPE_HELICP);
222 connect(m_aircraft->aircraftType, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
223 &ConfigVehicleTypeWidget::switchAirframeType);
226 connect(m_aircraft->fixedWingType, QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
227 &ConfigVehicleTypeWidget::doSetupAirframeUI);
228 connect(m_aircraft->multirotorFrameType, QOverload<int>::of(&QComboBox::currentIndexChanged),
229 this, &ConfigVehicleTypeWidget::doSetupAirframeUI);
230 connect(m_aircraft->groundVehicleType, QOverload<int>::of(&QComboBox::currentIndexChanged),
231 this, &ConfigVehicleTypeWidget::doSetupAirframeUI);
237 connect(m_aircraft->MultirotorRevMixercheckBox, &QAbstractButton::clicked,
this,
238 &ConfigVehicleTypeWidget::reverseMultirotorMotor);
241 connect(m_aircraft->bnLevelTrim, &QAbstractButton::clicked,
this,
242 &ConfigVehicleTypeWidget::bnLevelTrim_clicked);
243 connect(m_aircraft->bnServoTrim, &QAbstractButton::clicked,
this,
244 &ConfigVehicleTypeWidget::bnServoTrim_clicked);
248 refreshWidgetsValues();
252 m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
271 QStringList channelDesc;
278 SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
279 Q_ASSERT(systemSettings);
280 SystemSettings::DataFields systemSettingsData = systemSettings->getData();
282 switch (systemSettingsData.AirframeType) {
284 case SystemSettings::AIRFRAMETYPE_FIXEDWING:
285 case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
286 case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: {
287 channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
291 case SystemSettings::AIRFRAMETYPE_HELICP: {
292 channelDesc = ConfigCcpmWidget::getChannelDescriptions();
296 case SystemSettings::AIRFRAMETYPE_VTOL:
297 case SystemSettings::AIRFRAMETYPE_TRI:
298 case SystemSettings::AIRFRAMETYPE_QUADX:
299 case SystemSettings::AIRFRAMETYPE_QUADP:
300 case SystemSettings::AIRFRAMETYPE_OCTOV:
301 case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
302 case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
303 case SystemSettings::AIRFRAMETYPE_OCTO:
304 case SystemSettings::AIRFRAMETYPE_HEXAX:
305 case SystemSettings::AIRFRAMETYPE_HEXACOAX:
306 case SystemSettings::AIRFRAMETYPE_HEXA: {
307 channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
311 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
312 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
313 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: {
314 channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
318 for (i = 0; i < (int)(ActuatorCommand::CHANNEL_NUMELEM); i++)
319 channelDesc.append(QString(
"-"));
331 void ConfigVehicleTypeWidget::switchAirframeType(
int index)
333 m_aircraft->airframesWidget->setCurrentIndex(index);
334 m_aircraft->quadShape->setSceneRect(quad->boundingRect());
335 m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
336 switch (m_aircraft->aircraftType->itemData(index).toInt()) {
337 case AIRFRAME_FIXED_WING:
338 m_aircraft->bnServoTrim->setEnabled(
true);
340 case AIRFRAME_CUSTOM:
341 m_aircraft->customMixerTable->resizeColumnsToContents();
342 for (
int i = 0;
i < (int)(ActuatorCommand::CHANNEL_NUMELEM);
i++) {
343 m_aircraft->customMixerTable->setColumnWidth(
345 (m_aircraft->customMixerTable->width()
346 - m_aircraft->customMixerTable->verticalHeader()->width())
350 case AIRFRAME_MULTIROTOR:
351 case AIRFRAME_HELICOPTER:
352 case AIRFRAME_GROUND:
353 m_aircraft->bnServoTrim->setEnabled(
false);
367 m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
368 m_aircraft->customMixerTable->resizeColumnsToContents();
369 for (
int i = 0;
i < (int)(ActuatorCommand::CHANNEL_NUMELEM);
i++) {
370 m_aircraft->customMixerTable->setColumnWidth(
372 (m_aircraft->customMixerTable->width()
373 - m_aircraft->customMixerTable->verticalHeader()->width())
384 m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
386 m_aircraft->customMixerTable->resizeColumnsToContents();
387 for (
int i = 0;
i < (int)(ActuatorCommand::CHANNEL_NUMELEM);
i++) {
388 m_aircraft->customMixerTable->setColumnWidth(
390 (m_aircraft->customMixerTable->width()
391 - m_aircraft->customMixerTable->verticalHeader()->width())
396 void ConfigVehicleTypeWidget::toggleAileron2(
int index)
399 m_aircraft->fwAileron2ChannelBox->setEnabled(
true);
400 m_aircraft->fwAileron2Label->setEnabled(
true);
402 m_aircraft->fwAileron2ChannelBox->setEnabled(
false);
403 m_aircraft->fwAileron2Label->setEnabled(
false);
407 void ConfigVehicleTypeWidget::toggleElevator2(
int index)
410 m_aircraft->fwElevator2ChannelBox->setEnabled(
true);
411 m_aircraft->fwElevator2Label->setEnabled(
true);
413 m_aircraft->fwElevator2ChannelBox->setEnabled(
false);
414 m_aircraft->fwElevator2Label->setEnabled(
false);
418 void ConfigVehicleTypeWidget::toggleRudder2(
int index)
421 m_aircraft->fwRudder2ChannelBox->setEnabled(
true);
422 m_aircraft->fwRudder2Label->setEnabled(
true);
424 m_aircraft->fwRudder2ChannelBox->setEnabled(
false);
425 m_aircraft->fwRudder2Label->setEnabled(
false);
435 void ConfigVehicleTypeWidget::refreshWidgetsValues(
UAVObject *obj)
445 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
446 Q_ASSERT(mixerSettings);
448 SystemSettings *systemSettings = SystemSettings::GetInstance(
getObjectManager());
449 Q_ASSERT(systemSettings);
450 SystemSettings::DataFields systemSettingsData = systemSettings->getData();
455 frameType = (SystemSettings::AirframeTypeOptions)systemSettingsData.AirframeType;
456 setupAirframeUI(frameType);
463 vconfig->getThrottleCurve(mixerSettings, MixerSettings::MIXER1VECTOR_THROTTLECURVE2,
466 if (!vconfig->isValidThrottleCurve(&curveValues)) {
467 for (
int i = 0;
i < curveValues.count();
i++) {
468 curveValues[
i] = 1.0 * ((double)
i / curveValues.count());
471 vconfig->setThrottleCurve(mixerSettings, MixerSettings::MIXER1VECTOR_THROTTLECURVE2,
477 case SystemSettings::AIRFRAMETYPE_FIXEDWING:
478 case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
479 case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
481 m_fixedwing->refreshAirframeWidgetsValues(frameType);
483 case SystemSettings::AIRFRAMETYPE_TRI:
484 case SystemSettings::AIRFRAMETYPE_QUADX:
485 case SystemSettings::AIRFRAMETYPE_QUADP:
486 case SystemSettings::AIRFRAMETYPE_HEXA:
487 case SystemSettings::AIRFRAMETYPE_HEXAX:
488 case SystemSettings::AIRFRAMETYPE_HEXACOAX:
489 case SystemSettings::AIRFRAMETYPE_OCTO:
490 case SystemSettings::AIRFRAMETYPE_OCTOV:
491 case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
492 case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
494 m_multirotor->refreshAirframeWidgetsValues(frameType);
496 case SystemSettings::AIRFRAMETYPE_HELICP:
498 setComboCurrentIndex(m_aircraft->aircraftType,
499 m_aircraft->aircraftType->findText(
"Helicopter"));
500 m_heli->refreshAirframeWidgetsValues(frameType);
502 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
503 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
504 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
506 m_groundvehicle->refreshAirframeWidgetsValues(frameType);
510 setComboCurrentIndex(m_aircraft->aircraftType,
511 m_aircraft->aircraftType->findText(
"Custom"));
515 updateCustomAirframeUI();
526 void ConfigVehicleTypeWidget::doSetupAirframeUI(
int comboboxIndex)
530 if (m_aircraft->aircraftType->currentText() ==
"Multirotor") {
531 frameType = (SystemSettings::AirframeTypeOptions)m_aircraft->multirotorFrameType
532 ->itemData(comboboxIndex)
534 }
else if (m_aircraft->aircraftType->currentText() ==
"Fixed Wing") {
536 (SystemSettings::AirframeTypeOptions)m_aircraft->fixedWingType->itemData(comboboxIndex)
538 }
else if (m_aircraft->aircraftType->currentText() ==
"Helicopter") {
539 frameType = SystemSettings::AIRFRAMETYPE_HELICP;
540 }
else if (m_aircraft->aircraftType->currentText() ==
"Ground") {
541 frameType = (SystemSettings::AirframeTypeOptions)m_aircraft->groundVehicleType
542 ->itemData(comboboxIndex)
544 }
else if (m_aircraft->aircraftType->currentText() ==
"Custom") {
545 frameType = SystemSettings::AIRFRAMETYPE_CUSTOM;
549 setupAirframeUI(frameType);
556 void ConfigVehicleTypeWidget::setupAirframeUI(SystemSettings::AirframeTypeOptions frameType)
561 case SystemSettings::AIRFRAMETYPE_FIXEDWING:
562 case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
563 case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
565 m_fixedwing->setupUI(frameType);
567 case SystemSettings::AIRFRAMETYPE_TRI:
568 case SystemSettings::AIRFRAMETYPE_QUADX:
569 case SystemSettings::AIRFRAMETYPE_QUADP:
570 case SystemSettings::AIRFRAMETYPE_HEXA:
571 case SystemSettings::AIRFRAMETYPE_HEXAX:
572 case SystemSettings::AIRFRAMETYPE_HEXACOAX:
573 case SystemSettings::AIRFRAMETYPE_OCTO:
574 case SystemSettings::AIRFRAMETYPE_OCTOV:
575 case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
576 case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
578 m_multirotor->setupUI(frameType);
580 case SystemSettings::AIRFRAMETYPE_HELICP:
582 m_heli->setupUI(frameType);
584 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
585 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
586 case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
588 m_groundvehicle->setupUI(frameType);
595 m_aircraft->quadShape->setSceneRect(quad->boundingRect());
596 m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
615 void ConfigVehicleTypeWidget::updateCustomAirframeUI()
617 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
618 Q_ASSERT(mixerSettings);
624 MixerSettings::DataFields mixerSettingsData = mixerSettings->getData();
625 if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
632 vconfig->getThrottleCurve(mixerSettings, MixerSettings::MIXER1VECTOR_THROTTLECURVE2,
635 if (vconfig->isValidThrottleCurve(&curveValues)) {
636 m_aircraft->customThrottle2Curve->initCurve(&curveValues);
638 m_aircraft->customThrottle2Curve->initLinearCurve(
639 curveValues.count(), 1.0, m_aircraft->customThrottle2Curve->getMin());
643 for (
int channel = 0; channel < (int)(ActuatorCommand::CHANNEL_NUMELEM); channel++) {
644 UAVObjectField *field = mixerSettings->getField(mixerTypes.at(channel));
647 static_cast<QComboBox *
>(m_aircraft->customMixerTable->cellWidget(0, channel));
649 QString
s = field->
getValue().toString();
650 setComboCurrentIndex(q, q->findText(s));
653 m_aircraft->customMixerTable->item(1, channel)
654 ->setText(QString::number(vconfig->getMixerVectorValue(
655 mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE1)));
656 m_aircraft->customMixerTable->item(2, channel)
657 ->setText(QString::number(vconfig->getMixerVectorValue(
658 mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE2)));
659 m_aircraft->customMixerTable->item(3, channel)
660 ->setText(QString::number(vconfig->getMixerVectorValue(
661 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL)));
662 m_aircraft->customMixerTable->item(4, channel)
663 ->setText(QString::number(vconfig->getMixerVectorValue(
664 mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH)));
665 m_aircraft->customMixerTable->item(5, channel)
666 ->setText(QString::number(vconfig->getMixerVectorValue(
667 mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW)));
668 m_aircraft->customMixerTable->item(6, channel)
669 ->setText(QString::number(vconfig->getMixerVectorValue(
670 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY0)));
671 m_aircraft->customMixerTable->item(7, channel)
672 ->setText(QString::number(vconfig->getMixerVectorValue(
673 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY1)));
674 m_aircraft->customMixerTable->item(8, channel)
675 ->setText(QString::number(vconfig->getMixerVectorValue(
676 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY2)));
688 void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
690 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
691 Q_ASSERT(mixerSettings);
695 frameType = SystemSettings::AIRFRAMETYPE_CUSTOM;
697 if (m_aircraft->aircraftType->currentText() ==
"Fixed Wing") {
698 frameType = m_fixedwing->updateConfigObjectsFromWidgets();
699 }
else if (m_aircraft->aircraftType->currentText() ==
"Multirotor") {
700 frameType = m_multirotor->updateConfigObjectsFromWidgets();
701 }
else if (m_aircraft->aircraftType->currentText() ==
"Helicopter") {
702 frameType = m_heli->updateConfigObjectsFromWidgets();
703 }
else if (m_aircraft->aircraftType->currentText() ==
"Ground") {
704 frameType = m_groundvehicle->updateConfigObjectsFromWidgets();
707 for (
int channel = 0; channel < (int)(ActuatorCommand::CHANNEL_NUMELEM); channel++) {
709 static_cast<QComboBox *
>(m_aircraft->customMixerTable->cellWidget(0, channel));
710 if (q->currentText() ==
"Disabled")
711 vconfig->setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_DISABLED);
712 else if (q->currentText() ==
"Motor")
713 vconfig->setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_MOTOR);
714 else if (q->currentText() ==
"Servo")
715 vconfig->setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
716 else if (q->currentText() ==
"CameraRoll")
717 vconfig->setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_CAMERAROLL);
718 else if (q->currentText() ==
"CameraPitch")
719 vconfig->setMixerType(mixerSettings, channel,
720 MixerSettings::MIXER1TYPE_CAMERAPITCH);
721 else if (q->currentText() ==
"CameraYaw")
722 vconfig->setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_CAMERAYAW);
724 vconfig->setMixerVectorValue(
725 mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE1,
726 m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
727 vconfig->setMixerVectorValue(
728 mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE2,
729 m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
730 vconfig->setMixerVectorValue(
731 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ROLL,
732 m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
733 vconfig->setMixerVectorValue(
734 mixerSettings, channel, MixerSettings::MIXER1VECTOR_PITCH,
735 m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
736 vconfig->setMixerVectorValue(
737 mixerSettings, channel, MixerSettings::MIXER1VECTOR_YAW,
738 m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
739 vconfig->setMixerVectorValue(
740 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY0,
741 m_aircraft->customMixerTable->item(6, channel)->text().toDouble());
742 vconfig->setMixerVectorValue(
743 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY1,
744 m_aircraft->customMixerTable->item(7, channel)->text().toDouble());
745 vconfig->setMixerVectorValue(
746 mixerSettings, channel, MixerSettings::MIXER1VECTOR_ACCESSORY2,
747 m_aircraft->customMixerTable->item(8, channel)->text().toDouble());
751 SystemSettings *systemSettings = SystemSettings::GetInstance(
getObjectManager());
752 Q_ASSERT(systemSettings);
753 SystemSettings::DataFields systemSettingsData = systemSettings->getData();
755 systemSettingsData.AirframeType = frameType;
757 systemSettings->setData(systemSettingsData);
765 updateCustomAirframeUI();
773 void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox *box,
int index)
775 if (index >= 0 && index < box->count())
776 box->setCurrentIndex(index);
779 void ConfigVehicleTypeWidget::reverseMultirotorMotor()
781 m_multirotor->drawAirframe(frameType);
788 void ConfigVehicleTypeWidget::bnLevelTrim_clicked()
790 QMessageBox msgBox(QMessageBox::Question, tr(
"Trim level"),
791 tr(
"Use the transmitter trim to set the autopilot for straight and level "
792 "flight? (Please see the tooltip for more information.)"),
793 QMessageBox::Yes | QMessageBox::No,
this);
794 int userChoice = msgBox.exec();
797 if (userChoice != QMessageBox::Yes)
808 QMessageBox msgBox(QMessageBox::Critical, tr(
"No receiver detected"),
809 tr(
"Transmitter and receiver must be powered on."), QMessageBox::Ok,
815 QMessageBox msgBox(QMessageBox::Critical, tr(
"Vehicle armed"),
816 tr(
"The autopilot must be disarmed first."), QMessageBox::Ok,
this);
822 QMessageBox::Critical, tr(
"Vehicle not in Stabilized mode"),
823 tr(
"The autopilot must be in Leveling, Stabilized1, Stabilized2, or Stabilized3 mode."),
824 QMessageBox::Ok,
this);
829 QMessageBox msgBox(QMessageBox::Critical,
830 tr(
"Incorrect roll and pitch stabilization modes."),
831 tr(
"Both roll and pitch must be in Attitude stabilization mode."),
832 QMessageBox::Ok,
this);
838 QMessageBox::Information, tr(
"Trim updated"),
839 tr(
"Trim successfully updated, please reset the transmitter's trim to zero and be sure "
840 "to configure stabilization settings to use Attitude mode."),
841 QMessageBox::Ok,
this);
855 void ConfigVehicleTypeWidget::bnServoTrim_clicked()
857 QMessageBox msgBox(QMessageBox::Question, tr(
"Trim servos"),
858 "Use the transmitter trim to set servos for wings-level, constant-speed "
859 "flight? (Please see the tooltip for more information.)",
860 QMessageBox::Ok | QMessageBox::Cancel,
this);
861 int cancelAction = msgBox.exec();
864 if (cancelAction != QMessageBox::Ok)
875 QMessageBox msgBox(QMessageBox::Critical, tr(
"No receiver detected"),
876 "Transmitter and receiver must be powered on.", QMessageBox::Ok,
this);
881 QMessageBox msgBox(QMessageBox::Critical, tr(
"Vehicle not in manual mode"),
882 "The autopilot must be in manual flight mode.", QMessageBox::Ok,
this);
888 QMessageBox::Information, tr(
"Trim updated"),
889 "Servo trim successfully updated, please reset the transmitter's trim before flying.",
890 QMessageBox::Ok,
this);
904 void ConfigVehicleTypeWidget::addToDirtyMonitor()
908 addWidget(m_aircraft->groundVehicleType);
909 addWidget(m_aircraft->multirotorFrameType);
910 addWidget(m_aircraft->multiMotorChannelBox1);
911 addWidget(m_aircraft->multiMotorChannelBox2);
912 addWidget(m_aircraft->multiMotorChannelBox3);
913 addWidget(m_aircraft->multiMotorChannelBox4);
914 addWidget(m_aircraft->multiMotorChannelBox5);
915 addWidget(m_aircraft->multiMotorChannelBox6);
916 addWidget(m_aircraft->multiMotorChannelBox7);
917 addWidget(m_aircraft->multiMotorChannelBox8);
923 addWidget(m_aircraft->fwEngineChannelBox);
924 addWidget(m_aircraft->fwAileron1ChannelBox);
925 addWidget(m_aircraft->fwAileron2ChannelBox);
926 addWidget(m_aircraft->fwElevator1ChannelBox);
927 addWidget(m_aircraft->fwElevator2ChannelBox);
928 addWidget(m_aircraft->fwRudder1ChannelBox);
929 addWidget(m_aircraft->fwRudder2ChannelBox);
933 addWidget(m_heli->m_ccpm->ccpmTailChannel);
934 addWidget(m_heli->m_ccpm->ccpmEngineChannel);
935 addWidget(m_heli->m_ccpm->ccpmServoWChannel);
936 addWidget(m_heli->m_ccpm->ccpmServoXChannel);
937 addWidget(m_heli->m_ccpm->ccpmServoYChannel);
938 addWidget(m_heli->m_ccpm->ccpmSingleServo);
939 addWidget(m_heli->m_ccpm->ccpmServoZChannel);
942 addWidget(m_heli->m_ccpm->ccpmCorrectionAngle);
945 addWidget(m_heli->m_ccpm->ccpmCollectivePassthrough);
947 addWidget(m_heli->m_ccpm->ccpmLinkCyclic);
948 addWidget(m_heli->m_ccpm->ccpmRevoSlider);
949 addWidget(m_heli->m_ccpm->ccpmREVOspinBox);
950 addWidget(m_heli->m_ccpm->ccpmCollectiveSlider);
951 addWidget(m_heli->m_ccpm->ccpmCollectivespinBox);
952 addWidget(m_heli->m_ccpm->ccpmCollectiveScale);
953 addWidget(m_heli->m_ccpm->ccpmCollectiveScaleBox);
954 addWidget(m_heli->m_ccpm->ccpmCyclicScale);
955 addWidget(m_heli->m_ccpm->ccpmPitchScale);
956 addWidget(m_heli->m_ccpm->ccpmPitchScaleBox);
957 addWidget(m_heli->m_ccpm->ccpmRollScale);
958 addWidget(m_heli->m_ccpm->ccpmRollScaleBox);
959 addWidget(m_heli->m_ccpm->SwashLvlPositionSlider);
960 addWidget(m_heli->m_ccpm->SwashLvlPositionSpinBox);
961 addWidget(m_heli->m_ccpm->PitchCurve->getCurveWidget());
962 addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable);
~ConfigVehicleTypeWidget()
Gui-less support class for vehicle trimming.
ConfigVehicleTypeWidget(QWidget *parent=nullptr)
autopilotLevelBiasMessages
Core plugin system that manages the plugins, their life cycle and their registered objects...
static const double mixerRange
QVariant getValue(int index=0) const
autopilotLevelBiasMessages setAutopilotBias()
VehicleTrim::setFixedWingTrimAutopilotBias Takes the desired roll and pitch, and sets that as the aut...
int getNumElements() const
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
QStringList getOptions() const
void setValue(const QVariant &data, int index=0)
UAVObjectField * getField(const QString &name)
The VehicleTrim class is a UI free algorithm that can be connected to any interfaces. As such it only communicates with the UI via signals and slots, but has no direct handles to any particular controls or widgets.
actuatorTrimMessages setTrimActuators()
VehicleTrim::setFixedWingTrimActuators Reads the servo inputs from the transmitter, and sets these values as the neutral points.
SpinBoxDelegate(QObject *parent=nullptr)
void showEvent(QShowEvent *event)
UAVObject * getObject(const QString &name, quint32 instId=0)
void setEditorData(QWidget *editor, const QModelIndex &index) const
void resizeEvent(QResizeEvent *event)
static QStringList getChannelDescriptions()
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const