bbi.scenarios¶
- class Scenario(world: BaseWorld, num_frames: int, total_seconds: float)¶
Bases:
object
Defines a scenario, a collection of sequenced states.
Warning
A scenario should never be created directly. Use
World.new_scenario()
instead.- Parameters:
num_frames (int) – The number of frames in the scenario.
total_seconds (float) – The expected total duration of this scenario in seconds. This is used together with
num_frames
to calculate the delta time between frames. For example, ifnum_frames
is 100 andtotal_seconds
is 10, then the delta time between frames is 0.1 seconds. Set it to 0.0 to disable delta time calculation.
- set_keyframe(instance: Animatable, frame_id: int, **kwargs) None ¶
Update the attributes of an
Animatable
instance at a specific frame.- Parameters:
instance (Animatable) – Target
Animatable
instance to set the updates.frame_id (int) – The frame number (0-indexed) at which to set the updates.
**kwargs – The
Animatable
’s attribute to update.
- clear_keyframes(instance: Animatable) None ¶
Clear the keyframes of an
Animatable
instance.- Parameters:
instance (Animatable) – The
Animatable
instance to clear the keyframes.
- goto(frame_id: int)¶
Jumps to a specific frame id (0-indexed).
Useful when debugging camera or object positions.
- Parameters:
frame_id (int) – The frame number to jump to.
- preview_animation(start_frame: int = 0, end_frame: int | None = None)¶
Previews the animation by visualizing each frame in the scenario.
The viewport will be updated to show the requested frames. The assets will not return to their original positions after the preview.
- Parameters:
start_frame (int, optional) – The starting frame number (0-indexed) to preview. Defaults to 0.
end_frame (int | None, optional) – The ending frame number (inclusive) to preview. If
None
, the scenario will be previewed until the last frame. Defaults toNone
.
- render(params: RenderParams = RgbWithLabels(), start_frame: int = 0, warmup_frames: int | None = None, end_frame: int | None = None)¶
Dispatches the render call to the renderer.
For each frame in
num_frames
, the scene state is traversed. EachNode
is executed, i.e. SpawnZones instantiate objects in geometry, and animation states are updated. Finally, the scene is drawn.- Parameters:
params (RenderParams, optional) – The parameters to use for the render. The different subclasses of RenderParams result in different render outputs, where the valid subclasses are:
Rgb
,RgbWithLabels
. This defaults toRgbWithLabels()
, i.e. this will generate labelled RGB images using default settings. See each subclass’s documentation for the full set of parameters that can be passed.start_frame (int, optional) – The starting frame number (0-indexed) to render. Defaults to 0.
warmup_frames (int, optional) – The number of warmup frames before the render is captured. Defaults to None and will be determined by the weather and other scene variables.
end_frame (int, optional) – The ending frame number (inclusive) to render. If
None
, the scenario will be rendered until the last frame. Defaults toNone
.