Skip to content

Commit

Permalink
Add MTCS.park_mount and MTCS.unpark_mount methods to support TMA …
Browse files Browse the repository at this point in the history
…park/unpark operations
  • Loading branch information
MarcoRocchietti committed Nov 12, 2024
1 parent 09ee0a6 commit 28f3d42
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 37 deletions.
72 changes: 35 additions & 37 deletions python/lsst/ts/observatory/control/maintel/mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def __init__(
self.dome_flat_az = 20.0
self.dome_flat_el = self.dome_park_el
self.dome_slew_tolerance = Angle(1.5 * u.deg)
self.home_dome_az = 328.0

# TODO (DM-45609): This is an initial guess for the time it takes the
# dome to park. It might need updating.
Expand Down Expand Up @@ -845,42 +844,9 @@ async def close_m1_cover(self) -> None:
f"{MTMount.DeployableMotionState.DEPLOYED!r}"
)

async def home_dome(self, physical_az: float = 0.0) -> None:
"""Utility method to home dome.
Parameters
----------
physical_az : `float`
Azimuth angle of the dome as read by markings (in deg).
"""
self.log.info("Homing dome")
reported_az = await self.rem.mtdome.tel_azimuth.aget(timeout=self.fast_timeout)

offset = physical_az - reported_az.positionActual
self.log.debug(f"Dome azimuth offset: {offset} degrees")
target_az = self.home_dome_az - offset
await self.slew_dome_to(target_az)

self.rem.mtdome.evt_azMotion.flush()

await self.rem.mtdome.cmd_stop.set_start(
engageBrakes=True,
subSystemIds=MTDome.SubSystemId.AMCS,
timeout=self.long_long_timeout,
)
motion_state = await self.rem.mtdome.evt_azMotion.aget(
timeout=self.fast_timeout
)
while motion_state.state != MTDome.MotionState.STOPPED_BRAKED:
motion_state = await self.rem.mtdome.evt_azMotion.next(
flush=False, timeout=self.long_long_timeout
)
self.log.debug(f"Motion state: {MTDome.MotionState(motion_state.state)!r}")

await self.rem.mtdome.cmd_setZeroAz.start(timeout=self.fast_timeout)
azimuth = await self.rem.mtdome.tel_azimuth.aget(timeout=self.fast_timeout)
self.log.debug(f"{azimuth.positionActual=}, {azimuth.positionCommanded=}")
async def home_dome(self) -> None:
# TODO: Implement (DM-21336).
raise NotImplementedError("# TODO: Implement (DM-21336).")

async def open_dome_shutter(self) -> None:
# TODO: Implement (DM-21336).
Expand Down Expand Up @@ -989,6 +955,38 @@ async def in_m1_cover_operational_range(self) -> bool:

return elevation.actualPosition >= self.tel_operate_mirror_covers_el

async def park_mount(self, position: MTMount.ParkPosition) -> None:
"""Park the TMA in the selected position.
Parameters
----------
position : `MTMount.ParkPosition`
The position to park the TMA.
"""

await self.assert_all_enabled(
message="All components need to be enabled for parking the TMA."
)

# check first if Mount is already in PARKED state (?)
# to implement

await self.rem.mtmount.cmd_park.start(
position=position, timeout=self.long_timeout
)

async def unpark_mount(self) -> None:
"""Un-park the TMA."""

await self.assert_all_enabled(
message="All components need to be enabled for unparking the TMA."
)

# check first if Mount is PARKED state (?)
# to implement

await self.rem.mtmount.cmd_unpark.start(timeout=self.long_timeout)

async def prepare_for_flatfield(self, check: typing.Any = None) -> None:
# TODO: Implement (DM-21336).
raise NotImplementedError("# TODO: Implement (DM-21336).")
Expand Down
30 changes: 30 additions & 0 deletions tests/maintel/test_mtcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,36 @@ async def test_not_in_m1_cover_operational_range(self) -> None:

assert not elevation_in_range

async def test_park_mount_zenith(self) -> None:
await self.mtcs.enable()
await self.mtcs.assert_all_enabled()

await self.mtcs.park_mount(MTMount.ParkPosition.ZENITH)

self.mtcs.rem.mtmount.cmd_park.start.assert_awaited_with(
position=MTMount.ParkPosition.ZENITH, timeout=self.mtcs.long_timeout
)

async def test_park_mount_horizon(self) -> None:
await self.mtcs.enable()
await self.mtcs.assert_all_enabled()

await self.mtcs.park_mount(MTMount.ParkPosition.HORIZON)

self.mtcs.rem.mtmount.cmd_park.start.assert_awaited_with(
position=MTMount.ParkPosition.HORIZON, timeout=self.mtcs.long_timeout
)

async def test_unpark_mount(self) -> None:
await self.mtcs.enable()
await self.mtcs.assert_all_enabled()

await self.mtcs.unpark_mount()

self.mtcs.rem.mtmount.cmd_unpark.start.assert_awaited_with(
timeout=self.mtcs.long_timeout
)

async def test_slew_to_m1_cover_operational_range(self) -> None:
self._mtmount_tel_azimuth.actualPosition = 0.0
self._mtmount_tel_elevation.actualPosition = (
Expand Down

0 comments on commit 28f3d42

Please sign in to comment.