Skip to content

3D Scene

Robot and Shape

It is often desired to visualize all the robot's information about the world. To do so you can create a 3d scene with NiceGUI. RoSys provides a robot_object to render and update the robot:

from import Robot, RobotShape, World

shape = RobotShape(outline=[
    (0, 0), (-0.5, -0.5), (1.5, -0.5), (1.75, 0), (1.5, 0.5), (-0.5, 0.5),
])  # the shape for the robot will be used in 3d rendering
world = World(robot=Robot(shape=shape))
runtime = rosys.Runtime(world)
rosys.ui.configure(ui, runtime)

with ui.scene() as scene:
    # by passing `debug=True` to the robot 3d object you will see the wireframe, axis-center and follow-the-line target
    robot = rosys.ui.robot_object(debug=True)

Click Handler

You can also pass a click handler to the 3d scene. Here is a full example example for driving to a point on the ground by starting the built-in automation called drive_to:

#!/usr/bin/env python3
from rosys.automations import drive_to
from nicegui import ui
import rosys
import rosys.ui
from import Point

runtime = rosys.Runtime()
rosys.ui.configure(ui, runtime)

async def handle_click(msg):
    for hit in msg.hits:
        target = Point(x=hit.point.x, y=hit.point.y)
        runtime.automator.start(drive_to(, runtime.hardware, target))

with ui.scene(on_click=handle_click) as scene:
    robot = rosys.ui.robot_object(debug=True)
ui.label('click into the scene to drive the robot')'RoSys', port=8080)

Click Handler