science_jubilee.Machine#

Driver for Controlling Jubilee

Attributes#

Exceptions#

MachineConfigurationError

Raise this error if there is something wrong with how the machine is configured

MachineStateError

Raise this error if the machine is in the wrong state to perform the requested action.

Classes#

Machine

A class representation of Jubilee used to send motion commands and polling the machine state.

Functions#

get_root_dir()

Return the path to the duckbot directory.

machine_homed(func)

Decorator used to check if the machine is homed before performing certain actions.

requires_deck(func)

Decorator used ot check if a deck has been configured before performing certain actions.

requires_safe_z(func)

Decorator used to ensure the deck is at a safe height before performing certain actions.

Module Contents#

science_jubilee.Machine.logger[source]#
science_jubilee.Machine.get_root_dir()[source]#

Return the path to the duckbot directory.

exception science_jubilee.Machine.MachineConfigurationError[source]#

Bases: Exception

Raise this error if there is something wrong with how the machine is configured

exception science_jubilee.Machine.MachineStateError[source]#

Bases: Exception

Raise this error if the machine is in the wrong state to perform the requested action.

science_jubilee.Machine.machine_homed(func)[source]#

Decorator used to check if the machine is homed before performing certain actions.

science_jubilee.Machine.requires_deck(func)[source]#

Decorator used ot check if a deck has been configured before performing certain actions.

science_jubilee.Machine.requires_safe_z(func)[source]#

Decorator used to ensure the deck is at a safe height before performing certain actions.

class science_jubilee.Machine.Machine(port: str = None, baudrate: int = 115200, address: str = None, deck_config: str = None, simulated: bool = False, crash_detection: bool = False, crash_handler=None)[source]#

A class representation of Jubilee used to send motion commands and polling the machine state.

LOCALHOST = '192.168.1.2'[source]#
ser = None[source]#
port = None[source]#
baudrate = 115200[source]#
lineEnding = Multiline-String[source]#
Show Value
"""
"""
address = None[source]#
simulated = False[source]#
model_update_timestamp = 0[source]#
command_ws = None[source]#
wake_time = None[source]#
crash_detection = False[source]#
crash_handler = None[source]#
_absolute_positioning = True[source]#
_absolute_extrusion = True[source]#
_configured_axes = None[source]#
_configured_tools = None[source]#
_active_tool_index = None[source]#
_tool_z_offsets = None[source]#
_axis_limits = (None, None, None)[source]#
axes_homed = [False, False, False, False][source]#
deck = None[source]#
tools[source]#
tool = None[source]#
current_well = None[source]#
session[source]#
connect()[source]#

Connects to Jubilee over http.

Raises:

MachineStateError – If the connection to the machine is unsuccessful.

property configured_axes[source]#

Return the configured axes of the machine. This is a list of all configured axis on the machine. Usually these are [‘X’, ‘Y’, ‘Z’, ‘U’]. If a tool has a an associated driver, it will be appended at the end of the axis list.

Returns:

A list of configured axes.

Return type:

list

property configured_tools[source]#

Returns a list of configured tools.

Returns:

A list of configured tools.The tool name is queried from the config.g file on the machine.

Return type:

list

Note: This list is obtained directly from the tools added to the machine’s config.g file.

property active_tool_index[source]#

Return the index of the current active tool.

Returns:

The index of the current active tool. If no tool is active, returns -1.

Return type:

int

property tool_z_offsets[source]#

Return (in tool order) a list of tool’s z offsets.

Note: This list is obtained directly from the tools added to the machine’s config.g file.

Returns:

A list of tool z offsets, in the order of the tool index

Return type:

list

property axis_limits[source]#

Return (in XYZU order) a list of tuples specifying (min, max) axis limit

Returns:

A list of tuples specifying (min, max) axis limit

Return type:

list

Note: This list is obtained directly from the tools added to the machine’s config.g file.

property position[source]#

Returns the current machine control point in mm.

Returns:

A dictionary of the machine control point in mm. The keys are the axis name, e.g. ‘X’

Return type:

dict

load_deck(deck_filename: str, path: str = os.path.join(os.path.dirname(__file__), 'decks', 'deck_definition'))[source]#

Load a deck configuration file onto the machine.

Parameters:
  • deck_filename (str) – The name of the deck configuration file.

  • path (str, optional) – The path to the deck configuration .json files for the labware, defaults to the ‘deck_definition/’ in the science_jubilee/decks directory.

Returns:

A Deck object

Return type:

Deck

gcode(cmd: str = '', timeout=None, response_wait: float = 60)[source]#

Send a G-Code command to the Machine and return the response.

Parameters:
  • cmd (str, optional) – The G-Code command to send, defaults to “”

  • timeout (float, optional) – The time to wait for a response from the machine, defaults to None

  • response_wait (float, optional) – The time to wait for a response from the machine, defaults to 30

Returns:

The response message from the machine. If too long, the message might not display in the terminal.

Return type:

str

delay_time(n)[source]#

Calculate delay time for next request. dumb hard code for now, could be fancy exponential backoff

_set_absolute_positioning()[source]#

Set absolute positioning for all axes except extrusion

_set_relative_positioning()[source]#

Set relative positioning for all axes except extrusion

_set_absolute_extrusion()[source]#

Set absolute positioning for extrusion

_set_relative_extrusion()[source]#

Set relative positioning for extrusion

push_machine_state()[source]#

Push machine state onto a stack

pop_machine_state()[source]#

Recover previous machine state

download_file(filepath: str = None, timeout: float = None)[source]#

Download a file into a file object. Full machine filepath must be specified. Example: /sys/tfree0.g

Parameters:
  • filepath (str, optional) – The full filepath of the file to download, defaults to None

  • timeout (float, optional) – The time to wait for a response from the machine, defaults to None

Returns:

The file contents

Return type:

file object

reset()[source]#

Issue a software reset.

home_all()[source]#

Home all axes.

home_xyu()[source]#

Home the XYU axes. Home Y before X to prevent possibility of crashing into the tool rack.

home_x()[source]#

Home the X axis

home_y()[source]#

Home the Y axis

home_u()[source]#

Home the U (tool) axis

home_v()[source]#

Home the V axis

home_z()[source]#

Home the Z axis. Note: The deck must be clear first. Will ask for user input to verify.

home_e()[source]#

Home the extruder axis (syringe)

home_in_place(*args: str)[source]#

Set the current location of a machine axis or axes to 0.

set_tool_offset(tool_idx=None, x=None, y=None, z=None)[source]#
_move_xyzev(x: float = None, y: float = None, z: float = None, e: float = None, v: float = None, s: float = 6000, param: str = None, wait: bool = False)[source]#

Move X/Y/Z/E/V axes. Set absolute/relative mode externally.

Parameters:
  • x (float, optional) – x position on the bed, in whatever units have been set (default mm)

  • y (float, optional) – y position on the bed, in whatever units have been set (default mm)

  • z (float, optional) – z position on the bed, in whatever units have been set (default mm)

  • e (float, optional) – extruder position, in whatever units have been set (default mm)

  • v (float, optional) – v axis position, in whatever units have been set (default mm)

  • s (float, optional) – speed at which to move (default 6000 mm/min)

move_to(x: float = None, y: float = None, z: float = None, e: float = None, v: float = None, s: float = 6000, param: str = None, wait: bool = True)[source]#

Move to an absolute X/Y/Z/E/V position.

Parameters:
  • x (float, optional) – x position on the bed, in whatever units have been set (default mm)

  • y (float, optional) – y position on the bed, in whatever units have been set (default mm)

  • z (float, optional) – z position on the bed, in whatever units have been set (default mm)

  • e (float, optional) – extruder position, in whatever units have been set (default mm)

  • v (float, optional) – v axis position, in whatever units have been set (default mm)

  • s (float, optional) – speed at which to move (default 6000 mm/min)

move(dx: float = 0, dy: float = 0, dz: float = 0, de: float = 0, dv: float = 0, s: float = 6000, param: str = None, wait: bool = True)[source]#

Move relative to the current position

Parameters:
  • dx (float, optional) – change in x position, in whatever units have been set (default mm)

  • dy (float, optional) – change in y position, in whatever units have been set (default mm)

  • dz (float, optional) – change in z position, in whatever units have been set (default mm)

  • de (float, optional) – change in e position, in whatever units have been set (default mm)

  • dv (float, optional) – change in v position, in whatever units have been set (default mm)

  • s (float, optional) – speed at which to move (default 6000 mm/min)

dwell(t: float, millis: bool = True)[source]#

Pauses the machine for a period of time.

Parameters:
  • t (float) – time to pause, in milliseconds by default

  • millis (bool, optional) – boolean, set to false to use seconds. default unit is milliseconds.

safe_z_movement()[source]#

Move the Z axis to a safe height to avoid crashing into labware.

_get_tool_index(tool_item: int | science_jubilee.tools.Tool.Tool | str)[source]#

Return the tool index from the provided tool item.

This method is allows the user to call a toll by its index, its name, or to use a Tool object directly.

Parameters:

tool_item (Union[int, Tool, str]) – The tool index, name, or Tool object

Returns:

The tool index

Return type:

int

load_tool(tool: science_jubilee.tools.Tool.Tool = None)[source]#

Add a new tool for use on the machine.

reload_tool(tool: science_jubilee.tools.Tool.Tool = None)[source]#

Update a tool which has already been loaded.

pickup_tool(tool_id: int | str | science_jubilee.tools.Tool.Tool)[source]#

Pick up the tool specified by a tool index, name or Tool object.

Parameters:

tool_id (Union[int, str, Tool]) – The tool index, name, or Tool object

Raises:
park_tool()[source]#

Park the current tool adn cahnges active tool index to -1.

get_position()[source]#

Get the current position of the machine control point in mm.

Returns:

A dictionary of the machine control point in mm. The keys are the axis name, e.g. ‘X’

Return type:

dict

load_labware(labware_filename: str, slot: int, path: str = None, order: str = 'rows')[source]#
Function that loads a labware and associates it with a specific slot on the deck.

The slot offset is also applied to the labware asocaite with it.

Parameters:
  • labware_filename (str) – The name of the labware configuration file.

  • slot (int) – The index of the slot to load the labware into.

  • path (str, optional) – The path to the labware configuration .json files for the labware.

  • order (str, optional) – The order in which the labware is arranged on the deck. Can be ‘rows’ or ‘columns’, defaults to ‘rows’.

Returns:

The Labware object that has been loaded into the slot.

Return type:

Labware

tool_lock()[source]#

Runs Jubilee tool lock macro. Assumes tool_lock.g macro exists.

tool_unlock()[source]#

Runs Jubilee tool unlock macro. Assumes tool_unlock.g macro exists.

disconnect()[source]#

Close the connection.

__enter__()[source]#
__exit__(*args)[source]#