pudu.utils
Shared utilities used across PUDU protocols.
Camera— captures images and records video via ffmpeg during OT-2 protocol runs.SmartPipette— pipette wrapper that uses the Opentrons liquid-tracking API to compute safe aspiration heights for conical tubes, preventing tip plunging as tubes empty.colors— list of 24 hex colour strings used to colour-code liquids in the Opentrons deck visualiser.
- pudu.utils.colors = ['#4040BF', '#BF4040', '#40BF40', '#A640BF', '#BFBF40', '#BF7340', '#40BFBF', '#BF40A6', '#73BF40', '#4073BF', '#BF8C40', '#40BF73', '#7340BF', '#A6BF40', '#BF5940', '#40A6BF', '#BF4073', '#59BF40', '#BFA640', '#40BFA6', '#8CBF40', '#40BF59', '#40BF8C', '#BF40A6']
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- class pudu.utils.Camera(video_size='320x240', picture_size='640x480', video_device='/dev/video0', storage_path='/data/user_storage')[source]
Bases:
objectCamera class for handling picture and video capture during Opentrons protocols.
This class encapsulates all camera functionality including: - Taking snapshots at specific protocol steps - Recording video during protocol execution - Handling simulation mode gracefully - Managing ffmpeg processes
- __init__(video_size='320x240', picture_size='640x480', video_device='/dev/video0', storage_path='/data/user_storage')[source]
Initialize Camera with configuration options.
- Parameters:
- cleanup_ffmpeg_processes()[source]
Clean up any running ffmpeg processes using killall.
- Return type:
None
- capture_picture(protocol, when='image')[source]
Take a picture at a specific protocol step.
- Parameters:
protocol – Opentrons protocol context
when (str) – Description of when the picture was taken (used in filename)
- Returns:
Filename of captured image if successful, None if simulation or failed
- Return type:
None
- class pudu.utils.SmartPipette(pipette, protocol)[source]
Bases:
objectOpentrons pipette wrapper that uses the API’s liquid-tracking system to compute safe aspiration heights for conical tubes.
For standard flat-bottom or round-bottom wells,
SmartPipettebehaves identically to the underlying pipette. For conical tubes (detected by labware name or theuseflag), it queries the current liquid volume viawell.current_liquid_volume()and converts that to a millimetre height, keeping the tip above the meniscus and away from the narrow tip of the cone.This prevents the pipette tip from plunging into an empty tube or aspirating air when a tube is nearly empty — a common failure mode in protocols that dispense large total volumes from a single stock tube (e.g. LB distribution during plating).
- __init__(pipette, protocol)[source]
Initialize SmartPipette.
- Parameters:
pipette – A loaded Opentrons pipette instrument object.
protocol – The active
ProtocolContext. Must supportdefine_liquid(API level ≥ 2.14).
- Raises:
RuntimeError – If the protocol context does not expose liquid tracking (API level too old).
- is_conical_tube(well, use=False)[source]
Check if the well is from a conical tube labware or manually set as true
- get_well_volume(well)[source]
Get current volume in well using pure API method
- Return type:
float | None
- get_well_height(well)[source]
Get current liquid height using pure API method (if available)
- Return type:
float | None
- get_conical_tube_aspiration_height(well)[source]
Calculate safe aspiration height for conical tubes using proven method Uses API liquid tracking to get current volume
- Return type:
- get_aspiration_location(well, use=False)[source]
Get intelligent aspiration location using API volume data and proven height calculation