Skip to content

alignment: fix plugin selection persistence, sanitize polar sync entries#2372

Merged
knro merged 1 commit into
indilib:masterfrom
ckemper67:alignment-math-plugin-fixes
Apr 23, 2026
Merged

alignment: fix plugin selection persistence, sanitize polar sync entries#2372
knro merged 1 commit into
indilib:masterfrom
ckemper67:alignment-math-plugin-fixes

Conversation

@ckemper67
Copy link
Copy Markdown
Contributor

@ckemper67 ckemper67 commented Apr 20, 2026

Problem

Three independent bugs that each corrupt pointing after a restart or a single near-pole sync:

  1. Plugin selection not persisting. saveConfig(true, name) only patches the named property in the existing XML; it skips CURRENT_MATH_PLUGIN. After a restart the text property is replayed before the switch property, so the selected external plugin (Nearest, SVD, …) is overwritten by the stale built-in default.

  2. Mount alignment lost on plugin switch. When loading a new plugin, SetApproximateMountAlignment was never called on it. Every external plugin defaults to ZENITH, silently switching EQ drivers to the AltAz code path and producing garbage Goto coordinates whenever the user changes plugins at runtime.

  3. Degenerate sync points near the celestial pole. When all sync points are close to the celestial pole (Dec near +/-90), the HA component of the telescope direction vector is unconstrained — any HA value maps to nearly the same point on the sky. All plugins that solve a least-squares system over the sync database (BuiltIn, SVD, Nearest) are affected: the solver assigns an arbitrary HA-axis correction that produces wildly wrong Gotos away from the pole. The same singularity occurs for altaz mounts when all sync points are near the zenith.

Fix

  • telescope_simulator.cpp: use saveConfig() (full save) instead of saveConfig(true, name) so CURRENT_MATH_PLUGIN is included.
  • MathPluginManagement.cpp: capture ApproximateMountAlignment before unloading the old plugin, then call SetApproximateMountAlignment + Initialise on the newly loaded one. Also skip a redundant reload when the switch property arrives after the text property on startup.
  • MathPlugin.cpp / MathPlugin.h: add SanitizePolarEntries(), called from Initialise(). Entries with |Dec| > 88 (EQ) or encoder El > 88 (altaz) are shifted to 80 while applying the same delta to the paired celestial coordinate, preserving the pointing correction while breaking the degeneracy. The TDV is rebuilt using RA-based encoding, consistent with the BuiltIn/SVD/Nearest convention.
  • ccd_simulator.cpp, guide_simulator.cpp: fix a unit mismatch — IEquatorialCoordinates.rightascension is in degrees, not hours; remove the erroneous x15 / /15 factor in the EQUATORIAL_PE snooping path.

Tests

Six new PolarDegeneracy tests in test_alignment_plugins cover EQ and altaz single-point-near-pole scenarios for BuiltIn, SVD, and Nearest plugins.

…ur-angle encoding

Fix math plugin selection not persisting across restarts. Add polar/zenith
entry sanitization in MathPlugin base class to prevent degenerate sync points
near the celestial pole (EQ) or zenith (altaz) from producing garbage pointing
models. Switch CCD and guide simulator to hour-angle-based telescope direction
vector encoding to match the alignment subsystem convention.
@ckemper67 ckemper67 force-pushed the alignment-math-plugin-fixes branch from 6faba9e to ea87e9a Compare April 20, 2026 20:49
@knro knro merged commit a6961c6 into indilib:master Apr 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants