/** * @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); }
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_config = new Ui_OutputWidget(); m_config->setupUi(this); ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>(); if(!settings->useExpertMode()) m_config->saveRCOutputToRAM->setVisible(false); /* There's lots of situations where it's unsafe to run tests. * Import/export: */ UAVSettingsImportExportFactory * importexportplugin = pm->getObject<UAVSettingsImportExportFactory>(); connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests())); /* Board connection/disconnection: */ TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(stopTests())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(stopTests())); /* When we go into wizards, etc.. time to stop this too. */ Core::ModeManager *modeMngr = Core::ModeManager::instance(); connect(modeMngr, SIGNAL(currentModeAboutToChange(Core::IMode *)), this, SLOT(stopTests())); connect(modeMngr, SIGNAL(currentModeChanged(Core::IMode *)), this, SLOT(stopTests())); // NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10. // Register for ActuatorSettings changes: for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) { OutputChannelForm *outputForm = new OutputChannelForm(i, this, i==0); m_config->channelLayout->addWidget(outputForm); connect(m_config->channelOutTest, SIGNAL(toggled(bool)), outputForm, SLOT(enableChannelTest(bool))); connect(outputForm, SIGNAL(channelChanged(int,int)), this, SLOT(sendChannelTest(int,int))); connect(outputForm, SIGNAL(formChanged()), this, SLOT(do_SetDirty())); } connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool))); connect(m_config->calibrateESC, SIGNAL(clicked()), this, SLOT(startESCCalibration())); // Configure the task widget // Connect the help button connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD); // Track the ActuatorSettings object addUAVObject("ActuatorSettings"); // Associate the buttons with their UAVO fields addWidget(m_config->cb_outputRate6); addWidget(m_config->cb_outputRate5); addWidget(m_config->cb_outputRate4); addWidget(m_config->cb_outputRate3); addWidget(m_config->cb_outputRate2); addWidget(m_config->cb_outputRate1); addWidget(m_config->spinningArmed); // Cache all the combo boxes and labels lblList.clear(); lblList << m_config->chBank1 << m_config->chBank2 << m_config->chBank3 << m_config->chBank4 << m_config->chBank5 << m_config->chBank6; rateList.clear(); rateList << m_config->cb_outputRate1 << m_config->cb_outputRate2 << m_config->cb_outputRate3 << m_config->cb_outputRate4 << m_config->cb_outputRate5 << m_config->cb_outputRate6; resList.clear(); resList << m_config->cb_outputResolution1 << m_config->cb_outputResolution2 << m_config->cb_outputResolution3 << m_config->cb_outputResolution4 << m_config->cb_outputResolution5 << m_config->cb_outputResolution6; // Get the list of output resolutions and assign to the resolution dropdowns ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager()); Q_ASSERT(actuatorSettings); UAVObjectField *resolutions = actuatorSettings->getField("TimerPwmResolution"); Q_ASSERT(resolutions); QList<QComboBox*>::iterator resIter; for (resIter = resList.begin(); resIter != resList.end(); resIter++) { QComboBox *res = *resIter; res->clear(); res->addItems(resolutions->getOptions()); addWidget(res); connect(res, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshWidgetRanges())); } QList<QComboBox*>::iterator rateIter; for (rateIter = rateList.begin(); rateIter != rateList.end(); rateIter++) { QComboBox *rate = *rateIter; connect(rate, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshWidgetRanges())); } disconnect(this, SLOT(refreshWidgetsValues(UAVObject*))); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); UAVObject* obj = objManager->getObject(QString("ActuatorCommand")); if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) this->setEnabled(false); connect(SystemSettings::GetInstance(objManager), SIGNAL(objectUpdated(UAVObject*)),this,SLOT(assignOutputChannels(UAVObject*))); refreshWidgetsValues(); }
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; } }
/** * Create a clone of this object, a new instance ID must be specified. * Do not use this function directly to create new instances, the * UAVObjectManager should be used instead. */ UAVDataObject* ActuatorSettings::clone(quint32 instID) { ActuatorSettings* obj = new ActuatorSettings(); obj->initialize(instID, this->getMetaObject()); return obj; }