void UASActionsWidget::goToWaypointClicked() { if(!activeUas()) return; QLOG_INFO() << "Go to Waypoint" << ui.waypointListComboBox->currentIndex(); m_uas->getWaypointManager()->setCurrentWaypoint(ui.waypointListComboBox->currentIndex()); }
void UASActionsWidget::setRTLMode() { if(!activeUas()) return; QLOG_INFO() << "UASActionsWidget::setRTLMode()"; switch (m_uas->getAutopilotType()) { case MAV_AUTOPILOT_ARDUPILOTMEGA: { int idx = ui.modeComboBox->findText("RTL"); int mode = ui.modeComboBox->itemData(idx).toInt(); m_uas->setMode(MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, mode); } break; case MAV_AUTOPILOT_PX4: { // [TODO] PX4 flight controller go here } case MAV_AUTOPILOT_GENERIC: default: { // [TODO] Generic, and other flight controllers here (or own sections as above) } } }
void UASActionsWidget::setMode() { QLOG_INFO() << " UASActionsWidget::setMode()"; if(!activeUas()) return; QLOG_INFO() << "Set Mode to " << ui.modeComboBox->itemData(ui.modeComboBox->currentIndex()).toInt(); m_uas->setMode(MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, ui.modeComboBox->itemData(ui.modeComboBox->currentIndex()).toInt()); }
void UASActionsWidget::updateWaypointList() { if(!activeUas()) return; QLOG_INFO() << "updateWaypointList: "; ui.waypointListComboBox->clear(); for (int i=0;i<m_uas->getWaypointManager()->getWaypointEditableList().size();i++) { QLOG_INFO() << " WP:" << i; ui.waypointListComboBox->addItem(QString::number(i)); } }
void UASActionsWidget::setShortcutMode() { QLOG_INFO() << " UASActionsWidget::setShortcutMode()"; if(!activeUas()) return; QLOG_INFO() << "Set Mode to " << ui.shortcutButtonGroup->checkedButton()->text(); int index = ui.modeComboBox->findText(ui.shortcutButtonGroup->checkedButton()->text()); QLOG_DEBUG() << "index: " << index; ui.modeComboBox->setCurrentIndex(index); m_uas->setMode(MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, ui.modeComboBox->itemData(ui.modeComboBox->currentIndex()).toInt()); }
void UASActionsWidget::armButtonClicked() { QLOG_INFO() << "UASActionsWidget::armButtonClicked"; if(!activeUas()) return; if (m_uas->isArmed()) { QLOG_INFO() << "UAS:: Attempt to Disarm System"; m_uas->disarmSystem(); } else { QLOG_INFO() << "UAS:: Attempt to Arm System"; m_uas->armSystem(); } }
void UASActionsWidget::changeSpeedClicked() { if(!activeUas()) return; QLOG_INFO() << "Change Vehicle Speed "; if (m_uas->isMultirotor()) { QLOG_INFO() << "APMCopter: setting WPNAV_SPEED: " << ui.speedDoubleSpinBox->value() * 100.0f; m_uas->setParameter(1,"WPNAV_SPEED", QVariant((static_cast<float>(ui.speedDoubleSpinBox->value() * 100.0f)))); return; } else if (m_uas->isFixedWing()) { // [TODO} need to add AirSpeed/GroundSpeed options here as well QVariant variant; if (m_uas->getParamManager()->getParameterValue(1,"ARSPD_ENABLE",variant)) { if (variant.toInt() == 1) { QLOG_INFO() << "APMPlane: ARSPD_ENABLED setting TRIM_ARSPD_CN"; m_uas->setParameter(1,"TRIM_ARSPD_CN", QVariant((static_cast<float>(ui.speedDoubleSpinBox->value() * 100.0f)))); return; } } QLOG_INFO() << "APMPlane: setting TRIM_ARSPD_CN"; m_uas->setParameter(1,"TRIM_ARSPD_CN", QVariant((static_cast<float>(ui.speedDoubleSpinBox->value() * 100.0f)))); } else if (m_uas->isGroundRover()) { QLOG_INFO() << "APMCopter: setting CRUISE_SPEED: " << ui.speedDoubleSpinBox->value() * 100.0f; m_uas->setParameter(1, "CRUISE_SPEED", QVariant((static_cast<float>(ui.speedDoubleSpinBox->value() * 100.0f)))); } }
void UASActionsWidget::setAction() { QLOG_INFO() << "UASActionsWidget::setAction()"; if(!activeUas()) return; QLOG_INFO() << "Set Action to " << ui.actionComboBox->currentIndex(); int currentIndex = ui.actionComboBox->currentIndex(); MAV_CMD currentCommand = static_cast<MAV_CMD>(ui.actionComboBox->itemData(currentIndex).toInt()); switch (m_uas->getAutopilotType()) { case MAV_AUTOPILOT_ARDUPILOTMEGA: { if (m_uas->isFixedWing()){ sendApmPlaneCommand(currentCommand); } else if (m_uas->isMultirotor()){ sendApmCopterCommand(currentCommand); } else if (m_uas->isGroundRover()){ sendApmRoverCommand(currentCommand); } else { QLOG_WARN() << "UASActionWidget: Unsupported System Type" << m_uas->getSystemType(); } } break; case MAV_AUTOPILOT_PX4: { // [TODO] PX4 flight controller go here } case MAV_AUTOPILOT_GENERIC: default: { // [TODO] Generic, and other flight controllers here (or own sections as above) } } }
void UASActionsWidget::setShortcutMode() { QLOG_INFO() << " UASActionsWidget::setShortcutMode()"; if(!activeUas()) return; QLOG_INFO() << "Set Mode to " << ui.shortcutButtonGroup->checkedButton()->text(); QString modeString; modeString = ui.shortcutButtonGroup->checkedButton()->text(); int index = ui.modeComboBox->findText(modeString); QLOG_DEBUG() << "index: " << index; if (modeChangeWarningBox(modeString) == QMessageBox::Abort){ return; } ui.modeComboBox->setCurrentIndex(index); m_uas->setMode(MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, ui.modeComboBox->itemData(ui.modeComboBox->currentIndex()).toInt()); }