TCode Servicer API

The tcode_api.api submodule allows you to write tcode scripts, but how do you put them on the robot?

The tcode_api.servicer submodule provides a client interface and relevant data structures for running tcode scripts on a robot, as well as other common tasks such as pausing and querying current runstate.

class tcode_api.servicer.client.TCodeServicerClient(servicer_url=None)

Python client for a TCode servicer.

Intended to provide an interface with the Trilobio fleet via a single python class, sufficient for interacting with the fleet programmatically.

Parameters:

servicer_url (str | None)

clear_labware()

Delete all of the current labware on the fleet.

Note:

“current labware on the fleet” includes all plates and tips, both on the deck and mounted on robots/pipettes.

Return type:

None

clear_schedule()

Clear all of the currently scheduled (but as yet unexecuted) TCode commands on the fleet.

Return type:

ClearScheduleResponse

Returns:

A summary of what was cleared.

clear_tcode_resolution()

Clear the mapping of TCode ids to real entities on the fleet.

Note:

This command internally calls clear_schedule(), but NOT clear_labware().

Note:

This command does not clear the physical labware from the deck, merely their ids.

Return type:

None

discover_fleet()

Scan the fleet for new robots, and update all robot states. Useful if you swapped tools manually as a developer.

Return type:

None

dump_tf_tree()

Write the current internal state tree to a file for debugging purposes.

Return type:

None

execute_run_loop()
Return type:

None

Run a blocking loop that monitors the servicer’s status and exits when the current

script is complete or an error occurs.

Note:

This method can be interrupted with <Ctrl-C>, which will clear the robot state and exit cleanly.

Return type:

None

get_status()

Return the current status of the servicer and fleet.

Return type:

GetStatusResponse

run_script(script)

Schedule and execute a TCode script on the fleet, starting from an empty state.

This is a convenience method that combines scheduling, starting execution, and monitoring into a single call.

Parameters:

script (TCodeScript) – The TCode script to run.

Return type:

None

schedule_command(id, command)

Append a single TCode command to the end of the current schedule and register it with the provided id.

Parameters:
Return type:

ScheduleCommandResponse

Returns:

A report on the attempted scheduling. See ScheduleCommandResponse for details.

schedule_commands(commands)

Calls schedule_command() endpoint for a list of commands sequentially.

Parameters:

commands (list[tuple[str, ASPIRATE | ADD_LABWARE | ADD_PIPETTE_TIP_GROUP | ADD_ROBOT | ADD_TOOL | CALIBRATE_LABWARE_WELL_DEPTH | CALIBRATE_LABWARE_HEIGHT | CALIBRATE_TOOL_FOR_PROBING | COMMENT | CREATE_LABWARE | DELETE_LABWARE | DISCARD_PIPETTE_TIP_GROUP | DISPENSE | MOVE_TO_LOCATION | MOVE_TO_JOINT_POSE | PAUSE | PICK_UP_LABWARE | PICK_UP_PIPETTE_TIP | PUT_DOWN_LABWARE | PUT_DOWN_PIPETTE_TIP | REMOVE_LABWARE_LID | REPLACE_LABWARE_LID | RETRIEVE_PIPETTE_TIP_GROUP | RETRIEVE_TOOL | RETURN_PIPETTE_TIP_GROUP | RETURN_TOOL | SWAP_TO_TOOL | SEND_WEBHOOK | WAIT]]) – A list of tuples of (id, command) to schedule.

Return type:

list[ScheduleCommandResponse]

Returns:

A list of reports on the attempted scheduling, in the same order as the commands were given. See ScheduleCommandResponse for details.

set_run_state(state)

Pause or start the execution of the current schedule.

Parameters:

state (bool) – True to start/resume execution, False to pause.

Return type:

None