sim2bot.Robot.connect¶
connect() -> 'Robot'
¶
Open the configured bridge connection and start reader threads.
If auto_bridge=True, this first reuses a healthy local bridge or starts
one. If wait_for_sim=True, the call does not return until a browser
announces at least one robot or the configured timeout expires.
Returns:
-
'Robot'–This client instance, enabling
Robot(...).connect()chaining.
Raises:
-
TimeoutError–If waiting for a browser simulator times out.
-
RuntimeError–If an automatically started bridge cannot become healthy.
-
ConnectionClosed–If the WebSocket closes while sending its initial hello.
-
OSError–If the configured network endpoint cannot be opened.
Source code in sim2bot/client.py
Practical examples¶
Examples use objects discovered from the current scene rather than hard-coded robot metadata.
Connect manually
Connect with a context manager
Guidance¶
Usage tip
Prefer with Robot(...) as sim; call connect() directly when lifecycle ownership belongs to a larger application.
Common error
Calling command methods before connect() raises RuntimeError: not connected.