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 method for moving motor a distance relative to the current position #1116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions ophyd/epics_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,43 @@ def move(self, position, wait=True, **kwargs):

return status

@raise_if_disconnected
def rmove(self, distance, wait=True, **kwargs):
"""Move a specified distance from the current position

Parameters
----------
distance
Distance to move in positive or negative direction
moved_cb : callable
Call this callback when movement has finished. This callback must
accept one keyword argument: 'obj' which will be set to this
positioner instance.
timeout : float, optional
Maximum time to wait for the motion. If None, the default timeout
for this positioner is used.

Returns
-------
status : MoveStatus

Raises
------
TimeoutError
When motion takes longer than `timeout`
ValueError
On invalid positions
RuntimeError
If motion fails other than timing out
"""

# Simply add the distance to the current position and move to
# new position
current_position = self.position
position = current_position + distance

return self.move(position, wait=wait, **kwargs)

@property
@raise_if_disconnected
def position(self):
Expand Down