Skip to content

driving

Driver

Driver(
    wheels: Drivable,
    pose_provider: PoseProvider,
    *,
    parameters: DriveParameters | None = None
)

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 a pose_provider to get a current prediction of the robot's pose. Its parameters allow controlling the specific drive behavior.

pose property

pose: Pose

The current pose of the robot based on the pose_provider.

abort

abort() -> None

Abort the current drive routine.

drive_circle async

drive_circle(
    target: Point,
    *,
    angle_threshold: float = np.deg2rad(5),
    backward: bool = False,
    stop_at_end: bool = True
) -> None

Drive in a circular path.

When the angle between the robot's current direction and the target direction is less than angle_threshold, the robot stops driving.

Parameters:

Name Type Description Default
target Point

The target point to drive towards.

required
angle_threshold float

The angle threshold to stop driving (radians, default: 5°).

deg2rad(5)
backward bool

Whether to drive backwards (default: False).

False
stop_at_end bool

Whether to stop the robot at the end of the circular path (default: False).

True

Raises:

Type Description
DrivingAbortedException

If the driving process is aborted.

drive_path async

drive_path(
    path: list[PathSegment],
    *,
    throttle_at_end: bool = True,
    stop_at_end: bool = True
) -> None

Drive along a given path.

Parameters:

Name Type Description Default
path list[PathSegment]

The path to drive along, composed of PathSegments.

required
throttle_at_end bool

Whether to throttle down when approaching the end of the path (default: True).

True
stop_at_end bool

Whether to stop at the end of the path (default: True).

True

Raises:

Type Description
DrivingAbortedException

If the driving process is aborted.

drive_spline async

drive_spline(
    spline: Spline,
    *,
    flip_hook: bool = False,
    throttle_at_end: bool = True,
    stop_at_end: bool = True
) -> None

Drive along a given spline.

Parameters:

Name Type Description Default
spline Spline

The spline to drive along.

required
flip_hook bool

Whether to flip the hook offset (default: False).

False
throttle_at_end bool

Whether to throttle down when approaching the end of the spline (default: True).

True
stop_at_end bool

Whether to stop at the end of the spline (default: True).

True

Raises:

Type Description
DrivingAbortedException

If the driving process is aborted.

drive_to async

drive_to(
    target: Point,
    *,
    backward: bool = False,
    throttle_at_end: bool = True,
    stop_at_end: bool = True
) -> None

Drive to a given target point.

Parameters:

Name Type Description Default
target Point

The target point to drive to.

required
backward bool

Whether to drive backwards (default: False).

False
throttle_at_end bool

Whether to throttle down when approaching the target point (default: True).

True
stop_at_end bool

Whether to stop at the target point (default: True).

True

Raises:

Type Description
DrivingAbortedException

If the driving process is aborted.

Odometer

Odometer(wheels: VelocityProvider)

Bases: PoseProvider, FrameProvider

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.

odometry_frame instance-attribute

odometry_frame: Pose = Pose()

Local-to-world transform applied to the smooth, jump-free history.

Events

Name Description
WHEELS_TURNED the wheels have turned with non-zero velocity
POSE_UPDATED Emitted on movement or detection correction (argument: current Pose).
FRAME_UPDATED Emitted on movement or detection correction (argument: current Frame3d).

PoseProvider

Bases: Protocol

Protocol for objects that provide a 2D Pose.

POSE_UPDATED instance-attribute

POSE_UPDATED: Event[Pose]

Emitted when the pose has been updated (argument: current Pose).

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.

Events

Name Description
STEERING_STARTED steering has started
STEERING_STOPPED steering has stopped

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.

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).