Fix lock-position crosshair jump when guiding starts#1452
Conversation
The crosshair was drawn at the stale m_lockPosition from a previous session throughout calibration, then snapped to CurrentPosition() at STATE_GUIDING entry. Anchor the lock once at STATE_CALIBRATING_PRIMARY entry (preserving sticky), and stop overwriting a valid lock at STATE_GUIDING entry. The lock is now established once per cycle and stays static through calibration and guiding (except via lock-shift). Signed-off-by: Leo Shatz <leonid.shatz@gmail.com>
|
I have only looked at this briefly but I doubt that you can eliminate the call on SetLockPosition() at the start of guiding. You can't assume calibration has just been done, that will nearly always be false. Here's a quick test for the simulator:
I think we need to be extremely careful here. The problem you're addressing - which I can see - is essentially cosmetic and in fact has gone unnoticed for years and years. But the guiding behavior is completely accurate. I wouldn't want to see us jeopardize the latter for the former. :-) As I said, I've only looked at this briefly, so forgive me if I'm mistaken. |
|
Thanks, Bruce. I repeated the simulator test, and I think my initial interpretation of the result was mistaken. In this scenario, I now see the same final lock-position behavior both before and after the PR: when guiding starts, the current/latest star position is used as the lock position. The difference is that unmodified PHD2 shows a visible jump of the crosshairs from the originally selected star position to the latest star position, whereas with this PR the crosshairs are already updated consistently, so no jump is visible. Regarding the behavior you were concerned about, I do not currently see the PR changing the final lock position or causing it to remain at the original auto-selected location. It appears to preserve the existing guiding behavior while eliminating the misleading visual jump. That said, your test was very useful because it highlights a related behavioral question: should the original user-selected or auto-selected position remain the lock target if the star drifts before guiding starts, or should PHD2 continue using the latest star position, as it does today? I may experiment with that separately in my solar branch, but I agree that this would be a distinct behavior change and should not be conflated with this PR. For this PR, my intent is narrower: to preserve the existing final lock-position behavior while keeping the displayed crosshairs consistent during the transition into guiding. I’d appreciate it if someone else could also test this PR. |
|
My objection at this point is the elimination of the SetLockPosition call at the start of guiding. The undocumented rule is that unless you are using a sticky lock position, then the start of any guiding sequence will set the lock position to the current primary star position. This has the effect of starting at a zero-point and avoiding big guiding corrections, multi-star stabilization periods, and long settling times at the start of the guiding sequence. By not using a sticky lock position, you have basically said this convention is desirable. Coming back to the unexpected UI behavior for calibration, I don't have a problem with trying to fix that but it shouldn't have any effect on how the start of guiding behaves. I'll point out that if best practices are being followed and calibrations are being done by the Calibration Assistant, the UI behavior won't be seen. Similarly, if calibrations are being done only once at the start of the night, the behavior is very unlikely to be seen. These are the normal use cases because ST-4 style guiding and repetitive calibrations are a rarity these days. So if you can revert the changes you made regarding the start-of-guiding state, there should still be a way to eliminate the UI behavior in calibration that is bothering you. |
Summary
This PR fixes a long-standing and annoying PHD2 guiding issue:
when starting guiding from a state that already had a lock position
(e.g. after a previous guiding session or after AutoSelect/click), the
calibration crosshair was drawn at the stale lock from the previous
cycle and then visibly snapped to the new lock at the moment
STATE_GUIDING was entered.
With this change, the displayed lock/crosshair position is kept consistent
with the newly selected guide position from the start of the guiding transition,
avoiding the misleading stale crosshair and the visible snap.
Root cause
Guider::SetStateSTATE_GUIDINGentry block unconditionallyoverwrote a valid lock with
CurrentPosition()(unless sticky wasset), which is what produced the jump. Meanwhile, nothing refreshed
the lock at the start of the calibration cycle, so the crosshair
was drawn at the stale previous-session value throughout calibration.
Fix
Two paired edits in
src/guider.cpp:At
STATE_CALIBRATING_PRIMARYentry, anchor the lock on thecurrent star (skipping when sticky is set and the lock is already
valid). The calibration crosshair is now drawn at the correct
guiding target from the first frame.
At
STATE_GUIDINGentry, stop overwriting a valid lock withCurrentPosition(). Only fall back toCurrentPosition()if thelock is somehow missing.
Net effect: the lock is established once, at the start of the cycle,
and stays static through calibration and guiding (except via the
existing lock-shift mechanism). No visible snap.
Behavior preserved
sticky lock in place, and the guiding-entry fallback never fires.
ShiftLockPosition()runs inUpdateGuideState, not at state-entry.STATE_CALIBRATING_PRIMARYcase still executes the anchor beforefalling through, so the lock is set in that path too.
STATE_GUIDINGentry covers any path thatarrives without a valid lock.
Notification side-effect
EvtServer.NotifySetLockPositionfires once per cycle (at calibrationentry, only when the value differs from the previous lock) instead of
at guiding entry. No increase in notification rate.
Testing
click a new star. Click Guide.
during calibration, then snaps to the new star at GUIDING entry.
frame and does not move.
useStickyLock):lock stays where the user/controller set it.