Skip to content

driving

Driver

Driver(wheels: Drivable, odometer: Odometer | PoseProvider)

The driver module allows following a given path.

It requires a wheels module (or any drivable hardware representation) to execute individual drive commands. It also requires an odometer to get a current prediction of the robot's pose. Its parameters allow controlling the specific drive behavior.

prediction property

prediction: Pose

The current prediction of the robot's pose based on the odometer.

abort

abort() -> None

Abort the current drive routine.

driver_object

DriverObject

DriverObject(driver: Driver)

Bases: Group

The DriverObject UI element displays the path following process in a 3D scene.

The current pose is taken from a given odometer. An optional driver module shows debugging information about a current path-following process. The debug argument can be set to show a wireframe instead of a closed polygon.

joystick

joystick(steerer: Steerer, **options)

Bases: joystick

The Joystick UI element allows controlling a given steerer via touch events.

keyboard_control

keyboard_control(
    steerer: Steerer,
    *,
    default_speed: float = 2.0,
    connection_timeout: float = 1.0,
    check_connection_interval: float = 1.0
)

The KeyboardControl UI element allows controlling a given steerer via keyboard events.

Hold shift while pressing an arrow key to steer the robot. You can change the speed with the number keys 1 to 9 and the initial speed via the default_speed argument.

Events

Name Description
CONNECTION_INTERRUPTED the keyboard control has lost connection to the browser.

Odometer

Odometer(wheels: VelocityProvider)

An odometer collects velocity information from a given wheels module (or any velocity-providing hardware representation).

It can also handle "detections", i.e. absolute pose information with timestamps. Given the history of previously received velocities, it can update its prediction of the current pose.

The get_pose method provides robot poses from the within the last 10 seconds.

Events

Name Description
ROBOT_MOVED a robot movement is detected

robot_object

robot_object(
    shape: Prism, odometer: Odometer, *, debug: bool = False
)

Bases: Group

The RobotObject UI element displays the robot with its given shape in a 3D scene.

The current pose is taken from a given odometer. The debug argument can be set to show a wireframe instead of a closed polygon.

with_stl

with_stl(
    url: str,
    *,
    x: float = 0,
    y: float = 0,
    z: float = 0,
    omega: float = 0,
    phi: float = 0,
    kappa: float = 0,
    scale: float = 1.0,
    color: str = "#ffffff",
    opacity: float = 1.0
) -> RobotObject

Sets an STL to be displayed as the robot.

The file can be served from a local directory with app.add_static_files(url, path).

Steerer

Steerer(wheels: Drivable, speed_scaling: float = 1.0)

The steerer module translates x-y information (e.g. from a joystick) to linear/angular velocities sent to the robot.

The wheels module can be any drivable hardware representation. Changing the steering state emits events that can be used to react to manual user interaction.

The conversion from x-y joystick coordinates to linear and angular velocities is implemented as follows: The coordinates are translated into an angle (forward: 0 degrees, backward: 180 degrees). If the angle is below 110 degrees, y is used as linear velocity and x is used as angular velocity: Pulling the joystick to the front-right corner leads to a clockwise rotation while driving forwards. Above 110 degrees the angular velocity is flipped: Pulling the joystick to the rear-right corner leads to a counter-clockwise rotation while driving backwards. From 100 degrees to 110 degrees both velocities are throttled with a linear ramp from factor 1.0 down to 0.0. From 110 degrees to 120 degrees the throttle factor is linearly ramped from 0.0 back to 1.0.

Events

Name Description
STEERING_STARTED steering has started
STEERING_STOPPED steering has stopped