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.
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.
:param target: The target point to drive towards.
:param angle_threshold: The angle threshold to stop driving (radians, default: 5°).
:param backward: Whether to drive backwards (default: False
).
:param stop_at_end: Whether to stop the robot at the end of the circular path (default: False
).
:raises: 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.
:param path: The path to drive along, composed of PathSegments.
:param throttle_at_end: Whether to throttle down when approaching the end of the path (default: True
).
:param stop_at_end: Whether to stop at the end of the path (default: True
).
:raises: 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.
:param spline: The spline to drive along.
:param flip_hook: Whether to flip the hook offset (default: False
).
:param throttle_at_end: Whether to throttle down when approaching the end of the spline (default: True
).
:param stop_at_end: Whether to stop at the end of the spline (default: True
).
:raises 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.
:param target: The target point to drive to.
:param backward: Whether to drive backwards (default: False
).
:param throttle_at_end: Whether to throttle down when approaching the target point (default: True
).
:param stop_at_end: Whether to stop at the target point (default: True
).
:raises: DrivingAbortedException: If the driving process is aborted.
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 |
---|---|
WHEELS_TURNED | the wheels have turned with non-zero velocity |
PREDICTION_UPDATED | the pose prediction has been updated |
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.
Events¶
Name | Description |
---|---|
STEERING_STARTED | steering has started |
STEERING_STOPPED | steering has stopped |