Skip to content

Client and states

RSIClient is what RSIAPI drives. Use it directly only when you need the raw shared variables or the state machine.

Reference

ClientState

Bases: Enum

Connection states for RSIClient.

RSIClient

RSIClient(config_file: str, rsi_limits_file: Optional[str] = None, enable_auto_reconnect: bool = False, auto_reconnect_retries: int = 5, auto_reconnect_delay: float = 5.0, rsi_mode: str = 'relative', max_cartesian_rate: float = 0.0, max_joint_rate: float = 0.0, cycle_time: float = 0.004)

Main RSI API class that integrates network, config handling, and message processing.

Parameters:

Name Type Description Default
config_file str

Path to RSI_EthernetConfig.xml

required
rsi_limits_file Optional[str]

Optional path to .rsi.xml safety limits file

None
enable_auto_reconnect bool

Enable automatic reconnection on communication loss

False
auto_reconnect_retries int

Maximum reconnection attempts (0 = unlimited)

5
auto_reconnect_delay float

Base delay between retries in seconds

5.0
rsi_mode str

'absolute' or 'relative' — must match KRL RSI_MOVECORR() mode

'relative'
max_cartesian_rate float

Max mm/cycle for RKorr corrections (0 = disabled)

0.0
max_joint_rate float

Max degrees/cycle for AKorr corrections (0 = disabled)

0.0
cycle_time float

Expected RSI cycle time in seconds (0.004 or 0.012)

0.004

state property

state: ClientState

Get current client state (thread-safe).

start

start() -> None

Send start signal to NetworkProcess and run control loop.

Raises:

Type Description
RSIClientNotReady

If client is not in appropriate state to start

stop

stop(stop_auto_reconnect: bool = True) -> None

Stop the network process and the client thread safely.

Parameters:

Name Type Description Default
stop_auto_reconnect bool

Set False when called from the auto-reconnect path so the monitor thread survives (and is never self-joined).

True

reconnect

reconnect(restart: bool = True) -> None

Reconnect the network process safely.

Stops the existing connection, creates fresh communication resources and a new NetworkProcess, and (by default) restarts the control loop in a background thread. E-stop state and runtime safety limits are preserved across the reconnect.

wait_for_connection

wait_for_connection(timeout: float = 10.0) -> bool

Block until the first valid packet is received from the robot.

Parameters:

Name Type Description Default
timeout float

Maximum time to wait in seconds

10.0

Returns:

Type Description
bool

True if connected, False if timeout

emergency_stop

emergency_stop() -> None

E-stop: block new writes and substitute safe corrections on the wire.

Delivered via a shared Value the network process checks every cycle, so it takes effect within one robot cycle (not the command-queue polling interval). In relative mode the wire carries zero deltas; in absolute mode the last-transmitted offset is held (zeroing would command a return-to-path motion).

emergency_reset

emergency_reset() -> None

Reset E-stop and resume normal corrections.

Pending user corrections are zeroed FIRST (relative mode) so motion cannot resume from stale values the moment the flag clears.

zero_corrections

zero_corrections() -> None

Zero all motion corrections at the source.

Writes directly to receive_variables, deliberately bypassing SafetyManager.validate — zeroing is inherently safe and must work while an E-stop is latched (validate raises during E-stop).

set_limit

set_limit(path: str, min_val: float, max_val: float) -> None

Set a safety limit at runtime — enforced at write time (parent) and clamped at send time (network process).

set_safety_override

set_safety_override(enable: bool) -> None

Enable/disable safety override in both enforcement layers.

publish_corrections

publish_corrections(corrections: Dict[str, Dict[str, float]]) -> int

Atomically publish correction dicts and bump the waypoint sequence.

Values are validated through the SafetyManager (raises on E-stop or limit violation, aborting the caller's trajectory). Returns the new sequence number to pass to wait_correction_applied().

wait_correction_applied

wait_correction_applied(seq: int, timeout: float = 0.1) -> bool

Block until the network process has transmitted waypoint seq.

Cheap shared-memory polling (~0.5ms). Returns False on timeout (robot silent, E-stop latched, or reconnect in flight).

current_ipoc

current_ipoc() -> int

Robot's IPOC as of the last transmitted cycle (shared memory).