science_jubilee.Machine#

Driver for Controlling Jubilee

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#

Deck

Class that defines the Jubilee deck.

Tool

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#

class science_jubilee.Machine.Deck(deck_filename, path: str = os.path.join(os.path.dirname(__file__), 'deck_definition'))[source]#

Bases: SlotSet

Class that defines the Jubilee deck.

The deck is a set of slots that can have labware loaded into them. The deck is defined by a configuration file that specifies the number of slots, their offsets, and the type of bed they are arranged in.

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.

_get_slots()[source]#

Function that creates a dictionary of Slot objects from the deck configuration file.

Returns:

A dictionary of Slot objects, where the key is the slot’s index.

Return type:

Dict[str, Slot]

property bedType#
Function that returns the type of bed loaded onto Jubilee.
Returns:

The name/type of deck loaded onto Jubilee, e.g., Lab Automation Deck, Heated Deck, etc.

Return type:

str

property totalslots#
Function that returns the total number of slots on the deck.
Returns:

The total number of slots on the deck.

Return type:

int

property slotType#
Function that returns the type of slot arrangement the deck might have.
Returns:

The slot arrangement type. This is inidcated in the configuration file. Standard is “SLAS”.

Return type:

str

property offsetFrom#
Function that returns which corner or the slot to apply to a labware loaded on it.
Returns:

The corner of the slot to apply to the labware. This is inidcated in the configuration file.

Return type:

str

property deck_material#
Function that returns the material that the deck and possible mask are made of.
Returns:

The material that the deck is made of, as well as any mask that is applied to it.

Return type:

Dict[str, str]

property safe_z#
Function that returns the movement clearance height of the deck.
Returns:

The height at which the pipette can freely move without colliding with labware on the deck.

Return type:

float

load_labware(labware_filename: str, slot: int, path=os.path.join(os.path.dirname(__file__), '..', 'labware', 'labware_definition'), 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, defaults to the ‘labware_definition/’ in the science_jubilee/labware directory.

  • 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

class science_jubilee.Machine.Tool(index, name, **kwargs)[source]#
post_load()[source]#

Run any code after tool has been associated with the machine.

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)[source]#

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

LOCALHOST = '192.168.1.2'[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 = 30)[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

_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 = False)[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 = False)[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]#