LATRt XY Stage Agent
This agent is used to communicate with the XY Stages used in the LATRt lab. These stages are run off a Raspberry Pi connected to some custom electronics boards for communicating with the stages.
Since control of these stages need to be accessible inside and outside OCS, their drivers are shared here.
usage: python3 agent.py [-h] [--ip-address IP_ADDRESS] [--port PORT]
[--mode MODE]
[--sampling_frequency SAMPLING_FREQUENCY]
Agent Options
- --ip-address
- --port
- --mode
- --sampling_frequency
Dependencies
The LATRt XY Stage agent requires the xy_stage_control module. This can be installed via pip:
$ python -m pip install 'xy_stage_control @ git+https://github.com/kmharrington/xy_stage_control.git@main'
Configuration File Examples
Below are configuration examples for the ocs config file.
OCS Site Config
To configure the LATRt XY Stage Agent we need to add a block to our ocs configuration file. Here is an example configuration block using all of the available arguments:
{'agent-class': 'LATRtXYStageAgent',
'instance-id': 'XYWing',
'arguments': [
['--ip-address', '192.168.10.15'],
['--port', 3010],
['--mode', 'acq'],
['--sampling_freqency', '2'],
]},
Agent API
- class socs.agents.xy_stage.agent.LATRtXYStageAgent(agent, ip_addr, port, mode=None, samp=2)[source]
Agent for connecting to the LATRt XY Stages.
- Parameters:
ip_addr – IP address where RPi server is running.
port – Port the RPi Server is listening on.
mode – ‘acq’: Start data acquisition on initialize.
samp – Default sampling frequency in Hz.
- move_x_cm(distance, velocity)[source]
Task - Move the X axis.
- Parameters:
distance (float) – Distance to move in cm.
velocity (float) – Velocity to move at. Must be less than 1.2.
- move_y_cm(distance, velocity)[source]
Task - Move the Y axis.
- Parameters:
distance (float) – Distance to move in cm.
velocity (float) – Velocity to move at. Must be less than 1.2.
- set_position(position)[source]
Task - Set position of the XY stage.
- Parameters:
position (tuple) – (X, Y) position.
- acq(sampling_frequency=2)[source]
Process - Run data acquisition.
- Parameters:
sampling_frequency (float) – Sampling rate to acquire data at. Defaults to value set in site config file (or 2 Hz if unspecified.)
Notes
The most recent positions are stored in the session.data object in the format:
>>> response.session['data'] {"positions": {"x": x position in cm, "y": y position in cm} }
Example Clients
Below is an example client demonstrating full agent functionality. Note that all tasks can be run even while the data acquisition process is running.:
from ocs.ocs_client import OCSClient
# Initialize the Stages
xy_agent = OCSClient('XYWing', args=[])
xy_agent.init.start()
xy_agent.init.wait()
# Move in X
xy_agent.move_x_cm.start( distance=6, velocity=1)
xy_agent.move_x_cm.wait()
# Move in Y
xy_agent.move_y_cm.start( distance=6, velocity=1)
xy_agent.move_y_cm.wait()
# Get instantaneous position
status, message, session = xy_stage.acq.status()
print(session['data']['data'])