science_jubilee.Machine
#
Driver for Controlling Jubilee
Module Contents#
Classes#
A class representation of Jubilee used to send motion commands and polling the machine state. |
Functions#
Return the path to the duckbot directory. |
|
|
Decorator used to check if the machine is homed before performing certain actions. |
|
Decorator used ot check if a deck has been configured before performing certain actions. |
|
Decorator used to ensure the deck is at a safe height before performing certain actions. |
- science_jubilee.Machine.get_root_dir()#
Return the path to the duckbot directory.
- exception science_jubilee.Machine.MachineConfigurationError#
Bases:
Exception
Raise this error if there is something wrong with how the machine is configured
- exception science_jubilee.Machine.MachineStateError#
Bases:
Exception
Raise this error if the machine is in the wrong state to perform the requested action.
- science_jubilee.Machine.machine_homed(func)#
Decorator used to check if the machine is homed before performing certain actions.
- science_jubilee.Machine.requires_deck(func)#
Decorator used ot check if a deck has been configured before performing certain actions.
- science_jubilee.Machine.requires_safe_z(func)#
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)#
A class representation of Jubilee used to send motion commands and polling the machine state.
- property configured_axes#
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#
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#
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#
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#
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#
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
- LOCALHOST = '192.168.1.2'#
- connect()#
Connects to Jubilee over http.
- Raises:
MachineStateError – If the connection to the machine is unsuccessful.
- load_deck(deck_filename: str, path: str = os.path.join(os.path.dirname(__file__), 'decks', 'deck_definition'))#
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)#
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()#
Set absolute positioning for all axes except extrusion
- _set_relative_positioning()#
Set relative positioning for all axes except extrusion
- _set_absolute_extrusion()#
Set absolute positioning for extrusion
- _set_relative_extrusion()#
Set relative positioning for extrusion
- push_machine_state()#
Push machine state onto a stack
- pop_machine_state()#
Recover previous machine state
- download_file(filepath: str = None, timeout: float = None)#
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()#
Issue a software reset.
- home_all()#
Home all axes.
- home_xyu()#
Home the XYU axes. Home Y before X to prevent possibility of crashing into the tool rack.
- home_x()#
Home the X axis
- home_y()#
Home the Y axis
- home_u()#
Home the U (tool) axis
- home_v()#
Home the V axis
- home_z()#
Home the Z axis. Note: The deck must be clear first. Will ask for user input to verify.
- home_e()#
Home the extruder axis (syringe)
- home_in_place(*args: str)#
Set the current location of a machine axis or axes to 0.
- set_tool_offset(tool_idx=None, x=None, y=None, z=None)#
- _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)#
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)#
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)#
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)#
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()#
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)#
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)#
Add a new tool for use on the machine.
- reload_tool(tool: science_jubilee.tools.Tool.Tool = None)#
Update a tool which has already been loaded.
- pickup_tool(tool_id: int | str | science_jubilee.tools.Tool.Tool)#
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:
MachineConfigurationError – If the tool is not loaded on the machine.
ValueError – If the indicated tool_id is not of type Union[int, str, Tool].
- park_tool()#
Park the current tool adn cahnges active tool index to -1.
- get_position()#
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')#
- 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()#
Runs Jubilee tool lock macro. Assumes tool_lock.g macro exists.
- tool_unlock()#
Runs Jubilee tool unlock macro. Assumes tool_unlock.g macro exists.
- disconnect()#
Close the connection.
- __enter__()#
- __exit__(*args)#