示例#1
0
void UASActionsWidget::setupApmRoverModes()
{
    QLOG_INFO() << "UASActionWidget: Set for Rover";
    ApmUiHelpers::addRoverModes(ui.modeComboBox);

    ui.armDisarmButton->setVisible(false);
    ui.armedStatuslabel->setVisible(false);

    // Setup configurable shortcut action
    ui.opt1ModeButton->setText("Learn");
    ui.opt2ModeButton->setText("Steer");
    ui.opt3ModeButton->setText("Hold");
    ui.opt4ModeButton->setText("none");
    configureModeButtonEnableDisable();

    // Setup Action Combo Box
    ui.actionComboBox->clear();
    ui.actionComboBox->addItem("Loiter Unlimited", MAV_CMD_NAV_LOITER_UNLIM);
    ui.actionComboBox->addItem("Return To Launch", MAV_CMD_NAV_RETURN_TO_LAUNCH);
    ui.actionComboBox->addItem("Preflight Calibration", MAV_CMD_PREFLIGHT_CALIBRATION);
    ui.actionComboBox->addItem("Mission Start", MAV_CMD_MISSION_START);
    ui.actionComboBox->addItem("Preflight Reboot", MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN);
    ui.actionComboBox->addItem("Trigger Camera", MAV_CMD_DO_DIGICAM_CONTROL);

}
示例#2
0
void UASActionsWidget::contextMenuEvent(QContextMenuEvent *event)
{
    Q_UNUSED(event)

    QLOG_DEBUG() << "contextMenuEvent";

    if(m_uas == NULL)
        return;

    APMShortcutModesDialog* dialog = new APMShortcutModesDialog();

    if(m_uas->isMultirotor()){
        ApmUiHelpers::addCopterModes(dialog->opt1ComboBox());
        ApmUiHelpers::addCopterModes(dialog->opt2ComboBox());
        ApmUiHelpers::addCopterModes(dialog->opt3ComboBox());
        ApmUiHelpers::addCopterModes(dialog->opt4ComboBox());
    } else if (m_uas->isFixedWing()) {
        ApmUiHelpers::addPlaneModes(dialog->opt1ComboBox());
        ApmUiHelpers::addPlaneModes(dialog->opt2ComboBox());
        ApmUiHelpers::addPlaneModes(dialog->opt3ComboBox());
        ApmUiHelpers::addPlaneModes(dialog->opt4ComboBox());
    } else if (m_uas->isGroundRover()){
        ApmUiHelpers::addRoverModes(dialog->opt1ComboBox());
        ApmUiHelpers::addRoverModes(dialog->opt2ComboBox());
        ApmUiHelpers::addRoverModes(dialog->opt3ComboBox());
        ApmUiHelpers::addRoverModes(dialog->opt4ComboBox());
    } else {
        // Do nothing.
        delete dialog;
        dialog = NULL;
        return;
    }

    dialog->opt1ComboBox()->setCurrentIndex(dialog->opt1ComboBox()->findText(ui.opt1ModeButton->text()));
    dialog->opt2ComboBox()->setCurrentIndex(dialog->opt2ComboBox()->findText(ui.opt2ModeButton->text()));
    dialog->opt3ComboBox()->setCurrentIndex(dialog->opt3ComboBox()->findText(ui.opt3ModeButton->text()));
    dialog->opt4ComboBox()->setCurrentIndex(dialog->opt4ComboBox()->findText(ui.opt4ModeButton->text()));

    if(dialog->exec() == QDialog::Accepted) {
        // Changes where made and OK'd
        ui.opt1ModeButton->setText(dialog->opt1ComboBox()->currentText());
        ui.opt2ModeButton->setText(dialog->opt2ComboBox()->currentText());
        ui.opt3ModeButton->setText(dialog->opt3ComboBox()->currentText());
        ui.opt4ModeButton->setText(dialog->opt4ComboBox()->currentText());
        configureModeButtonEnableDisable();
        saveApmSettings();
     } else {
        QLOG_DEBUG() << "No Shortcut mode changes made";
     }
}
void UASActionsWidget::setupApmCopterModes()
{
    QLOG_INFO() << "UASActionWidget: set for Copter";
    ApmUiHelpers::addCopterModes(ui.modeComboBox);

    ui.armDisarmButton->setVisible(true);
    ui.armedStatuslabel->setVisible(true);

    // Setup configurable shortcut action
    ui.opt1ModeButton->setText("none");
    ui.opt2ModeButton->setText("Acro");
    ui.opt3ModeButton->setText("Alt Hold");
    ui.opt4ModeButton->setText("Land");
    configureModeButtonEnableDisable();
}
void UASActionsWidget::setupApmRoverModes()
{
    QLOG_INFO() << "UASActionWidget: Set for Rover";
    ApmUiHelpers::addRoverModes(ui.modeComboBox);

    ui.armDisarmButton->setVisible(false);
    ui.armedStatuslabel->setVisible(false);

    // Setup configurable shortcut action
    ui.opt1ModeButton->setText("Learn");
    ui.opt2ModeButton->setText("Steer");
    ui.opt3ModeButton->setText("Hold");
    ui.opt4ModeButton->setText("none");
    configureModeButtonEnableDisable();

}
void UASActionsWidget::activeUASSet(UASInterface *uas)
{
    QLOG_INFO() << "UASActionWidget::activeUASSet";
    if (uas == NULL) {
        QLOG_ERROR() << "uas object NULL";
        return;
    }

    if (m_uas) {
        // disconnect previous connections
        disconnect(m_uas->getWaypointManager(),SIGNAL(waypointEditableListChanged()),
                this,SLOT(updateWaypointList()));
        disconnect(m_uas->getWaypointManager(),SIGNAL(currentWaypointChanged(quint16)),
                this,SLOT(currentWaypointChanged(quint16)));
        disconnect(m_uas,SIGNAL(armingChanged(bool)),this,SLOT(armingChanged(bool)));

        disconnect(m_uas, SIGNAL(connected()), this, SLOT(uasConnected()));
        disconnect(m_uas, SIGNAL(disconnected()), this, SLOT(uasDisconnected()));

        disconnect(m_uas,SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)),
                this,SLOT(parameterChanged(int,int,int,int,QString,QVariant)));
        disconnect(m_uas, SIGNAL(heartbeat(UASInterface*)),
                   this, SLOT(heartbeatReceived(UASInterface*)));
    }

    // enable the controls
    ui.actionsGroupBox->setDisabled(false);
    ui.missionGroupBox->setDisabled(false);
    ui.altitudeTypeComboBox->addItem(tr("Relative (AGL)"), MAV_FRAME_GLOBAL_RELATIVE_ALT);
    ui.altitudeTypeComboBox->addItem(tr("Absolute (ASL)"), MAV_FRAME_GLOBAL);
    ui.shortcutGroupBox->setDisabled(false);
    ui.altitudeDoubleSpinBox->setValue(50.0f); // set a default altitude

    m_uas = static_cast<UAS*>(uas);

    connect(m_uas->getWaypointManager(),SIGNAL(waypointEditableListChanged()),
            this,SLOT(updateWaypointList()));
    connect(m_uas->getWaypointManager(),SIGNAL(currentWaypointChanged(quint16)),
            this,SLOT(currentWaypointChanged(quint16)));
    connect(m_uas,SIGNAL(armingChanged(bool)),this,SLOT(armingChanged(bool)));

    connect(m_uas, SIGNAL(connected()), this, SLOT(uasConnected()));
    connect(m_uas, SIGNAL(disconnected()), this, SLOT(uasDisconnected()));

    connect(m_uas,SIGNAL(parameterChanged(int,int,int,int,QString,QVariant)),
            this,SLOT(parameterChanged(int,int,int,int,QString,QVariant)));
    connect(m_uas, SIGNAL(heartbeat(UASInterface*)),
               this, SLOT(heartbeatReceived(UASInterface*)));

    armingChanged(m_uas->isArmed());
    updateWaypointList();

    switch (uas->getAutopilotType()){
        case MAV_AUTOPILOT_ARDUPILOTMEGA: {
            if (uas->isFixedWing()){
                setupApmPlaneModes();

            } else if (uas->isMultirotor()){
                setupApmCopterModes();

            } else if (uas->isGroundRover()){
                setupApmRoverModes();

            } else {
                QLOG_WARN() << "UASActionWidget: Unsupported System Type" << uas->getSystemType();
            }
            // Setup Final Connections
            connect(ui.setModeButton, SIGNAL(clicked()),this, SLOT(setMode()));

        } break;
        case MAV_AUTOPILOT_PX4:
        {
            // [TODO] PX4 flight controller go here
        }
        case MAV_AUTOPILOT_GENERIC:
        default:
        {
            // [TODO] Generic, and other flight controllers
        }

        loadApmSettings();
        configureModeButtonEnableDisable();
    }
}