-
Notifications
You must be signed in to change notification settings - Fork 22
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
Helper to check against motor limits #41
Comments
My current work around is: class XYZLimitsChecker(Device):
"""Checks that a position is within the XYZ limits of the motor.
To use set the x, y, z vector to the device and read check `within_limits`
"""
def __init__(self, prefix: str) -> None:
self.within_limits = False
axes = ["X", "Y", "Z"]
self.limit_signals = {
axis: (
epics_signal_r(float, f"{prefix}{axis}.LLM"),
epics_signal_r(float, f"{prefix}{axis}.HLM"),
)
for axis in axes
}
def children(self) -> Iterator[Tuple[str, Device]]:
for attr, signals in self.limit_signals.items():
yield attr + "low_lim", signals[0]
yield attr + "high_lim", signals[1]
return super().children()
async def _check_limits(self, position: np.ndarray):
check_within_limits = True
for i, axis_limits in enumerate(self.limit_signals.values()):
check_within_limits &= (
(await axis_limits[0].get_value())
< position[i]
< (await axis_limits[1].get_value())
)
self.within_limits = check_within_limits
def set(self, position: np.ndarray) -> AsyncStatus:
return AsyncStatus(wait_for(self._check_limits(position), None))
def my_plan():
yield from bps.set(limit_checker, [1, 2, 3])
if limit_checker.within_limits:
... |
Discussed offline and decided plan logic that gets limits from specific signals on the motor, then put the plan stub in ophyd-async next to the Motor class |
Something like: def motor_position_within_limits(motor: Motor, position: float):
low, high = yield bps.locate(motor.low_limit_travel, motor.high_limit_travel)
return low.readback <= position <= high.readback Living in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Hyperion, and in general across MX DAQ, we want to be able to easily check if a position is within motion limits. Specifically, we use optical edge detection to find a pin tip and then want to check if that's within the smargon limits or else stop the collection.
In
ophyd
we do something like:There are issues in doing this in
ophyd-async
:Motor
object (Change motor internals to better match ophyd #42)get
s without going through theRE
The text was updated successfully, but these errors were encountered: