Skip to content


The following example simulates a robot that can be steered using keyboard controls or a joystick via web interface.

#!/usr/bin/env python3
from nicegui import ui

from rosys.driving import Odometer, Steerer, joystick, keyboard_control, robot_object
from rosys.geometry import Prism
from rosys.hardware import RobotSimulation, WheelsSimulation

shape = Prism.default_robot_shape()
wheels = WheelsSimulation()
robot = RobotSimulation([wheels])
odometer = Odometer(wheels)
steerer = Steerer(wheels)

joystick(steerer, size=50, color='blue')
with ui.scene():
    robot_object(shape, odometer)'RoSys')


Keyboard Control
By adding a KeyboardControl to the user interface you enable steering the robot with the keyboard. Press the arrow keys while holding the SHIFT key to steer the robot. You can also modify the speed of the robot by pressing the a number key. Use the optional parameter default_speed to change the initial value.
When operating from a mobile phone, you can use a Joystick to create a UI element with touch control. You can drive the robot by dragging the mouse inside the top left square.