Skip to main content
rua.sim serves a simulator. The guides are Serving a gym env and Writing a bridge.
DirectControl has its own page, and so has CodeControl.

RobotBridge

Serves a sim over the robot WebSocket (rua/0) plus a JSON-RPC control channel. host and port are the WebSocket’s address; port 0 binds an ephemeral port on start().

Hooks

Every hook is synchronous and, under serve(), runs on the sim thread.

Attributes

Methods

The control channel’s methods, and the slot and barrier rules, are on the Capabilities page.

GymBridge

A RobotBridge that serves any gym-style env. attach_gym runs it in a sim process. Build args (the factory’s named parameters, plus defaults’ keys when it takes **kwargs; only num_envs for a registry target) rebuild the env when they change. Other task args are episodic: seed goes to env.reset(seed=...) and the rest to env.reset(options=...). A registry target with num_envs is built with gymnasium.make_vec, else gymnasium.make. start() builds the env once to derive the contract when no contract file exists, and raises RuntimeError when a build arg has no default anywhere. sample_observation() returns one per-env (state, frames) sample.

attach_gym

Serves target as the capability name on env. It builds a spawning RobotEndpoint for python -m rua.sim.gym ..., calls endpoint.attach(env), and registers an @env.initialize hook that starts it and publishes every capability it reports, and an @env.shutdown hook that stops it. target may be a module-level callable (passed as path.py:name), a registry id, or a constructed registry env (passed as its spec JSON and closed). Anything else raises ValueError.

RobotEndpoint

The env server’s handle on a sim process. For an instance, constructor parameters of the subclass (not host / port) are read back from attributes of the same name or with a leading underscore and sent as JSON. Callables are skipped; values that don’t serialize raise TypeError. contract, metadata and num_envs (when not 1) are sent too. Spawned sims inherit stderr; their stdout is forwarded line by line.