Skip to content

Commit

Permalink
Merge pull request #182 from lsst-ts/tickets/DM-47641
Browse files Browse the repository at this point in the history
  • Loading branch information
edennihy authored Dec 2, 2024
2 parents 5050117 + 9d2bf5d commit 837b33b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs, reduce m1m3 setting time.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In base_tcs, update _handle_in_position method to expose the timeout to use when handling the initial state race condition. 81efa99 Tiago Ribeiro <[email protected]> Dec 1, 2024 at 10:59 PM
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs, use the custom race_condition_timeout for checking the mount and hexapod are in position.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs.py, update wait_for_rotator_inposition to use a lower race condition timeout and to not await any settling time.
1 change: 1 addition & 0 deletions doc/news/DM-47641.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In maintel/mtcs, update _handle_m1m3_hardpoint_correction_command to wait for m1m3_settle_time after enabling/disabling force balance.
1 change: 1 addition & 0 deletions doc/news/DM-47641.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed backwards compatibility with m1m3 FATables not being in ts-xml.
5 changes: 4 additions & 1 deletion python/lsst/ts/observatory/control/base_tcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,7 @@ async def _handle_in_position(
timeout: float,
settle_time: float = 5.0,
component_name: str = "",
race_condition_timeout: float = 5.0,
) -> str:
"""Handle inPosition event.
Expand All @@ -1917,6 +1918,8 @@ async def _handle_in_position(
component_name : `str`, optional
The name of the component. This is used in log messages and to
construct a return message when in position.
race_condition_timeout : `float`
Timeout to use when handling race condition (in seconds).
Returns
-------
Expand All @@ -1931,7 +1934,7 @@ async def _handle_in_position(
in_position = await in_position_event.aget(timeout=self.fast_timeout)
self.log.debug(f"{component_name} in position: {in_position.inPosition}.")

_settle_time = max([settle_time, self.fast_timeout])
_settle_time = max([settle_time, race_condition_timeout])

if in_position.inPosition:
self.log.debug(
Expand Down
32 changes: 23 additions & 9 deletions python/lsst/ts/observatory/control/maintel/mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@
from lsst.ts import salobj, utils
from lsst.ts.utils import angle_diff
from lsst.ts.xml.enums import MTM1M3, MTM2, MTDome, MTMount, MTPtg, MTRotator

try:
from lsst.ts.xml.tables.m1m3 import FATable
except ImportError:
from lsst.ts.criopy.M1M3FATable import FATABLE as FATable
from lsst.ts.xml.tables.m1m3 import FATable

from ..base_tcs import BaseTCS
from ..constants import mtcs_constants
Expand Down Expand Up @@ -128,6 +124,20 @@ def __init__(

self.open_dome_shutter_time = 1200.0
self.timeout_hardpoint_test_status = 600.0
# There is a race condition when commanding the mount
# to a new target, which is the time it takes for it
# to start moving after we send the command to the pointing.
# This timeout expresses how long to wait when handling this
# race condition.
self.mtmount_race_condition_timeout = 3.0
# Similar to the mtmount_race_condition_timeout, this is
# used to check the in position event race condition for
# the hexapod when checking if it is ready to take data.
self.hexapod_ready_to_take_data_timeout = 0.5
# Similar to the mtmount_race_condition_timeout, this is
# used to check the in position event race condition for
# the rotator when checking if it is in position.
self.mtrotator_race_condition_timeout = 3.0

self.tel_park_el = 80.0
self.tel_park_az = 0.0
Expand Down Expand Up @@ -155,7 +165,7 @@ def __init__(
# timeout to raise m1m3, in seconds.
self.m1m3_raise_timeout = 600.0
# time it takes for m1m3 to settle after a slew finishes.
self.m1m3_settle_time = 5.0
self.m1m3_settle_time = 0.0

# Tolerance on the stability of the balance force magnitude
self.m1m3_force_magnitude_stable_tolerance = 50.0
Expand Down Expand Up @@ -503,12 +513,14 @@ async def wait_for_mtmount_inposition(
timeout=timeout,
settle_time=0.0,
component_name="MTMount elevation",
race_condition_timeout=self.mtmount_race_condition_timeout,
),
self._handle_in_position(
self.rem.mtmount.evt_azimuthInPosition,
timeout=timeout,
settle_time=0.0,
component_name="MTMount azimuth",
race_condition_timeout=self.mtmount_race_condition_timeout,
),
)

Expand Down Expand Up @@ -572,8 +584,9 @@ async def wait_for_rotator_inposition(
return await self._handle_in_position(
self.rem.mtrotator.evt_inPosition,
timeout=timeout,
settle_time=self.tel_settle_time,
settle_time=0.0,
component_name="MTRotator",
race_condition_timeout=self.mtrotator_race_condition_timeout,
)

async def dome_az_in_position(self) -> str:
Expand Down Expand Up @@ -1547,9 +1560,9 @@ async def _handle_m1m3_hardpoint_correction_command(
)
except (asyncio.TimeoutError, salobj.base.AckTimeoutError):
self.log.warning("Command timed out, continuing.")
else:
self.log.debug("Waiting for force balance system to settle.")
self.log.info("Waiting for force balance system to settle.")
await self._wait_force_balance_system_state(enable=enable)
await asyncio.sleep(self.m1m3_settle_time)
else:
self.log.warning(
f"Hardpoint corrections already in desired state ({enable=}). Nothing to do."
Expand Down Expand Up @@ -2595,6 +2608,7 @@ async def _ready_to_take_data(self) -> None:
timeout=self.long_timeout,
settle_time=0.0,
component_name="Camera Hexapod",
race_condition_timeout=self.hexapod_ready_to_take_data_timeout,
),
)
except asyncio.TimeoutError:
Expand Down
9 changes: 7 additions & 2 deletions python/lsst/ts/observatory/control/remote_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,16 @@ async def get_state(
timeout=self.fast_timeout
)
return salobj.State(ss.summaryState)
except asyncio.TimeoutError as e:
except asyncio.TimeoutError:
if ignore_timeout:
return None
else:
raise e
raise asyncio.TimeoutError(
f"Timeout getting summary state for {component}. "
"This usually means that no historical data is available. "
"You might have to recycle the CSC state manually to recover "
"from this condition."
)

async def next_state(self, component: str) -> salobj.State:
"""Get summary state for component.
Expand Down
1 change: 0 additions & 1 deletion ups/ts_observatory_control.table
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ setupRequired(sconsUtils)
setupRequired(ts_utils)
setupRequired(ts_salobj)
setupRequired(ts_idl)
setupRequired(ts_criopy)

envPrepend(PATH, ${PRODUCT_DIR}/bin)

Expand Down

0 comments on commit 837b33b

Please sign in to comment.