mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-39 Finished up motor/servo calibration, actuator settings.
Bug fixes after initial testing end2end testing. I am making a note here: First successful 1-2-Fly! session ever!
This commit is contained in:
parent
3a38cb2cc1
commit
d337fcf1d8
@ -31,8 +31,6 @@
|
||||
#include "vehicleconfigurationhelper.h"
|
||||
#include "manualcontrolsettings.h"
|
||||
|
||||
const quint16 OutputCalibrationUtil::UPDATE_CHANNEL_MAPPING[10] = {0, 0, 0, 1, 2, 3, 2, 2, 3, 3};
|
||||
|
||||
OutputCalibrationUtil::OutputCalibrationUtil(QObject *parent) :
|
||||
QObject(parent), m_outputChannel(-1), m_safeValue(1000)
|
||||
{
|
||||
@ -46,44 +44,6 @@ OutputCalibrationUtil::~OutputCalibrationUtil()
|
||||
stopChannelOutput();
|
||||
}
|
||||
|
||||
void OutputCalibrationUtil::setupOutputRates(const QList<quint16> &outputRates)
|
||||
{
|
||||
//Set actuator settings for channels
|
||||
ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(m_uavObjectManager);
|
||||
Q_ASSERT(actuatorSettings);
|
||||
ActuatorSettings::DataFields aData = actuatorSettings->getData();
|
||||
|
||||
for(int i = 0; i < outputRates.size(); i++) {
|
||||
aData.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM;
|
||||
aData.ChannelAddr[i] = i;
|
||||
aData.ChannelMin[i] = 1000;
|
||||
aData.ChannelNeutral[i] = 1000;
|
||||
aData.ChannelMax[i] = 2000;
|
||||
aData.ChannelUpdateFreq[UPDATE_CHANNEL_MAPPING[i]] = outputRates[i];
|
||||
}
|
||||
|
||||
actuatorSettings->setData(aData);
|
||||
actuatorSettings->updated();
|
||||
|
||||
ManualControlSettings *manualControlSettings = ManualControlSettings::GetInstance(m_uavObjectManager);
|
||||
Q_ASSERT(manualControlSettings);
|
||||
ManualControlSettings::DataFields cData = manualControlSettings->getData();
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_THROTTLE] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_ROLL] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_YAW] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_PITCH] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_THROTTLE] = 1;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_ROLL] = 2;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_YAW] = 3;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_PITCH] = 4;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = 5;
|
||||
|
||||
manualControlSettings->setData(cData);
|
||||
manualControlSettings->updated();
|
||||
}
|
||||
|
||||
void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValue)
|
||||
{
|
||||
if(m_outputChannel < 0 && channel >= 0 && channel < ActuatorCommand::CHANNEL_NUMELEM)
|
||||
|
@ -46,15 +46,12 @@ public:
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setupOutputRates(const QList<quint16> &outputRates);
|
||||
void startChannelOutput(quint16 channel, quint16 safeValue);
|
||||
void stopChannelOutput();
|
||||
|
||||
void setChannelOutputValue(quint16 value);
|
||||
|
||||
private:
|
||||
static const quint16 UPDATE_CHANNEL_MAPPING[10];
|
||||
actuatorSettings *m_actuatorSettings;
|
||||
qint16 m_outputChannel;
|
||||
quint16 m_safeValue;
|
||||
UAVObject::Metadata m_savedActuatorCommandMetadata;
|
||||
|
@ -64,6 +64,7 @@ void LevellingPage::enableButtons(bool enable)
|
||||
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void LevellingPage::performLevelling()
|
||||
|
@ -57,57 +57,53 @@ OutputCalibrationPage::~OutputCalibrationPage()
|
||||
|
||||
void OutputCalibrationPage::setupVehicle()
|
||||
{
|
||||
m_actuatorSettings = getWizard()->getActuatorSettings();
|
||||
m_wizardIndexes.clear();
|
||||
m_vehicleElementIds.clear();
|
||||
m_vehicleHighlightElementIndexes.clear();
|
||||
m_channelIndex.clear();
|
||||
m_currentWizardIndex = 0;
|
||||
m_vehicleScene->clear();
|
||||
m_channelUpdateRates.clear();
|
||||
quint16 escUpdateRate = getEscUpdateRate();
|
||||
quint16 servoUpdateRate = getServoUpdateRate();
|
||||
switch(getWizard()->getVehicleSubType())
|
||||
{
|
||||
case SetupWizard::MULTI_ROTOR_TRI_Y:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 3 << 4;
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 3 << 4 << 5;
|
||||
m_vehicleElementIds << "tri" << "tri-frame" << "tri-m1" << "tri-m2" << "tri-m3" << "tri-s1";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << servoUpdateRate;
|
||||
m_actuatorSettings.channels[4].channelMin = 1500;
|
||||
m_actuatorSettings.channels[4].channelMax = 1500;
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 4;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 3;
|
||||
m_actuatorSettings[4].channelMin = 1500;
|
||||
m_actuatorSettings[4].channelMax = 1500;
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_X:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2;
|
||||
m_vehicleElementIds << "quad-x" << "quad-x-frame" << "quad-x-m1" << "quad-x-m2" << "quad-x-m3" << "quad-x-m4";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3;
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_QUAD_PLUS:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2;
|
||||
m_vehicleElementIds << "quad-p" << "quad-p-frame" << "quad-p-m1" << "quad-p-m2" << "quad-p-m3" << "quad-p-m4";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3;
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_HEXA:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2;
|
||||
m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4"
|
||||
<< "hexa-m5" << "hexa-m6";
|
||||
m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4" << "hexa-m5" << "hexa-m6";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5;
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2;
|
||||
m_vehicleElementIds << "hexa-y6" << "hexa-y6-frame" << "hexa-y6-m2" << "hexa-y6-m1" << "hexa-y6-m4" << "hexa-y6-m3"
|
||||
<< "hexa-y6-m6" << "hexa-y6-m5";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate;
|
||||
m_vehicleElementIds << "hexa-y6" << "hexa-y6-frame" << "hexa-y6-m2" << "hexa-y6-m1" << "hexa-y6-m4" << "hexa-y6-m3" << "hexa-y6-m6" << "hexa-y6-m5";
|
||||
m_vehicleHighlightElementIndexes << 0 << 2 << 2 << 1 << 1 << 4 << 4 << 3 << 3 << 6 << 6 << 5 << 5;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5;
|
||||
break;
|
||||
case SetupWizard::MULTI_ROTOR_HEXA_H:
|
||||
m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2;
|
||||
m_vehicleElementIds << "hexa-h" << "hexa-h-frame" << "hexa-h-m1" << "hexa-h-m2" << "hexa-h-m3" << "hexa-h-m4"
|
||||
<< "hexa-h-m5" << "hexa-h-m6";
|
||||
m_vehicleElementIds << "hexa-h" << "hexa-h-frame" << "hexa-h-m1" << "hexa-h-m2" << "hexa-h-m3" << "hexa-h-m4" << "hexa-h-m5" << "hexa-h-m6";
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6;
|
||||
m_channelUpdateRates << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate << escUpdateRate;
|
||||
break;
|
||||
m_channelIndex << 0 << 0 << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -120,7 +116,6 @@ void OutputCalibrationPage::setupVehicle()
|
||||
m_calibrationUtil = 0;
|
||||
}
|
||||
m_calibrationUtil = new OutputCalibrationUtil();
|
||||
m_calibrationUtil->setupOutputRates(m_channelUpdateRates);
|
||||
|
||||
setupVehicleItems();
|
||||
}
|
||||
@ -172,28 +167,38 @@ void OutputCalibrationPage::setupVehicleHighlightedPart()
|
||||
|
||||
void OutputCalibrationPage::setWizardPage()
|
||||
{
|
||||
qDebug() << "Wizard index: " << m_currentWizardIndex;
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
ui->backPageButton->setEnabled(m_currentWizardIndex > 0);
|
||||
ui->nextPageButton->setEnabled(m_currentWizardIndex < m_wizardIndexes.size() - 1);
|
||||
int currentPageIndex = m_wizardIndexes.at(m_currentWizardIndex);
|
||||
|
||||
QApplication::processEvents();
|
||||
|
||||
int currentPageIndex = m_wizardIndexes[m_currentWizardIndex];
|
||||
qDebug() << "Current page: " << currentPageIndex;
|
||||
ui->calibrationStack->setCurrentIndex(currentPageIndex);
|
||||
|
||||
int currentChannel = getCurrentChannel();
|
||||
qDebug() << "Current channel: " << currentChannel;
|
||||
if(currentChannel >= 0) {
|
||||
if(currentPageIndex == 1) {
|
||||
ui->motorNeutralSlider->setValue(m_actuatorSettings.channels[currentChannel].channelNeutral);
|
||||
ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
|
||||
}
|
||||
else if (currentPageIndex == 2) {
|
||||
ui->motorMaxSlider->setValue(m_actuatorSettings.channels[currentChannel].channelMax);
|
||||
ui->motorMaxSlider->setValue(m_actuatorSettings[currentChannel].channelMax);
|
||||
}
|
||||
else if(currentPageIndex == 3) {
|
||||
ui->servoCenterSlider->setValue(m_actuatorSettings.channels[currentChannel].channelNeutral);
|
||||
ui->servoCenterSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
|
||||
}
|
||||
else if(currentPageIndex == 4) {
|
||||
ui->servoMinAngleSlider->setValue(m_actuatorSettings.channels[currentChannel].channelMin);
|
||||
ui->servoMaxAngleSlider->setValue(m_actuatorSettings.channels[currentChannel].channelMax);
|
||||
ui->servoMinAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMin);
|
||||
}
|
||||
else if(currentPageIndex == 5) {
|
||||
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMax);
|
||||
}
|
||||
}
|
||||
setupVehicleHighlightedPart();
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::initializePage()
|
||||
@ -204,6 +209,12 @@ void OutputCalibrationPage::initializePage()
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputCalibrationPage::validatePage()
|
||||
{
|
||||
getWizard()->setActuatorSettings(m_actuatorSettings);
|
||||
return true;
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
@ -215,19 +226,23 @@ void OutputCalibrationPage::showEvent(QShowEvent *event)
|
||||
|
||||
void OutputCalibrationPage::on_nextPageButton_clicked()
|
||||
{
|
||||
m_currentWizardIndex++;
|
||||
setWizardPage();
|
||||
if(m_currentWizardIndex < m_wizardIndexes.size() - 1) {
|
||||
m_currentWizardIndex++;
|
||||
setWizardPage();
|
||||
}
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_backPageButton_clicked()
|
||||
{
|
||||
m_currentWizardIndex--;
|
||||
setWizardPage();
|
||||
if(m_currentWizardIndex > 0) {
|
||||
m_currentWizardIndex--;
|
||||
setWizardPage();
|
||||
}
|
||||
}
|
||||
|
||||
quint16 OutputCalibrationPage::getCurrentChannel()
|
||||
{
|
||||
return m_vehicleHighlightElementIndexes[m_currentWizardIndex] - 1;
|
||||
return m_channelIndex[m_currentWizardIndex];
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::enableButtons(bool enable)
|
||||
@ -237,13 +252,14 @@ void OutputCalibrationPage::enableButtons(bool enable)
|
||||
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked)
|
||||
{
|
||||
ui->motorNeutralButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
quint16 channel = getCurrentChannel();
|
||||
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings.channels[channel].channelNeutral, 1000, ui->motorNeutralSlider);
|
||||
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, 1000, ui->motorNeutralSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider) {
|
||||
@ -252,7 +268,7 @@ void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16
|
||||
enableButtons(false);
|
||||
m_calibrationUtil->startChannelOutput(channel, safeValue);
|
||||
slider->setValue(value);
|
||||
//m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
}
|
||||
else {
|
||||
button->setChecked(false);
|
||||
@ -269,10 +285,11 @@ bool OutputCalibrationPage::checkAlarms()
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *uavObjectManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(uavObjectManager);
|
||||
SystemAlarms * systemAlarmsObj = SystemAlarms::GetInstance(uavObjectManager);
|
||||
SystemAlarms::DataFields systemAlarms = systemAlarmsObj->getData();
|
||||
SystemAlarms * systemAlarms = SystemAlarms::GetInstance(uavObjectManager);
|
||||
Q_ASSERT(systemAlarms);
|
||||
SystemAlarms::DataFields data = systemAlarms->getData();
|
||||
|
||||
if(systemAlarms.Alarm[SystemAlarms::ALARM_ACTUATOR] != SystemAlarms::ALARM_OK) {
|
||||
if(data.Alarm[SystemAlarms::ALARM_ACTUATOR] != SystemAlarms::ALARM_OK) {
|
||||
QMessageBox mbox;
|
||||
mbox.setText(QString(tr("The actuator module is in an error state.\n\n"
|
||||
"This error can be caused by not having the board correctly connected or\n"
|
||||
@ -293,7 +310,7 @@ void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
|
||||
if(ui->motorNeutralButton->isChecked()) {
|
||||
quint16 value = ui->motorNeutralSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings.channels[getCurrentChannel()].channelNeutral = value;
|
||||
m_actuatorSettings[getCurrentChannel()].channelNeutral = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +318,7 @@ void OutputCalibrationPage::on_motorMaxButton_toggled(bool checked)
|
||||
{
|
||||
ui->motorNeutralButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
quint16 channel = getCurrentChannel();
|
||||
onStartButtonToggle(ui->motorMaxButton, channel, m_actuatorSettings.channels[channel].channelMax, 1000, ui->motorMaxSlider);
|
||||
onStartButtonToggle(ui->motorMaxButton, channel, m_actuatorSettings[channel].channelMax, 1000, ui->motorMaxSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_motorMaxSlider_valueChanged(int position)
|
||||
@ -309,7 +326,7 @@ void OutputCalibrationPage::on_motorMaxSlider_valueChanged(int position)
|
||||
if(ui->motorMaxButton->isChecked()) {
|
||||
quint16 value = ui->motorMaxSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings.channels[getCurrentChannel()].channelMax = value;
|
||||
m_actuatorSettings[getCurrentChannel()].channelMax = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,8 +334,8 @@ void OutputCalibrationPage::on_servoCenterButton_toggled(bool checked)
|
||||
{
|
||||
ui->servoCenterButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
quint16 channel = getCurrentChannel();
|
||||
m_actuatorSettings.channels[channel].channelNeutral = 1500;
|
||||
onStartButtonToggle(ui->servoCenterButton, channel, m_actuatorSettings.channels[channel].channelNeutral, 1500, ui->servoCenterSlider);
|
||||
m_actuatorSettings[channel].channelNeutral = 1500;
|
||||
onStartButtonToggle(ui->servoCenterButton, channel, m_actuatorSettings[channel].channelNeutral, 1500, ui->servoCenterSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoCenterSlider_valueChanged(int position)
|
||||
@ -326,48 +343,34 @@ void OutputCalibrationPage::on_servoCenterSlider_valueChanged(int position)
|
||||
if(ui->servoCenterButton->isChecked()) {
|
||||
quint16 value = ui->servoCenterSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings.channels[getCurrentChannel()].channelNeutral = value;
|
||||
m_actuatorSettings[getCurrentChannel()].channelNeutral = value;
|
||||
}
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoAngleButton_toggled(bool checked)
|
||||
void OutputCalibrationPage::on_servoMinAngleButton_toggled(bool checked)
|
||||
{
|
||||
ui->servoAngleButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
ui->servoMinAngleButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
quint16 channel = getCurrentChannel();
|
||||
ui->servoMinAngleSlider->setValue(m_actuatorSettings.channels[channel].channelMax);
|
||||
onStartButtonToggle(ui->servoAngleButton, channel, m_actuatorSettings.channels[channel].channelMin, 1500, ui->servoMinAngleSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position)
|
||||
{
|
||||
if(ui->servoAngleButton->isChecked()) {
|
||||
quint16 value = ui->servoMaxAngleSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings.channels[getCurrentChannel()].channelMax = value;
|
||||
}
|
||||
onStartButtonToggle(ui->servoMinAngleButton, channel, m_actuatorSettings[channel].channelMin, 1500, ui->servoMinAngleSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoMinAngleSlider_valueChanged(int position)
|
||||
{
|
||||
if(ui->servoAngleButton->isChecked()) {
|
||||
quint16 value = ui->servoMinAngleSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings.channels[getCurrentChannel()].channelMin = value;
|
||||
}
|
||||
quint16 value = ui->servoMinAngleSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings[getCurrentChannel()].channelMin = value;
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoMaxAngleSliderRB_toggled(bool checked)
|
||||
void OutputCalibrationPage::on_servoMaxAngleButton_toggled(bool checked)
|
||||
{
|
||||
if(ui->servoAngleButton->isChecked() && ui->servoMaxAngleSliderRB->isChecked())
|
||||
{
|
||||
m_calibrationUtil->setChannelOutputValue(ui->servoMaxAngleSlider->value());
|
||||
}
|
||||
ui->servoMaxAngleButton->setText(checked ? tr("Stop") : tr("Start"));
|
||||
quint16 channel = getCurrentChannel();
|
||||
onStartButtonToggle(ui->servoMaxAngleButton, channel, m_actuatorSettings[channel].channelMax, 1500, ui->servoMaxAngleSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_servoMinAngleSliderRB_toggled(bool checked)
|
||||
void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position)
|
||||
{
|
||||
if(ui->servoAngleButton->isChecked() && ui->servoMinAngleSliderRB->isChecked())
|
||||
{
|
||||
m_calibrationUtil->setChannelOutputValue(ui->servoMinAngleSlider->value());
|
||||
}
|
||||
quint16 value = ui->servoMaxAngleSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
m_actuatorSettings[getCurrentChannel()].channelMax = value;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
explicit OutputCalibrationPage(SetupWizard *wizard, QWidget *parent = 0);
|
||||
~OutputCalibrationPage();
|
||||
void initializePage();
|
||||
bool validatePage();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
@ -63,13 +64,11 @@ private slots:
|
||||
void on_servoCenterButton_toggled(bool checked);
|
||||
void on_servoCenterSlider_valueChanged(int position);
|
||||
|
||||
void on_servoAngleButton_toggled(bool checked);
|
||||
void on_servoMaxAngleSlider_valueChanged(int position);
|
||||
void on_servoMinAngleButton_toggled(bool checked);
|
||||
void on_servoMinAngleSlider_valueChanged(int position);
|
||||
|
||||
void on_servoMaxAngleSliderRB_toggled(bool checked);
|
||||
|
||||
void on_servoMinAngleSliderRB_toggled(bool checked);
|
||||
void on_servoMaxAngleButton_toggled(bool checked);
|
||||
void on_servoMaxAngleSlider_valueChanged(int position);
|
||||
|
||||
private:
|
||||
void setupVehicle();
|
||||
@ -82,11 +81,6 @@ private:
|
||||
bool checkAlarms();
|
||||
quint16 getCurrentChannel();
|
||||
|
||||
quint16 getEscUpdateRate(){ return getWizard()->getESCType() == VehicleConfigurationSource::ESC_RAPID ?
|
||||
VehicleConfigurationHelper::RAPID_ESC_FREQUENCE : VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE; }
|
||||
|
||||
quint16 getServoUpdateRate(){ return VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE; }
|
||||
|
||||
Ui::OutputCalibrationPage *ui;
|
||||
QSvgRenderer *m_vehicleRenderer;
|
||||
QGraphicsScene *m_vehicleScene;
|
||||
@ -97,10 +91,10 @@ private:
|
||||
QList<QString> m_vehicleElementIds;
|
||||
QList<QGraphicsSvgItem*> m_vehicleItems;
|
||||
QList<quint16> m_vehicleHighlightElementIndexes;
|
||||
QList<quint16> m_channelIndex;
|
||||
QList<quint16> m_wizardIndexes;
|
||||
QList<quint16> m_channelUpdateRates;
|
||||
|
||||
actuatorSettings m_actuatorSettings;
|
||||
QList<actuatorChannelSettings> m_actuatorSettings;
|
||||
|
||||
OutputCalibrationUtil *m_calibrationUtil;
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="intro">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@ -306,7 +306,7 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="servoMinMax">
|
||||
<widget class="QPushButton" name="servoAngleButton">
|
||||
<widget class="QPushButton" name="servoMinAngleButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
@ -335,7 +335,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>To save the servo and other hardware from damage we have to set the max and min angles for the servo. </p><p>To set the extreme angles for the servo, press the Start button below and select the top slider and slide it to the right until max angle is reached. Then select the lower slider and slide it left until the minimum angle is set.</p><p>When done press button again to stop.</p></body></html></string>
|
||||
<string><html><head/><body><p>To save the servo and other hardware from damage we have to set the max and min angles for the servo. </p><p>To set the minimum angle for the servo, press the Start button below and select the top slider and slide it to the left until min angle is reached.</p><p>When done press button again to stop.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
@ -344,133 +344,137 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="sliderWidget" native="true">
|
||||
<widget class="QSlider" name="servoMinAngleSlider">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>200</y>
|
||||
<width>241</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page">
|
||||
<widget class="QPushButton" name="servoMaxAngleButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>240</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="servoMaxAngleSlider">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>200</y>
|
||||
<width>241</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>160</y>
|
||||
<y>10</y>
|
||||
<width>261</width>
|
||||
<height>80</height>
|
||||
<height>151</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="servoMinAngleSliderRB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>16</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="servoMaxAngleSliderRB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>0</y>
|
||||
<width>16</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="servoMaxAngleSlider">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>39</x>
|
||||
<y>0</y>
|
||||
<width>211</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="servoMinAngleSlider">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>39</x>
|
||||
<y>40</y>
|
||||
<width>211</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
</property>
|
||||
<property name="tracking">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>To set the maximum angle for the servo, press the Start button below and select the top slider and slide it to the right until max angle is reached.</p><p>When done press button again to stop.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -529,38 +533,6 @@
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>servoMaxAngleSliderRB</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>servoMaxAngleSlider</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>37</x>
|
||||
<y>208</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>164</x>
|
||||
<y>209</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>servoMinAngleSliderRB</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>servoMinAngleSlider</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>37</x>
|
||||
<y>248</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>164</x>
|
||||
<y>249</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>motorNeutralButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
@ -610,9 +582,9 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>servoAngleButton</sender>
|
||||
<sender>servoMaxAngleButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>sliderWidget</receiver>
|
||||
<receiver>servoMaxAngleSlider</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -621,7 +593,23 @@
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>150</x>
|
||||
<y>239</y>
|
||||
<y>249</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>servoMinAngleButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>servoMinAngleSlider</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>147</x>
|
||||
<y>291</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>150</x>
|
||||
<y>249</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "pages/notyetimplementedpage.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "vehicleconfigurationhelper.h"
|
||||
#include "actuatorsettings.h"
|
||||
|
||||
SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent), VehicleConfigurationSource(),
|
||||
m_controllerType(CONTROLLER_UNKNOWN),
|
||||
@ -52,6 +53,10 @@ SetupWizard::SetupWizard(QWidget *parent) : QWizard(parent), VehicleConfiguratio
|
||||
setWindowTitle(tr("OpenPilot Setup Wizard"));
|
||||
setOption(QWizard::IndependentPages, false);
|
||||
setFixedSize(640, 530);
|
||||
for(int i = 0; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++)
|
||||
{
|
||||
m_actuatorSettings << actuatorChannelSettings();
|
||||
}
|
||||
createPages();
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,9 @@ public:
|
||||
bool isLevellingPerformed() const { return m_levellingPerformed; }
|
||||
accelGyroBias getLevellingBias() const { return m_levellingBias; }
|
||||
|
||||
void setActuatorSettings(actuatorSettings neutralSettings) { m_actuatorNeutralConfig = neutralSettings; }
|
||||
void setActuatorSettings(QList<actuatorChannelSettings> actuatorSettings) { m_actuatorSettings = actuatorSettings; }
|
||||
bool isMotorCalibrationPerformed() const { return m_motorCalibrationPerformed; }
|
||||
actuatorSettings getActuatorSettings() const { return m_actuatorNeutralConfig; }
|
||||
QList<actuatorChannelSettings> getActuatorSettings() const { return m_actuatorSettings; }
|
||||
|
||||
QString getSummaryText();
|
||||
|
||||
@ -93,7 +93,7 @@ private:
|
||||
accelGyroBias m_levellingBias;
|
||||
|
||||
bool m_motorCalibrationPerformed;
|
||||
actuatorSettings m_actuatorNeutralConfig;
|
||||
QList<actuatorChannelSettings> m_actuatorSettings;
|
||||
|
||||
Core::ConnectionManager *m_connectionManager;
|
||||
};
|
||||
|
@ -52,14 +52,12 @@ VehicleConfigurationHelper::VehicleConfigurationHelper(VehicleConfigurationSourc
|
||||
bool VehicleConfigurationHelper::setupVehicle(bool save)
|
||||
{
|
||||
m_progress = 0;
|
||||
if(save) {
|
||||
clearModifiedObjects();
|
||||
resetVehicleConfig();
|
||||
resetGUIData();
|
||||
if(!saveChangesToController())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
clearModifiedObjects();
|
||||
resetVehicleConfig();
|
||||
resetGUIData();
|
||||
if(!saveChangesToController(save))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
applyHardwareConfiguration();
|
||||
@ -68,18 +66,16 @@ bool VehicleConfigurationHelper::setupVehicle(bool save)
|
||||
applyFlighModeConfiguration();
|
||||
applyLevellingConfiguration();
|
||||
applyStabilizationConfiguration();
|
||||
applyManualControlDefaults();
|
||||
|
||||
if(save) {
|
||||
bool result = saveChangesToController();
|
||||
if(result) {
|
||||
emit saveProgress(PROGRESS_STEPS, ++m_progress, tr("Done!"));
|
||||
}
|
||||
else {
|
||||
emit saveProgress(PROGRESS_STEPS, ++m_progress, tr("Failed!"));
|
||||
}
|
||||
return result;
|
||||
bool result = saveChangesToController(save);
|
||||
if(result) {
|
||||
emit saveProgress(PROGRESS_STEPS, ++m_progress, tr("Done!"));
|
||||
}
|
||||
return true;
|
||||
else {
|
||||
emit saveProgress(PROGRESS_STEPS, ++m_progress, tr("Failed!"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void VehicleConfigurationHelper::addModifiedObject(UAVDataObject *object, QString description)
|
||||
@ -189,13 +185,13 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
|
||||
case VehicleConfigurationSource::VEHICLE_MULTI: {
|
||||
ActuatorSettings::DataFields data = actSettings->getData();
|
||||
|
||||
actuatorSettings actuatorSettings = m_configSource->getActuatorSettings();
|
||||
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.channels[i].channelMin;
|
||||
data.ChannelNeutral[i] = actuatorSettings.channels[i].channelNeutral;
|
||||
data.ChannelMax[i] = actuatorSettings.channels[i].channelMax;
|
||||
data.ChannelMin[i] = actuatorSettings[i].channelMin;
|
||||
data.ChannelNeutral[i] = actuatorSettings[i].channelNeutral;
|
||||
data.ChannelMax[i] = actuatorSettings[i].channelMax;
|
||||
}
|
||||
|
||||
data.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
|
||||
@ -241,7 +237,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration()
|
||||
break;
|
||||
}
|
||||
actSettings->setData(data);
|
||||
addModifiedObject(actSettings, tr("Writing output rate settings"));
|
||||
addModifiedObject(actSettings, tr("Writing actuator settings"));
|
||||
break;
|
||||
}
|
||||
case VehicleConfigurationSource::VEHICLE_FIXEDWING:
|
||||
@ -336,7 +332,7 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerSettings mixer)
|
||||
}
|
||||
|
||||
// Apply updates
|
||||
//mSettings->setData(mSettings->getData());
|
||||
mSettings->setData(mSettings->getData());
|
||||
addModifiedObject(mSettings, tr("Writing mixer settings"));
|
||||
|
||||
}
|
||||
@ -356,7 +352,28 @@ void VehicleConfigurationHelper::applyMultiGUISettings(SystemSettings::AirframeT
|
||||
addModifiedObject(sSettings, tr("Writing vehicle settings"));
|
||||
}
|
||||
|
||||
bool VehicleConfigurationHelper::saveChangesToController()
|
||||
void VehicleConfigurationHelper::applyManualControlDefaults()
|
||||
{
|
||||
ManualControlSettings *mcSettings = ManualControlSettings::GetInstance(m_uavoManager);
|
||||
Q_ASSERT(mcSettings);
|
||||
ManualControlSettings::DataFields cData = mcSettings->getData();
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_THROTTLE] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_ROLL] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_YAW] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_PITCH] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = ManualControlSettings::CHANNELGROUPS_PWM;
|
||||
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_THROTTLE] = 1;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_ROLL] = 2;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_YAW] = 3;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_PITCH] = 4;
|
||||
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = 5;
|
||||
|
||||
mcSettings->setData(cData);
|
||||
addModifiedObject(mcSettings, tr("Writing manual control defaults"));
|
||||
}
|
||||
|
||||
bool VehicleConfigurationHelper::saveChangesToController(bool save)
|
||||
{
|
||||
qDebug() << "Saving modified objects to controller. " << m_modifiedObjects.count() << " objects in found.";
|
||||
const int OUTER_TIMEOUT = 3000 * 20; // 10 seconds timeout for saving all objects
|
||||
@ -404,21 +421,23 @@ bool VehicleConfigurationHelper::saveChangesToController()
|
||||
disconnect(obj, SIGNAL(transactionCompleted(UAVObject* ,bool)), this, SLOT(uAVOTransactionCompleted(UAVObject*, bool)));
|
||||
if(m_transactionOK) {
|
||||
qDebug() << "Object " << obj->getName() << " was successfully updated.";
|
||||
m_transactionOK = false;
|
||||
m_currentTransactionObjectID = obj->getObjID();
|
||||
// Try to save until success or timeout
|
||||
while(!m_transactionOK && !m_transactionTimeout) {
|
||||
// Allow the transaction to take some time
|
||||
innerTimeoutTimer.start(INNER_TIMEOUT);
|
||||
if(save) {
|
||||
m_transactionOK = false;
|
||||
m_currentTransactionObjectID = obj->getObjID();
|
||||
// Try to save until success or timeout
|
||||
while(!m_transactionOK && !m_transactionTimeout) {
|
||||
// Allow the transaction to take some time
|
||||
innerTimeoutTimer.start(INNER_TIMEOUT);
|
||||
|
||||
// Persist object in controller
|
||||
utilMngr->saveObjectToSD(obj);
|
||||
if(!m_transactionOK) {
|
||||
m_eventLoop.exec();
|
||||
// Persist object in controller
|
||||
utilMngr->saveObjectToSD(obj);
|
||||
if(!m_transactionOK) {
|
||||
m_eventLoop.exec();
|
||||
}
|
||||
innerTimeoutTimer.stop();
|
||||
}
|
||||
innerTimeoutTimer.stop();
|
||||
m_currentTransactionObjectID = -1;
|
||||
}
|
||||
m_currentTransactionObjectID = -1;
|
||||
}
|
||||
|
||||
if(!m_transactionOK) {
|
||||
@ -665,8 +684,8 @@ void VehicleConfigurationHelper::setupQuadCopter()
|
||||
|
||||
guiSettings.multi.VTOLMotorNW = 1;
|
||||
guiSettings.multi.VTOLMotorNE = 2;
|
||||
guiSettings.multi.VTOLMotorSW = 3;
|
||||
guiSettings.multi.VTOLMotorSE = 4;
|
||||
guiSettings.multi.VTOLMotorSE = 3;
|
||||
guiSettings.multi.VTOLMotorSW = 4;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -68,16 +68,11 @@ signals:
|
||||
void saveProgress(int total, int current, QString description);
|
||||
|
||||
private:
|
||||
|
||||
static const qint16 ACTUATOR_MIN = 1000;
|
||||
static const qint16 ACTUATOR_NEUTRAL = 1000;
|
||||
static const qint16 ACTUATOR_MAX = 2000;
|
||||
|
||||
static const int MIXER_TYPE_DISABLED = 0;
|
||||
static const int MIXER_TYPE_MOTOR = 1;
|
||||
static const int MIXER_TYPE_SERVO = 2;
|
||||
|
||||
static const int PROGRESS_STEPS = 10;
|
||||
static const int PROGRESS_STEPS = 11;
|
||||
|
||||
VehicleConfigurationSource *m_configSource;
|
||||
UAVObjectManager *m_uavoManager;
|
||||
@ -92,13 +87,14 @@ private:
|
||||
void applyFlighModeConfiguration();
|
||||
void applyLevellingConfiguration();
|
||||
void applyStabilizationConfiguration();
|
||||
void applyManualControlDefaults();
|
||||
|
||||
void applyMixerConfiguration(mixerSettings mixer);
|
||||
|
||||
GUIConfigDataUnion getGUIConfigData();
|
||||
void applyMultiGUISettings(SystemSettings::AirframeTypeOptions airframe, GUIConfigDataUnion guiConfig);
|
||||
|
||||
bool saveChangesToController();
|
||||
bool saveChangesToController(bool save);
|
||||
QEventLoop m_eventLoop;
|
||||
bool m_transactionOK;
|
||||
bool m_transactionTimeout;
|
||||
|
@ -50,9 +50,6 @@ struct actuatorChannelSettings {
|
||||
actuatorChannelSettings(): channelMin(1000), channelNeutral(1080), channelMax(1800) {}
|
||||
};
|
||||
|
||||
struct actuatorSettings {
|
||||
actuatorChannelSettings channels[ActuatorSettings::CHANNELADDR_NUMELEM];
|
||||
};
|
||||
|
||||
class VehicleConfigurationSource
|
||||
{
|
||||
@ -78,7 +75,7 @@ public:
|
||||
virtual accelGyroBias getLevellingBias() const = 0;
|
||||
|
||||
virtual bool isMotorCalibrationPerformed() const = 0;
|
||||
virtual actuatorSettings getActuatorSettings() const = 0;
|
||||
virtual QList<actuatorChannelSettings> getActuatorSettings() const = 0;
|
||||
|
||||
virtual QString getSummaryText() = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user