Skip to content
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

Add unpark MTDome logic for MTCS #161

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Add unpark MTDome logic for MTCS #161

merged 2 commits into from
Sep 26, 2024

Conversation

iglesu
Copy link
Contributor

@iglesu iglesu commented Sep 6, 2024

Add unpark MTDome logic for MTCS and related tests

- Implemented unpark logic in MTCS to move the dome from PARKED state.
- Added mock support for dome events in MTCSAsyncMock.
- Included unit tests for unpark_dome

@iglesu iglesu requested a review from tribeiro September 6, 2024 22:30
@iglesu iglesu marked this pull request as draft September 10, 2024 17:32
@iglesu iglesu marked this pull request as ready for review September 18, 2024 21:45
@iglesu iglesu force-pushed the tickets/DM-45610 branch 3 times, most recently from 0bed32e to 276a77f Compare September 20, 2024 20:23
Copy link
Member

@tribeiro tribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I some some questions regarding the use of azEnabled event, why not rely on the azMotion like we did for parking?

Also, please, make sure all methods and attributes are snake_case.

timeout=self.fast_timeout
)

az_delta = 0.1 # A small move to un-park the Dome
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this a class attribute instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we also add the
unpark_velocity = 0.0 # The Dome defaults to a crawl velocity

as an attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per @tribeiro comment:
velocity will always be zero, no matter what.. you can even ignore that parameter and don't set it as the default is zero.

@@ -25,6 +25,7 @@
import copy
import enum
import logging
import time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't use the time module, you already have timing functionality with the lsst.ts.utils module. You can user utils.current_tai().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the azEnabled check

@@ -632,6 +633,52 @@ def dome_ready(az_motion: salobj.type_hints.BaseMsgType) -> bool:
f"Dome state: {MTDome.MotionState(az_motion.state).name}, inPosition: {az_motion.inPosition}"
)

async def wait_for_dome_azEnabled(self, timeout: float) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name should be snake_case, please rename it to wait_for_dome_az_enabled.

However, do you really need this method? won't the one you included for parking (wait_for_dome_state) do the work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azEnabled check removed

)

# The cmd_MoveAz should issue a azEnabled event set to ENABLED
await self.wait_for_dome_azEnabled(timeout=self.park_dome_timeout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you really need to look for this event? Why not rely on the wait_for_dome_state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the azEnabled event, I'm following the advice given by you and Wouter on the issue: https://rubinobs.atlassian.net/browse/DM-45608?focusedCommentId=523258 specifically:

Also check the azMotion, and azEnabled events to verify UNPARKED status.

but happy to do otherwise.

Copy link
Contributor Author

@iglesu iglesu Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per @tribeiro comment:
I think the comments was more on the lines of use one or the other..

in light of that I'm removing the azEnabled check

@@ -121,10 +121,14 @@ async def setup_types(self) -> None:
)

# MTDome Motion PARKED state. State is set by the mocked park cmd.
self._mtdome_evt_azMotion_state = types.SimpleNamespace(
self._mtdome_evt_azMotion = types.SimpleNamespace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use snake_case for attributes.

state=MTDome.MotionState.UNDETERMINED, inPosition=False
)

self._mtdome_evt_azEnabled = types.SimpleNamespace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake_case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing the azEnabled check

@@ -148,6 +148,9 @@ def __init__(
self._dome_az_in_position: typing.Union[None, asyncio.Event] = None
self._dome_el_in_positio: typing.Union[None, asyncio.Event] = None

self.az_delta = 0.1 # A small move to un-park the Dome
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, instead of relying on the comment (that is only really here) to specify what the attribute is, use a more expressive name. Something like;

# Small offset (in degrees) applied to the dome to unpark it.
self.dome_az_unpark_offset = 0.1

Would be better.

@@ -148,6 +148,9 @@ def __init__(
self._dome_az_in_position: typing.Union[None, asyncio.Event] = None
self._dome_el_in_positio: typing.Union[None, asyncio.Event] = None

self.az_delta = 0.1 # A small move to un-park the Dome
self.dome_unpark_velocity = 0.0 # A small move to un-park the Dome
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary so please, consider removing it.

message="All components need to be enabled for un-parking the Dome."
)

self.log.info("Checking if the dome is currently PARKED.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe debug level instead?

self.rem.mtdome.evt_azMotion.flush()

# We don't specify the dome velocity as it defaults to a
# `crawl` which is what we want.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correctly stated. This should read:

# We don't specify the dome velocity as it defaults to
# zero, which is what we want.

Copy link
Member

@tribeiro tribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

- Implemented unpark logic in MTCS to move the dome from PARKED state.
- Added mock support for dome events in MTCSAsyncMock.
- Included unit tests for unpark_dome
@iglesu iglesu merged commit fa702c9 into develop Sep 26, 2024
5 checks passed
@iglesu iglesu deleted the tickets/DM-45610 branch September 26, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants