RWS (Robot Web Services) AsyncIO

abb_robot_client.rws_aio

The rws_aio module implements asyncio methods. To use, the abb_robot_client[aio] option must be installed with pip.

class abb_robot_client.rws_aio.RWS_AIO(base_url='http://127.0.0.1:80', username=None, password=None)

Robot Web Services asyncio client. This class has the same functionality as abb_robot_client.rws.RWS, but uses asyncio instead of synchronous interface.

Parameters:
  • base_url – Base URL of the robot. For Robot Studio instances, this should be http://127.0.0.1:80, the default value. For a real robot, 127.0.0.1 should be replaced with the IP address of the robot controller. The WAN port ethernet must be used, not the maintenance port.

  • username – The HTTP username for the robot. Defaults to ‘Default User’

  • password – The HTTP password for the robot. Defaults to ‘robotics’

async activate_task(task)

Activate a RAPID task

Parameters:

task (str) – The name of the task to activate

async deactivate_task(task)

Deactivate a RAPID task

Parameters:

task (str) – The name of the task to activate

async delete_file(filename)

Delete a file on the controller

Parameters:

filename (str) – The filename to delete

Return type:

None

async get_analog_io(signal, network='Local', unit='DRV_1')

Get the value of an analog IO signal.

Parameters:
  • signal (str) – The name of the signal

  • network (str) – The network the signal is on. The default Local will work for most signals.

  • unit (str) – The drive unit of the signal. The default DRV_1 will work for most signals.

Return type:

float

Returns:

The value of the signal

async get_controller_state()

Get the controller state. The controller state can have the following values:

init, motoroff, motoron, guardstop, emergencystop, emergencystopreset, sysfail

RAPID can only be executed and the robot can only be moved in the motoron state.

Return type:

str

Returns:

The controller state

async get_digital_io(signal, network='Local', unit='DRV_1')

Get the value of a digital IO signal.

Parameters:
  • signal (str) – The name of the signal

  • network (str) – The network the signal is on. The default Local will work for most signals.

  • unit (str) – The drive unit of the signal. The default DRV_1 will work for most signals.

Return type:

int

Returns:

The value of the signal. Typically 1 for ON and 0 for OFF

async get_execution_state()

Get the RAPID execution state

Return type:

RAPIDExecutionState

Returns:

The RAPID execution state

async get_ipc_queue(queue_name)

Get the IPC queue

Parameters:

queue_name – The name of the queue

async get_jointtarget(mechunit='ROB_1')

Get the current jointtarget for specified mechunit

Parameters:

mechunit (str) – The mechanical unit to read

Returns:

The current jointtarget

async get_operation_mode()

Get the controller operational mode. The controller operational mode can have the following values:

INIT, AUTO_CH, MANF_CH, MANR, MANF, AUTO, UNDEF

Typical values returned by the controller are AUTO for auto mode, and MANR for manual reduced-speed mode.

Return type:

str

Returns:

The controller operational mode.

async get_ramdisk_path()

Get the path of the RAMDISK variable on the controller

Return type:

str

Returns:

The RAMDISK path

async get_rapid_variable(var, task='T_ROB1')

Get value of a RAPID pers variable

Parameters:
  • var (str) – The pers variable name

  • task (str) – The task containing the pers variable

Return type:

str

Returns:

The pers variable encoded as a string

async get_rapid_variable_jointtarget(var, task='T_ROB1')

Get a RAPID pers variable and convert to JointTarget

Parameters:
  • var (str) – The pers variable name

  • task (str) – The task containing the pers variable

Returns:

The pers variable encoded as a JointTarget

async get_rapid_variable_jointtarget_array(var, task='T_ROB1')

Get a RAPID pers variable and convert to JointTarget list

Parameters:
  • var – The pers variable name

  • task (str) – The task containing the pers variable

Returns:

The pers variable encoded as a list of JointTarget

async get_rapid_variable_num(var, task='T_ROB1')

Get a RAPID pers variable and convert to float

Parameters:
  • var (str) – The pers variable name

  • task (str) – The task containing the pers variable

Returns:

The pers variable encoded as a float

async get_rapid_variable_num_array(var, task='T_ROB1')

Get a RAPID pers variable float array

Parameters:
  • var – The pers variable name

  • task (str) – The task containing the pers variable

Return type:

ndarray

Returns:

The variable value as an array

async get_rapid_variables(task='T_ROB1')

Get a list of the persistent variables in a task

Parameters:

task (str) – The RAPID task to query

Return type:

str

Returns:

List of persistent variables in task

async get_robtarget(mechunit='ROB_1', tool='tool0', wobj='wobj0', coordinate='Base')

Get the current robtarget (cartesian pose) for the specified mechunit

Parameters:
  • mechunit (str) – The mechanical unit to read

  • tool (str) – The tool to use to compute robtarget

  • wobj (str) – The wobj to use to compute robtarget

  • coordinate (str) – The coordinate system to use to compute robtarget. Can be Base, World, Tool, or Wobj

Returns:

The current robtarget

async get_tasks()

Get controller tasks and task state

Return type:

List[TaskState]

Returns:

The tasks and task state

async list_files(path)

List files at a path on a controller

Parameters:

path (str) – The path to list

Return type:

List[str]

Returns:

The filenames in the path

async poll_rmmp()

Poll rmmp to maintain remote mastering. Call periodically after rmmp enabled using request_rmmp()

async read_event_log(elog=0)

Read the controller event log

Parameters:

elog (int) – The event log id to read

Return type:

List[EventLogEntry]

Returns:

The event log entries

async read_file(filename)

Read a file off the controller

Parameters:

filename (str) – The filename to read

Return type:

bytes

Returns:

The file bytes

async read_ipc_message(queue_name, timeout=0)

Read IPC message. IPC is used to communicate with RMQ in controller tasks. Create IPC using try_create_ipc_queue().

Parameters:
  • queue_name (str) – The name of the queue created using try_create_ipc_queue()

  • timeout (float) – The timeout to receive a message in seconds

Return type:

List[IpcMessage]

Returns:

Messages received from IPC queue

async request_rmmp(timeout=5)

Request Remote Mastering. Required to alter pers variables in manual control mode. The teach pendant will prompt to enable remote mastering, and the user must confirm. Once remote mastering is enabled, poll_rmmp() must be executed periodically to maintain rmmp.

Parameters:

timeout (float) – The request timeout in seconds

async resetpp()

Reset RAPID program pointer to main in normal tasks

async send_ipc_message(target_queue, data, queue_name, cmd=111, userdef=1, msgtype=1)

Send an IPC message to the specified queue

Parameters:
  • target_queue (str) – The target IPC queue. Can also be the name of a task to send to RMQ of controller task.

  • data (str) – The data to send to the controller. Encoding must match the expected type of RMQ

  • queue_name (str) – The queue to send message from. Must be created with try_create_ipc_queue()

  • cmd (int) – The cmd entry in the message

  • userdef (int) – User defined value

  • msgtype (int) – The type of message. Must be 0 or 1

async set_analog_io(signal, value, network='Local', unit='DRV_1')

Set the value of an analog IO signal.

Parameters:
  • value (int) – The value of the signal

  • signal (str) – The name of the signal

  • network (str) – The network the signal is on. The default Local will work for most signals.

  • unit (str) – The drive unit of the signal. The default DRV_1 will work for most signals.

async set_digital_io(signal, value, network='Local', unit='DRV_1')

Set the value of an digital IO signal.

Parameters:
  • value (Union[bool, int]) – The value of the signal. Bool or bool convertible input

  • signal (str) – The name of the signal

  • network (str) – The network the signal is on. The default Local will work for most signals.

  • unit (str) – The drive unit of the signal. The default DRV_1 will work for most signals.

async set_rapid_variable(var, value, task='T_ROB1')

Set value of a RAPID pers variable

Parameters:
  • var (str) – The pers variable name

  • value (str) – The new variable value encoded as a string

  • task (str) – The task containing the pers variable

async set_rapid_variable_jointtarget(var, value, task='T_ROB1')

Set a RAPID pers variable from a JointTarget

Parameters:
  • var (str) – The pers variable name

  • value (JointTarget) – The new variable JointTarget value

  • task (str) – The task containing the pers variable

async set_rapid_variable_jointtarget_array(var, value, task='T_ROB1')

Set a RAPID pers variable from a JointTarget list

Parameters:
  • var (str) – The pers variable name

  • value (List[JointTarget]) – The new variable JointTarget value

  • task (str) – The task containing the pers variable

async set_rapid_variable_num(var, val, task='T_ROB1')

Set a RAPID pers variable from a float

Parameters:
  • var (str) – The pers variable name

  • value – The new variable float value

  • task (str) – The task containing the pers variable

async set_rapid_variable_num_array(var, val, task='T_ROB1')

Set a RAPID pers variable from a float list or array

Parameters:
  • var (str) – The pers variable name

  • value – The new variable float array value

  • task (str) – The task containing the pers variable

async start(cycle='asis', tasks=['T_ROB1'])

Start one or more RAPID tasks

Parameters:
  • cycle (str) – The cycle mode of the robot. Can be asis, once, or forever.

  • tasks (List[str]) – One or more tasks to start.

async stop()

Stop RAPID execution of normal tasks

async subscribe(resources)

Create subscription that will receive real-time updates from the controller. handler will be called with the new values. RWS subscriptions are relatively slow, with delays in the hundreds of milliseconds. Use EGM for faster real-time updates.

See abb_robot_client.RWS.subscribe() for more information on resources parameter.

The asyncio version of subscribe() returns an async generator. Use async for to receive events.

Parameters:
Returns:

Generator to use with async for.

async try_create_ipc_queue(queue_name, queue_size=4440, max_msg_size=444)

Try creating an IPC queue. Returns True if the queue is created, False if queue already exists. Raises exception for all other errors.

Parameters:
  • queue_name (str) – The name of the new IPC queue

  • queue_size (int) – The buffer size of the queue

  • max_msg_size (int) – The maximum message size of the queue

Returns:

True if queue created, False if queue already exists

async upload_file(filename, contents)

Upload a file to the controller

Parameters:
  • filename (str) – The filename to write

  • contents (bytes) – The file content bytes

Return type:

None

class abb_robot_client.rws_aio.UnknownSubscriptionMessage(xml: str)

Contents of an unknown subscription resource type

xml: str

Raw xml returned by controller