Execution

abb_rws_client_python_rw6.highlevel.execution

High-level RAPID execution control for ABB RWS RobotWare 6.

Author: Clement RACINET

Composed operations built exclusively from atomic rws/ functions. No HTTP calls are made directly in this module.

All functions are async and require an open RWSClient instance.

is_running(client) async

Check whether RAPID execution is currently running.

Wraps get_rapid_execution_state and parses the ctrlexecstate field from the response.

Route (delegated): GET /rw/rapid/execution

Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

Returns:
  • bool –

    True if the controller execution state is "running",

  • bool –

    False otherwise ("stopped", "idle", etc.).

Raises:
Example
async with RWSClient(host="192.168.125.1") as client:
    running = await is_running(client)
    print("Running:", running)
Source code in abb_rws_client_python_rw6/highlevel/execution.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
async def is_running(client: RWSClient) -> bool:
    """Check whether RAPID execution is currently running.

    Wraps ``get_rapid_execution_state`` and parses the ``ctrlexecstate``
    field from the response.

    Route (delegated): ``GET /rw/rapid/execution``

    Args:
        client: Open ``RWSClient`` instance.

    Returns:
        ``True`` if the controller execution state is ``"running"``,
        ``False`` otherwise (``"stopped"``, ``"idle"``, etc.).

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.
        ValueError: If the execution state cannot be parsed.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            running = await is_running(client)
            print("Running:", running)
        ```
    """
    response = await get_rapid_execution_state(client)
    return _parse_exec_state(response) == _RUNNING_VALUE

start_rapid(client, *, regain='continue', execmode='continue', cycle='forever', condition='none', stopatbp='disabled', alltaskbytsp='false') async

Reset the program pointer to main and start RAPID execution.

Composes reset_rapid_program_pointer_to_main followed by start_rapid_execution. Mastership is not requested explicitly because ABB handles it internally for both resetpp and start in RW6 AUTO mode.

Route (delegated): - POST /rw/rapid/execution (action=resetpp) - POST /rw/rapid/execution (action=start)

ABB constraints
  • Controller must be in AUTO mode with motors ON.
  • resetpp requires mastership; ABB grants it implicitly.
Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

  • regain (str, default: 'continue' ) –

    Regain mode. One of continue | regain | clear. Defaults to "continue".

  • execmode (str, default: 'continue' ) –

    Execution mode. One of continue | stepin | stepover | stepout | stepback | steplast | stepmotion. Defaults to "continue".

  • cycle (str, default: 'forever' ) –

    Cycle mode. One of forever | asis | once. Defaults to "forever".

  • condition (str, default: 'none' ) –

    Condition. One of none | callchain. Defaults to "none".

  • stopatbp (str, default: 'disabled' ) –

    Stop at breakpoint. One of disabled | enabled. Defaults to "disabled".

  • alltaskbytsp (str, default: 'false' ) –

    All tasks by TSP. One of true | false. Defaults to "false".

Returns:
  • None –

    None. Both underlying calls expect HTTP 204.

Raises:
Example
async with RWSClient(host="192.168.125.1") as client:
    await start_rapid(client, cycle="once")
Source code in abb_rws_client_python_rw6/highlevel/execution.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
async def start_rapid(
    client: RWSClient,
    *,
    regain: str = "continue",
    execmode: str = "continue",
    cycle: str = "forever",
    condition: str = "none",
    stopatbp: str = "disabled",
    alltaskbytsp: str = "false",
) -> None:
    """Reset the program pointer to main and start RAPID execution.

    Composes ``reset_rapid_program_pointer_to_main`` followed by
    ``start_rapid_execution``. Mastership is not requested explicitly
    because ABB handles it internally for both ``resetpp`` and ``start``
    in RW6 AUTO mode.

    Route (delegated):
        - ``POST /rw/rapid/execution`` (action=resetpp)
        - ``POST /rw/rapid/execution`` (action=start)

    ABB constraints:
        - Controller must be in AUTO mode with motors ON.
        - ``resetpp`` requires mastership; ABB grants it implicitly.

    Args:
        client: Open ``RWSClient`` instance.
        regain: Regain mode. One of ``continue | regain | clear``.
            Defaults to ``"continue"``.
        execmode: Execution mode. One of ``continue | stepin | stepover
            | stepout | stepback | steplast | stepmotion``.
            Defaults to ``"continue"``.
        cycle: Cycle mode. One of ``forever | asis | once``.
            Defaults to ``"forever"``.
        condition: Condition. One of ``none | callchain``.
            Defaults to ``"none"``.
        stopatbp: Stop at breakpoint. One of ``disabled | enabled``.
            Defaults to ``"disabled"``.
        alltaskbytsp: All tasks by TSP. One of ``true | false``.
            Defaults to ``"false"``.

    Returns:
        None. Both underlying calls expect HTTP 204.

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            await start_rapid(client, cycle="once")
        ```
    """
    await reset_rapid_program_pointer_to_main(client, action="resetpp")
    await start_rapid_execution(
        client,
        action="start",
        regain=regain,
        execmode=execmode,
        cycle=cycle,
        condition=condition,
        stopatbp=stopatbp,
        alltaskbytsp=alltaskbytsp,
    )
    logger.debug("RAPID execution started (cycle=%s)", cycle)

stop_rapid(client, *, stopmode='stop') async

Stop RAPID execution.

Wraps stop_rapid_execution with action="stop".

Route (delegated): POST /rw/rapid/execution (action=stop)

ABB constraints
  • No mastership required to stop.
Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

  • stopmode (str, default: 'stop' ) –

    Stop mode. One of stop | qstop | halt. Defaults to "stop".

Returns:
  • None –

    None. Expects HTTP 204.

Raises:
Example
async with RWSClient(host="192.168.125.1") as client:
    await stop_rapid(client)
Source code in abb_rws_client_python_rw6/highlevel/execution.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
async def stop_rapid(
    client: RWSClient,
    *,
    stopmode: str = "stop",
) -> None:
    """Stop RAPID execution.

    Wraps ``stop_rapid_execution`` with ``action="stop"``.

    Route (delegated): ``POST /rw/rapid/execution`` (action=stop)

    ABB constraints:
        - No mastership required to stop.

    Args:
        client: Open ``RWSClient`` instance.
        stopmode: Stop mode. One of ``stop | qstop | halt``.
            Defaults to ``"stop"``.

    Returns:
        None. Expects HTTP 204.

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            await stop_rapid(client)
        ```
    """
    await stop_rapid_execution(client, action="stop", stopmode=stopmode)
    logger.debug("RAPID execution stopped (stopmode=%s)", stopmode)

wait_until_stopped(client, *, poll_interval=0.2, timeout=None) async

Poll until RAPID execution is no longer running.

Repeatedly calls get_rapid_execution_state until ctrlexecstate is no longer "running", or until the optional timeout is exceeded.

Route (delegated): GET /rw/rapid/execution

ABB constraints
  • Polling-based; no WebSocket/subscription used.
  • poll_interval should be ≥ 0.1 s to avoid flooding the controller.
Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

  • poll_interval (float, default: 0.2 ) –

    Seconds between each poll. Defaults to 0.2.

  • timeout (float | None, default: None ) –

    Maximum seconds to wait. None means wait forever. Defaults to None.

Returns:
  • None –

    None. Returns as soon as the controller is no longer running.

Raises:
  • RWSAuthenticationError –

    On HTTP 401.

  • RWSNotFoundError –

    On HTTP 404.

  • RWSHTTPError –

    On any other HTTP >= 400.

  • TimeoutError –

    If timeout is set and exceeded before the controller stops.

  • ValueError –

    If the execution state cannot be parsed.

Example
async with RWSClient(host="192.168.125.1") as client:
    await start_rapid(client, cycle="once")
    await wait_until_stopped(client, timeout=30.0)
    print("Program finished.")
Source code in abb_rws_client_python_rw6/highlevel/execution.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
async def wait_until_stopped(
    client: RWSClient,
    *,
    poll_interval: float = 0.2,
    timeout: float | None = None,
) -> None:
    """Poll until RAPID execution is no longer running.

    Repeatedly calls ``get_rapid_execution_state`` until
    ``ctrlexecstate`` is no longer ``"running"``, or until the optional
    timeout is exceeded.

    Route (delegated): ``GET /rw/rapid/execution``

    ABB constraints:
        - Polling-based; no WebSocket/subscription used.
        - ``poll_interval`` should be ≥ 0.1 s to avoid flooding the
          controller.

    Args:
        client: Open ``RWSClient`` instance.
        poll_interval: Seconds between each poll. Defaults to ``0.2``.
        timeout: Maximum seconds to wait. ``None`` means wait forever.
            Defaults to ``None``.

    Returns:
        None. Returns as soon as the controller is no longer running.

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.
        TimeoutError: If ``timeout`` is set and exceeded before the
            controller stops.
        ValueError: If the execution state cannot be parsed.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            await start_rapid(client, cycle="once")
            await wait_until_stopped(client, timeout=30.0)
            print("Program finished.")
        ```
    """
    elapsed = 0.0
    while True:
        if not await is_running(client):
            return
        if timeout is not None and elapsed >= timeout:
            raise TimeoutError(
                f"RAPID still running after {timeout}s (poll_interval={poll_interval}s)"
            )
        await asyncio.sleep(poll_interval)
        elapsed += poll_interval