Skip to content

Commit 76824bc

Browse files
committed
Apply rotation correction first
1 parent d65614b commit 76824bc

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### ✨ Improved
66

77
* Back to using the official `sep` package from `sep-developers/sep` now that it's maintained again.
8+
* Apply rotation and translation corrections independently, starting with rotation until the rotator has converged.
89

910

1011
## 0.7.0 - February 27, 2025

src/lvmguider/guider.py

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ async def offset_telescope(
560560
off_rot: float,
561561
timeout: float = 10,
562562
use_motor_axes: bool = False,
563+
apply_all_at_once: bool = False,
563564
) -> tuple[npt.NDArray, npt.NDArray, float]:
564565
"""Sends a correction offset to the telescope.
565566
@@ -586,6 +587,9 @@ async def offset_telescope(
586587
is applied as RA/Dec.
587588
applied_rot
588589
Correction applied to the k-mirror, in degrees.
590+
apply_all_at_once
591+
If :obj:`True`, applies the rotation and translation offsets in one go.
592+
Otherwise applies the rotation correction first, if any, and returns.
589593
590594
"""
591595

@@ -598,13 +602,38 @@ async def offset_telescope(
598602
min_rot_correction = self.config.get("min_rot_correction", 0.01)
599603
max_rot_correction = self.config.get("max_rot_correction", 3)
600604

605+
telescope = self.command.actor.telescope
606+
607+
# Rotation
608+
guide_in_rot = self.config["has_kmirror"] and self.config["guide_in_rot"]
609+
610+
if guide_in_rot and not self.is_guiding():
611+
if off_rot > max_rot_correction:
612+
self.command.warning("Requested rotator correction is too big.")
613+
614+
# Note that we do not take abs(off_rot) here because we cannot apply
615+
# correction in negative direction. This prevents that.
616+
elif off_rot > min_rot_correction:
617+
km = f"lvm.{telescope}.km"
618+
cmd_km_str = f"slewAdjust --offset_angle {off_rot:.6f}"
619+
cmd_km = await self.command.send_command(km, cmd_km_str)
620+
621+
if cmd_km.status.did_fail:
622+
self.command.error(f"Failed offsetting k-mirror {telescope}.")
623+
apply_all_at_once = True # Rotation failed, so do translation.
624+
else:
625+
applied_rot = off_rot
626+
627+
if not apply_all_at_once:
628+
return applied_radec, applied_motax, applied_rot
629+
630+
# Translation
631+
pwi = f"lvm.{telescope}.pwi"
632+
601633
if numpy.any(numpy.abs([off0, off1]) > max_ax_correction):
602634
self.command.error("Requested correction is too big. Not applying it.")
603635
return applied_radec, applied_motax, applied_rot
604636

605-
telescope = self.command.actor.telescope
606-
pwi = f"lvm.{telescope}.pwi"
607-
608637
if use_motor_axes is False:
609638
cmd_str = f"offset --ra_add_arcsec {off0} --dec_add_arcsec {off1}"
610639
applied_radec = numpy.array([off0, off1])
@@ -626,24 +655,6 @@ async def offset_telescope(
626655
if cmd.status.did_fail:
627656
raise RuntimeError(f"Failed offsetting telescope {telescope}.")
628657

629-
guide_in_rot = self.config["has_kmirror"] and self.config["guide_in_rot"]
630-
631-
if guide_in_rot and not self.is_guiding():
632-
if off_rot > max_rot_correction:
633-
self.command.warning("Requested rotator correction is too big.")
634-
635-
# Note that we do not take abs(off_rot) here because we cannot apply
636-
# correction in negative direction. This prevents that.
637-
elif off_rot > min_rot_correction:
638-
km = f"lvm.{telescope}.km"
639-
cmd_km_str = f"slewAdjust --offset_angle {off_rot:.6f}"
640-
cmd_km = await self.command.send_command(km, cmd_km_str)
641-
642-
if cmd_km.status.did_fail:
643-
self.command.error(f"Failed offsetting k-mirror {telescope}.")
644-
else:
645-
applied_rot = off_rot
646-
647658
return applied_radec, applied_motax, applied_rot
648659

649660
async def update_fits(self, guider_solution: GuiderSolution):

0 commit comments

Comments
 (0)