sim2bot.Robot.wait_for_sim¶
wait_for_sim(timeout: Optional[float] = None, poll_interval: float = 0.5) -> list[RobotInfo]
¶
Wait until a browser simulator connects and announces robots.
Parameters:
-
timeout(Optional[float], default:None) –Maximum total wait in seconds, or
Noneto wait forever. -
poll_interval(float, default:0.5) –Delay in seconds between unsuccessful discovery calls.
Returns:
Raises:
-
TimeoutError–If no browser scene appears before
timeout. -
RuntimeError–If the client is not connected.
-
ConnectionClosed–If the WebSocket closes during discovery.
-
OSError–If the selected transport cannot send a discovery request.
Examples:
This allows a controller to start before the browser::
with Robot(auto_bridge=True, wait_for_sim=True) as sim:
robots = sim.describe()
Source code in sim2bot/client.py
Practical examples¶
Examples use objects discovered from the current scene rather than hard-coded robot metadata.
Wait indefinitely
Use a bounded startup timeout
Guidance¶
Usage tip
A bounded timeout is better for services and CI; an infinite wait is convenient for interactive scripts.