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

DEV: added robot file #27

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
DEV: Added load_sample function
.ropeproject .gitignore
brookeferber committed Jul 24, 2017
commit 5ec26372302c2a853eee7e4c9ba807ff1c03b667
42 changes: 39 additions & 3 deletions xpdsim/robot.py
Original file line number Diff line number Diff line change
@@ -2,12 +2,48 @@


class Robot(be.Mover):
# Include class variables (and the mpas) that appear in reference code?
def __init__(self, name, fields, initial_set, theta, sample_map, **kwargs):
def __init__(self, name, fields, initial_set, theta, sample_map=None):
theta = be.Mover('theta', {'rad': lambda x: x}, {'x': 0})
self.theta = theta
self._current_sample_gemorety = None
if sample_map is None:
# sample_map maps positions with image cycles @ build_image_cycle
# sample_map = {path (str): Cycler (iterable like object to cycle
# through images}
self._current_sample_geometry = None
super().__init__(name, fields, initial_set, **kwargs)

def load_sample(self, saple_number, sample_geometry=None):
Copy link
Member

Choose a reason for hiding this comment

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

Spelling

# If no sample is loaded, current_sample_number = 0
# is reported by the robot
if self.current_sample_number.get() != 0:
raise RuntimeError("Sample %d is already loaded."
% self.current_sample_number.get())

#Rotate theta into loading position if necessary
load_pos = self.TH_POS[sample_geometry]['load']
if load_post is not None:
print('Moving theta to load position')
self.theta.move(load_pos, wait=True)

# Loading the sample is a three-step procedure:
# Set sample_number; issue load_cmd; issue execute_cmd.
set_and_wait(self.sample_number, sample_number)
set_and_wait(self.load_cmd, 1)
self.execute_cmd.put(1)
print('Loading...')
self._poll_until_idle()

# Rotate theta into measurement position if necessary
measure_pos = self.TH_POS[sample_geometry]['measure']
if measure_pos is not None:
print('Moving theta to measure position')
self.theta.move(measure_pos, wait=True)

# Stash the current sample geomtery for reference when we unload
self._current_sample_geometry = sample_geometry




# What functions should be included?