1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

Merge branch 'thread/OP-1756_Multi_Motor_Calibration' into next

This commit is contained in:
m_thread 2015-03-06 00:22:31 +01:00
commit 6fb19b99cb
7 changed files with 200 additions and 65 deletions

View File

@ -168,7 +168,7 @@ void ConnectionDiagram::setupGraphicsScene()
case VehicleConfigurationSource::CONTROLLER_CC3D:
prefix = "cc-";
if (m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT ||
m_configSource->getEscType() == VehicleConfigurationSource::ESC_RAPID) {
m_configSource->getEscType() == VehicleConfigurationSource::ESC_RAPID) {
suffix = "-oneshot";
}
break;

View File

@ -100,7 +100,7 @@ void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValu
startChannelOutput(channels, safeValue);
}
void OutputCalibrationUtil::startChannelOutput(QList<quint16> channels, quint16 safeValue)
void OutputCalibrationUtil::startChannelOutput(QList<quint16> &channels, quint16 safeValue)
{
if (c_prepared) {
m_outputChannels = channels;

View File

@ -44,7 +44,7 @@ public:
public slots:
void startChannelOutput(quint16 channel, quint16 safeValue);
void startChannelOutput(QList<quint16> channels, quint16 safeValue);
void startChannelOutput(QList<quint16> &channels, quint16 safeValue);
void stopChannelOutput();
void setChannelOutputValue(quint16 value);

View File

@ -44,7 +44,7 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren
m_vehicleRenderer = new QSvgRenderer();
// move the code that was here to setupVehicle() so we can determine which image to use.
m_vehicleScene = new QGraphicsScene(this);
m_vehicleScene = new QGraphicsScene(this);
ui->vehicleView->setScene(m_vehicleScene);
}
@ -112,6 +112,7 @@ void OutputCalibrationPage::setupVehicle()
m_actuatorSettings = getWizard()->getActuatorSettings();
m_wizardIndexes.clear();
m_vehicleElementIds.clear();
m_vehicleElementTypes.clear();
m_vehicleHighlightElementIndexes.clear();
m_channelIndex.clear();
m_currentWizardIndex = 0;
@ -131,6 +132,9 @@ void OutputCalibrationPage::setupVehicle()
// All element ids to load from the svg file and manage.
m_vehicleElementIds << "tri" << "tri-frame" << "tri-m1" << "tri-m2" << "tri-m3" << "tri-s1";
// The type of each element.
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << SERVO;
// The index of the elementId to highlight ( not dim ) for each step
// this is the index in the m_vehicleElementIds - 1.
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4;
@ -146,6 +150,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1;
m_vehicleElementIds << "quad-x" << "quad-x-frame" << "quad-x-m1" << "quad-x-m2" << "quad-x-m3" << "quad-x-m4";
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4;
m_channelIndex << 0 << 0 << 1 << 2 << 3;
setupActuatorMinMaxAndNeutral(0, 3, 4);
@ -154,6 +159,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1;
m_vehicleElementIds << "quad-p" << "quad-p-frame" << "quad-p-m1" << "quad-p-m2" << "quad-p-m3" << "quad-p-m4";
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4;
m_channelIndex << 0 << 0 << 1 << 2 << 3;
setupActuatorMinMaxAndNeutral(0, 3, 4);
@ -162,6 +168,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4" << "hexa-m5" << "hexa-m6";
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
setupActuatorMinMaxAndNeutral(0, 5, 6);
@ -170,6 +177,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
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_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 2 << 1 << 4 << 3 << 6 << 5;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
setupActuatorMinMaxAndNeutral(0, 5, 6);
@ -178,6 +186,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
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_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
setupActuatorMinMaxAndNeutral(0, 5, 6);
@ -186,6 +195,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(MULTI_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1;
m_vehicleElementIds << "hexa-x" << "hexa-x-frame" << "hexa-x-m1" << "hexa-x-m2" << "hexa-x-m3" << "hexa-x-m4" << "hexa-x-m5" << "hexa-x-m6";
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6;
m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5;
setupActuatorMinMaxAndNeutral(0, 5, 6);
@ -195,6 +205,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(FIXEDWING_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2 << 2 << 2 << 2;
m_vehicleElementIds << "aileron" << "aileron-frame" << "aileron-motor" << "aileron-ail-left" << "aileron-ail-right" << "aileron-elevator" << "aileron-rudder";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO << SERVO << SERVO << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5;
m_channelIndex << 0 << 2 << 0 << 5 << 1 << 3;
@ -206,6 +217,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(FIXEDWING_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2 << 2 << 2;
m_vehicleElementIds << "aileron-single" << "ail2-frame" << "ail2-motor" << "ail2-aileron" << "ail2-elevator" << "ail2-rudder";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO << SERVO << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4;
m_channelIndex << 0 << 2 << 0 << 1 << 3;
@ -217,6 +229,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(FIXEDWING_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2 << 2;
m_vehicleElementIds << "elevon" << "elevon-frame" << "elevon-motor" << "elevon-left" << "elevon-right";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3;
m_channelIndex << 0 << 2 << 0 << 1;
@ -228,6 +241,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(FIXEDWING_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2 << 2 << 2 << 2;
m_vehicleElementIds << "vtail" << "vtail-frame" << "vtail-motor" << "vtail-ail-left" << "vtail-ail-right" << "vtail-rudder-left" << "vtail-rudder-right";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO << SERVO << SERVO << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5;
m_channelIndex << 0 << 2 << 0 << 5 << 3 << 1;
@ -241,6 +255,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(GROUND_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2;
m_vehicleElementIds << "car" << "car-frame" << "car-motor" << "car-steering";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2;
m_channelIndex << 0 << 1 << 0;
@ -252,6 +267,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(GROUND_SVG_FILE);
m_wizardIndexes << 0 << 1 << 1;
m_vehicleElementIds << "tank" << "tank-frame" << "tank-left-motor" << "tank-right-motor";
m_vehicleElementTypes << FULL << FRAME << MOTOR << MOTOR;
m_vehicleHighlightElementIndexes << 0 << 1 << 2;
m_channelIndex << 0 << 0 << 1;
@ -263,6 +279,7 @@ void OutputCalibrationPage::setupVehicle()
loadSVGFile(GROUND_SVG_FILE);
m_wizardIndexes << 0 << 1 << 2;
m_vehicleElementIds << "motorbike" << "motorbike-frame" << "motorbike-motor" << "motorbike-steering";
m_vehicleElementTypes << FULL << FRAME << MOTOR << SERVO;
m_vehicleHighlightElementIndexes << 0 << 1 << 2;
m_channelIndex << 0 << 1 << 0;
@ -308,6 +325,7 @@ void OutputCalibrationPage::setupVehicleItems()
void OutputCalibrationPage::startWizard()
{
ui->calibrationStack->setCurrentIndex(m_wizardIndexes[0]);
enableAllMotorsCheckBox(true);
setupVehicleHighlightedPart();
}
@ -319,7 +337,11 @@ void OutputCalibrationPage::setupVehicleHighlightedPart()
for (int i = 0; i < m_vehicleItems.size(); i++) {
QGraphicsSvgItem *item = m_vehicleItems[i];
item->setOpacity((highlightedIndex == i) ? highlightOpaque : dimOpaque);
if (highlightedIndex == i || (ui->calibrateAllMotors->isChecked() && m_vehicleElementTypes[i + 1] == MOTOR)) {
item->setOpacity(highlightOpaque);
} else {
item->setOpacity(dimOpaque);
}
}
}
@ -333,7 +355,9 @@ void OutputCalibrationPage::setWizardPage()
qDebug() << "Current page: " << currentPageIndex;
ui->calibrationStack->setCurrentIndex(currentPageIndex);
int currentChannel = getCurrentChannel();
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
int currentChannel = currentChannels[0];
qDebug() << "Current channel: " << currentChannel + 1;
if (currentChannel >= 0) {
if (currentPageIndex == 1) {
@ -378,11 +402,21 @@ void OutputCalibrationPage::initializePage()
bool OutputCalibrationPage::validatePage()
{
if (!isFinished()) {
m_currentWizardIndex++;
if (ui->calibrateAllMotors->isChecked() &&
m_currentWizardIndex > 0 &&
m_wizardIndexes[m_currentWizardIndex - 1] == 1) {
while (!isFinished() && m_wizardIndexes[m_currentWizardIndex] == 1) {
m_currentWizardIndex++;
}
}
}
if (isFinished()) {
getWizard()->setActuatorSettings(m_actuatorSettings);
return true;
} else {
m_currentWizardIndex++;
setWizardPage();
return false;
}
@ -408,17 +442,46 @@ void OutputCalibrationPage::resizeEvent(QResizeEvent *event)
void OutputCalibrationPage::customBackClicked()
{
if (m_currentWizardIndex > 0) {
if (m_currentWizardIndex >= 0) {
m_currentWizardIndex--;
if (ui->calibrateAllMotors->isChecked()) {
while (m_currentWizardIndex > 0 &&
m_wizardIndexes[m_currentWizardIndex] == 1 &&
m_wizardIndexes[m_currentWizardIndex - 1] == 1) {
m_currentWizardIndex--;
}
}
}
if (m_currentWizardIndex >= 0) {
setWizardPage();
} else {
getWizard()->back();
}
}
quint16 OutputCalibrationPage::getCurrentChannel()
void OutputCalibrationPage::getCurrentChannels(QList<quint16> &channels)
{
return m_channelIndex[m_currentWizardIndex];
if (ui->calibrateAllMotors->isChecked()) {
for (int i = 1; i < m_channelIndex.size(); i++) {
if (m_vehicleElementTypes[i + 1] == MOTOR) {
channels << m_channelIndex[i];
}
}
} else {
channels << m_channelIndex[m_currentWizardIndex];
}
}
void OutputCalibrationPage::enableAllMotorsCheckBox(bool enable)
{
if (getWizard()->getVehicleType() == SetupWizard::VEHICLE_MULTI) {
ui->calibrateAllMotors->setVisible(true);
ui->calibrateAllMotors->setEnabled(enable);
} else {
ui->calibrateAllMotors->setChecked(false);
ui->calibrateAllMotors->setVisible(false);
}
}
void OutputCalibrationPage::enableButtons(bool enable)
@ -427,6 +490,7 @@ void OutputCalibrationPage::enableButtons(bool enable)
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
enableAllMotorsCheckBox(enable);
QApplication::processEvents();
}
@ -434,35 +498,43 @@ void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked)
{
ui->motorNeutralButton->setText(checked ? tr("Stop") : tr("Start"));
ui->motorNeutralSlider->setEnabled(checked);
quint16 channel = getCurrentChannel();
quint16 safeValue = m_actuatorSettings[channel].channelMin;
if (m_actuatorSettings[channel].isReversableMotor) {
safeValue = m_actuatorSettings[channel].channelNeutral;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
quint16 safeValue = m_actuatorSettings[currentChannel].channelMin;
if (m_actuatorSettings[currentChannel].isReversableMotor) {
safeValue = m_actuatorSettings[currentChannel].channelNeutral;
}
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, safeValue, ui->motorNeutralSlider);
onStartButtonToggle(ui->motorNeutralButton, currentChannels, m_actuatorSettings[currentChannel].channelNeutral, safeValue, ui->motorNeutralSlider);
}
void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider)
void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, QList<quint16> &channels,
quint16 value, quint16 safeValue, QSlider *slider)
{
if (button->isChecked()) {
// Start calibration
if (checkAlarms()) {
enableButtons(false);
enableServoSliders(true);
m_calibrationUtil->startChannelOutput(channel, safeValue);
m_calibrationUtil->startChannelOutput(channels, safeValue);
slider->setValue(value);
m_calibrationUtil->setChannelOutputValue(value);
} else {
button->setChecked(false);
}
} else {
// Servos and ReversableMotors
m_calibrationUtil->startChannelOutput(channel, m_actuatorSettings[channel].channelNeutral);
// Normal motor
// Stop calibration
quint16 channel = channels[0];
if ((button == ui->motorNeutralButton) && !m_actuatorSettings[channel].isReversableMotor) {
m_calibrationUtil->startChannelOutput(channel, m_actuatorSettings[channel].channelMin);
// Normal motor
m_calibrationUtil->startChannelOutput(channels, m_actuatorSettings[channel].channelMin);
} else {
// Servos and ReversableMotors
m_calibrationUtil->startChannelOutput(channels, m_actuatorSettings[channel].channelNeutral);
}
m_calibrationUtil->stopChannelOutput();
@ -514,11 +586,13 @@ bool OutputCalibrationPage::checkAlarms()
void OutputCalibrationPage::debugLogChannelValues()
{
quint16 channel = getCurrentChannel();
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
qDebug() << "ChannelMin : " << m_actuatorSettings[channel].channelMin;
qDebug() << "ChannelNeutral: " << m_actuatorSettings[channel].channelNeutral;
qDebug() << "ChannelMax : " << m_actuatorSettings[channel].channelMax;
qDebug() << "ChannelMin : " << m_actuatorSettings[currentChannel].channelMin;
qDebug() << "ChannelNeutral: " << m_actuatorSettings[currentChannel].channelNeutral;
qDebug() << "ChannelMax : " << m_actuatorSettings[currentChannel].channelMax;
}
void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
@ -529,7 +603,12 @@ void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
if (ui->motorNeutralButton->isChecked()) {
quint16 value = ui->motorNeutralSlider->value();
m_calibrationUtil->setChannelOutputValue(value);
m_actuatorSettings[getCurrentChannel()].channelNeutral = value;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
foreach(quint16 channel, currentChannels) {
m_actuatorSettings[channel].channelNeutral = value;
}
debugLogChannelValues();
}
}
@ -537,33 +616,41 @@ void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
void OutputCalibrationPage::on_servoButton_toggled(bool checked)
{
ui->servoButton->setText(checked ? tr("Stop") : tr("Start"));
quint16 channel = getCurrentChannel();
quint16 safeValue = m_actuatorSettings[channel].channelNeutral;
onStartButtonToggle(ui->servoButton, channel, safeValue, safeValue, ui->servoCenterAngleSlider);
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
quint16 safeValue = m_actuatorSettings[currentChannel].channelNeutral;
onStartButtonToggle(ui->servoButton, currentChannels, safeValue, safeValue, ui->servoCenterAngleSlider);
}
void OutputCalibrationPage::on_servoCenterAngleSlider_valueChanged(int position)
{
Q_UNUSED(position);
quint16 value = ui->servoCenterAngleSlider->value();
quint16 value = ui->servoCenterAngleSlider->value();
m_calibrationUtil->setChannelOutputValue(value);
quint16 channel = getCurrentChannel();
m_actuatorSettings[channel].channelNeutral = value;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
m_actuatorSettings[currentChannel].channelNeutral = value;
ui->servoPWMValue->setText(tr("Output value : <b>%1</b> µs").arg(value));
// Adjust min and max
if (ui->reverseCheckbox->isChecked()) {
if (value >= m_actuatorSettings[channel].channelMin) {
if (value >= m_actuatorSettings[currentChannel].channelMin) {
ui->servoMinAngleSlider->setValue(value);
}
if (value <= m_actuatorSettings[channel].channelMax) {
if (value <= m_actuatorSettings[currentChannel].channelMax) {
ui->servoMaxAngleSlider->setValue(value);
}
} else {
if (value <= m_actuatorSettings[channel].channelMin) {
if (value <= m_actuatorSettings[currentChannel].channelMin) {
ui->servoMinAngleSlider->setValue(value);
}
if (value >= m_actuatorSettings[channel].channelMax) {
if (value >= m_actuatorSettings[currentChannel].channelMax) {
ui->servoMaxAngleSlider->setValue(value);
}
}
@ -575,21 +662,26 @@ void OutputCalibrationPage::on_servoMinAngleSlider_valueChanged(int position)
Q_UNUSED(position);
quint16 value = ui->servoMinAngleSlider->value();
m_calibrationUtil->setChannelOutputValue(value);
m_actuatorSettings[getCurrentChannel()].channelMin = value;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
m_actuatorSettings[currentChannel].channelMin = value;
// Adjust neutral and max
if (ui->reverseCheckbox->isChecked()) {
if (value <= m_actuatorSettings[getCurrentChannel()].channelNeutral) {
if (value <= m_actuatorSettings[currentChannel].channelNeutral) {
ui->servoCenterAngleSlider->setValue(value);
}
if (value <= m_actuatorSettings[getCurrentChannel()].channelMax) {
if (value <= m_actuatorSettings[currentChannel].channelMax) {
ui->servoMaxAngleSlider->setValue(value);
}
} else {
if (value >= m_actuatorSettings[getCurrentChannel()].channelNeutral) {
if (value >= m_actuatorSettings[currentChannel].channelNeutral) {
ui->servoCenterAngleSlider->setValue(value);
}
if (value >= m_actuatorSettings[getCurrentChannel()].channelMax) {
if (value >= m_actuatorSettings[currentChannel].channelMax) {
ui->servoMaxAngleSlider->setValue(value);
}
}
@ -601,21 +693,26 @@ void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position)
Q_UNUSED(position);
quint16 value = ui->servoMaxAngleSlider->value();
m_calibrationUtil->setChannelOutputValue(value);
m_actuatorSettings[getCurrentChannel()].channelMax = value;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
m_actuatorSettings[currentChannel].channelMax = value;
// Adjust neutral and min
if (ui->reverseCheckbox->isChecked()) {
if (value >= m_actuatorSettings[getCurrentChannel()].channelNeutral) {
if (value >= m_actuatorSettings[currentChannel].channelNeutral) {
ui->servoCenterAngleSlider->setValue(value);
}
if (value >= m_actuatorSettings[getCurrentChannel()].channelMin) {
if (value >= m_actuatorSettings[currentChannel].channelMin) {
ui->servoMinAngleSlider->setValue(value);
}
} else {
if (value <= m_actuatorSettings[getCurrentChannel()].channelNeutral) {
if (value <= m_actuatorSettings[currentChannel].channelNeutral) {
ui->servoCenterAngleSlider->setValue(value);
}
if (value <= m_actuatorSettings[getCurrentChannel()].channelMin) {
if (value <= m_actuatorSettings[currentChannel].channelMin) {
ui->servoMinAngleSlider->setValue(value);
}
}
@ -624,14 +721,18 @@ void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position)
void OutputCalibrationPage::on_reverseCheckbox_toggled(bool checked)
{
if (checked && m_actuatorSettings[getCurrentChannel()].channelMax > m_actuatorSettings[getCurrentChannel()].channelMin) {
quint16 oldMax = m_actuatorSettings[getCurrentChannel()].channelMax;
m_actuatorSettings[getCurrentChannel()].channelMax = m_actuatorSettings[getCurrentChannel()].channelMin;
m_actuatorSettings[getCurrentChannel()].channelMin = oldMax;
} else if (!checked && m_actuatorSettings[getCurrentChannel()].channelMax < m_actuatorSettings[getCurrentChannel()].channelMin) {
quint16 oldMax = m_actuatorSettings[getCurrentChannel()].channelMax;
m_actuatorSettings[getCurrentChannel()].channelMax = m_actuatorSettings[getCurrentChannel()].channelMin;
m_actuatorSettings[getCurrentChannel()].channelMin = oldMax;
QList<quint16> currentChannels;
getCurrentChannels(currentChannels);
quint16 currentChannel = currentChannels[0];
if (checked && m_actuatorSettings[currentChannel].channelMax > m_actuatorSettings[currentChannel].channelMin) {
quint16 oldMax = m_actuatorSettings[currentChannel].channelMax;
m_actuatorSettings[currentChannel].channelMax = m_actuatorSettings[currentChannel].channelMin;
m_actuatorSettings[currentChannel].channelMin = oldMax;
} else if (!checked && m_actuatorSettings[currentChannel].channelMax < m_actuatorSettings[currentChannel].channelMin) {
quint16 oldMax = m_actuatorSettings[currentChannel].channelMax;
m_actuatorSettings[currentChannel].channelMax = m_actuatorSettings[currentChannel].channelMin;
m_actuatorSettings[currentChannel].channelMin = oldMax;
}
ui->servoCenterAngleSlider->setInvertedAppearance(checked);
ui->servoCenterAngleSlider->setInvertedControls(checked);
@ -641,16 +742,22 @@ void OutputCalibrationPage::on_reverseCheckbox_toggled(bool checked)
ui->servoMaxAngleSlider->setInvertedControls(checked);
if (ui->reverseCheckbox->isChecked()) {
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMax);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelNeutral);
ui->servoMinAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMin);
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMax);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
ui->servoMinAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMin);
} else {
ui->servoMinAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMin);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelNeutral);
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMax);
ui->servoMinAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMin);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMax);
}
}
void OutputCalibrationPage::on_calibrateAllMotors_toggled(bool checked)
{
Q_UNUSED(checked);
setupVehicleHighlightedPart();
}
void OutputCalibrationPage::resetOutputCalibrationUtil()
{
if (m_calibrationUtil) {

View File

@ -49,7 +49,7 @@ public:
bool isFinished()
{
return m_currentWizardIndex >= m_wizardIndexes.size() - 1;
return m_currentWizardIndex >= m_wizardIndexes.size();
}
void loadSVGFile(QString file);
@ -70,8 +70,10 @@ private slots:
void on_servoMinAngleSlider_valueChanged(int position);
void on_servoMaxAngleSlider_valueChanged(int position);
void on_reverseCheckbox_toggled(bool checked);
void on_calibrateAllMotors_toggled(bool checked);
private:
enum ElementType { FULL, FRAME, MOTOR, SERVO };
void setupVehicle();
void startWizard();
void setupVehicleItems();
@ -79,10 +81,12 @@ private:
void setWizardPage();
void enableButtons(bool enable);
void enableServoSliders(bool enabled);
void onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider);
void onStartButtonToggle(QAbstractButton *button, QList<quint16> &channels,
quint16 value, quint16 safeValue, QSlider *slider);
bool checkAlarms();
void debugLogChannelValues();
quint16 getCurrentChannel();
void getCurrentChannels(QList<quint16> &channels);
void enableAllMotorsCheckBox(bool enable);
Ui::OutputCalibrationPage *ui;
QSvgRenderer *m_vehicleRenderer;
@ -92,6 +96,7 @@ private:
qint16 m_currentWizardIndex;
QList<QString> m_vehicleElementIds;
QList<ElementType> m_vehicleElementTypes;
QList<QGraphicsSvgItem *> m_vehicleItems;
QList<quint16> m_vehicleHighlightElementIndexes;
QList<quint16> m_channelIndex;

View File

@ -53,7 +53,7 @@
<item row="1" column="0">
<widget class="QStackedWidget" name="calibrationStack">
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="intro">
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -123,6 +123,26 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="calibrateAllMotors">
<property name="text">
<string>Calibrate all motor outputs at the same time</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="motorPWMValue">
<property name="text">

View File

@ -489,6 +489,9 @@ void SetupWizard::customBackClicked()
static_cast<OutputCalibrationPage *>(currentPage())->customBackClicked();
} else {
back();
if (currentId() == PAGE_OUTPUT_CALIBRATION) {
static_cast<OutputCalibrationPage *>(currentPage())->customBackClicked();
}
}
}