Domain Randomization [omni.isaac.dr]

This extension provides an interface to a Domain Randomization(DR) prim defined in a stage.

Example

To use this interface you must first call the acquire interface function. You can create a cube in the editor (Create->Shapes->Cube) and then use the DR commands to create a DR color component. Then use the interface to call API to switch to manual mode.

import omni
import omni.isaac.dr as dr
dr_interface = dr._dr.acquire_dr_interface()
# Create DR color component
result, prim = omni.kit.commands.execute(
    "CreateColorComponentCommand",
    prim_paths=["/World/Cube"],
    first_color_range=(0.0, 0.0, 0.0),
    second_color_range=(1.0, 1.0, 1.0),
    roughness_range=(0.0, 1.0),
    metallic_range=(0.0, 1.0),
    duration=0.3,
    include_children=False,
)
# Switch to manual mode
dr_interface.toggle_manual_mode()

Next, use the interface to call API to randomize the scene once.

# Randomize the scene once
dr_interface.randomize_once()

Finally, you can switch back to non-manual mode by calling the toggle_manual_mode() again. By pressing play in the editor, you will see the color of the cube change every 0.3 seconds.

# Switch to non-manual mode
dr_interface.toggle_manual_mode()
# Python equivalent of pressing play in editor
timeline = omni.timeline.get_timeline_interface()
if not timeline.is_playing():
    timeline.play()

Refer to the sample documentation for more examples and usage

class DomainRandomizer

Bases: pybind11_builtins.pybind11_object

randomize_once(self: omni.isaac.dr._dr.DomainRandomizer)None

Randomizes the scene once. This is mainly executed while in manual mode.

toggle_manual_mode(self: omni.isaac.dr._dr.DomainRandomizer)None

Toggles mode between manual and non-manual. In manual mode, user can control when scene randomization occur whereas in non-manual mode scene randomization is controlled via the duration parameter in various DR components.

acquire_dr_interface(plugin_name: str = None, library_path: str = None)omni::isaac::dr::DomainRandomizer
release_dr_interface(arg0: omni::isaac::dr::DomainRandomizer)None

Commands

Isaac Domain Randomization commands to create various randomization components.

class CreateAttributeComponentCommand(path=None, prim_paths=[], custom_data={}, duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a attribute randomization component.

Typical usage example:

attribute_dict = {
    "attribute_3": {
        "name": "xformOp:rotateXYZ",
        "min": "0.0",
        "max": "360.0",
        "distribution": "uniform"
    },
    "attribute_1": {
        "name": "xformOp:translate",
        "min": "1.0",
        "max": "50.0",
        "distribution": "uniform"
    }
}
result, prim = omni.kit.commands.execute(
    "CreateAttributeComponentCommand",
    prim_paths=["/World/Cube"],
    custom_data = attribute_dict,
    duration=1.0,
)
class CreateColorComponentCommand(path=None, prim_paths=[], first_color_range=(0.0, 0.0, 0.0), second_color_range=(1.0, 1.0, 1.0), roughness_range=(0.0, 1.0), metallic_range=(0.0, 1.0), duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a color randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateColorComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1"],
    first_color_range=(0.0, 0.0, 0.0),
    second_color_range=(1.0, 1.0, 1.0),
    roughness_range=(0.0, 1.0),
    metallic_range=(0.0, 1.0),
    duration=1.0,
    include_children=False,
)
class CreateLightComponentCommand(path=None, light_paths=[], first_color_range=(0.0, 0.0, 0.0), second_color_range=(1.0, 1.0, 1.0), intensity_range=(40000.0, 70000.0), temperature_range=(1500.0, 6500.0), enable_temperature=True, duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a light randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateLightComponentCommand",
    light_paths=["/World/RectLight"],
    first_color_range=(0.9, 0.9, 0.9),
    second_color_range=(1.0, 1.0, 1.0),
    intensity_range=(40000.0, 70000.0),
    temperature_range=(1500.0, 6500.0),
    enable_temperature=True,
    duration=1.0,
    include_children=False,
)
class CreateMaterialComponentCommand(path=None, prim_paths=[], material_list=[], ignored_class_list=[], grouped_class_list=[], loaded_material_paths=[], duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a material randomization component.

Typical usage example:

material_list = [
    <server_path> + "/material1.mdl",
    <server_path> + "/material2.mdl",
]
result, prim = omni.kit.commands.execute(
    "CreateMaterialComponentCommand",
    prim_paths=["/World/Room"],
    material_list=material_list,
    duration=1.0,
    include_children=True,
)
class CreateMeshComponentCommand(path=None, prim_paths=[], mesh_list=[], mesh_range=(1, 1), duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a mesh randomization component.

Typical usage example:

mesh_list = [
    <server_path> + "/mesh1.mdl",
    <server_path> + "/mesh2.mdl",
]
result, prim = omni.kit.commands.execute(
    "CreateMeshComponentCommand",
    mesh_list=mesh_list,
    mesh_range=[3, 5],
)
class CreateMovementComponentCommand(path=None, prim_paths=[], min_range=(0.0, 0.0, 0.0), max_range=(100.0, 100.0, 100.0), target_position=None, target_paths=None, polygon_points=[], draw_polygon=False, target_points=[], lookat_target_points=[], enable_sequential_behavior=False, duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a movement randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateMovementComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1"],
    min_range=(0.0, 0.0, 0.0),
    max_range=(100.0, 100.0, 100.0),
    duration=1.0,
    include_children=False,
)
class CreateRotationComponentCommand(path=None, prim_paths=[], min_range=(0.0, 0.0, 0.0), max_range=(360.0, 360.0, 360.0), duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a rotation randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateRotationComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1"],
    min_range=(0.0, 0.0, 0.0),
    max_range=(360.0, 360.0, 360.0),
    duration=1.0,
    include_children=False,
)
class CreateScaleComponentCommand(path=None, prim_paths=[], min_range=(1.0, 1.0, 1.0), max_range=(5.0, 5.0, 5.0), uniform_scaling=False, duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a scale randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateScaleComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1"],
    min_range=(1.0, 1.0, 1.0),
    max_range=(5.0, 5.0, 5.0),
    duration=1.0,
    include_children=False,
)
class CreateTextureComponentCommand(path=None, prim_paths=[], enable_project_uvw=False, texture_list=[], ignored_class_list=[], grouped_class_list=[], duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a texture randomization component.

Typical usage example:

texture_list = [
    <server_path> + "/texture1.png",
    <server_path> + "/texture2.png",
]
result, prim = omni.kit.commands.execute(
    "CreateTextureComponentCommand",
    prim_paths=["/World/Room"],
    enable_project_uvw=False,
    texture_list=texture_list,
    duration=1.0,
    include_children=True,
)
class CreateTransformComponentCommand(path=None, prim_paths=[], translate_min_range=(0.0, 0.0, 0.0), translate_max_range=(100.0, 100.0, 100.0), rotate_min_range=(0.0, 0.0, 0.0), rotate_max_range=(0.0, 0.0, 0.0), scale_min_range=(0.0, 0.0, 0.0), scale_max_range=(0.0, 0.0, 0.0), target_position=None, target_paths=None, polygon_points=[], draw_polygon=False, target_points=[], lookat_target_points=[], target_point_instancer_paths=None, enable_sequential_behavior=False, combine_random_range=False, excluded_target_paths=None, excluded_target_offset=(0.0, 0.0, 0.0), duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a transform randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateTransformComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1"],
    translate_min_range=(0.0, 0.0, 0.0),
    translate_max_range=(100.0, 100.0, 100.0),
    duration=1.0,
    include_children=False,
)
class CreateVisibilityComponentCommand(path=None, prim_paths=[], num_visible_range=(1, 1), duration=0.0, include_children=False, seed=12345)

Bases: omni.kit.commands.command.Command

Commands class to create a visibility randomization component.

Typical usage example:

result, prim = omni.kit.commands.execute(
    "CreateVisibilityComponentCommand",
    prim_paths=["/World/Cube", "/World/Cube1", "/World/Cube2", "/World/Cube3", "/World/Cube4"],
    num_visible_range=[1, 3],
    duration=1.0,
)

Generated USD Schema API

The following USD Schema API was automatically generated, it is provided here as a reference

class AttributeComponent

Bases: omni.isaac.DrSchema.BaseComponent

static Define()
static Get()
static GetSchemaAttributeNames()
class BaseComponent

Bases: pxr.Usd.Typed

CreateCompNameAttr()
CreateDurationAttr()
CreateIncludeChildrenAttr()
CreatePrimPathsRel()
CreateSeedAttr()
static Get()
GetCompNameAttr()
GetDurationAttr()
GetIncludeChildrenAttr()
GetPrimPathsRel()
static GetSchemaAttributeNames()
GetSeedAttr()
class ColorComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateFirstColorAttr()
CreateMetallicAttr()
CreateRoughnessAttr()
CreateSecondColorAttr()
static Define()
static Get()
GetFirstColorAttr()
GetMetallicAttr()
GetRoughnessAttr()
static GetSchemaAttributeNames()
GetSecondColorAttr()
class LightComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateEnableTemperatureAttr()
CreateFirstColorAttr()
CreateIntensityRangeAttr()
CreateSecondColorAttr()
CreateTemperatureRangeAttr()
static Define()
static Get()
GetEnableTemperatureAttr()
GetFirstColorAttr()
GetIntensityRangeAttr()
static GetSchemaAttributeNames()
GetSecondColorAttr()
GetTemperatureRangeAttr()
class MaterialComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateGroupedClassAttr()
CreateIgnoredClassAttr()
CreateLoadedMaterialPrimPathsRel()
CreateMaterialListAttr()
static Define()
static Get()
GetGroupedClassAttr()
GetIgnoredClassAttr()
GetLoadedMaterialPrimPathsRel()
GetMaterialListAttr()
static GetSchemaAttributeNames()
class MeshComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateMeshListAttr()
CreateNumMeshRangeAttr()
static Define()
static Get()
GetMeshListAttr()
GetNumMeshRangeAttr()
static GetSchemaAttributeNames()
class MovementComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateDrawPolygonAttr()
CreateEnableLookAtTargetAttr()
CreateEnableSequentialBehaviorAttr()
CreateLookAtTargetOffsetAttr()
CreateLookAtTargetPathsRel()
CreateLookAtTargetPointsAttr()
CreatePolygonPointsAttr()
CreateTargetPointsAttr()
CreateXRangeAttr()
CreateYRangeAttr()
CreateZRangeAttr()
static Define()
static Get()
GetDrawPolygonAttr()
GetEnableLookAtTargetAttr()
GetEnableSequentialBehaviorAttr()
GetLookAtTargetOffsetAttr()
GetLookAtTargetPathsRel()
GetLookAtTargetPointsAttr()
GetPolygonPointsAttr()
static GetSchemaAttributeNames()
GetTargetPointsAttr()
GetXRangeAttr()
GetYRangeAttr()
GetZRangeAttr()
class RotationComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateXRangeAttr()
CreateYRangeAttr()
CreateZRangeAttr()
static Define()
static Get()
static GetSchemaAttributeNames()
GetXRangeAttr()
GetYRangeAttr()
GetZRangeAttr()
class ScaleComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateEnableUniformAttr()
CreateXRangeAttr()
CreateYRangeAttr()
CreateZRangeAttr()
static Define()
static Get()
GetEnableUniformAttr()
static GetSchemaAttributeNames()
GetXRangeAttr()
GetYRangeAttr()
GetZRangeAttr()
class TextureComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateEnableProjectUVWAttr()
CreateGroupedClassAttr()
CreateIgnoredClassAttr()
CreateTextureListAttr()
static Define()
static Get()
GetEnableProjectUVWAttr()
GetGroupedClassAttr()
GetIgnoredClassAttr()
static GetSchemaAttributeNames()
GetTextureListAttr()
class TransformComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateCombineRandomRangeAttr()
CreateDrawPolygonAttr()
CreateEnableLookAtTargetAttr()
CreateEnableSequentialBehaviorAttr()
CreateExcludedTargetOffsetAttr()
CreateExcludedTargetPathsRel()
CreateLookAtTargetOffsetAttr()
CreateLookAtTargetPathsRel()
CreateLookAtTargetPointsAttr()
CreatePolygonPointsAttr()
CreateRotateMaxAttr()
CreateRotateMinAttr()
CreateScaleMaxAttr()
CreateScaleMinAttr()
CreateTargetPointInstancersRel()
CreateTargetPointsAttr()
CreateTranslateMaxAttr()
CreateTranslateMinAttr()
static Define()
static Get()
GetCombineRandomRangeAttr()
GetDrawPolygonAttr()
GetEnableLookAtTargetAttr()
GetEnableSequentialBehaviorAttr()
GetExcludedTargetOffsetAttr()
GetExcludedTargetPathsRel()
GetLookAtTargetOffsetAttr()
GetLookAtTargetPathsRel()
GetLookAtTargetPointsAttr()
GetPolygonPointsAttr()
GetRotateMaxAttr()
GetRotateMinAttr()
GetScaleMaxAttr()
GetScaleMinAttr()
static GetSchemaAttributeNames()
GetTargetPointInstancersRel()
GetTargetPointsAttr()
GetTranslateMaxAttr()
GetTranslateMinAttr()
class VisibilityComponent

Bases: omni.isaac.DrSchema.BaseComponent

CreateNumVisibleRangeAttr()
static Define()
static Get()
GetNumVisibleRangeAttr()
static GetSchemaAttributeNames()