-
Notifications
You must be signed in to change notification settings - Fork 19
Automatic pier flip in TelescopeBase (replaces chimera-autopierchange) #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,67 @@ def __init__(self): | |
| super().__init__() | ||
|
|
||
| self._park_position = None | ||
| # True once the mount has been seen tracking east of pier_flip_ha, i.e. | ||
| # heading for the flip. See _check_pier_flip(). | ||
| self._pier_flip_armed = False | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This boolean is not needed, you can just take the desired flip/not-flip and return inside _check_pier_flip. A decision doesn't carry for the next cycle, it is always evaluated again. |
||
|
|
||
| # a pier flip is a minutes-scale event and every check asks the mount | ||
| # where it is: 2 Hz (the ChimeraObject default) is pointless traffic on | ||
| # a serial mount. Drivers needing a faster loop call set_hz() in | ||
| # __start__, which runs after this. | ||
| self.set_hz(1 / 5.0) | ||
|
|
||
| def control(self) -> bool: | ||
| """ | ||
| Runs the automatic pier flip check on every cycle of the object's | ||
| control loop, then the driver's own periodic work. Drivers implement | ||
| L{_control}. | ||
| """ | ||
| self._check_pier_flip() | ||
| return self._control() | ||
|
|
||
| def _control(self) -> bool: | ||
| """ | ||
| Periodic driver work, called from L{control} on every cycle of the | ||
| control loop. Runs unlocked, on the control loop thread. | ||
|
|
||
| @return: False to stop the control loop. | ||
| @rtype: bool | ||
| """ | ||
| return True | ||
|
|
||
| def _check_pier_flip(self): | ||
| """ | ||
| Flip a German equatorial mount that has tracked past C{pier_flip_ha}. | ||
|
|
||
| The mount is re-slewed to where it is already pointing, which is what | ||
| makes it choose the other side of the pier. Only a mount that reached | ||
| the limit by tracking is flipped: one that slewed straight to an object | ||
| past the limit is already on the side the mount driver picked for it. | ||
| """ | ||
| flip_ha = self["pier_flip_ha"] | ||
| if flip_ha is None: | ||
| return | ||
|
|
||
| if self.is_slewing() or not self.is_tracking(): | ||
| # wherever the next slew lands is the new starting point | ||
| self._pier_flip_armed = False | ||
| return | ||
|
|
||
| ha = self.get_site().ra_to_ha(self.get_ra()) | ||
|
|
||
| if ha < flip_ha: | ||
| self._pier_flip_armed = True | ||
| return | ||
|
|
||
| if not self._pier_flip_armed: | ||
| return | ||
|
|
||
| self.log.info(f"Hour angle {ha:.3f} h is past {flip_ha} h, flipping the pier.") | ||
| self.slew_to_ra_dec(*self.get_position_ra_dec()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double check if the epoch return by get_position_ra_dec would be the expected one for the next slew so we don't move targets by mistake. |
||
| # only on success: a flip that raised stays armed and is retried on the | ||
| # next cycle, rather than leaving the mount tracking into the pier | ||
| self._pier_flip_armed = False | ||
|
|
||
| @lock | ||
| def slew_to_object(self, name): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the coord convention adjustment to CoordUtil.ra_to_ha itself.