[education/kstars] kstars: AI Guide: fix stale gain default, wire up mount type auto-detect
Jasem Mutlaq <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit c8a538938e98002e9bac1b93db74354a681815c3 by Jasem Mutlaq. Committed on 04/08/2026 at 02:55. Pushed by mutlaqja into branch 'master'. AI Guide: fix stale gain default, wire up mount type auto-detect - kstars.kcfg: RAProportionalGain/DECProportionalGain compiled default was a stale 133.33 left over from before the 2021 rescale to a 0.0-1.0 control-gain convention (UI default 0.75). Fixed to 0.75. - aiguideprotocol.h/.cpp: add AIGuideProtocol::detectMountType(), querying the connected mount's device name against mount_types.json via MountGuiderFactory::detectMountType() (previously wired up but never called from anywhere). - aiguidewizard.h/.cpp: call detectMountType() once from showEvent() to pre-select the AI Guide Assistant wizard's mount-type combo box; manual override remains available and is logged either way. Co-Authored-By: Claude Sonnet 5 <[email protected]> M +9 -0 kstars/ekos/guide/aiguideprotocol.cpp M +8 -0 kstars/ekos/guide/aiguideprotocol.h M +23 -0 kstars/ekos/guide/aiguidewizard.cpp M +1 -0 kstars/ekos/guide/aiguidewizard.h M +2 -2 kstars/kstars.kcfg https://invent.kde.org/education/kstars/-/commit/c8a538938e98002e9bac1b93db74354a681815c3 diff --git a/kstars/ekos/guide/aiguideprotocol.cpp b/kstars/ekos/guide/aiguideprotocol.cpp index 56ab021a5d..4d9e0990bc 100644 --- a/kstars/ekos/guide/aiguideprotocol.cpp +++ b/kstars/ekos/guide/aiguideprotocol.cpp @@ -14,6 +14,7 @@ #include "Options.h" #include "internalguide/internalguider.h" #include "internalguide/calibration.h" +#include "internalguide/mount_guider_factory.h" #include <QDateTime> #include <QDebug> #include <QDir> @@ -28,6 +29,14 @@ AIGuideProtocol::AIGuideProtocol(Guide *guide) : QObject(guide), m_Guide(guide) setObjectName("AIGuideProtocol"); } +QString AIGuideProtocol::detectMountType() const +{ + if (!m_Guide || !m_Guide->mount()) + return "NOT_FOUND"; + + return MountGuiderFactory::detectMountType(m_Guide->mount()->getDeviceName()); +} + QJsonObject AIGuideProtocol::buildFingerprint() const { QJsonObject fingerprint; diff --git a/kstars/ekos/guide/aiguideprotocol.h b/kstars/ekos/guide/aiguideprotocol.h index 06e7811806..c2e29ea618 100644 --- a/kstars/ekos/guide/aiguideprotocol.h +++ b/kstars/ekos/guide/aiguideprotocol.h @@ -78,6 +78,14 @@ class AIGuideProtocol : public QObject return m_LogFilename; } + /** + * @brief Auto-detect the mount class from the connected mount's device name via + * mount_types.json (MountGuiderFactory::detectMountType()). + * @return "WORM_GEAR" / "HARMONIC_DRIVE" / "DIRECT_DRIVE" / "NOT_FOUND" -- "NOT_FOUND" + * if no mount is connected or the name has no entry in the lookup table. + */ + QString detectMountType() const; + Q_SIGNALS: void protocolLog(const QString &message); void protocolProgress(int current, int total, const QString &status); diff --git a/kstars/ekos/guide/aiguidewizard.cpp b/kstars/ekos/guide/aiguidewizard.cpp index dbf406567c..7b83510ce7 100644 --- a/kstars/ekos/guide/aiguidewizard.cpp +++ b/kstars/ekos/guide/aiguidewizard.cpp @@ -259,6 +259,29 @@ void AIGuideWizard::showEvent(QShowEvent *event) { QWizard::showEvent(event); + // Suggest a mount type from the connected mount's device name (mount_types.json), once. + // The user can still change the selection manually -- this only sets the initial value. + if (!m_MountTypeAutoDetectAttempted) + { + m_MountTypeAutoDetectAttempted = true; + QString comboText; + const QString detected = m_Protocol->detectMountType(); + if (detected == "WORM_GEAR") + comboText = "Worm Gear"; + else if (detected == "HARMONIC_DRIVE") + comboText = "Harmonic Drive"; + else if (detected == "DIRECT_DRIVE") + comboText = "Direct Drive"; + + if (!comboText.isEmpty()) + { + mountTypeCombo->setCurrentText(comboText); + appendLog(i18n("Detected mount type: %1. Change the selection above if this is incorrect.", comboText)); + } + else + appendLog(i18n("Could not auto-detect the mount type. Please select it manually above.")); + } + m_AutoNavigating = true; // If protocol is already running (e.g. started via EkosLive), jump to page 2 diff --git a/kstars/ekos/guide/aiguidewizard.h b/kstars/ekos/guide/aiguidewizard.h index 7556b44986..a302701d08 100644 --- a/kstars/ekos/guide/aiguidewizard.h +++ b/kstars/ekos/guide/aiguidewizard.h @@ -65,6 +65,7 @@ class AIGuideWizard : public QWizard, public Ui::AIGuideWizard AIGuideProtocol *m_Protocol { nullptr }; bool m_AutoNavigating { false }; + bool m_MountTypeAutoDetectAttempted { false }; }; } \ No newline at end of file diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg index 28c458d7ed..8b7960fdf2 100644 --- a/kstars/kstars.kcfg +++ b/kstars/kstars.kcfg @@ -3297,10 +3297,10 @@ <default>true</default> </entry> <entry name="RAProportionalGain" type="Double"> - <default>133.33</default> + <default>0.75</default> </entry> <entry name="DECProportionalGain" type="Double"> - <default>133.33</default> + <default>0.75</default> </entry> <entry name="RAIntegralGain" type="Double"> <default>0</default>