Studio¶
bt.studio(scene) serves the 3D studio on 127.0.0.1 and opens a browser. The
UI and your Python session share one scene: dragging the TCP gizmo runs IK and
the new joint values are visible from Python, and scene.set_tcp_target(...)
moves the robot in the browser.
bt.studio(scene) # blocks until Ctrl-C
server = bt.studio(scene, block=False) # or keep working in the same script
print(server.url)
server.stop()
bt.studio(scene, view=((2.0, -2.0, 1.5), (0.0, 0.0, 0.5)), follow="part/7") # the view stays on that part
The studio assets must be present
Wheels bundle the built UI. In a source checkout, run
./scripts/build_studio.sh first, or point BOTRAIL_STUDIO_DIR at a built
studio dist directory.
studio
¶
studio(
scene: Scene,
*,
host: str = "127.0.0.1",
port: int = 0,
open_browser: bool = True,
block: bool = True,
physics=None,
view: tuple[
tuple[float, float, float],
tuple[float, float, float],
]
| None = None,
follow: str | None = None,
) -> StudioServer | None
Serves the studio UI for scene and (by default) opens a browser.
With block=True (default) this runs until Ctrl-C. With
block=False it returns a :class:StudioServer handle; the server
stops when the handle is garbage collected or stop() is called.
physics is what the studio's physics toggle bakes under: None
(the default) the whole cell — bt.Physics(world=True), every
obstacle and robot the engine's, ground at z = 0 —, a bt.Physics(...)
exactly that (powered=False makes the toggle a power cut), False
no physics on this host (the toggle reports it).
view=(eye, target) sets the initial orbit view in the printed/opened
browser URL, with both points in world metres. The returned server's
url remains the base endpoint.
follow="part/7" opens with the view staying on that obstacle — or
robot — as it moves: a part followed through the cycle that is played,
from its feeder to its pallet. The eye keeps the place view gives
it from the target (the target itself is the thing followed); the
orbit and the zoom stay the viewer's, and the chip in the viewport's
corner lets go. Like view, it rides the printed/opened URL.
StudioServer¶
The handle returned by studio(..., block=False). The server also stops when
the handle is garbage-collected.