예제 #1
0
/**
 * @brief ConfigOutputWidget::assignOutputChannels Sets the output channel form text and min/max values
 * @param actuatorSettings UAVO input
 */
void ConfigOutputWidget::assignOutputChannels(UAVObject *obj)
{
    Q_UNUSED(obj);

    // Get UAVO
    ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager());
    ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData();

    // Get channel descriptions
    QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions();

    // Find all output forms in the tab, and set the text and min/max values
    QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>();
    foreach(OutputChannelForm *outputChannelForm, outputChannelForms)
    {
        outputChannelForm->setAssignment(ChannelDesc[outputChannelForm->index()]);

        // init min,max,neutral
        quint32 minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
        quint32 maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()];
        outputChannelForm->setMinmax(minValue, maxValue);

        quint32 neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()];
        outputChannelForm->setNeutral(neutral);

        // init type
        quint16 type = actuatorSettingsData.ChannelType[outputChannelForm->index()];
        outputChannelForm->setType(type);
    }
예제 #2
0
void VehicleConfigurationHelper::applyActuatorConfiguration()
{
    ActuatorSettings *actSettings = ActuatorSettings::GetInstance(m_uavoManager);

    switch (m_configSource->getVehicleType()) {
    case VehicleConfigurationSource::VEHICLE_MULTI:
    {
        ActuatorSettings::DataFields data = actSettings->getData();

        QList<actuatorChannelSettings> actuatorSettings = m_configSource->getActuatorSettings();
        for (quint16 i = 0; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) {
            data.ChannelType[i]    = ActuatorSettings::CHANNELTYPE_PWM;
            data.ChannelAddr[i]    = i;
            data.ChannelMin[i]     = actuatorSettings[i].channelMin;
            data.ChannelNeutral[i] = actuatorSettings[i].channelNeutral;
            data.ChannelMax[i]     = actuatorSettings[i].channelMax;
        }

        data.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;

        for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) {
            data.ChannelUpdateFreq[i] = LEGACY_ESC_FREQUENCE;
        }

        qint16 updateFrequence = LEGACY_ESC_FREQUENCE;
        switch (m_configSource->getESCType()) {
        case VehicleConfigurationSource::ESC_LEGACY:
            updateFrequence = LEGACY_ESC_FREQUENCE;
            break;
        case VehicleConfigurationSource::ESC_RAPID:
            updateFrequence = RAPID_ESC_FREQUENCE;
            break;
        default:
            break;
        }

        // TOOD: vehicle specific sets of update frequencies
        switch (m_configSource->getVehicleSubType()) {
        case VehicleConfigurationSource::MULTI_ROTOR_TRI_Y:
            data.ChannelUpdateFreq[0] = updateFrequence;
            data.ChannelUpdateFreq[1] = updateFrequence;
            break;
        case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
        case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS:
            data.ChannelUpdateFreq[0] = updateFrequence;
            data.ChannelUpdateFreq[1] = updateFrequence;
            data.ChannelUpdateFreq[2] = updateFrequence;
            break;
        case VehicleConfigurationSource::MULTI_ROTOR_HEXA:
        case VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y:
        case VehicleConfigurationSource::MULTI_ROTOR_HEXA_H:
        case VehicleConfigurationSource::MULTI_ROTOR_OCTO:
        case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X:
        case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS:
        case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V:
            data.ChannelUpdateFreq[0] = updateFrequence;
            data.ChannelUpdateFreq[1] = updateFrequence;
            data.ChannelUpdateFreq[2] = updateFrequence;
            data.ChannelUpdateFreq[3] = updateFrequence;
            break;
        default:
            break;
        }
        actSettings->setData(data);
        addModifiedObject(actSettings, tr("Writing actuator settings"));
        break;
    }
    case VehicleConfigurationSource::VEHICLE_FIXEDWING:
    case VehicleConfigurationSource::VEHICLE_HELI:
    case VehicleConfigurationSource::VEHICLE_SURFACE:
        // TODO: Implement settings for other vehicle types?
        break;
    default:
        break;
    }
}