bbi.scenarios¶
- class Scenario(world: BaseWorld, num_frames: int, total_seconds: float)¶
Bases:
objectDefines 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_framesto calculate the delta time between frames. For example, ifnum_framesis 100 andtotal_secondsis 10, then the delta time between frames is 0.1 seconds. Set it to 0.0 to disable delta time calculation.
- set_simulation_warmup_seconds(seconds: float) None¶
Set the simulation warmup duration in seconds.
- Parameters:
seconds (float) – The warmup duration in seconds. Must be non-negative.
- set_per_frame_warmup_seconds(seconds: float) None¶
Set the per-frame warmup duration in seconds.
- Parameters:
seconds (float) – The warmup duration in seconds. Must be non-negative.
- set_keyframe(instance: Animatable, frame_id: int, **kwargs) None¶
Update the attributes of an
Animatableinstance at a specific frame.- Parameters:
instance (Animatable) – Target
Animatableinstance 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.
- set_metadata_keyframe(frame_id: int, key: str, value: Any)¶
Set the metadata for a specific frame.
- Parameters:
frame_id (int) – The frame number (0-indexed) at which to set the metadata.
key (str) – The key of the metadata.
value (Any) – The value of the metadata.
- get_metadata_at_frame(frame_id: int) dict[str, Any]¶
Get the metadata for a specific frame.
- Parameters:
frame_id (int) – The frame number (0-indexed) at which to get the metadata.
- clear_keyframes(instance: Animatable) None¶
Clear the keyframes of an
Animatableinstance.- Parameters:
instance (Animatable) – The
Animatableinstance 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. EachNodeis 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.