API#
Python API#
Module for triggering domain randomization events in Isaac Sim. |
|
Contains trigger functions for controlling when domain randomization occurs in Isaac Sim. |
|
Provides domain randomization functionality for physics simulation views in Isaac Sim. |
|
Provides utility functions for domain randomization in Isaac Sim replicator, including distribution parameter management, semantic data processing, 3D to 2D projection, truncation calculations, and NumPy JSON serialization. |
trigger#
Module for triggering domain randomization events in Isaac Sim.
- on_rl_frame(num_envs: int)#
Creates a node that triggers domain randomization on reinforcement learning frames.
This function sets up domain randomization to occur at specific intervals during RL training, allowing for environment variations across multiple parallel environments.
- Parameters:
num_envs – The number of environments corresponding to the number of prims encapsulated in the RigidPrimViews and ArticulationViews.
- Returns:
The created OgnOnRLFrame node for domain randomization.
gate#
Contains trigger functions for controlling when domain randomization occurs in Isaac Sim.
- on_env_reset() omni.replicator.core.utils.ReplicatorItem#
Create a trigger node for domain randomization that activates on environment reset.
This function sets up a filtering node that ignores interval-based triggering and instead responds to environment reset signals, enabling randomization to occur when environments are reset rather than at regular intervals.
- Returns:
The created interval filtering node configured for environment reset triggering.
- on_interval(interval) omni.replicator.core.utils.ReplicatorItem#
Create a trigger node for domain randomization that activates at specified intervals.
This function sets up a filtering node that triggers randomization at regular intervals based on frame counts, enabling periodic domain randomization during simulation.
- Parameters:
interval – The frequency interval for randomization. The interval is incremented by isaacsim.replicator.domain_randomization.physics_view.step_randomization() call.
- Returns:
The created interval filtering node configured for interval-based triggering.
physics_view#
Provides domain randomization functionality for physics simulation views in Isaac Sim.
- randomize_articulation_view(
- view_name: str,
- operation: str = 'direct',
- num_buckets: int = None,
- stiffness: omni.replicator.core.utils.ReplicatorItem = None,
- damping: omni.replicator.core.utils.ReplicatorItem = None,
- joint_friction: omni.replicator.core.utils.ReplicatorItem = None,
- position: omni.replicator.core.utils.ReplicatorItem = None,
- orientation: omni.replicator.core.utils.ReplicatorItem = None,
- linear_velocity: omni.replicator.core.utils.ReplicatorItem = None,
- angular_velocity: omni.replicator.core.utils.ReplicatorItem = None,
- velocity: omni.replicator.core.utils.ReplicatorItem = None,
- joint_positions: omni.replicator.core.utils.ReplicatorItem = None,
- joint_velocities: omni.replicator.core.utils.ReplicatorItem = None,
- lower_dof_limits: omni.replicator.core.utils.ReplicatorItem = None,
- upper_dof_limits: omni.replicator.core.utils.ReplicatorItem = None,
- max_efforts: omni.replicator.core.utils.ReplicatorItem = None,
- joint_armatures: omni.replicator.core.utils.ReplicatorItem = None,
- joint_max_velocities: omni.replicator.core.utils.ReplicatorItem = None,
- joint_efforts: omni.replicator.core.utils.ReplicatorItem = None,
- body_masses: omni.replicator.core.utils.ReplicatorItem = None,
- body_inertias: omni.replicator.core.utils.ReplicatorItem = None,
- material_properties: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_stiffnesses: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_dampings: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_limit_stiffnesses: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_lower_limits: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_upper_limits: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_rest_lengths: omni.replicator.core.utils.ReplicatorItem = None,
- tendon_offsets: omni.replicator.core.utils.ReplicatorItem = None,
Randomizes various properties of a registered articulation view.
- Parameters:
view_name – The name of a registered Articulation.
operation – Can be “direct”, “additive”, or “scaling”. “direct” means random values are directly written into the view. “additive” means random values are added to the default values. “scaling” means random values are multiplied to the default values.
num_buckets – Number of buckets to sample values from for material_properties randomization.
stiffness – Randomizes the stiffness of the joints in the articulation prims.
damping – Randomizes the damping of the joints in the articulation prims.
joint_friction – Randomizes the friction of the joints in the articulation prims.
position – Randomizes the root position of the prims.
orientation – Randomizes the root orientation of the prims using euler angles (rad).
linear_velocity – Randomizes the root linear velocity of the prims.
angular_velocity – Randomizes the root angular velocity of the prims.
velocity – Randomizes the root linear and angular velocity of the prims.
joint_positions – Randomizes the joint positions of the articulation prims.
joint_velocities – Randomizes the joint velocities of the articulation prims.
lower_dof_limits – Randomizes the lower joint limits of the articulation prims.
upper_dof_limits – Randomizes the upper joint limits of the articulation prims.
max_efforts – Randomizes the maximum joint efforts of the articulation prims.
joint_armatures – Randomizes the joint armatures of the articulation prims.
joint_max_velocities – Randomizes the maximum joint velocities of the articulation prims.
joint_efforts – Randomizes the joint efforts of the articulation prims.
body_masses – Randomizes the mass of each body in the articulation prims. The replicator distribution takes in K values, where K is the number of bodies in the articulation.
body_inertias – Randomizes the inertia of each body in the articulation prims. The replicator distribution takes in K * 3 values, where K is the number of bodies in the articulation.
material_properties – Randomizes the material properties of the bodies in the articulation.
tendon_stiffnesses – Randomizes the stiffnesses of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_dampings – Randomizes the dampings of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_limit_stiffnesses – Randomizes the limit stiffnesses of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_lower_limits – Randomizes the lower limits of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_upper_limits – Randomizes the upper limits of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_rest_lengths – Randomizes the rest lengths of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
tendon_offsets – Randomizes the offsets of the fixed tendons in the articulation. The replicator distribution takes in T values, where T is the number of tendons in the articulation.
- Raises:
ValueError – If called outside the correct context managers or if the view is not registered.
- randomize_rigid_prim_view(
- view_name: str,
- operation: str = 'direct',
- num_buckets: int = None,
- position: omni.replicator.core.utils.ReplicatorItem = None,
- orientation: omni.replicator.core.utils.ReplicatorItem = None,
- linear_velocity: omni.replicator.core.utils.ReplicatorItem = None,
- angular_velocity: omni.replicator.core.utils.ReplicatorItem = None,
- velocity: omni.replicator.core.utils.ReplicatorItem = None,
- force: omni.replicator.core.utils.ReplicatorItem = None,
- mass: omni.replicator.core.utils.ReplicatorItem = None,
- inertia: omni.replicator.core.utils.ReplicatorItem = None,
- material_properties: omni.replicator.core.utils.ReplicatorItem = None,
- contact_offset: omni.replicator.core.utils.ReplicatorItem = None,
- rest_offset: omni.replicator.core.utils.ReplicatorItem = None,
Randomizes various properties of a registered rigid prim view.
- Parameters:
view_name – The name of a registered RigidPrimView.
operation – Can be “direct”, “additive”, or “scaling”. “direct” means random values are directly written into the view. “additive” means random values are added to the default values. “scaling” means random values are multiplied to the default values.
num_buckets – Number of buckets to sample values from for material_properties randomization.
position – Randomizes the position of the prims.
orientation – Randomizes the orientation of the prims using euler angles (rad).
linear_velocity – Randomizes the linear velocity of the prims.
angular_velocity – Randomizes the angular velocity of the prims.
velocity – Randomizes the linear and angular velocity of the prims.
force – Applies a random force to the prims.
mass – Randomizes the mass of the prims. CPU pipeline only.
inertia – Randomizes the inertia of the prims. Takes in three values for the replicator distribution, corresponding to the diagonal elements of the inertia matrix. CPU pipeline only.
material_properties – Takes in three values for the replicator distriution, corresponding to static friction, dynamic friction, and restitution.
contact_offset – Randomizes the contact offset of the prims.
rest_offset – Randomizes the rest offset of the prims.
- Raises:
ValueError – If called outside the correct context managers or if the view is not registered.
- randomize_simulation_context(
- operation: str = 'direct',
- gravity: omni.replicator.core.utils.ReplicatorItem = None,
Randomizes properties of the simulation context.
- Parameters:
operation – Can be “direct”, “additive”, or “scaling”. “direct” means random values are directly written into the view. “additive” means random values are added to the default values. “scaling” means random values are multiplied to the default values.
gravity – Randomizes the gravity vector of the simulation.
- Raises:
ValueError – If called outside the correct context managers or if no simulation context is registered.
- register_articulation_view(
- articulation_view: Articulation,
Registers an articulation view for domain randomization.
Stores the articulation view and captures its initial property values for use in randomization. The view must be registered before it can be randomized.
- Parameters:
articulation_view – Registering the Articulation to be randomized.
- register_rigid_prim_view(
- rigid_prim_view: RigidPrim,
Registers a rigid prim view for domain randomization.
Stores the rigid prim view and captures its initial property values for use in randomization. The view must be registered before it can be randomized.
- Parameters:
rigid_prim_view – Registering the RigidPrim to be randomized.
- register_simulation_context(
- simulation_context: SimulationContext | World,
Registers a simulation context for domain randomization.
Stores the simulation context and captures its initial property values for use in randomization. The context must be registered before it can be randomized.
- Parameters:
simulation_context – Registering the SimulationContext.
utils#
Provides utility functions for domain randomization in Isaac Sim replicator, including distribution parameter management, semantic data processing, 3D to 2D projection, truncation calculations, and NumPy JSON serialization.
- class NumpyEncoder(
- *,
- skipkeys=False,
- ensure_ascii=True,
- check_circular=True,
- allow_nan=True,
- sort_keys=False,
- indent=None,
- separators=None,
- default=None,
Bases:
JSONEncoderCustom JSON encoder that handles NumPy arrays.
This encoder extends the standard JSON encoder to properly serialize NumPy arrays by converting them to Python lists, making them JSON-serializable. When encountering a NumPy array during JSON serialization, it automatically converts the array to a list format that can be included in the JSON output.
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float, bool or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be an (item_separator, key_separator) tuple. The default is (’, ‘, ‘: ‘) if indent is
Noneand (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a
TypeError.- default(obj)#
Converts NumPy arrays to Python lists for JSON serialization.
- Parameters:
obj – Object to serialize. If it’s a NumPy array, converts to list.
- Returns:
Python list if obj is a NumPy array, otherwise the result of the parent class default method.
- calculate_truncation_ratio_simple(
- corners,
- img_width: int,
- img_height: int,
Calculate the truncation ratio of a cuboid using a simplified bounding box method.
- Parameters:
corners – (9, 2) numpy array containing the projected corners of the cuboid.
img_width – Width of image.
img_height – Height of image.
- Returns:
The truncation ratio of the cuboid. 1 means object is fully truncated and 0 means object is fully within screen.
- get_distribution_params(
- distribution: omni.replicator.core.utils.ReplicatorItem,
- parameters: List[str],
Retrieves parameter values from a replicator distribution object.
- Parameters:
distribution – A replicator distribution object.
parameters – A list of the names of the replicator distribution parameters.
- Returns:
A list of the distribution parameters of the given replicator distribution object.
- Raises:
ValueError – If the distribution does not have the specified parameter.
- get_image_space_points(points, view_proj_matrix) ndarray#
Projects 3D world space points into 2D image space coordinates.
- Parameters:
points – Numpy array of N points (N, 3) in the world space. Points will be projected into the image space.
view_proj_matrix – Desired view projection matrix, transforming points from world frame to image space of desired camera.
- Returns:
Numpy array of shape (N, 3) of points projected into the image space.
- get_semantics(
- num_semantics,
- num_semantic_tokens,
- instance_semantic_map,
- min_semantic_idx,
- max_semantic_hierarchy_depth,
- semantic_token_map,
- required_semantic_types,
Extracts and processes semantic information from instance semantic data.
Processes semantic tokens to build hierarchical relationships between semantic entities and their parents, filtering by required semantic types to generate semantic labels and unique identifiers.
- Parameters:
num_semantics – Number of semantic entities to process.
num_semantic_tokens – Number of tokens per semantic entity.
instance_semantic_map – Array mapping instances to semantic indices.
min_semantic_idx – Minimum semantic index value for offset calculation.
max_semantic_hierarchy_depth – Maximum depth of semantic hierarchy.
semantic_token_map – Array containing semantic token strings.
required_semantic_types – List of semantic types to filter and include.
- Returns:
A tuple containing (serialized_labels, semantic_ids, valid_count, prim_paths) where serialized_labels is JSON string of semantic mappings, semantic_ids is list of unique identifiers, valid_count is number of valid semantic entities, and prim_paths is list of primitive paths.
- set_distribution_params(
- distribution: omni.replicator.core.utils.ReplicatorItem,
- parameters: Dict,
Updates parameter values of a replicator distribution object.
- Parameters:
distribution – The replicator distribution object to be modified.
parameters – A dictionary where the keys are the names of the replicator distribution parameters and the values are the parameter values to be set.
- Raises:
ValueError – If the distribution does not have the specified parameter.