From 498aba5c1967f72133e3b75a3f59cfa62c42beed Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 28 Jan 2018 01:28:14 +0100 Subject: [PATCH] LP-514 Add DShot150/600/1200 and OneShot42/MultiShot Esc support to Wizard --- .../plugins/setupwizard/connectiondiagram.cpp | 4 +- .../setupwizard/pages/esccalibrationpage.cpp | 6 +- .../setupwizard/pages/esccalibrationpage.h | 2 +- .../src/plugins/setupwizard/pages/escpage.cpp | 55 +++- .../src/plugins/setupwizard/pages/escpage.h | 1 + .../src/plugins/setupwizard/pages/escpage.ui | 271 +++++++++++++++++- .../pages/outputcalibrationpage.cpp | 49 +++- .../setupwizard/pages/outputcalibrationpage.h | 9 +- .../src/plugins/setupwizard/setupwizard.cpp | 27 +- .../vehicleconfigurationhelper.cpp | 39 ++- .../setupwizard/vehicleconfigurationhelper.h | 18 +- .../setupwizard/vehicleconfigurationsource.h | 2 +- 12 files changed, 436 insertions(+), 47 deletions(-) diff --git a/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp b/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp index c8f02c137..a694a2d5e 100644 --- a/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp +++ b/ground/gcs/src/plugins/setupwizard/connectiondiagram.cpp @@ -179,7 +179,9 @@ void ConnectionDiagram::setupGraphicsScene() case VehicleConfigurationSource::CONTROLLER_CC: case VehicleConfigurationSource::CONTROLLER_CC3D: prefix = "cc-"; - if (m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT || + if (m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT125 || + m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT42 || + m_configSource->getEscType() == VehicleConfigurationSource::ESC_MULTISHOT || m_configSource->getEscType() == VehicleConfigurationSource::ESC_SYNCHED) { suffix = "-oneshot"; } diff --git a/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp b/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp index 874beeba2..b8bd5a218 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp @@ -93,8 +93,10 @@ void EscCalibrationPage::resetAllSecurityCheckboxes() int EscCalibrationPage::getHighOutputRate() { - if (getWizard()->getEscType() == SetupWizard::ESC_ONESHOT) { - return HIGH_ONESHOT125_OUTPUT_PULSE_LENGTH_MICROSECONDS; + if (getWizard()->getEscType() == SetupWizard::ESC_ONESHOT125 || + getWizard()->getEscType() == SetupWizard::ESC_ONESHOT42 || + getWizard()->getEscType() == SetupWizard::ESC_MULTISHOT) { + return HIGH_ONESHOT_MULTISHOT_OUTPUT_PULSE_LENGTH_MICROSECONDS; } else { return HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; } diff --git a/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.h b/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.h index f9abf5b56..18768a606 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.h +++ b/ground/gcs/src/plugins/setupwizard/pages/esccalibrationpage.h @@ -59,7 +59,7 @@ private: // Min value should match min value defined in vehicleconfigurationsource.h static const int LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1000; static const int HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1900; - static const int HIGH_ONESHOT125_OUTPUT_PULSE_LENGTH_MICROSECONDS = 2000; + static const int HIGH_ONESHOT_MULTISHOT_OUTPUT_PULSE_LENGTH_MICROSECONDS = 2000; Ui::EscCalibrationPage *ui; bool m_isCalibrating; OutputCalibrationUtil m_outputUtil; diff --git a/ground/gcs/src/plugins/setupwizard/pages/escpage.cpp b/ground/gcs/src/plugins/setupwizard/pages/escpage.cpp index 2bd35b1dd..9e0645b00 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/escpage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/escpage.cpp @@ -47,17 +47,41 @@ void EscPage::initializePage() { bool enabled = isSynchOrOneShotAvailable(); - ui->oneshotESCButton->setEnabled(enabled); - if (ui->oneshotESCButton->isChecked() && !enabled) { - ui->oneshotESCButton->setChecked(false); + ui->oneshot125ESCButton->setEnabled(enabled); + ui->oneshot42ESCButton->setEnabled(enabled); + ui->multishotESCButton->setEnabled(enabled); + + if ((ui->oneshot125ESCButton->isChecked() || + ui->oneshot42ESCButton->isChecked() || + ui->multishotESCButton->isChecked()) && !enabled) { + ui->oneshot125ESCButton->setChecked(false); + ui->oneshot42ESCButton->setChecked(false); + ui->multishotESCButton->setChecked(false); ui->rapidESCButton->setChecked(true); } + + enabled = isFastDShotAvailable(); + ui->dshot1200ESCButton->setEnabled(enabled); + if (ui->dshot1200ESCButton->isChecked() && !enabled) { + ui->dshot1200ESCButton->setChecked(false); + ui->dshot600ESCButton->setChecked(true); + } } bool EscPage::validatePage() { - if (ui->oneshotESCButton->isChecked()) { - getWizard()->setEscType(SetupWizard::ESC_ONESHOT); + if (ui->dshot1200ESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_DSHOT1200); + } else if (ui->dshot600ESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_DSHOT600); + } else if (ui->dshot150ESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_DSHOT150); + } else if (ui->multishotESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_MULTISHOT); + } else if (ui->oneshot42ESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_ONESHOT42); + } else if (ui->oneshot125ESCButton->isChecked()) { + getWizard()->setEscType(SetupWizard::ESC_ONESHOT125); } else if (ui->rapidESCButton->isChecked()) { if (isSynchOrOneShotAvailable()) { getWizard()->setEscType(SetupWizard::ESC_SYNCHED); @@ -65,7 +89,7 @@ bool EscPage::validatePage() getWizard()->setEscType(SetupWizard::ESC_RAPID); } } else if (ui->defaultESCButton->isChecked()) { - getWizard()->setEscType(SetupWizard::ESC_STANDARD); + getWizard()->setEscType(SetupWizard::ESC_STANDARD300); } return true; @@ -107,3 +131,22 @@ bool EscPage::isSynchOrOneShotAvailable() return available; } + +bool EscPage::isFastDShotAvailable() +{ + bool available = true; + + switch (getWizard()->getControllerType()) { + case SetupWizard::CONTROLLER_CC3D: + case SetupWizard::CONTROLLER_SPRACINGF3: + case SetupWizard::CONTROLLER_SPRACINGF3EVO: + case SetupWizard::CONTROLLER_PIKOBLX: + case SetupWizard::CONTROLLER_TINYFISH: + available = false; + break; + default: + break; + } + + return available; +} diff --git a/ground/gcs/src/plugins/setupwizard/pages/escpage.h b/ground/gcs/src/plugins/setupwizard/pages/escpage.h index a0e4ec0fb..cba0e8466 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/escpage.h +++ b/ground/gcs/src/plugins/setupwizard/pages/escpage.h @@ -46,6 +46,7 @@ public: private: Ui::EscPage *ui; bool isSynchOrOneShotAvailable(); + bool isFastDShotAvailable(); }; #endif // ESCPAGE_H diff --git a/ground/gcs/src/plugins/setupwizard/pages/escpage.ui b/ground/gcs/src/plugins/setupwizard/pages/escpage.ui index b26f440d2..40d22e685 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/escpage.ui +++ b/ground/gcs/src/plugins/setupwizard/pages/escpage.ui @@ -6,8 +6,8 @@ 0 0 - 641 - 400 + 699 + 549 @@ -59,7 +59,7 @@ p, li { white-space: pre-wrap; } - Standard ESC: Slow refresh rate (50Hz), not recommended for Multirotors. + Standard ESC: Minimal refresh rate (300Hz), for Multirotors. QToolButton { border: none } @@ -69,8 +69,8 @@ p, li { white-space: pre-wrap; } - :/setupwizard/resources/bttn-ESC-up.png - :/setupwizard/resources/bttn-ESC-down.png:/setupwizard/resources/bttn-ESC-up.png + :/setupwizard/resources/bttn-esc300-up.png + :/setupwizard/resources/bttn-esc300-dwn.png:/setupwizard/resources/bttn-esc300-up.png @@ -139,10 +139,17 @@ p, li { white-space: pre-wrap; } + + + + + + 0 + - + - false + true @@ -150,18 +157,260 @@ p, li { white-space: pre-wrap; } - OneShot ESC: BLHeli, Kiss... + OneShot125 ESC: BLHeli, Kiss... QToolButton { border: none } - OneShot ESC + OneShot125 ESC - :/setupwizard/resources/bttn-oneshot-up.png - :/setupwizard/resources/bttn-oneshot-dwn.png:/setupwizard/resources/bttn-oneshot-up.png + :/setupwizard/resources/bttn-oneshot125-up.png + :/setupwizard/resources/bttn-oneshot125-dwn.png:/setupwizard/resources/bttn-oneshot125-up.png + + + + 200 + 100 + + + + true + + + false + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + + true + + + + 10 + + + + OneShot42 ESC: BLHeli, Kiss... + + + QToolButton { border: none } + + + OneShot42 ESC + + + + :/setupwizard/resources/bttn-oneshot42-up.png + :/setupwizard/resources/bttn-oneshot42-dwn.png:/setupwizard/resources/bttn-oneshot42-up.png + + + + 200 + 100 + + + + true + + + false + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + + true + + + + 10 + + + + MultiShot ESC: BLHeli, Kiss... + + + QToolButton { border: none } + + + MultiShot ESC + + + + :/setupwizard/resources/bttn-multishot-up.png + :/setupwizard/resources/bttn-multishot-dwn.png:/setupwizard/resources/bttn-multishot-up.png + + + + 200 + 100 + + + + true + + + false + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + + + + 0 + + + + + true + + + + 10 + + + + DShot150 ESC: BLHeli_S... + + + QToolButton { border: none } + + + DShot150 ESC + + + + :/setupwizard/resources/bttn-dshot150-up.png + :/setupwizard/resources/bttn-dshot150-dwn.png:/setupwizard/resources/bttn-dshot150-up.png + + + + 200 + 100 + + + + true + + + false + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + + true + + + + 10 + + + + DShot600 ESC: BLHeli_S... + + + QToolButton { border: none } + + + DShot600 ESC + + + + :/setupwizard/resources/bttn-dshot600-up.png + :/setupwizard/resources/bttn-dshot600-dwn.png:/setupwizard/resources/bttn-dshot600-up.png + + + + 200 + 100 + + + + true + + + false + + + true + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + + true + + + + 10 + + + + DShot1200 ESC: BLHeli_S... + + + QToolButton { border: none } + + + DShot1200 ESC + + + + :/setupwizard/resources/bttn-dshot1200-up.png + :/setupwizard/resources/bttn-dshot1200-dwn.png:/setupwizard/resources/bttn-dshot1200-up.png diff --git a/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index 838a3c2ac..d23abac22 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -82,8 +82,8 @@ void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart, for (int servoid = 0; servoid < 12; servoid++) { if (servoid >= motorChannelStart && servoid <= motorChannelEnd) { // Set to motor safe values - m_actuatorSettings[servoid].channelMin = LOW_OUTPUT_RATE_MILLISECONDS; - m_actuatorSettings[servoid].channelNeutral = LOW_OUTPUT_RATE_MILLISECONDS; + m_actuatorSettings[servoid].channelMin = getLowOutputRate(); + m_actuatorSettings[servoid].channelNeutral = getLowOutputRate(); m_actuatorSettings[servoid].channelMax = getHighOutputRate(); m_actuatorSettings[servoid].isReversableMotor = false; // Car, Tank, Boat and Boat differential should use reversable Esc/motors @@ -93,10 +93,10 @@ void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart, || (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_DIFFERENTIAL_BOAT)) { m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MILLISECONDS; m_actuatorSettings[servoid].isReversableMotor = true; - // Set initial output value - m_calibrationUtil->startChannelOutput(servoid, NEUTRAL_OUTPUT_RATE_MILLISECONDS); - m_calibrationUtil->stopChannelOutput(); } + // Set initial output value + m_calibrationUtil->startChannelOutput(servoid, m_actuatorSettings[servoid].channelNeutral); + m_calibrationUtil->stopChannelOutput(); } else if (servoid < totalUsedChannels) { // Set to servo safe values m_actuatorSettings[servoid].channelMin = NEUTRAL_OUTPUT_RATE_MILLISECONDS; @@ -466,11 +466,18 @@ void OutputCalibrationPage::setWizardPage() qDebug() << "Current channel: " << currentChannel + 1; if (currentChannel >= 0) { if (currentPageIndex == 1) { + // Set Min, Neutral and Max for slider in all cases, needed for DShot. + ui->motorNeutralSlider->setMinimum(m_actuatorSettings[currentChannel].channelMin); ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral); - ui->motorPWMValue->setText(QString(tr("Output value : %1 µs")).arg(m_actuatorSettings[currentChannel].channelNeutral)); + ui->motorNeutralSlider->setMaximum(m_actuatorSettings[currentChannel].channelMin + NEUTRAL_OUTPUT_RATE_RANGE); + if (ui->motorNeutralSlider->minimum() == LOW_OUTPUT_RATE_DSHOT) { + // DShot output + ui->motorPWMValue->setText(QString(tr("Digital output value : %1")).arg(m_actuatorSettings[currentChannel].channelNeutral)); + } else { + ui->motorPWMValue->setText(QString(tr("Output value : %1 µs")).arg(m_actuatorSettings[currentChannel].channelNeutral)); + } // Reversable motor found if (m_actuatorSettings[currentChannel].isReversableMotor) { - ui->motorNeutralSlider->setMinimum(m_actuatorSettings[currentChannel].channelMin); ui->motorNeutralSlider->setMaximum(m_actuatorSettings[currentChannel].channelMax); ui->motorInfo->setText(tr("

To find the neutral rate for this reversable motor, press the Start button below and slide the slider to the right or left until you find the value where the motor doesn't start.

When done press button again to stop.

")); } @@ -816,10 +823,27 @@ void OutputCalibrationPage::debugLogChannelValues(bool showFirst) qDebug() << "ChannelMax : " << m_actuatorSettings[currentChannel].channelMax; } +int OutputCalibrationPage::getLowOutputRate() +{ + if (getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT150 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT600 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT1200) { + return LOW_OUTPUT_RATE_DSHOT; + } else { + return LOW_OUTPUT_RATE_MILLISECONDS_PWM; + } +} + int OutputCalibrationPage::getHighOutputRate() { - if (getWizard()->getEscType() == SetupWizard::ESC_ONESHOT) { - return HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT125; + if (getWizard()->getEscType() == VehicleConfigurationSource::ESC_ONESHOT125 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_ONESHOT42 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_MULTISHOT) { + return HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT_MULTISHOT; + } else if (getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT150 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT600 || + getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT1200) { + return HIGH_OUTPUT_RATE_DSHOT; } else { return HIGH_OUTPUT_RATE_MILLISECONDS_PWM; } @@ -828,8 +852,13 @@ int OutputCalibrationPage::getHighOutputRate() void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value) { Q_UNUSED(value); - ui->motorPWMValue->setText(tr("Output value : %1 µs").arg(value)); + if (ui->motorNeutralSlider->minimum() == LOW_OUTPUT_RATE_DSHOT) { + // DShot output + ui->motorPWMValue->setText(QString(tr("Digital output value : %1")).arg(value)); + } else { + ui->motorPWMValue->setText(QString(tr("Output value : %1 µs")).arg(value)); + } if (ui->motorNeutralButton->isChecked()) { quint16 value = ui->motorNeutralSlider->value(); m_calibrationUtil->setChannelOutputValue(value); diff --git a/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.h b/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.h index 13cd2c427..09c33310f 100644 --- a/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.h +++ b/ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.h @@ -87,10 +87,14 @@ private slots: private: enum ElementType { FULL, FRAME, MOTOR, SERVO }; + static const int LOW_OUTPUT_RATE_DSHOT = 0; + static const int HIGH_OUTPUT_RATE_DSHOT = 2000; static const int LOW_OUTPUT_RATE_MILLISECONDS = 1000; - static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500; + static const int LOW_OUTPUT_RATE_MILLISECONDS_PWM = 1000; static const int HIGH_OUTPUT_RATE_MILLISECONDS_PWM = 1900; - static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT125 = 2000; + static const int NEUTRAL_OUTPUT_RATE_RANGE = 500; + static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500; + static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT_MULTISHOT = 2000; void setupVehicle(); void startWizard(); @@ -112,6 +116,7 @@ private: void getCurrentChannels(QList &channels); void enableAllMotorsCheckBox(bool enable); + int getLowOutputRate(); int getHighOutputRate(); quint16 getCurrentChannel(); diff --git a/ground/gcs/src/plugins/setupwizard/setupwizard.cpp b/ground/gcs/src/plugins/setupwizard/setupwizard.cpp index 5bb2f5833..5a8f46728 100644 --- a/ground/gcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/gcs/src/plugins/setupwizard/setupwizard.cpp @@ -181,7 +181,10 @@ int SetupWizard::nextId() const } case PAGE_BIAS_CALIBRATION: - if (getVehicleType() == VEHICLE_MULTI) { + if ((getVehicleType() == VEHICLE_MULTI) && + (getEscType() != ESC_DSHOT150) && + (getEscType() != ESC_DSHOT600) && + (getEscType() != ESC_DSHOT1200)) { return PAGE_ESC_CALIBRATION; } else { return PAGE_OUTPUT_CALIBRATION; @@ -414,14 +417,32 @@ QString SetupWizard::getSummaryText() case ESC_STANDARD: summary.append(tr("Standard ESC (%1 Hz)").arg(VehicleConfigurationHelper::LEGACY_ESC_FREQUENCY)); break; + case ESC_STANDARD300: + summary.append(tr("Standard ESC (%1 Hz)").arg(VehicleConfigurationHelper::LEGACY_MULTI_ESC_FREQUENCY)); + break; case ESC_RAPID: summary.append(tr("Rapid ESC (%1 Hz)").arg(VehicleConfigurationHelper::RAPID_ESC_FREQUENCY)); break; case ESC_SYNCHED: summary.append(tr("Synched ESC")); break; - case ESC_ONESHOT: - summary.append(tr("Oneshot ESC")); + case ESC_ONESHOT125: + summary.append(tr("Oneshot125 ESC")); + break; + case ESC_ONESHOT42: + summary.append(tr("Oneshot42 ESC")); + break; + case ESC_MULTISHOT: + summary.append(tr("Multishot ESC")); + break; + case ESC_DSHOT150: + summary.append(tr("Dshot150 ESC")); + break; + case ESC_DSHOT600: + summary.append(tr("Dshot600 ESC")); + break; + case ESC_DSHOT1200: + summary.append(tr("Dshot1200 ESC")); break; default: summary.append(tr("Unknown")); diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index dd266f6e3..9ae0f840b 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -157,7 +157,9 @@ void VehicleConfigurationHelper::applyHardwareConfiguration() data.CC_RcvrPort = HwSettings::CC_RCVRPORT_PWMNOONESHOT; break; case VehicleConfigurationSource::INPUT_PPM: - if (m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT || + if (m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT125 || + m_configSource->getEscType() == VehicleConfigurationSource::ESC_ONESHOT42 || + m_configSource->getEscType() == VehicleConfigurationSource::ESC_MULTISHOT || m_configSource->getEscType() == VehicleConfigurationSource::ESC_SYNCHED) { data.CC_RcvrPort = HwSettings::CC_RCVRPORT_PPM_PIN8ONESHOT; } else { @@ -515,6 +517,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() ActuatorSettings *actSettings = ActuatorSettings::GetInstance(m_uavoManager); qint16 escFrequence = LEGACY_ESC_FREQUENCY; + qint16 escDShotMode = LEGACY_DSHOT_MODE; ActuatorSettings::BankModeOptions bankMode = ActuatorSettings::BANKMODE_PWM; switch (m_configSource->getEscType()) { @@ -522,6 +525,10 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() escFrequence = LEGACY_ESC_FREQUENCY; bankMode = ActuatorSettings::BANKMODE_PWM; break; + case VehicleConfigurationSource::ESC_STANDARD300: + escFrequence = LEGACY_MULTI_ESC_FREQUENCY; + bankMode = ActuatorSettings::BANKMODE_PWM; + break; case VehicleConfigurationSource::ESC_RAPID: bankMode = ActuatorSettings::BANKMODE_PWM; escFrequence = RAPID_ESC_FREQUENCY; @@ -530,9 +537,32 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() bankMode = ActuatorSettings::BANKMODE_PWMSYNC; escFrequence = PWMSYNC_ESC_FREQUENCY; break; - case VehicleConfigurationSource::ESC_ONESHOT: + case VehicleConfigurationSource::ESC_ONESHOT125: bankMode = ActuatorSettings::BANKMODE_ONESHOT125; - escFrequence = ONESHOT_ESC_FREQUENCY; + escFrequence = ESC_FREQUENCY_ZERO; + break; + case VehicleConfigurationSource::ESC_ONESHOT42: + bankMode = ActuatorSettings::BANKMODE_ONESHOT42; + escFrequence = ESC_FREQUENCY_ZERO; + break; + case VehicleConfigurationSource::ESC_MULTISHOT: + bankMode = ActuatorSettings::BANKMODE_MULTISHOT; + escFrequence = ESC_FREQUENCY_ZERO; + break; + case VehicleConfigurationSource::ESC_DSHOT150: + bankMode = ActuatorSettings::BANKMODE_DSHOT; + escFrequence = ESC_FREQUENCY_ZERO; + escDShotMode = DSHOT_MODE_150; + break; + case VehicleConfigurationSource::ESC_DSHOT600: + bankMode = ActuatorSettings::BANKMODE_DSHOT; + escFrequence = ESC_FREQUENCY_ZERO; + // escDShotFrequence = LEGACY_DSHOT_ESC_FREQUENCY; + break; + case VehicleConfigurationSource::ESC_DSHOT1200: + bankMode = ActuatorSettings::BANKMODE_DSHOT; + escFrequence = ESC_FREQUENCY_ZERO; + escDShotMode = DSHOT_MODE_1200; break; default: break; @@ -574,6 +604,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() switch (m_configSource->getVehicleSubType()) { case VehicleConfigurationSource::MULTI_ROTOR_TRI_Y: // Servo always on channel 4 + data.DShotMode = escDShotMode; data.BankUpdateFreq[0] = escFrequence; data.BankMode[0] = bankMode; if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO @@ -591,6 +622,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() break; case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X: case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS: + data.DShotMode = escDShotMode; data.BankUpdateFreq[0] = escFrequence; data.BankMode[0] = bankMode; data.BankUpdateFreq[1] = escFrequence; @@ -617,6 +649,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X: case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS: case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V: + data.DShotMode = escDShotMode; data.BankUpdateFreq[0] = escFrequence; data.BankMode[0] = bankMode; data.BankUpdateFreq[1] = escFrequence; diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.h b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.h index 31f7707ac..7227ecd96 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.h +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.h @@ -61,15 +61,19 @@ public: VehicleConfigurationHelper(VehicleConfigurationSource *configSource); bool setupVehicle(bool save = true); bool setupHardwareSettings(bool save = true); - static const qint16 LEGACY_ESC_FREQUENCY = 50; - static const qint16 RAPID_ESC_FREQUENCY = 490; - static const qint16 PWMSYNC_ESC_FREQUENCY = 0; - static const qint16 ONESHOT_ESC_FREQUENCY = 0; - static const qint16 ANALOG_SERVO_FREQUENCY = 50; - static const qint16 DIGITAL_SERVO_FREQUENCY = 333; + static const qint16 LEGACY_ESC_FREQUENCY = 50; + static const qint16 LEGACY_MULTI_ESC_FREQUENCY = 300; + static const qint16 RAPID_ESC_FREQUENCY = 490; + static const qint16 PWMSYNC_ESC_FREQUENCY = 0; + static const qint16 ESC_FREQUENCY_ZERO = 0; + static const qint16 DSHOT_MODE_150 = 150; + static const qint16 LEGACY_DSHOT_MODE = 600; + static const qint16 DSHOT_MODE_1200 = 1200; + static const qint16 ANALOG_SERVO_FREQUENCY = 50; + static const qint16 DIGITAL_SERVO_FREQUENCY = 333; static const int MIXER_TYPE_NONE = 0; static const int MIXER_TYPE_MOTOR = 1; - static const int MIXER_TYPE_REVERSABLEMOTOR = 2; + static const int MIXER_TYPE_REVERSABLEMOTOR = 2; static const int MIXER_TYPE_SERVO = 3; diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h index bb5885364..ee0be765f 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -65,7 +65,7 @@ public: MULTI_ROTOR_OCTO_X, MULTI_ROTOR_OCTO_V, MULTI_ROTOR_OCTO_COAX_X, MULTI_ROTOR_OCTO_COAX_PLUS, FIXED_WING_DUAL_AILERON, FIXED_WING_AILERON, FIXED_WING_ELEVON, FIXED_WING_VTAIL, HELI_CCPM, GROUNDVEHICLE_MOTORCYCLE, GROUNDVEHICLE_CAR, GROUNDVEHICLE_DIFFERENTIAL, GROUNDVEHICLE_BOAT, GROUNDVEHICLE_DIFFERENTIAL_BOAT }; - enum ESC_TYPE { ESC_ONESHOT, ESC_SYNCHED, ESC_RAPID, ESC_STANDARD, ESC_UNKNOWN }; + enum ESC_TYPE { ESC_DSHOT1200, ESC_DSHOT600, ESC_DSHOT150, ESC_MULTISHOT, ESC_ONESHOT42, ESC_ONESHOT125, ESC_SYNCHED, ESC_RAPID, ESC_STANDARD300, ESC_STANDARD, ESC_UNKNOWN }; enum SERVO_TYPE { SERVO_ANALOG, SERVO_DIGITAL, SERVO_UNKNOWN }; enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSM, INPUT_SRXL, INPUT_HOTT_SUMD, INPUT_EXBUS, INPUT_IBUS, INPUT_UNKNOWN }; enum AIRSPEED_TYPE { AIRSPEED_ESTIMATE, AIRSPEED_EAGLETREE, AIRSPEED_MS4525, AIRSPEED_DISABLED };