29 #include <QStringList>
32 #include <QVBoxLayout>
33 #include <QPushButton>
38 #include "actuatorcommand.h"
39 #include "mixersettings.h"
41 const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString(
"multiMotorChannelBox");
42 const QString ConfigMultiRotorWidget::CHANNELLABELNAME = QString(
"MotorOutputLabel");
51 m_aircraft = aircraft;
62 void ConfigMultiRotorWidget::setupUI(SystemSettings::AirframeTypeOptions frameType)
75 m_aircraft->aircraftType->findText(
"Multirotor"));
76 m_aircraft->triYawChannelBox->setEnabled(
false);
79 for (i = 1; i <= 8; i++) {
82 uiowner->findChild<QComboBox *>(
"multiMotorChannelBox" + QString::number(i));
84 combobox->setEnabled(
false);
85 combobox->setItemData(0, 0, Qt::DecorationRole);
90 case SystemSettings::AIRFRAMETYPE_TRI:
92 m_aircraft->multirotorFrameType,
93 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_TRI));
95 m_aircraft->mrRollMixLevel->setValue(100);
96 m_aircraft->mrPitchMixLevel->setValue(100);
99 m_aircraft->triYawChannelBox->setEnabled(
true);
107 case SystemSettings::AIRFRAMETYPE_QUADX:
109 m_aircraft->multirotorFrameType,
110 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_QUADX));
116 m_aircraft->mrRollMixLevel->setValue(50);
117 m_aircraft->mrPitchMixLevel->setValue(50);
127 case SystemSettings::AIRFRAMETYPE_QUADP:
129 m_aircraft->multirotorFrameType,
130 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_QUADP));
135 m_aircraft->mrRollMixLevel->setValue(100);
136 m_aircraft->mrPitchMixLevel->setValue(100);
146 case SystemSettings::AIRFRAMETYPE_HEXA:
148 m_aircraft->multirotorFrameType,
149 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXA));
151 m_aircraft->mrRollMixLevel->setValue(50);
152 m_aircraft->mrPitchMixLevel->setValue(33);
158 case SystemSettings::AIRFRAMETYPE_HEXAX:
160 m_aircraft->multirotorFrameType,
161 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXAX));
163 m_aircraft->mrRollMixLevel->setValue(33);
164 m_aircraft->mrPitchMixLevel->setValue(50);
170 case SystemSettings::AIRFRAMETYPE_HEXACOAX:
172 m_aircraft->multirotorFrameType,
173 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXACOAX));
175 m_aircraft->mrRollMixLevel->setValue(100);
176 m_aircraft->mrPitchMixLevel->setValue(50);
182 case SystemSettings::AIRFRAMETYPE_OCTO:
184 m_aircraft->multirotorFrameType,
185 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTO));
187 m_aircraft->mrRollMixLevel->setValue(33);
188 m_aircraft->mrPitchMixLevel->setValue(33);
194 case SystemSettings::AIRFRAMETYPE_OCTOV:
196 m_aircraft->multirotorFrameType,
197 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOV));
199 m_aircraft->mrRollMixLevel->setValue(25);
200 m_aircraft->mrPitchMixLevel->setValue(25);
206 case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
208 m_aircraft->multirotorFrameType,
209 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOCOAXP));
211 m_aircraft->mrRollMixLevel->setValue(100);
212 m_aircraft->mrPitchMixLevel->setValue(100);
218 case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
220 m_aircraft->multirotorFrameType,
221 m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOCOAXX));
223 m_aircraft->mrRollMixLevel->setValue(50);
224 m_aircraft->mrPitchMixLevel->setValue(50);
236 for (
int i = labels.length() + 1; i <= numMotors; i++)
237 labels << QString::number(i);
243 drawAirframe(frameType);
246 void ConfigMultiRotorWidget::drawAirframe(SystemSettings::AirframeTypeOptions frameType)
249 invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1;
252 case SystemSettings::AIRFRAMETYPE_TRI:
253 if (invertMotors > 0)
254 quad->setElementId(
"tri");
256 quad->setElementId(
"tri_reverse");
258 case SystemSettings::AIRFRAMETYPE_QUADX:
259 if (invertMotors > 0)
260 quad->setElementId(
"quad-x");
262 quad->setElementId(
"quad-x_reverse");
264 case SystemSettings::AIRFRAMETYPE_QUADP:
265 if (invertMotors > 0)
266 quad->setElementId(
"quad-plus");
268 quad->setElementId(
"quad-plus_reverse");
270 case SystemSettings::AIRFRAMETYPE_HEXA:
271 if (invertMotors > 0)
272 quad->setElementId(
"quad-hexa");
274 quad->setElementId(
"quad-hexa_reverse");
276 case SystemSettings::AIRFRAMETYPE_HEXAX:
277 if (invertMotors > 0)
278 quad->setElementId(
"quad-hexa-H");
280 quad->setElementId(
"quad-hexa-H_reverse");
282 case SystemSettings::AIRFRAMETYPE_HEXACOAX:
283 if (invertMotors > 0)
284 quad->setElementId(
"hexa-coax");
286 quad->setElementId(
"hexa-coax_reverse");
288 case SystemSettings::AIRFRAMETYPE_OCTO:
289 if (invertMotors > 0)
290 quad->setElementId(
"quad-octo");
292 quad->setElementId(
"quad-octo_reverse");
294 case SystemSettings::AIRFRAMETYPE_OCTOV:
295 if (invertMotors > 0)
296 quad->setElementId(
"quad-octo-v");
298 quad->setElementId(
"quad-octo-v_reverse");
300 case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
301 if (invertMotors > 0)
302 quad->setElementId(
"octo-coax-P");
304 quad->setElementId(
"octo-coax-P_reverse");
306 case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
307 if (invertMotors > 0)
308 quad->setElementId(
"octo-coax-X");
310 quad->setElementId(
"octo-coax-X_reverse");
320 configData->
multi.VTOLMotorN = 0;
321 configData->
multi.VTOLMotorNE = 0;
322 configData->
multi.VTOLMotorE = 0;
323 configData->
multi.VTOLMotorSE = 0;
324 configData->
multi.VTOLMotorS = 0;
325 configData->
multi.VTOLMotorSW = 0;
326 configData->
multi.VTOLMotorW = 0;
327 configData->
multi.VTOLMotorNW = 0;
328 configData->
multi.TRIYaw = 0;
331 QStringList ConfigMultiRotorWidget::getChannelDescriptions()
333 QStringList channelDesc;
336 for (
int i = 0; i < (int)(ActuatorCommand::CHANNEL_NUMELEM); i++) {
337 channelDesc.append(QString(
"-"));
342 multiGUISettingsStruct multi = configData.
multi;
344 if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ActuatorCommand::CHANNEL_NUMELEM)
345 channelDesc[multi.VTOLMotorN - 1] = QString(
"VTOLMotorN");
346 if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ActuatorCommand::CHANNEL_NUMELEM)
347 channelDesc[multi.VTOLMotorNE - 1] = QString(
"VTOLMotorNE");
348 if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ActuatorCommand::CHANNEL_NUMELEM)
349 channelDesc[multi.VTOLMotorNW - 1] = QString(
"VTOLMotorNW");
350 if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ActuatorCommand::CHANNEL_NUMELEM)
351 channelDesc[multi.VTOLMotorS - 1] = QString(
"VTOLMotorS");
352 if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ActuatorCommand::CHANNEL_NUMELEM)
353 channelDesc[multi.VTOLMotorSE - 1] = QString(
"VTOLMotorSE");
354 if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ActuatorCommand::CHANNEL_NUMELEM)
355 channelDesc[multi.VTOLMotorSW - 1] = QString(
"VTOLMotorSW");
356 if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ActuatorCommand::CHANNEL_NUMELEM)
357 channelDesc[multi.VTOLMotorW - 1] = QString(
"VTOLMotorW");
358 if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ActuatorCommand::CHANNEL_NUMELEM)
359 channelDesc[multi.VTOLMotorE - 1] = QString(
"VTOLMotorE");
360 if (multi.TRIYaw > 0 && multi.TRIYaw <= ActuatorCommand::CHANNEL_NUMELEM)
361 channelDesc[multi.TRIYaw - 1] = QString(
"Tri-Yaw");
366 void ConfigMultiRotorWidget::setYawMixLevel(
int value)
369 m_aircraft->mrYawMixLevel->setValue((-1) * value);
370 m_aircraft->MultirotorRevMixercheckBox->setChecked(
true);
372 m_aircraft->mrYawMixLevel->setValue(value);
373 m_aircraft->MultirotorRevMixercheckBox->setChecked(
false);
380 SystemSettings::AirframeTypeOptions ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
382 SystemSettings::AirframeTypeOptions airframeType = SystemSettings::AIRFRAMETYPE_FIXEDWING;
385 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
386 Q_ASSERT(mixerSettings);
388 if (m_aircraft->multirotorFrameType->itemData(m_aircraft->multirotorFrameType->currentIndex())
389 == SystemSettings::AIRFRAMETYPE_QUADP) {
390 airframeType = SystemSettings::AIRFRAMETYPE_QUADP;
392 }
else if (m_aircraft->multirotorFrameType->itemData(
393 m_aircraft->multirotorFrameType->currentIndex())
394 == SystemSettings::AIRFRAMETYPE_QUADX) {
395 airframeType = SystemSettings::AIRFRAMETYPE_QUADX;
397 }
else if (m_aircraft->multirotorFrameType->itemData(
398 m_aircraft->multirotorFrameType->currentIndex())
399 == SystemSettings::AIRFRAMETYPE_HEXA) {
400 airframeType = SystemSettings::AIRFRAMETYPE_HEXA;
402 }
else if (m_aircraft->multirotorFrameType->itemData(
403 m_aircraft->multirotorFrameType->currentIndex())
404 == SystemSettings::AIRFRAMETYPE_HEXAX) {
405 airframeType = SystemSettings::AIRFRAMETYPE_HEXAX;
407 }
else if (m_aircraft->multirotorFrameType->itemData(
408 m_aircraft->multirotorFrameType->currentIndex())
409 == SystemSettings::AIRFRAMETYPE_HEXACOAX) {
410 airframeType = SystemSettings::AIRFRAMETYPE_HEXACOAX;
413 if (throwConfigError(6)) {
416 motorList <<
"VTOLMotorNW"
422 setupMotors(motorList, airframeType);
426 double mixer[8][3] = { { 0.5, 1, -1 }, { 0.5, 1, 1 }, { 0.5, -1, -1 }, { 0.5, -1, 1 },
427 { -1, 0, -1 }, { -1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 } };
428 setupMultiRotorMixer(mixer);
429 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
431 }
else if (m_aircraft->multirotorFrameType->itemData(
432 m_aircraft->multirotorFrameType->currentIndex())
433 == SystemSettings::AIRFRAMETYPE_OCTO) {
434 airframeType = SystemSettings::AIRFRAMETYPE_OCTO;
437 if (throwConfigError(8)) {
440 motorList <<
"VTOLMotorN"
448 setupMotors(motorList, airframeType);
451 double mixer[8][3] = { { 1, 0, -1 }, { 1, -1, 1 }, { 0, -1, -1 }, { -1, -1, 1 },
452 { -1, 0, -1 }, { -1, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 } };
453 setupMultiRotorMixer(mixer);
454 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
456 }
else if (m_aircraft->multirotorFrameType->itemData(
457 m_aircraft->multirotorFrameType->currentIndex())
458 == SystemSettings::AIRFRAMETYPE_OCTOV) {
459 airframeType = SystemSettings::AIRFRAMETYPE_OCTOV;
462 if (throwConfigError(8)) {
465 motorList <<
"VTOLMotorN"
473 setupMotors(motorList, airframeType);
477 double mixer[8][3] = { { 0.33, -1, -1 }, { 1, -1, 1 }, { -1, -1, -1 }, { -0.33, -1, 1 },
478 { -0.33, 1, -1 }, { -1, 1, 1 }, { 1, 1, -1 }, { 0.33, 1, 1 } };
479 setupMultiRotorMixer(mixer);
480 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
482 }
else if (m_aircraft->multirotorFrameType->itemData(
483 m_aircraft->multirotorFrameType->currentIndex())
484 == SystemSettings::AIRFRAMETYPE_OCTOCOAXP) {
485 airframeType = SystemSettings::AIRFRAMETYPE_OCTOCOAXP;
488 if (throwConfigError(8)) {
491 motorList <<
"VTOLMotorN"
499 setupMotors(motorList, airframeType);
502 double mixer[8][3] = { { 1, 0, -1 }, { 1, 0, 1 }, { 0, -1, -1 }, { 0, -1, 1 },
503 { -1, 0, -1 }, { -1, 0, 1 }, { 0, 1, -1 }, { 0, 1, 1 } };
504 setupMultiRotorMixer(mixer);
505 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
507 }
else if (m_aircraft->multirotorFrameType->itemData(
508 m_aircraft->multirotorFrameType->currentIndex())
509 == SystemSettings::AIRFRAMETYPE_OCTOCOAXX) {
510 airframeType = SystemSettings::AIRFRAMETYPE_OCTOCOAXX;
513 if (throwConfigError(8)) {
516 motorList <<
"VTOLMotorNW"
524 setupMotors(motorList, airframeType);
527 double mixer[8][3] = { { 1, 1, -1 }, { 1, 1, 1 }, { 1, -1, -1 }, { 1, -1, 1 },
528 { -1, -1, -1 }, { -1, -1, 1 }, { -1, 1, -1 }, { -1, 1, 1 } };
529 setupMultiRotorMixer(mixer);
530 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
532 }
else if (m_aircraft->multirotorFrameType->itemData(
533 m_aircraft->multirotorFrameType->currentIndex())
534 == SystemSettings::AIRFRAMETYPE_TRI) {
535 airframeType = SystemSettings::AIRFRAMETYPE_TRI;
538 if (throwConfigError(3)) {
541 if (m_aircraft->triYawChannelBox->currentText() ==
"None") {
542 m_aircraft->mrStatusLabel->setText(
543 "<font color='red'>Error: Assign a Yaw channel</font>");
546 motorList <<
"VTOLMotorNW"
549 setupMotors(motorList, airframeType);
553 double mixer[8][3] = { { 0.5, 1, 0 }, { 0.5, -1, 0 }, { -1, 0, 0 }, { 0, 0, 0 },
554 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
555 setupMultiRotorMixer(mixer);
559 int channel = m_aircraft->triYawChannelBox->currentIndex() - 1;
561 setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_SERVO);
566 m_aircraft->mrStatusLabel->setText(tr(
"Configuration OK"));
575 void ConfigMultiRotorWidget::refreshAirframeWidgetsValues(
576 SystemSettings::AirframeTypeOptions frameType)
582 multiGUISettingsStruct multi = config.
multi;
584 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
585 Q_ASSERT(mixerSettings);
587 if (frameType == SystemSettings::AIRFRAMETYPE_QUADP) {
598 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
601 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
604 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
606 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
608 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
610 }
else if (frameType == SystemSettings::AIRFRAMETYPE_QUADX) {
620 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
623 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
626 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
629 m_aircraft->mrRollMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
632 }
else if (frameType == SystemSettings::AIRFRAMETYPE_HEXA) {
646 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
649 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
652 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
655 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
657 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
660 }
else if (frameType == SystemSettings::AIRFRAMETYPE_HEXAX) {
674 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
677 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
680 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
682 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
684 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
686 }
else if (frameType == SystemSettings::AIRFRAMETYPE_HEXACOAX) {
699 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
702 m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / (
mixerScale / 100.0)));
704 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
706 setYawMixLevel(qRound(value / (
mixerScale / 100.0)));
709 m_aircraft->mrRollMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
711 }
else if (frameType == SystemSettings::AIRFRAMETYPE_OCTO
712 || frameType == SystemSettings::AIRFRAMETYPE_OCTOV
713 || frameType == SystemSettings::AIRFRAMETYPE_OCTOCOAXP) {
728 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
730 if (frameType == SystemSettings::AIRFRAMETYPE_OCTO) {
733 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
737 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
740 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
743 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
744 }
else if (frameType == SystemSettings::AIRFRAMETYPE_OCTOV) {
747 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
751 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
754 channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
757 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
758 }
else if (frameType == SystemSettings::AIRFRAMETYPE_OCTOCOAXP) {
761 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
765 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
768 channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1;
771 m_aircraft->mrRollMixLevel->setValue(-qRound(value / (
mixerScale / 100.0)));
774 }
else if (frameType == SystemSettings::AIRFRAMETYPE_OCTOCOAXX) {
789 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
792 m_aircraft->mrPitchMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
795 setYawMixLevel(-qRound(value / (
mixerScale / 100.0)));
798 m_aircraft->mrRollMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
800 }
else if (frameType == SystemSettings::AIRFRAMETYPE_TRI) {
809 channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
812 m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / (
mixerScale / 100.0)));
815 m_aircraft->mrRollMixLevel->setValue(qRound(value / (
mixerScale / 100.0)));
819 drawAirframe(frameType);
825 void ConfigMultiRotorWidget::setupQuadMotor(
int channel,
double pitch,
double roll,
double yaw)
827 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
828 Q_ASSERT(mixerSettings);
830 setMixerType(mixerSettings, channel, MixerSettings::MIXER1TYPE_MOTOR);
834 setMixerVectorValue(mixerSettings, channel, MixerSettings::MIXER1VECTOR_THROTTLECURVE2, 0);
846 void ConfigMultiRotorWidget::setupMotors(
QList<QString> motorList,
847 SystemSettings::AirframeTypeOptions vehicle)
850 mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2
851 << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4
852 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
853 << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
856 ResetActuators(&configData);
859 foreach (QString motor, motorList) {
861 index = mmList.takeFirst()->currentIndex();
863 if (motor == QString(
"VTOLMotorN"))
864 configData.
multi.VTOLMotorN = index;
865 else if (motor == QString(
"VTOLMotorNE"))
866 configData.
multi.VTOLMotorNE = index;
867 else if (motor == QString(
"VTOLMotorE"))
868 configData.
multi.VTOLMotorE = index;
869 else if (motor == QString(
"VTOLMotorSE"))
870 configData.
multi.VTOLMotorSE = index;
871 else if (motor == QString(
"VTOLMotorS"))
872 configData.
multi.VTOLMotorS = index;
873 else if (motor == QString(
"VTOLMotorSW"))
874 configData.
multi.VTOLMotorSW = index;
875 else if (motor == QString(
"VTOLMotorW"))
876 configData.
multi.VTOLMotorW = index;
877 else if (motor == QString(
"VTOLMotorNW"))
878 configData.
multi.VTOLMotorNW = index;
881 if (vehicle == SystemSettings::AIRFRAMETYPE_TRI) {
882 configData.
multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
891 bool ConfigMultiRotorWidget::setupQuad(
bool pLayout)
896 if (throwConfigError(4)) {
902 motorList <<
"VTOLMotorN"
907 motorList <<
"VTOLMotorNW"
912 setupMotors(motorList,
913 pLayout ? SystemSettings::AIRFRAMETYPE_QUADP : SystemSettings::AIRFRAMETYPE_QUADX);
922 double xMixer[8][3] = { { 1, 1, -1 }, { 1, -1, 1 }, { -1, -1, -1 }, { -1, 1, 1 },
923 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
931 double pMixer[8][3] = { { 1, 0, -1 }, { 0, -1, 1 }, { -1, 0, -1 }, { 0, 1, 1 },
932 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
935 setupMultiRotorMixer(pMixer);
937 setupMultiRotorMixer(xMixer);
939 m_aircraft->mrStatusLabel->setText(tr(
"Configuration OK"));
946 bool ConfigMultiRotorWidget::setupHexa(
bool pLayout)
950 if (throwConfigError(6))
955 motorList <<
"VTOLMotorN"
962 motorList <<
"VTOLMotorNE"
969 setupMotors(motorList,
970 pLayout ? SystemSettings::AIRFRAMETYPE_HEXA : SystemSettings::AIRFRAMETYPE_HEXAX);
983 double pMixer[8][3] = { { 1, 0, -1 }, { 1, -1, 1 }, { -1, -1, -1 }, { -1, 0, 1 },
984 { -1, 1, -1 }, { 1, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } };
994 double xMixer[8][3] = { { 1, -1, -1 }, { 0, -1, 1 }, { -1, -1, -1 }, { -1, 1, 1 },
995 { 0, 1, -1 }, { 1, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } };
998 setupMultiRotorMixer(pMixer);
1000 setupMultiRotorMixer(xMixer);
1002 m_aircraft->mrStatusLabel->setText(
"Configuration OK");
1009 bool ConfigMultiRotorWidget::setupMultiRotorMixer(
double mixerFactors[8][3])
1012 mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2
1013 << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4
1014 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
1015 << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
1017 MixerSettings *mixerSettings = MixerSettings::GetInstance(
getObjectManager());
1018 Q_ASSERT(mixerSettings);
1022 double pFactor = (double)m_aircraft->mrPitchMixLevel->value() / 100;
1023 double rFactor = (double)m_aircraft->mrRollMixLevel->value() / 100;
1024 invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1;
1025 double yFactor = invertMotors * (double)m_aircraft->mrYawMixLevel->value() / 100;
1026 for (
int i = 0; i < 8; i++) {
1027 if (mmList.at(i)->isEnabled()) {
1028 int channel = mmList.at(i)->currentIndex() - 1;
1030 setupQuadMotor(channel, mixerFactors[i][0] * pFactor, rFactor * mixerFactors[i][1],
1031 yFactor * mixerFactors[i][2]);
1041 bool ConfigMultiRotorWidget::throwConfigError(
int numMotors)
1047 for (
int i = 0; i < numMotors; i++) {
1049 QComboBox *combobox =
1050 uiowner->findChild<QComboBox *>(
"multiMotorChannelBox" + QString::number(i + 1));
1052 if (combobox->currentText() ==
"None") {
1053 int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
1054 QPixmap pixmap(size, size);
1055 pixmap.fill(QColor(
"red"));
1056 combobox->setItemData(0, pixmap, Qt::DecorationRole);
1059 combobox->setItemData(0, 0, Qt::DecorationRole);
1065 m_aircraft->mrStatusLabel->setText(
1066 QString(
"<font color='red'>ERROR: Assign all %1 motor channels</font>").arg(numMotors));
static void SetConfigData(GUIConfigDataUnion configData, SystemSettings::AirframeTypeOptions vehicle)
static GUIConfigDataUnion GetConfigData()
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName)
void resetMixers(UAVDataObject *mixer)
void setMixerType(UAVDataObject *mixer, int channel, MixerSettings::Mixer1TypeOptions mixerType)
multiGUISettingsStruct multi
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName, double value)
ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft=nullptr, QWidget *parent=nullptr)
static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
else error('Your technical computing program does not support file choosers.Please input the file name in the argument. ') end elseif nargin >0 logfile
void setLabelText(QWidget *owner, const QString &boxName, const QStringList &labels)
static const double mixerScale
~ConfigMultiRotorWidget()
static void setComboCurrentIndex(QComboBox *box, int index)