Python API#

omni.physics.tensors.impl.api.acquire_tensor_api(
plugin_name: str = None,
library_path: str = None,
) omni.physics.tensors.bindings._physicsTensors.TensorApi#
omni.physics.tensors.impl.api.create_simulation_view(frontend_name, stage_id=-1)#

Creates an entry point to the physics simulation through physics tensors.

It allows creating a SimulationView object given the frontend tensor framework and the physX-based tensorization backend.

Parameters:
  • frontend_name (str) – The name of the frontend to use. It can be one of the following: “numpy”, “torch”, “tensorflow”, “warp”.

  • stage_id (int) – The stage id to use. Default is -1.

Returns:

The simulation view object created with the specified frontend and physX backend.

Return type:

SimulationView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
omni.physics.tensors.impl.api.reset()#

Resets the physics simulation with physX backend.

This will reset the underlying tensor buffers that are created based on the exisiting stage.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> sim_view.reset() # required step to stop the simulation
class omni.physics.tensors.impl.api.SimulationView(backend, frontend)#

SimulationView class represents a simulation environment.

SimulationView class binds the tensor framework used to represent data with the physics simulation backend. This class isn’t meant to be instantiated directly, but rather created using the create_simulation_view() function. Once created, the simulation view can be used to create specific views for different types of physics objects such as rigid bodies, articulations, soft bodies, etc.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*")
property device#

The device property returns the device used by the frontend tensor framework.

Note

The numpy frontend can only be used on cpu. For GPU data/pipeline, use torch or warp frontends.

property is_valid#

The is_valid property returns whether the simulation view is valid or not.

Note

The simulation view can become invalid under certain conditions such as when a physX object participating in tensorization is removed from the backend. In such scenarios, accessing the physics data is unsafe therefore the simulation view is marked as invalid. The user of the class can also invalidate a SimulationView object by calling the invalidate() method manually.

property device_ordinal#

The device_ordinal property returns the device ordinal, which is -1 for CPU and 0,1,… for GPU devices depending on the number of GPUs available and the one being used for simulation.

property cuda_context#

The cuda_context property returns the cuda context when using GPU simulation and None for CPU simulation.

invalidate()#

Marks the simulation view as invalid.

The invalidate method marks the simulation view as invalid to prevent it from being used further by other references. This is needed when the topology of the stage changes and the existing views of the physics objects cannot be used anymore.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> sim_view.invalidate() # sim_view.is_valid = False
set_subspace_roots(pattern)#

Sets the environment transform based on the transforms that match the given pattern.

In Simulations with multiple environments each environment can have its own environment transform. When this exists, some APIs such as RigidBodyView.get_transforms() will return the transforms in the local space of the environment with respect to the environment local transform. This API can be used to inform the simulation view about the subspace prims with local transforms.

Parameters:

pattern (Union[str, List[str]]) – The pattern to set the subspace roots. The pattern can be a wildcard pattern to match multiple objects.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> sim_view.set_subspace_roots("/envs/*") # This will set environment transforms based on transforms found in /envs/* pattern
>>> sim_view.set_subspace_roots("/") # This will set environment transforms based on the world transform
create_articulation_view(pattern)#

Creates a view of articulations of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the articulations in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The articulation view object created that match the given pattern. Each articulation view object can be used to get/set data for the articulations of that view.

Return type:

ArticulationView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_articulation_view("/World/Franka_*") # This will create a view of all Franka articulations in the scene whose paths start with "/World/Franka_"
>>> subset_view = create_articulation_view(["/World/Franka_[0-2]", "/World/Franka_[8-9]"]) # This will create a view of Franka articulations whose paths match "/World/Franka_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_articulation_view(["/World/Franka_0", "/World/Franka_3", "/World/Franka_7"]) # This will create a view of Franka articulations whose paths match "/World/Franka_i" where i is in [0,3,7]
create_rigid_body_view(pattern)#

Creates a view of rigid bodies of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the rigid bodies in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The rigid body view object created that match the given pattern. Each rigid body view object can be used to get/set data for the rigid bodies of that view.

Return type:

RigidBodyView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_rigid_body_view("/World/Cube_*") # This will create a view of all rigid bodies in the scene whose paths start with "/World/Cube_"
>>> subset_view = create_rigid_body_view(["/World/Cube_[0-2]", "/World/Cube_[8-9]"]) # This will create a view of rigid bodies whose paths match "/World/Cube_i" where i is in [0,1,2,8,9]
>>> same_view = create_rigid_body_view(["/World/Cube_0", "/World/Cube_3", "/World/Cube_7"]) # This will create a view of rigid bodies whose paths match "/World/Cube_i" where i is in [0,3,7]
create_soft_body_view(pattern)#

Creates a view of soft bodies of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the soft bodies in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The soft body view object created that match the given pattern. Each soft body view object can be used to get/set data for the soft bodies of that view.

Return type:

SoftBodyView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_soft_body_view("/World/Soft_*") # This will create a view of all soft bodies in the scene whose paths start with "/World/Soft_"
>>> subset_view = create_soft_body_view(["/World/Soft_[0-2]", "/World/Soft_[8-9]"]) # This will create a view of soft bodies whose paths match "/World/Soft_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_soft_body_view(["/World/Soft_0", "/World/Soft_3", "/World/Soft_7"]) # This will create a view of soft bodies whose paths match "/World/Soft_i" where i is in [0,3,7]
create_soft_body_material_view(pattern)#

Creates a view of soft body materials of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the soft body materials in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The soft body material view object created that match the given pattern. Each soft body material view object can be used to get/set data for the soft body materials of that view.

Return type:

SoftBodyMaterialView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This will create a view of all soft body materials in the scene whose paths start with "/World/SoftMaterial_"
>>> subset_view = create_soft_body_material_view(["/World/SoftMaterial_[0-2]", "/World/SoftMaterial_[8-9]"]) # This will create a view of soft body materials whose paths match "/World/SoftMaterial_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_soft_body_material_view(["/World/SoftMaterial_0", "/World/SoftMaterial_3", "/World/SoftMaterial_7"]) # This will create a view of soft body materials whose paths match "/World/SoftMaterial_i" where i is in [0,3,7]
create_rigid_contact_view(
pattern,
filter_patterns=[],
max_contact_data_count=0,
)#

Creates a view of rigid contacts of the scene that match the given pattern/filter_pattern, or a list of patterns and a list of lists of filter_patterns.

Note

providing filter_patterns is optional. If not used, the view can only provide the net contact forces of the sensors with all the objects in the scene. If filter_patterns are provided, the view can provide the pair-wise contact forces of the sensors with the filter objects as well.

Warning

There is a one-to-one relationship between the sensors and the filter objects created via this API, and because of this some care is needed to ensure this API does what you intent to do.

  • If a single pattern is provided for sensor pattern, then a list of filter patterns should be provided for filter_pattern. This list contains all the filters for each sensor. Note that the same number of filters should be provided for all sensors.

  • If a list of regular expressions is provided for sensor pattern, then a list of lists of filter patterns should be provided for filter_pattern (each list of filter patterns corresponds to the corresponding sensor pattern in the list of sensor patterns).

In this scenario, the order of lists of filter patterns, should match the order of the sensor patterns in the sensor pattern list.

Parameters:
  • pattern (Union[str, List[str]]) – The pattern to match the rigid bodies in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects. Note that the pattern is used to select a set of “sensors”, which are the objects whose contacts are tracked.

  • filter_patterns (Optional[Union[List[str], List[list[str]]]]) – The list of patterns of “filter” rigid bodies in the scene. This can be a single pattern or a list of patterns. The pattern can be a list of wildcard patterns to match multiple objects. Note that the filter pattern is used to select a set of “filter”, which are the objects that the sensors can come in contact with. The filter objects will not report their contacts directly, but only when they are in contact with the sensors their contact forces will be included in the sensor’s contact data.

Returns:

The rigid contact view object created based on the given sensor/filter patterns. Each rigid contact view object can be used to get specific contact data for the sensor rigid bodies of the view.

Return type:

RigidContactView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
# The following will create a view of all rigid contacts in the scene whose paths start with "/World/Cube_"
>>> view_1 = sim_view.create_rigid_contact_view("/World/Cube_*")
# The following will create a view consisting of cubes 0,1,2,8, and 9
>>> view_2 = sim_view.create_rigid_contact_view(["/World/Cube_[0-2]", "/World/Cube_[8-9]"])
# The following will create a view consisting of cubes 0,3, and 7
>>> view_3 = sim_view.create_rigid_contact_view(["/World/Cube_0", "/World/Cube_3", "/World/Cube_7"])
# The following will create a view between all cube sensors and the Ground plane. Note that providing a filter pattern that matches a single prim (as opposed to the same number of prims as the sensors) will work as an exception.
>>> view_4 = sim_view.create_rigid_contact_view("/World/Cube_*", ["/World/GroundPlane"])
# The following will create a view between all cube sensors and the Ground plane and spheres. Note again that each Cube sensor will match with one Sphere prim. All Cube sensors will match with the GroundPlane prim (single prim exception explained in the above example).
>>> view_5 = sim_view.create_rigid_contact_view("/World/Cube_*", ["/World/GroundPlane", "/World/Sphere_*"])
# The following will create a view between cubes 0,1,2,8, and 9 and the Ground plane and spheres 0,1,2,8, and 9 respectively. Note that each Cube sensor will match with one Sphere prim. All Cube sensors will match with the GroundPlane prim (single prim exception explained in the above example).
>>> view_5 = sim_view.create_rigid_contact_view(["/World/Cube_[0-2]", "/World/Cube_[8-9]"], [["/World/GroundPlane", "/World/Sphere_[0-2]"], ["/World/GroundPlane", "/World/Sphere_[8-9]"]])
# The following will create a view between cubes 0,1,2,8, and 9 and the Ground plane and spheres 0,1,2,8, and 9 as well as box 0,1,2,8 and 9 respectively. Note that each Cube sensor will match with one Sphere prim and one box prim. All Cube sensors will match with the GroundPlane prim (single prim exception explained in the above example).
>>> view_6 = sim_view.create_rigid_contact_view(["/World/Cube_[0-2]", "/World/Cube_[8-9]"], [["/World/GroundPlane", "/World/Sphere_[0-2]", "/World/Box_[0-2]"], ["/World/GroundPlane", "/World/Sphere_[8-9]", "/World/Box_[8-9]"]])
# Creating one-to-many relationship is also possible but works slightly differently.
# The following will create a view to track contacts between num_sensors cubes and for each cube to track contacts with num_filters spheres.
# Note that instead of providing regular expressions you can provide prim paths directly. Note also that for each sensor there is one list of filter of size num_filters that encapsulates all the spheres.
>>> view_7 = create_rigid_contact_view([f"/World/Cube_{j}" for j in range(num_sensors)], filter_patterns= [[f"/World/Sphere_{j}" for j in range(num_filters)]] * num_sensors)
create_sdf_shape_view(pattern, num_points)#

Creates a view of SDF shapes of the scene that match the given pattern, or a list of patterns.

Parameters:
  • pattern (Union[str, List[str]]) – The pattern to match the SDF shapes in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

  • num_points (int) – The number of points to sample the SDF shape with.

Returns:

The SDF shape view object created that match the given pattern. Each SDF shape view object can be used to get signed distance field properties of a shape.

Return type:

SdfShapeView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_sdf_shape_view("/World/SDF_*", 1000) # This will create a view of all SDF shapes in the scene whose paths start with "/World/SDF_" with 1000 points sample per shape
>>> subset_view = create_sdf_shape_view(["/World/SDF_[0-2]", "/World/SDF_[8-9]"], 1000) # This will create a view of SDF shapes whose paths match "/World/SDF_i" where i is in [0,1,2,8,9] with 1000 points sample per shape
>>> another_subset_view = create_sdf_shape_view(["/World/SDF_0", "/World/SDF_3", "/World/SDF_7"], 1000) # This will create a view of SDF shapes whose paths match "/World/SDF_i" where i is in [0,3,7] with 1000 points sample per shape
create_particle_system_view(pattern)#

Creates a view of particle systems of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the particle systems in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The particle system view object created that match the given pattern. Each particle system view object can be used to get/set data for the particle systems of that view.

Return type:

ParticleSystemView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_particle_system_view("/World/Particles_*") # This will create a view of all particle systems in the scene whose paths start with "/World/Particles_"
>>> subset_view = create_particle_system_view(["/World/Particles_[0-2]", "/World/Particles_[8-9]"]) # This will create a view of particle systems whose paths match "/World/Particles_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_particle_system_view(["/World/Particles_0", "/World/Particles_3", "/World/Particles_7"]) # This will create a view of particle systems whose paths match "/World/Particles_i" where i is in [0,3,7]
create_particle_cloth_view(pattern)#

Creates a view of particle cloths of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the particle cloths in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The particle cloth view object created that match the given pattern. Each particle cloth view object can be used to get/set data for the particle cloths of that view.

Return type:

ParticleClothView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_particle_cloth_view("/World/Cloth_*") # This will create a view of all particle cloths in the scene whose paths start with "/World/Cloth_"
>>> subset_view = create_particle_cloth_view(["/World/Cloth_[0-2]", "/World/Cloth_[8-9]"]) # This will create a view of particle cloths whose paths match "/World/Cloth_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_particle_cloth_view(["/World/Cloth_0", "/World/Cloth_3", "/World/Cloth_7"]) # This will create a view of particle cloths whose paths match "/World/Cloth_i" where i is in [0,3,7]
create_particle_material_view(pattern)#

Creates a view of particle materials of the scene that match the given pattern, or a list of patterns.

Parameters:

pattern (Union[str, List[str]]) – The pattern to match the particle materials in the scene. This can be a single pattern or a list of patterns. The pattern can be a wildcard pattern to match multiple objects.

Returns:

The particle material view object created that match the given pattern. Each particle material view object can be used to get/set data for the particle materials of that view.

Return type:

ParticleMaterialView

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_particle_material_view("/World/ParticleMaterial_*") # This will create a view of all particle materials in the scene whose paths start with "/World/ParticleMaterial_"
>>> subset_view = create_particle_material_view(["/World/ParticleMaterial_[0-2]", "/World/ParticleMaterial_[8-9]"]) # This will create a view of particle materials whose paths match "/World/ParticleMaterial_i" where i is in [0,1,2,8,9]
>>> another_subset_view = create_particle_material_view(["/World/ParticleMaterial_0", "/World/ParticleMaterial_3", "/World/ParticleMaterial_7"]) # This will create a view of particle materials whose paths match "/World/ParticleMaterial_i" where i is in [0,3,7]
flush()#
clear_forces()#

Clears the force/torque data buffers from the physics simulation backend.

enable_warnings(enable)#

Enables or disables extra warnings from all APIs.

Parameters:

enable (bool) – True to enable warnings, False to disable warnings.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> sim_view.enable_warnings(False) # warnings are not sent anymore
update_articulations_kinematic()#

Updates the kinematic state of all articulations in the scene.

Depending on the concrete implementation, calling this might be necessary before taking another simulation step to update link transforms according to the latest joint states set by the user at the current time step.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> view.set_dof_positions(new_franka_dof_positions, franka_indices) # This will change the pose of all the Franka articulaitons in the view
>>> sim_view.update_articulations_kinematic() # For GPU, this is required to update the links kinematic
initialize_kinematic_bodies()#

Initializes all the kinematics bodies in the scene. By default kinematic bodies are not part of the simulated physics. This function performs any necessary initialization to make them report their transforms and velocities.

check()#

Checks all the physics views created by this object for validity.

If any of the views are invalid, e.g. when a corresponding physics object is not found on the physics engine this will return False.

Returns:

True if all the views are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*")
>>> sim_view.check() # returns False if rigid_body_view or articulation_view is invalid, True otherwise
step(dt)#
set_gravity(gravity)#

Sets the gravity of the physics scene.

Parameters:

gravity (carb.Float3) – The gravity vector to set.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> sim_view.set_gravity(carb.Float3(0, -9.8, 0)) # This will set the gravity to be -9.8 in the y direction
get_gravity()#

Gets the gravity of the physics scene.

Returns:

The gravity vector of the scene or None if the gravity is not defined.

Return type:

carb.Float3

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("torch")
>>> gravity = sim_view.get_gravity() # This will fetch the gravity vector used by the simulation
class omni.physics.tensors.impl.api.ArticulationView(backend, frontend)#

ArticulationView class represents a batch of articulations.

ArticulationView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_articulation_view() method of the SimulationView object which manages all the physics views, the device where the simulation is performed and data resides.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
property count#

The number of articulations in the view.

The maximum number of links in all the view’s articulations.

property max_dofs#

The maximum number of degrees of freedom in all the view’s articulations.

property max_shapes#

The maximum number of shapes in all the view’s articulations.

property max_fixed_tendons#

The maximum number of fixed tendons in all the view’s articulations.

property is_homogeneous#

The is_homogeneous property indicates whether all the articulations in the view are of the same type. Note that currently only homogeneous articulation views are supported. To handle inhomogeneous articulations, create separate views for each type.

property shared_metatype#

The shared_metatype property indicates the metatype of the articulations in the view. The metatype features static information about articulation links and joints.

property jacobian_shape#

The jacobian_shape property indicates the dimension of the Jacobian matrix of the articulations in the view. The Jacobian matrix dimension depends on the number of degrees of freedom, number of links as well as floating/fixed base properties of the articulations. For fixed base articulations, the Jacobian matrix dimensions are max_dofs x ((numLinks - 1) * 6). For floating base articulations, the Jacobian matrix dimensions are (max_dofs + 6) x (numLinks * 6).

property mass_matrix_shape#

The mass_matrix_shape property indicates the dimension of the mass matrix of the articulations in the view. The mass matrix dimension depends on the number of degrees of freedom of the articulations and is max_dofs x max_dofs.

Warning

This property is deprecated and will be removed in the future. Use ArticulationView.generalized_mass_matrix_shape instead.

property generalized_mass_matrix_shape#

The generalized_mass_matrix_shape property indicates the dimension of the generalized mass matrix of the articulations in the view. The mass matrix dimension depends on the number of degrees of freedom as well as floating/fixed base properties of the articulations. For fixed base articulations, the mass matrix dimensions are max_dofs x max_dofs. For floating base articulations, the mass matrix dimensions are (max_dofs + 6) x (max_dofs + 6).

property prim_paths#

The prim_paths property indicates the paths to the articulations encapsulated in the view.

property dof_paths#

The dof_paths property indicates the paths to the degrees of freedom (DOF) encapsulated in the view. For single DOF joints, the path is the same as the joint path whereas for multi-DOF joints, the path is the joint path appended with the DOF index.

The link_paths property indicates the paths to the links of articulations encapsulated in the view.

get_metatype(arti_idx)#

Gets the metatype of the articulation at the given index.

Parameters:

arti_idx (int) – The index of the articulation to get the metatype of.

Note

The metatype features static information about articulation links and joints as follows: - link_count: The total number of links in the articulation. - joint_count: The total number of joints in the articulation. - dof_count: The total number of degrees of freedom in the articulation. - link_names: A list of the link names in the articulation. - link_parents: A list of each link’s parent name. This corresponds to the link_names list above. - joint_names: A list of the joint names in the articulation. - dof_names: A list of the DOF (Degrees Of Freedom) names. - link_indices: A mapping from link names to link index. - link_parent_indices: A mapping from link names to the index of their parent link. - joint_indices: A mapping from joint names to their index. - dof_indices: A mapping from DOF names to their index. - joint_types: A list of the type of each joint. - joint_dof_offsets: A list indicating the start offset of each joint’s DOFs. - joint_dof_counts: A list indicating how many DOFs each joint has. - dof_types: A list of the type of each DOF. - fixed_base: A boolean indicating if the base link is fixed (True) or floating (False).

Returns:

The metatype of the articulation at the given index.

Return type:

ArticulationMetatype

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> metatype = articulation_view.get_metatype(1) # Get the metatype of the articulation with index 1 in the given articulation view
>>> fixed_base = metatype.fixed_base # Get a boolean indicating whether the articulation is fixed base or floating base
>>> link_count = metatype.link_count # Get the number of links in the articulation
>>> link_0_name = metatype.link_names[0] # Get the name of the link 0
>>> link_0_parent_name = metatype.link_parents[0] # Get the parent name of link 0
>>> link_0_idx = metatype.link_indices[link_0_name] # Get the link index of link_0_name
>>> link_0_parent_idx = metatype.link_parent_indices[link_0_name] # Get the parent index of link 0 by name from the link name to parent index map.
>>> joint_count = metatype.joint_count # Get the number of joints in the articulation
>>> joint_0_name = metatype.joint_names[0] # Get the name of the joint 0
>>> joint_0_idx = metatype.joint_indices[joint_0_name] # Get the joint index of joint_0_name
>>> joint_0_type = metatype.joint_types[joint_0_idx] # Get the joint type of joint_0_name
>>> joint_0_dof_offset = metatype.joint_dof_offsets[joint_0_idx] # Get the joint DOF offset of joint_0_name
>>> joint_0_dof_count = metatype.joint_dof_counts[joint_0_idx] # Get the number of DOFs of joint_0_name
>>> dof_count = metatype.dof_count # Get the number of DOFs in the articulation
>>> dof_0_name = metatype.dof_names[0] # Get the name of the DOF 0
>>> dof_0_idx = metatype.dof_indices[dof_0_name] # Get the DOF index of dof_0_name
>>> dof_0_type = metatype.dof_types[dof_0_idx] # Get the DOF type of dof_0_name
>>> joint_0_dof_0_type = metatype.dof_types[joint_0_dof_offset] # Get the DOF type of the first DOF of joint_0_name
get_dof_types()#

Gets the degrees of freedom (DOF) types of the articulations in the view.

Potential DOF types are:

  • 0 (DofType.Rotation) for rotation.

  • 1 (DofType.Translation) for translation.

  • 255 (DofType.Invalid) for invalid DOF type.

Note

The function raises an exception if the DOF types cannot be obtained from the backend.

Returns:

An array of DOF types with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_types = articulation_view.get_dof_types() # Get the DOF type for all DOFs and all articulations in the view
>>> dof_types_np = dof_types.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
>>> dof_types_final = dof_types_np[0] # Takes only the results for the first articulation as all articulations in a view must be identical
get_dof_motions()#

Gets the degrees of freedom (DOF) motion types for all articulations in the view.

Potential DOF motions are:

  • 0 (DofMotion.Free) when the DOF motion has no constraint.

  • 1 (DofMotion.Limited) when the DOF is limited in its movement.

  • 2 (DofMotion.Locked) when the DOF is locked.

  • 255 (DofMotion.Invalid) when the motion is invalid.

Note

The function raises an exception if the DOF motions cannot be obtained from the backend.

Returns:

An array of DOF motions with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_motions = articulation_view.get_dof_motions() # Get the DOF motion for all DOFs and all articulations in the view
>>> dof_motions_np = dof_motions.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
>>> dof_motions_final = dof_motions_np[0] # Takes only the results for the first articulation as all articulations in a view must be identical
get_dof_limits()#

Gets the degrees of freedom (DOF) upper and lower limits for all articulations in the view.

Note

The function raises an exception if the DOF limits cannot be obtained from the backend.

Returns:

An array of DOF limits with shape (count, max_dofs, 2) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations. The first index of the last dimension is reserved for the lower limit and the second index is for the upper limit.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_limits = articulation_view.get_dof_limits() # Get the DOF limits for all DOFs and all articulations in the view
>>> dof_limits_np = dof_limits.numpy().reshape(articulation_view.count, articulation_view.max_dofs, 2) # Reshape the obtained array in a 3D numpy array on the host
>>> dof_limits_final = dof_limits_np[0] # Takes only the results for the first articulation as all articulations in a view must be identical
get_drive_types()#

Gets the degrees of freedom (DOF) drive types for all articulations in the view.

Potential drive types are:

  • 0 (DofDriveType.None) if no drive is present.

  • 1 (DofDriveType.Force) if a force drive is present.

  • 2 (DofDriveType.Acceleration) if an acceleration drive is present.

Note

The function raises an exception if the DOF drive types cannot be obtained from the backend.

Returns:

An array of DOF drive types with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> drive_types = articulation_view.get_drive_types() # Get the drive type for all DOFs and all articulations in the view
>>> drive_types_np = drive_types.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_stiffnesses()#

Gets the degrees of freedom (DOF) drive stiffnesses for all articulations in the view.

Note

The function raises an exception if the DOF stiffnesses cannot be obtained from the backend.

Returns:

An array of DOF stiffnesses with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_stiffnesses = articulation_view.get_dof_stiffnesses() # Get the DOF stiffness for all DOFs and all articulations in the view
>>> dof_stiffnesses_np = dof_stiffnesses.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_dampings()#

Gets the degrees of freedom (DOF) drive dampings for all articulations in the view.

Note

The function raises an exception if the DOF dampings cannot be obtained from the backend.

Returns:

An array of DOF dampings with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_dampings = articulation_view.get_dof_dampings() # Get the DOF damping for all DOFs and all articulations in the view
>>> dof_dampings_np = dof_dampings.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_max_forces()#

Gets the degrees of freedom (DOF) maximum forces applied by the drive for all articulations in the view.

Note

The function raises an exception if the DOF maximum forces cannot be obtained from the backend.

Returns:

An array of DOF maximum forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_max_forces = articulation_view.get_dof_max_forces() # Get the DOF maximum force applied by the drive for all DOFs and all articulations in the view
>>> dof_max_forces_np = dof_max_forces.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_friction_coefficients()#

Gets the degrees of freedom (DOF) friction coefficients for all articulations in the view.

Note

The function raises an exception if the DOF friction coefficients cannot be obtained from the backend.

Returns:

An array of DOF friction coefficients with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_friction_coefficients = articulation_view.get_dof_friction_coefficients() # Get the DOF friction coefficient for all DOFs and all articulations in the view
>>> dof_friction_coefficients_np = dof_friction_coefficients.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_max_velocities()#

Gets the degrees of freedom (DOF) maximum velocities for all articulations in the view.

Note

The function raises an exception if the DOF maximum velocities cannot be obtained from the backend.

Returns:

An array of DOF maximum velocities with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_max_velocities = articulation_view.get_dof_max_velocities() # Get the DOF maximum velocity for all DOFs and all articulations in the view
>>> dof_max_velocities_np = dof_max_velocities.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_armatures()#

Gets the degrees of freedom (DOF) armatures for all articulations in the view.

Note

The function raises an exception if the DOF armatures cannot be obtained from the backend.

Returns:

An array of DOF armatures with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_armatures = articulation_view.get_dof_armatures() # Get the DOF armature for all DOFs and all articulations in the view
>>> dof_armatures_np = dof_armatures.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
set_dof_limits(data, indices)#

Sets the degrees of freedom (DOF) limits for articulations indicated by indices.

Note

  • The function raises an exception if the DOF limits cannot be set in the backend.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_limits() can be used to get the current limits and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF limits with shape (count, max_dofs, 2) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations. The first index of the last dimension is reserved for the lower limit and the second index is for the upper limit.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the limits for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_limits_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs, 2]) # Create an array with the expected shape
>>> dof_limits_np[:, :, 0] = -0.5 # Modify the lower limit of all DOF and all articulation
>>> dof_limits_np[:, :, 1] = 0.5 # Modify the upper limit of all DOF and all articulation
>>> dof_limits_wp = warp.from_numpy(dof_limits_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_limits(dof_limits_wp, all_indices) # Set the new DOF limits
set_dof_stiffnesses(data, indices)#

Sets the degrees of freedom (DOF) drive stiffnesses for articulations indicated by indices.

Note

  • The function raises an exception if the DOF stiffnesses cannot be set in the backend.

  • Value would be set even if no drive is present, but it would have no effect on the dynamics.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_stiffnesses() can be used to get the current stiffnesses and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF stiffnesses with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the stiffnesses for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_stiffnesses_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_stiffnesses_np[0, 1] = 100.0 # Modify the stiffness of the drive applied to the DOF 1 of articulation 0
>>> dof_stiffnesses_wp = warp.from_numpy(dof_stiffnesses_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_stiffnesses(dof_stiffnesses_wp, all_indices) # Set the new DOF stiffnesses
set_dof_dampings(data, indices)#

Sets the degrees of freedom (DOF) drive dampings for articulations indicated by indices.

Note

  • The function raises an exception if the DOF dampings cannot be set in the backend.

  • Value would be set even if no drive is present, but it would have no effect on the dynamics.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_dampings() can be used to get the current dampings and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF dampings with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the dampings for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_dampings_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_dampings_np[0, 1] = 200.0 # Modify the damping of the drive applied to the DOF 1 of articulation 0
>>> dof_dampings_wp = warp.from_numpy(dof_dampings_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_dampings(dof_dampings_wp, all_indices) # Set the new DOF dampings
set_dof_max_forces(data, indices)#

Sets the degrees of freedom (DOF) maximum forces applied by the drive for articulations indicated by indices.

Note

  • The function raises an exception if the DOF maximum forces cannot be set in the backend.

  • Value would be set even if no drive is present, but it would have no effect on the dynamics.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_max_forces() can be used to get the current maximum forces and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF maximum forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the maximum forces for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_max_forces_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_max_forces_np[0, 1] = 10000.0 # Modify the maximum force of the drive applied to the DOF 1 of articulation 0
>>> dof_max_forces_wp = warp.from_numpy(dof_max_forces_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_max_forces(dof_max_forces_wp, all_indices) # Set the new DOF maximum forces
set_dof_friction_coefficients(data, indices)#

Sets the degrees of freedom (DOF) friction coefficients for articulations indicated by indices.

Note

  • The function raises an exception if the DOF friction coefficients cannot be set in the backend.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_friction_coefficients() can be used to get the current friction coefficients and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF friction coefficients with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the friction coefficients for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_friction_coefficients_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_friction_coefficients_np[0, 1] = 0.1 # Modify the friction coefficient of DOF 1 of articulation 0
>>> dof_friction_coefficients_wp = warp.from_numpy(dof_friction_coefficients_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_friction_coefficients(dof_friction_coefficients_wp, all_indices) # Set the new DOF friction coefficients
set_dof_max_velocities(data, indices)#

Sets the degrees of freedom (DOF) maximum velocities for articulations indicated by indices.

Note

  • The function raises an exception if the DOF maximum velocities cannot be set in the backend.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_max_velocities() can be used to get the current maximum velocities and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF maximum velocities with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the maximum velocities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_max_velocities_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_max_velocities_np[:, :] = 10.0 # Modify the maximum velocity of all DOF and all articulation
>>> dof_max_velocities_wp = warp.from_numpy(dof_max_velocities_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_max_velocities(dof_max_velocities_wp, all_indices) # Set the new DOF maximum velocities
set_dof_armatures(data, indices)#

Sets the degrees of freedom (DOF) armatures for articulations indicated by indices.

Note

  • The function raises an exception if the DOF armatures cannot be set in the backend.

  • The sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_armatures() can be used to get the current armatures and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF armatures with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the armatures for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> dof_armatures_np = numpy.zeros([articulation_view.count, articulation_view.max_dofs]) # Create an array with the expected shape
>>> dof_armatures_np[0, 1] = 0.0 # Modify the armature of DOF 1 of articulation 0
>>> dof_armatures_wp = warp.from_numpy(dof_armatures_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_dof_armatures(dof_armatures_wp, all_indices) # Set the new DOF armatures

Gets the link transforms for all articulations in the view.

Note

  • The function raises an exception if the link transforms cannot be obtained from the backend.

  • Note also that the link transforms may not have been updated if SimulationView.update_articulations_kinematic() has not been called after setting the joint states.

Returns:

An array of link transforms with shape (count, max_links, 7) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 7 elements of the last dimension are the translation and quaternion components of the transform.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_transforms = articulation_view.get_link_transforms() # Get the transform for all links and all articulations in the view
>>> link_transforms_np = link_transforms.numpy().reshape(articulation_view.count, articulation_view.max_links, 7) # Reshape the obtained array in a 3D numpy array on the host

Gets the link velocities for all articulations in the view.

Note

The function raises an exception if the link velocities cannot be obtained from the backend.

Returns:

An array of link velocities with shape (count, max_links, 6) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 6 elements of the last dimension are the linear and angular velocities of the links.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_velocities = articulation_view.get_link_velocities() # Get the velocity for all links and all articulations in the view
>>> link_velocities_np = link_velocities.numpy().reshape(articulation_view.count, articulation_view.max_links, 6) # Reshape the obtained array in a 3D numpy array on the host

Gets the link accelerations for all articulations in the view.

Note

The function raises an exception if the link accelerations cannot be obtained from the backend.

Returns:

An array of link accelerations with shape (count, max_links, 6) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 6 elements of the last dimension are the linear and angular accelerations of the links.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_accelerations = articulation_view.get_link_accelerations() # Get the acceleration for all links and all articulations in the view
>>> link_accelerations_np = link_accelerations.numpy().reshape(articulation_view.count, articulation_view.max_links, 6) # Reshape the obtained array in a 3D numpy array on the host
get_root_transforms()#

Gets the articulation root link transforms for all articulations in the view.

Note

The function raises an exception if the root link transforms cannot be obtained from the backend.

Returns:

An array of root link transforms with shape (count, 7) where count is the number of articulations in the view. The 7 elements of the last dimension are the translation and quaternion components of the transform.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> root_transforms = articulation_view.get_root_transforms() # Get the transform for all articulations root in the view
>>> root_transforms_np = root_transforms.numpy().reshape(articulation_view.count, 7) # Reshape the obtained array in a 2D numpy array on the host
get_root_velocities()#

Gets the articulation root link velocities for all articulations in the view.

Note

The function raises an exception if the root link velocities cannot be obtained from the backend.

Returns:

An array of root link velocities with shape (count, 6) where count is the number of articulations in the view. The 6 elements of the last dimension are the linear and angular velocities of the root link.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> root_velocities = articulation_view.get_root_velocities() # Get the velocity for all articulations root in the view
>>> root_velocities_np = root_velocities.numpy().reshape(articulation_view.count, 6) # Reshape the obtained array in a 2D numpy array on the host
set_root_transforms(data, indices)#

Sets the articulation root link transforms for articulations indicated by indices.

Note

The function raises an exception if the root link transforms cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of root link transforms with shape (count, 7) where count is the number of articulations in the view. The 7 elements of the last dimension are the translation and quaternion components of the transform.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the root link transforms for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> root_transforms = articulation_view.get_root_transforms() # Get initial transform for all articulations root in the view
>>> # simulate physics for a period of time and then reset the root transforms to their initial values
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> articulation_view.set_root_transforms(root_transforms, all_indices) # Reset the root transforms
set_root_velocities(data, indices)#

Sets the articulation root link velocities for articulations indicated by indices.

Note

The function raises an exception if the root link velocities cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of root link velocities with shape (count, 6) where count is the number of articulations in the view. The 6 elements of the last dimension are the linear and angular velocities of the root link.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the root link velocities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> root_velocities_wp = wp.zeros(articulation_view.count * 6, dtype=wp.float32, device=device) # Create new root velocity array
>>> articulation_view.set_root_velocities(root_velocities_wp, all_indices) # Set the new root velocities
get_dof_positions()#

Gets the degrees of freedom (DOF) positions for all articulations in the view.

Note

  • The function raises an exception if the DOF positions cannot be obtained from the backend.

  • The function returns the positions in radians for rotational DOFs. Note that this is different from the USD attributes which are in degrees for rotational DOFs.

Returns:

An array of DOF positions with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_positions = articulation_view.get_dof_positions() # Get the DOF position for all DOFs and all articulations in the view
>>> dof_positions_np = dof_positions.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_velocities()#

Gets the degrees of freedom (DOF) velocities for all articulations in the view.

Note

  • The function raises an exception if the DOF velocities cannot be obtained from the backend.

  • The function returns the positions in radians/second for rotational DOFs. Note that this is different from the USD attributes which are in degrees/second for rotational DOFs.

Returns:

An array of DOF velocities with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_velocities = articulation_view.get_dof_velocities() # Get the DOF velocity for all DOFs and all articulations in the view
>>> dof_velocities_np = dof_velocities.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
set_dof_positions(data, indices)#

Sets the degrees of freedom (DOF) positions for articulations indicated by indices.

Note that this API sets the instantaneous positions of the DOFs not the desired target positions.

Note

  • The function raises an exception if the DOF positions cannot be set in the backend.

  • Sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_positions() can be used to get the current positions and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF positions with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the positions for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> dof_positions_wp = wp.zeros(articulation_view.count * articulation_view.max_dofs, dtype=wp.float32, device=device) # Create new DOF position array
>>> articulation_view.set_dof_positions(dof_positions_wp, all_indices) # Set the new DOF positions
set_dof_velocities(data, indices)#

Sets the degrees of freedom (DOF) velocities for articulations indicated by indices.

Note that this API sets the instantaneous velocities of the DOFs not the desired target velocities.

Note

  • The function raises an exception if the DOF velocities cannot be set in the backend.

  • Sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_velocities() can be used to get the current velocities and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF velocities with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the velocities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> dof_velocities_wp = wp.zeros(articulation_view.count * articulation_view.max_dofs, dtype=wp.float32, device=device) # Create new DOF velocity array
>>> articulation_view.set_dof_velocities(dof_velocities_wp, all_indices) # Set the new DOF velocities
set_dof_actuation_forces(data, indices)#

Sets the degrees of freedom (DOF) actuation forces for articulations indicated by indices.

Note that this function applies external forces/torques to all DOFs in the articulations and is independent of the implicit PD controller forces.

Note

  • The function raises an exception if the DOF actuation forces cannot be set in the backend.

  • Sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_actuation_forces() can be used to get the current actuation forces and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF actuation forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the actuation forces for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> dof_actuation_forces_wp = wp.zeros(articulation_view.count * articulation_view.max_dofs, dtype=wp.float32, device=device) # Create new DOF actuation force array
>>> articulation_view.set_dof_actuation_forces(dof_actuation_forces_wp, all_indices) # Set the new DOF actuation forces
set_dof_position_targets(data, indices)#

Sets the degrees of freedom (DOF) position targets for articulations indicated by indices.

Note that this API sets the desired target positions of the DOFs not the instantaneous positions. It may take multiple frames for the DOFs to reach the target positions depending on the stiffness and damping values of the controller.

Note

  • The function raises an exception if the DOF position targets cannot be set in the backend.

  • Value would be set even if no drive is present, but it would have no effect on the dynamics.

  • Sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_position_targets() can be used to get the current position targets and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF position targets with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the position targets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> dof_position_targets_wp = wp.ones(articulation_view.count * articulation_view.max_dofs, dtype=wp.float32, device=device) # Create new DOF position target array
>>> articulation_view.set_dof_position_targets(dof_position_targets_wp, all_indices) # Set the new DOF position targets
set_dof_velocity_targets(data, indices)#

Sets the degrees of freedom (DOF) velocity targets for articulations indicated by indices.

Note that this API sets the desired target velocities of the DOFs not the instantaneous velocities. It may take multiple frames for the DOFs to reach the target velocities depending on the damping values of the controller.

Note

  • The function raises an exception if the DOF velocity targets cannot be set in the backend.

  • Value would be set even if no drive is present, but it would have no effect on the dynamics.

  • Sparse setting of subset of DOFs within an articulation is not supported yet. ArticulationView.get_dof_velocity_targets() can be used to get the current velocity targets and modify them before setting them back.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of DOF velocity targets with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the velocity targets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> dof_velocity_targets_wp = wp.ones(articulation_view.count * articulation_view.max_dofs, dtype=wp.float32, device=device) # Create new DOF position velocity array
>>> articulation_view.set_dof_velocity_targets(dof_velocity_targets_wp, all_indices) # Set the new DOF velocity targets
apply_forces_and_torques_at_position(
force_data,
torque_data,
position_data,
indices,
is_global,
)#

Applies forces and torques at the specified positions in the articulations indicated by indices.

Note that there are a few different ways this function can be used:

  • Not specifying the position_data will apply the forces at link transforms location.

  • Specifying the position_data will apply the forces at the specified positions at link transforms location.

  • Specifying the is_global as True will apply the forces and torques in the global frame of reference. If position_data is specified, its components are considered in the global frame of reference as well.

  • Specifying the is_global as False will apply the forces and torques in the local frame of reference of the link transforms. If position_data is specified, its components are considered in the local frame of reference as well.

  • Not specifying the force_data and torque_data won’t have any effects, so at least one of them should be specified.

Note

The function raises an exception if the forces and torques cannot be applied in the backend.

Parameters:
  • force_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of forces with shape (count, max_links, 3) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 3 elements of the last dimension are the x, y, z components of the force.

  • torque_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of torques with shape (count, max_links, 3) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 3 elements of the last dimension are the x, y, z components of the torque.

  • position_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of positions with shape (count, max_links, 3) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 3 elements of the last dimension are the x, y, z components of the applied position in the local/global frame of reference.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to apply the forces and torques for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

  • is_global (bool) – A boolean flag to indicate if the forces, torques and positions are in the global frame of reference. If set to False, the forces, torques and positions are in the local frame of reference of the link transforms.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> forces_wp = wp.ones(articulation_view.count * articulation_view.max_links * 3, dtype=wp.float32, device=device) # Create new link force array
>>> articulation_view.apply_forces_and_torques_at_position(forces_wp, None, None, all_indices, True) # Apply forces to the links at the link transform considering the global frame of reference
get_dof_position_targets()#

Gets the degrees of freedom (DOF) position targets for all articulations in the view.

Note

  • The function raises an exception if the DOF position targets cannot be obtained from the backend.

  • The function returns the positions in radians for rotational DOFs. Note that this is different from the USD attributes which are in degrees for rotational DOFs.

Returns:

An array of DOF position targets with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_position_targets = articulation_view.get_dof_position_targets() # Get the DOF position target for all DOFs and all articulations in the view
>>> dof_position_targets_np = dof_position_targets.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_velocity_targets()#

Gets the degrees of freedom (DOF) velocity targets for all articulations in the view.

Note

  • The function raises an exception if the DOF velocity targets cannot be obtained from the backend.

  • The function returns the velocities in radians/second for rotational DOFs. Note that this is different from the USD attributes which are in degrees/second for rotational DOFs.

Returns:

An array of DOF velocity targets with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_velocity_targets = articulation_view.get_dof_velocity_targets() # Get the DOF velocity target for all DOFs and all articulations in the view
>>> dof_velocity_targets_np = dof_velocity_targets.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_actuation_forces()#

Gets the degrees of freedom (DOF) actuation forces for all articulations in the view.

Note

The function raises an exception if the DOF actuation forces cannot be obtained from the backend.

Returns:

An array of DOF actuation forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_actuation_forces = articulation_view.get_dof_actuation_forces() # Get the DOF actuation force for all DOFs and all articulations in the view
>>> dof_actuation_forces_np = dof_actuation_forces.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_dof_projected_joint_forces()#

Gets the degrees of freedom (DOF) projected joint forces for all articulations in the view.

Note that this function projects the links incoming joint forces in the motion direction and hence is the active component of the force. To get the total 6D joint forces, including the active and passive components of the force, use ArticulationView.get_link_incoming_joint_force().

Note

The function raises an exception if the DOF projected joint forces cannot be obtained from the backend.

Returns:

An array of DOF projected joint forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> dof_projected_joint_forces = articulation_view.get_dof_projected_joint_forces() # Get the DOF projected joint force for all DOFs and all articulations in the view
>>> dof_projected_joint_forces_np = dof_projected_joint_forces.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_jacobians()#

Gets the Jacobian matrix for all articulations in the view.

The Jacobian matrix maps the degrees of freedom (DOF) velocities to the world space link velocities.

Note

  • The function raises an exception if the Jacobians cannot be obtained from the backend.

  • The size of the Jacobian is ((numLinks - 1) * 6) x max_dofs for fixed base articulations and (numLinks * 6) x (max_dofs + 6) for floating base articulations.

Returns:

An array of Jacobians with shape (count, jacobian_shape.numCols, jacobian_shape.numRows) where count is the number of articulations in the view and jacobian_shape.numCols and jacobian_shape.numRows are the number of columns and rows of the Jacobian matrix.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> jacobians = articulation_view.get_jacobians() # Get the Jacobian for all articulations in the view
>>> jacobians_np = jacobians.numpy().reshape(articulation_view.count, (articulation_view.max_links - 1) * 6, articulation_view.max_dofs) # Reshape the obtained array in a 3D numpy array on the host
get_mass_matrices()#

Gets the mass matrices for all articulations in the view.

This matrix represents the joint space inertia of the articulation and can be used to convert joint accelerations into joint forces/torques.

Warning

This function is deprecated and will be removed in the future. Use ArticulationView.get_generalized_mass_matrices() instead.

Note

  • The function raises an exception if the mass matrices cannot be obtained from the backend.

  • For floating base articulations, the mass matrix provided does not allow to convert root accelerations into root forces/torques.

Returns:

An array of mass matrices with shape (count, mass_matrix_shape.numCols, mass_matrix_shape.numRows) where count is the number of articulations in the view and mass_matrix_shape.numCols and mass_matrix_shape.numRows are the number of columns and rows of the mass matrix.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

get_generalized_mass_matrices()#

Gets the mass matrices for all articulations in the view.

This matrix represents the joint space inertia of the articulation and can be used to convert joint accelerations into joint forces/torques.

Note

  • The function raises an exception if the generalized mass matrices cannot be obtained from the backend.

  • The size of the mass matrix is max_dofs x max_dofs for fixed base articulations and (max_dofs + 6) x (max_dofs + 6) for floating base articulations.

  • For floating base articulations, the mass matrix can also be used to convert root accelerations into root forces/torques.

Returns:

An array of mass matrices with shape (count, generalized_mass_matrix_shape.numCols, generalized_mass_matrix_shape.numRows) where count is the number of articulations in the view and generalized_mass_matrix_shape.numCols and generalized_mass_matrix_shape.numRows are the number of columns and rows of the mass matrix.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> mass_matrices = articulation_view.get_generalized_mass_matrices() # Get the mass matrix for all articulations in the view
>>> mass_matrices_np = mass_matrices.numpy().reshape(articulation_view.count, articulation_view.max_dofs, articulation_view.max_dofs) # Reshape the obtained array in a 3D numpy array on the host
get_coriolis_and_centrifugal_forces()#

Gets the Coriolis and Centrifugal forces for all articulations in the view.

Warning

This function is deprecated and will be removed in the future. Use ArticulationView.get_coriolis_and_centrifugal_compensation_forces() instead.

Note

  • The function raises an exception if the Coriolis and Centrifugal forces cannot be obtained from the backend.

  • For floating base articulations, this API does not provide the Coriolis and Centrifugal forces acting on the root.

Returns:

An array of Coriolis and Centrifugal forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

get_coriolis_and_centrifugal_compensation_forces()#

Gets the Coriolis and Centrifugal compensation forces for all articulations in the view.

Note

  • The function raises an exception if the Coriolis and Centrifugal compensation forces cannot be obtained from the backend.

  • For floating base articulations, the Coriolis and Centrifugal forces acting on the root is also provided.

Returns:

An array of Coriolis and Centrifugal compensation forces with shape (count, max_dofs) for fixed based articulations, and (count, max_dofs + 6) for floating base articulatons where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> coriolis_and_centrifugal_compensation_forces = articulation_view.get_coriolis_and_centrifugal_compensation_forces() # Get the Coriolis and centrifugal compensation force for all articulations in the view
>>> coriolis_and_centrifugal_compensation_forces_np = coriolis_and_centrifugal_compensation_forces.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_generalized_gravity_forces()#

Gets the Generalized Gravity forces for all articulations in the view.

Warning

This function is deprecated and will be removed in the future. Use ArticulationView.get_gravity_compensation_forces() instead.

Note

  • The function raises an exception if the Generalized Gravity forces cannot be obtained from the backend.

  • For floating base articulations, this API does not provide the Generalized Gravity forces acting on the root.

Returns:

An array of Generalized Gravity forces with shape (count, max_dofs) where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

get_gravity_compensation_forces()#

Gets the Gravity compensation forces for all articulations in the view.

Note

  • The function raises an exception if the Gravity compensation forces cannot be obtained from the backend.

  • For floating base articulations, the Gravity compensation forces of the root is also provided.

Returns:

An array of Gravity compensation forces with shape (count, max_dofs) for fixed based articulations, and (count, max_dofs + 6) for floating base articulatons where count is the number of articulations in the view and max_dofs is the maximum number of degrees of freedom in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> gravity_compensation_forces = articulation_view.get_gravity_compensation_forces() # Get the gravity compensation force for all articulations in the view
>>> gravity_compensation_forces_np = gravity_compensation_forces.numpy().reshape(articulation_view.count, articulation_view.max_dofs) # Reshape the obtained array in a 2D numpy array on the host
get_articulation_mass_center(local_frame=False)#

Gets the center of mass for all articulations in the view.

Note

The function raises an exception if the center of mass cannot be obtained from the backend.

Parameters:

local_frame (bool) – A boolean flag to indicate if the center of mass is in the local frame of reference of the articulations. If set to False, the center of mass is in the global frame of reference. Default to False.

Returns:

An array of center of mass with shape (count, 3) where count is the number of articulations in the view. The 3 elements of the last dimension are the x, y, z components of the center of mass.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> articulation_COMs = articulation_view.get_articulation_mass_center(False) # Get the center of mass in the global frame for all articulations in the view
>>> articulation_COMs_np = articulation_COMs.numpy().reshape(articulation_view.count, 3) # Reshape the obtained array in a 2D numpy array on the host
get_articulation_centroidal_momentum()#

Gets the centroidal momentum for all articulations in the view.

The centroidal momentum matrix allows mapping of the articulation centroidal momentum to velocities. The bias force is a second-order term that allows for better estimation of the derivative of the centroidal momentum.

Note

  • The function raises an exception if the centroidal momentum cannot be obtained from the backend.

  • This function is only implemented for floating-base articulations.

Returns:

An array of centroidal momentum data with shape (count, 6, max_dofs + 7), where count is the number of articulations in the view. The first max_dofs + 6 columns of the last dimension are the centroidal momentum matrix (i.e. a 6 x (max_dofs + 6) matrix for each articulation) and the last column’s 6 elements are the components of the centroidal momentum bias force (i.e. a 6 x 1 vector for each articulation).

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Ant_*") # This assumes that the prims referenced by "/World/Ant_*" were already created in the stage
>>> temp_buffer = articulation_view.get_articulation_centroidal_momentum() # Get the centroidal momentum matrix and the bias force for all articulations in the view
>>> temp_buffer_np = temp_buffer.numpy().reshape(articulation_view.count, 6, articulation_view.max_dofs + 7) # Reshape the obtained array in a 3D numpy array on the host
>>> centroidal_momentum_matrices_np = temp_buffer[:, :, :-1] # Extract the centroidal momentum matrices from the results
>>> bias_forces_np = temp_buffer[:, :, -1:] # Extract the bias force from the results

Gets the link incoming joint forces for all articulation in the view.

In a kinematic tree, each link has a single incoming joint and this function provides the total 6D force/torque of links incoming joints.

Note

The function raises an exception if the incoming joint forces cannot be obtained from the backend.

Returns:

An array of incoming joint forces with shape (count, max_links, 6) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 6 elements of the last dimension are the force components of the incoming joint of links.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_incoming_joint_forces = articulation_view.get_link_incoming_joint_force() # Get the incoming joint force for all links and all articulations in the view
>>> link_incoming_joint_forces_np = link_incoming_joint_forces.numpy().reshape(articulation_view.count, articulation_view.max_links, 6) # Reshape the obtained array in a 3D numpy array on the host
get_masses()#

Gets the link masses for all articulation in the view.

Note

The function raises an exception if the masses cannot be obtained from the backend.

Returns:

An array of masses with shape (count, max_links) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_masses = articulation_view.get_masses() # Get the mass for all links and all articulations in the view
>>> link_masses_np = link_masses.numpy().reshape(articulation_view.count, articulation_view.max_links) # Reshape the obtained array in a 2D numpy array on the host
get_inv_masses()#

Gets the link inverse masses for all articulation in the view.

Note

The function raises an exception if the inverse masses cannot be obtained from the backend.

Returns:

An array of inverse masses with shape (count, max_links) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_inv_masses = articulation_view.get_inv_masses() # Get the inverse mass for all links and all articulations in the view
>>> link_inv_masses_np = link_inv_masses.numpy().reshape(articulation_view.count, articulation_view.max_links) # Reshape the obtained array in a 2D numpy array on the host
get_coms()#

Gets the link centers of mass local pose for all articulation in the view.

Note

The function raises an exception if the centers of mass cannot be obtained from the backend.

Returns:

An array of centers of mass with shape (count, max_links, 7) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 7 elements of the last dimension are the x, y, z, qx, qy, qz, qw components of the center of mass local pose.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_coms = articulation_view.get_coms() # Get the transform of the center of mass for all links and all articulations in the view
>>> link_coms_np = link_coms.numpy().reshape(articulation_view.count, articulation_view.max_links, 7) # Reshape the obtained array in a 3D numpy array on the host
get_inertias()#

Gets the link inertia tensors for all articulation in the view.

The inertia tensor is given in the center of mass local frame.

Note

The function raises an exception if the inertias cannot be obtained from the backend.

Returns:

An array of inertias with shape (count, max_links, 9) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 9 elements of the last dimension are the components of the inertia tensor.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_inertias = articulation_view.get_inertias() # Get the inertia tensor for all links and all articulations in the view
>>> link_inertias_np = link_inertias.numpy().reshape(articulation_view.count, articulation_view.max_links, 9) # Reshape the obtained array in a 3D numpy array on the host
get_inv_inertias()#

Gets the link inverse inertia tensor for all articulation in the view.

The inertia tensor is given in the center of mass local frame.

Note

The function raises an exception if the inverse inertias cannot be obtained from the backend.

Returns:

An array of inverse inertias with shape (count, max_links, 9) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 9 elements of the last dimension are the components of the inverse inertia tensor.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_inv_inertias = articulation_view.get_inv_inertias() # Get the inverse inertia tensor for all links and all articulations in the view
>>> link_inv_inertias_np = link_inv_inertias.numpy().reshape(articulation_view.count, articulation_view.max_links, 9) # Reshape the obtained array in a 3D numpy array on the host
get_disable_gravities()#

Receives whether the gravity is activated on articulation links.

Note

The function raises an exception if the disable gravities cannot be obtained from the backend.

Returns:

An array of disable gravities with shape (count, max_links) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> link_disable_gravities = articulation_view.get_disable_gravities() # Get an array of boolean indicating whether the gravity is activated for all links and all articulations in the view
>>> link_disable_gravities_np = link_disable_gravities.numpy().reshape(articulation_view.count, articulation_view.max_links) # Reshape the obtained array in a 2D numpy array on the host
set_masses(data, indices)#

Sets the link masses for articulations indicated by indices.

Note

  • The function raises an exception if the masses cannot be set in the backend.

  • The sparse setting of subset of link masses is not supported. ArticulationView.get_masses() can be used to get the current masses and modify them before setting the masses, or use RigidBodyView functionality instead.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of masses with shape (count, max_links) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the masses for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> link_masses_np = numpy.zeros([articulation_view.count, articulation_view.max_links]) # Create an array with the expected shape
>>> link_masses_np[0, 1] = 7.5 # Modify the mass of link 1 of articulation 0
>>> link_masses_wp = warp.from_numpy(link_masses_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_masses(link_masses_wp, all_indices) # Set the new link masses
set_coms(data, indices)#

Sets the pose of the center of mass relative to the link frame for articulations indicated by indices.

Note

  • The function raises an exception if the centers of mass cannot be set in the backend.

  • The sparse setting of subset of link data is not supported yet. ArticulationView.get_coms() can be used to get the current centers of mass poses and modify them before setting the centers of mass for the subset of links, or use RigidBodyView functionality instead.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of centers of mass with shape (count, max_links, 7) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 7 elements of the last dimension are the x, y, z, qx, qy, qz, qw components of the center of mass local pose.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the centers of mass for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> link_coms_np = numpy.zeros([articulation_view.count, articulation_view.max_links, 7]) # Create an array with the expected shape
>>> link_coms_np[0, 1, 2] = 0.3 # Modify the position in the Z direction of the center of mass of link 1 of articulation 0
>>> link_coms_wp = warp.from_numpy(link_coms_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_coms(link_coms_wp, all_indices) # Set the new link center of mass
set_inertias(data, indices)#

Sets the links inertia tensors for articulations indicated by indices.

The inertia tensor should be given in the center of mass local frame.

Note

  • The function raises an exception if the inertias cannot be set in the backend.

  • The sparse setting of subset of link data is not supported yet. ArticulationView.get_inertias() can be used to get the current inertias and modify them before setting the inertias, or use RigidBodyView functionality instead.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of inertia tensors with shape (count, max_links, 9) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations. The 9 elements of the last dimension are the components of the inertia tensor.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the inertias for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> link_inertias_np = numpy.zeros([articulation_view.count, articulation_view.max_links, 9]) # Create an array with the expected shape
>>> link_inertias_np[0, 1, 3] = 70.0 # Modify the inertia tensor of link 1 of articulation 0
>>> link_inertias_wp = warp.from_numpy(link_inertias_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_inertias(link_inertias_wp, all_indices) # Set the new link inertia tensors
set_disable_gravities(data, indices)#

Sets the links gravity activation flag for articulations indicated by indices.

Note

  • The function raises an exception if the disable gravities cannot be set in the backend.

  • The sparse setting of subset of link data is not supported yet. ArticulationView.get_disable_gravities() can be used to get the current gravity flags and modify them before setting the gravity flags, or use RigidBodyView functionality instead.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of gravity activation flags (1 for disabled and 0 for enabled) with shape (count, max_links) where count is the number of articulations in the view and max_links is the maximum number of links in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the disable gravities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> link_disable_gravities_np = numpy.ones([articulation_view.count, articulation_view.max_links]) # Create an array with the expected shape
>>> link_disable_gravities_np[0, 1] = False # Disable the gravity for link 1 of articulation 0
>>> link_disable_gravities_wp = warp.from_numpy(link_disable_gravities_np, dtype=warp.uint8, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_disable_gravities(link_disable_gravities_wp, all_indices) # Set whether the gravity is enabled or not for all links
get_material_properties()#

Gets the material properties for all shapes in the view.

The material properties array is composed of the following properties (provided in the order of appearance in the array):

  • static friction

  • dynamic friction

  • restitution

Note

The function raises an exception if the material properties cannot be obtained from the backend.

Returns:

An array of material properties with shape (count, max_shapes, 3) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations. The 3 elements of the last dimension are the static friction, dynamic friction, and restitution respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> material_properties = articulation_view.get_material_properties() # Get the material properties for all shapes in the view
>>> material_properties_np = material_properties.numpy().reshape(articulation_view.count, articulation_view.max_shapes, 3) # Reshape the obtained array in a 3D numpy array on the host
get_contact_offsets()#

Gets the contact offsets for all shapes in the view.

Note

The function raises an exception if the contact offsets cannot be obtained from the backend.

Returns:

An array of contact offsets with shape (count, max_shapes) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> contact_offsets = articulation_view.get_contact_offsets() # Get the contact offset for all shapes in the view
>>> contact_offsets_np = contact_offsets.numpy().reshape(articulation_view.count, articulation_view.max_shapes) # Reshape the obtained array in a 2D numpy array on the host
get_rest_offsets()#

Gets the rest offsets for all shapes in the view.

Note

The function raises an exception if the rest offsets cannot be obtained from the backend.

Returns:

An array of rest offsets with shape (count, max_shapes) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> rest_offsets = articulation_view.get_rest_offsets() # Get the rest offset for all shapes in the view
>>> rest_offsets_np = rest_offsets.numpy().reshape(articulation_view.count, articulation_view.max_shapes) # Reshape the obtained array in a 2D numpy array on the host
set_material_properties(data, indices)#

Sets the material properties for shapes indicated by indices.

The material properties array should have the following properties (provided in the order of appearance in the array):

  • static friction

  • dynamic friction

  • restitution

Note

  • The function raises an exception if the material properties cannot be set in the backend.

  • The sparse setting of subset of shape data is not supported yet. ArticulationView.get_material_properties() can be used to get the current material properties and modify them before setting the material properties for the subset of shapes.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of material properties with shape (count, max_shapes, 3) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations. The 3 elements of the last dimension are the static friction, dynamic friction, and restitution respectively.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the material properties for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> material_properties_np = numpy.zeros([articulation_view.count, articulation_view.max_shapes, 3]) # Create an array with the expected shape
>>> material_properties_np[0, 1, 0] = 0.5 # Modify the static friction of shape 1 of articulation 0
>>> material_properties_np[0, 2, 1] = 0.5 # Modify the dynamic friction of shape 2 of articulation 0
>>> material_properties_np[1, 1, 2] = 0.3 # Modify the restitution of shape 1 of articulation 1
>>> material_properties_wp = warp.from_numpy(material_properties_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_material_properties(material_properties_wp, all_indices) # Set the new shape material properties
set_contact_offsets(data, indices)#

Sets the contact offsets for shapes indicated by indices.

Note

  • The function raises an exception if the contact offsets cannot be set in the backend.

  • The sparse setting of subset of shape data is not supported yet. ArticulationView.get_contact_offsets() can be used to get the current contact offsets and modify them before setting the contact offsets for the subset of shapes.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of contact offsets with shape (count, max_shapes) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the contact offsets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> contact_offsets_np = numpy.zeros([articulation_view.count, articulation_view.max_shapes]) # Create an array with the expected shape
>>> contact_offsets_np[0, 1] = 0.3 # Modify the contact offset of shape 1 of articulation 0
>>> contact_offsets_wp = warp.from_numpy(contact_offsets_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_contact_offsets(contact_offsets_wp, all_indices) # Set the new shape contact offsets
set_rest_offsets(data, indices)#

Sets the rest offsets for shapes indicated by indices.

Note

  • The function raises an exception if the rest offsets cannot be set in the backend.

  • The sparse setting of subset of shape data is not supported yet. ArticulationView.get_rest_offsets() can be used to get the current rest offsets and modify them before setting the rest offsets for the subset of shapes.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of rest offsets with shape (count, max_shapes) where count is the number of articulations in the view and max_shapes is the maximum number of shapes in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the rest offsets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)
>>> rest_offsets_np = numpy.zeros([articulation_view.count, articulation_view.max_shapes]) # Create an array with the expected shape
>>> rest_offsets_np[0, 1] = 0.3 # Modify the rest offset of shape 1 of articulation 0
>>> rest_offsets_wp = warp.from_numpy(rest_offsets_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> articulation_view.set_rest_offsets(rest_offsets_wp, all_indices) # Set the new shape rest offsets
get_fixed_tendon_stiffnesses()#

Gets the stiffnesses for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon stiffnesses cannot be obtained from the backend.

Returns:

An array of stiffnesses with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_stiffnesses = articulation_view.get_fixed_tendon_stiffnesses() # Get the stiffness for all fixed tendons in the view
>>> fixed_tendon_stiffnesses_np = fixed_tendon_stiffnesses.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons) # Reshape the obtained array in a 2D numpy array on the host
get_fixed_tendon_dampings()#

Gets the dampings for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon dampings cannot be obtained from the backend.

Returns:

An array of dampings with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_dampings = articulation_view.get_fixed_tendon_dampings() # Get the damping for all fixed tendons in the view
>>> fixed_tendon_dampings_np = fixed_tendon_dampings.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons) # Reshape the obtained array in a 2D numpy array on the host
get_fixed_tendon_limit_stiffnesses()#

Gets the limit stiffnesses for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon limit stiffnesses cannot be obtained from the backend.

Returns:

An array of limit stiffnesses with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_limit_stiffnesses = articulation_view.get_fixed_tendon_limit_stiffnesses() # Get the limit stiffness for all fixed tendons in the view
>>> fixed_tendon_limit_stiffnesses_np = fixed_tendon_limit_stiffnesses.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons) # Reshape the obtained array in a 2D numpy array on the host
get_fixed_tendon_limits()#

Gets the limits for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon limits cannot be obtained from the backend.

Returns:

An array of limits with shape (count, max_fixed_tendons, 2) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations. The 2 elements of the last dimension are the lower and upper limits respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_limits = articulation_view.get_fixed_tendon_limits() # Get the limits for all fixed tendons in the view
>>> fixed_tendon_limits_np = fixed_tendon_limits.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons, 2) # Reshape the obtained array in a 3D numpy array on the host
get_fixed_tendon_rest_lengths()#

Gets the rest lengths for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon rest lengths cannot be obtained from the backend.

Returns:

An array of rest lengths with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_rest_lengths = articulation_view.get_fixed_tendon_rest_lengths() # Get the rest length for all fixed tendons in the view
>>> fixed_tendon_rest_lengths_np = fixed_tendon_rest_lengths.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons) # Reshape the obtained array in a 2D numpy array on the host
get_fixed_tendon_offsets()#

Gets the offsets for all fixed tendons in the view.

Note

The function raises an exception if the fixed tendon offsets cannot be obtained from the backend.

Returns:

An array of offsets with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> fixed_tendon_offsets = articulation_view.get_fixed_tendon_offsets() # Get the offset for all fixed tendons in the view
>>> fixed_tendon_offsets_np = fixed_tendon_offsets.numpy().reshape(articulation_view.count, articulation_view.max_fixed_tendons) # Reshape the obtained array in a 2D numpy array on the host
set_fixed_tendon_properties(
stiffnesses,
dampings,
limit_stiffnesses,
limits,
rest_lengths,
offsets,
indices,
)#

Sets the fixed tendon properties for fixed tendons indicated by indices.

Note

Parameters:
  • stiffnesses (Union[np.ndarray, torch.Tensor, wp.array]) – An array of stiffnesses with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

  • dampings (Union[np.ndarray, torch.Tensor, wp.array]) – An array of dampings with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

  • limit_stiffnesses (Union[np.ndarray, torch.Tensor, wp.array]) – An array of limit stiffnesses with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

  • limits (Union[np.ndarray, torch.Tensor, wp.array]) – An array of limits with shape (count, max_fixed_tendons, 2) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations. The 2 elements of the last dimension are the lower and upper limits respectively.

  • rest_lengths (Union[np.ndarray, torch.Tensor, wp.array]) – An array of rest lengths with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

  • offsets (Union[np.ndarray, torch.Tensor, wp.array]) – An array of offsets with shape (count, max_fixed_tendons) where count is the number of articulations in the view and max_fixed_tendons is the maximum number of fixed tendons in all the view’s articulations.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of articulations to set the fixed tendon properties for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of articulations in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> all_indices = wp_utils.arange(articulation_view.count)

>>> fixed_tendon_stiffnesses_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons]) # Create an array with the expected shape
>>> fixed_tendon_dampings_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons]) # Create an array with the expected shape
>>> fixed_tendon_limit_stiffnesses_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons]) # Create an array with the expected shape
>>> fixed_tendon_limits_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons, 2]) # Create an array with the expected shape
>>> fixed_tendon_rest_lengths_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons]) # Create an array with the expected shape
>>> fixed_tendon_offsets_np = numpy.zeros([articulation_view.count, articulation_view.max_fixed_tendons]) # Create an array with the expected shape

>>> fixed_tendon_stiffnesses_np[0, 1] = 50.0 # Modify the stiffness of fixed tendon 1 of articulation 0
>>> fixed_tendon_dampings_np[1, 1] = 200.0 # Modify the damping of fixed tendon 1 of articulation 1
>>> fixed_tendon_limit_stiffnesses_np[2, 1] = 100.0 # Modify the limit stiffness of fixed tendon 1 of articulation 2
>>> fixed_tendon_limits_np[0, 0, 1] = 0.5 # Modify the upper limit of fixed tendon 0 of articulation 0
>>> fixed_tendon_rest_lengths_np[0, 2] -= 0.2 # Modify the rest length of fixed tendon 2 of articulation 0
>>> fixed_tendon_offsets_np[0, 3] += 0.1 # Modify the offset of fixed tendon 3 of articulation 0

>>> fixed_tendon_stiffnesses_wp = warp.from_numpy(fixed_tendon_stiffnesses_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> fixed_tendon_dampings_wp = warp.from_numpy(fixed_tendon_dampings_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> fixed_tendon_limit_stiffnesses_wp = warp.from_numpy(fixed_tendon_limit_stiffnesses_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> fixed_tendon_limits_wp = warp.from_numpy(fixed_tendon_limits_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> fixed_tendon_rest_lengths_wp = warp.from_numpy(fixed_tendon_rest_lengths_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> fixed_tendon_offsets_wp = warp.from_numpy(fixed_tendon_offsets_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API

>>> articulation_view.set_fixed_tendon_properties(fixed_tendon_stiffnesses_wp, fixed_tendon_dampings_wp, fixed_tendon_limit_stiffnesses_wp, fixed_tendon_limits_wp, fixed_tendon_rest_lengths_wp, fixed_tendon_offsets_wp, all_indices) # Set the new fixed tendon properties
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> articulation_view = sim_view.create_articulation_view("/World/Franka_*") # This assumes that the prims referenced by "/World/Franka_*" were already created in the stage
>>> articulation_view.check() # returns False if articulation_view is invalid, True otherwise
class omni.physics.tensors.impl.api.RigidBodyView(backend, frontend)#

RigidBodyView class represents a batch of rigid objects.

RigidBodyView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_rigid_body_view() method of the SimulationView object which manages all the physics views, the device where the simulation is performed and data resides.

Note

A rigid object can be either an articulation link or an individual rigid body.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
property count#

The number of rigid objects (articulation links and rigid bodies) in the view.

property max_shapes#

The maximum number of shapes in all the rigid objects in the view.

property prim_paths#

The USD paths for all the rigid objects in the view.

get_transforms()#

Gets the transforms for all rigid objects in the view.

Note

The function raises an exception if the transforms cannot be obtained from the backend.

Returns:

An array of transforms with shape (count, 7) where count is the number of rigid objects in the view. The 7 elements of the last dimension are the translation and quaternion components of the transform, respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_transforms = rigid_body_view.get_transforms() # Get the transform for all rigid bodies in the view
>>> rb_transforms_np = rb_transforms.numpy().reshape(rigid_body_view.count, 7) # Reshape the obtained array in a 2D numpy array on the host
get_velocities()#

Gets the velocities for all rigid objects in the view.

Note

The function raises an exception if the velocities cannot be obtained from the backend.

Returns:

An array of velocities with shape (count, 6) where count is the number of rigid objects in the view. The 6 elements of the last dimension are the linear and angular velocities respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_velocities = rigid_body_view.get_velocities() # Get the velocity for all rigid bodies in the view
>>> rb_velocities_np = rb_velocities.numpy().reshape(rigid_body_view.count, 6) # Reshape the obtained array in a 2D numpy array on the host
get_accelerations()#

Gets the accelerations for all rigid objects in the view.

Note

The function raises an exception if the accelerations cannot be obtained from the backend.

Returns:

An array of accelerations with shape (count, 6) where count is the number of rigid objects in the view. The 6 elements of the last dimension are the linear and angular accelerations respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_accelerations = rigid_body_view.get_accelerations() # Get the acceleration for all rigid bodies in the view
>>> rb_accelerations_np = rb_accelerations.numpy().reshape(rigid_body_view.count, 6) # Reshape the obtained array in a 2D numpy array on the host
set_kinematic_targets(data, indices)#

Sets the kinematic targets for rigid objects indicated by indices.

Note

  • The function raises an exception if the kinematic targets cannot be set in the backend.

  • The function does not modify the tranforms of dynamic rigid bodies or articulation links (as they are simulated by the solver), and can return warning when encountering dynamic rigid bodies in the view.

  • Correctly setting the kinematic targets may require creating a view of only kinematic rigid bodies rather than using an existing view that combines both kinematic and dynamic rigid bodies.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of transforms with shape (count, 7) where count is the number of rigid objects in the view. The 7 elements of the last dimension are the translation and quaternion components of the transform, respectively.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the kinematic targets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> kinematic_rigid_body_view = sim_view.create_rigid_body_view("/World/KinematicCube_*") # This assumes that the prims referenced by "/World/KinematicCube_*" were already created in the stage
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*")
>>> rb_transforms = rigid_body_view.get_transforms() # Get the transform for all rigid bodies in the view
>>> all_indices = wp_utils.arange(kinematic_rigid_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> kinematic_rigid_body_view.set_kinematic_targets(rb_transforms, all_indices) # Set the kinematic targets as the cube position
set_transforms(data, indices)#

Sets the transforms for rigid objects indicated by indices.

Note

  • The function raises an exception if the transforms cannot be set in the backend.

  • Note that setting only the translation or only the rotation part of the transform is not supported yet. RigidBodyView.get_transforms() can be used to get the current transforms and modify them before setting back the transforms for the subset of rigid objects.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of transforms with shape (count, 7) where count is the number of rigid objects in the view. The 7 elements of the last dimension are the translation and quaternion components of the transform, respectively.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the transforms for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_transforms = rigid_body_view.get_transforms() # Get the transform for all rigid bodies in the view
>>> # simulate physics for a period of time and then reset the transforms to their initial values
>>> all_indices = wp_utils.arange(rigid_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> rigid_body_view.set_transforms(rb_transforms, all_indices) # Reset the rigid body transforms
set_velocities(data, indices)#

Sets the velocities for rigid objects indicated by indices.

Note

  • The function raises an exception if the velocities cannot be set in the backend.

  • Note that setting only the linear or only the angular part of the velocity is not supported yet. RigidBodyView.get_velocities() can be used to get the current velocities and modify them before setting back the velocities for the subset of rigid objects.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of velocities with shape (count, 6) where count is the number of rigid objects in the view. The 6 elements of the last dimension are the linear and angular velocities respectively.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the velocities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> rb_velocities_wp = wp.zeros(rigid_body_view.count * 6, dtype=wp.float32, device=device) # Create new rigid body velocity array
>>> rigid_body_view.set_velocities(rb_velocities_wp, all_indices) # Reset the rigid body velocities
apply_forces_and_torques_at_position(
force_data,
torque_data,
position_data,
indices,
is_global,
)#

Applies forces and torques at the specified positions in the rigid objects indicated by indices.

Note that there are a few different ways this function can be used:

  • Not specifying the position_data will apply the forces at link transforms location.

  • Specifying the position_data will apply the forces at the specified positions at link transforms location.

  • Specifying the is_global as True will apply the forces and torques in the global frame of reference. If position_data is specified, its components are considered in the global frame of reference as well.

  • Specifying the is_global as False will apply the forces and torques in the local frame of reference of the link transforms. If position_data is specified, its components are considered in the local frame of reference as well.

  • Not specifying the force_data and torque_data won’t have any effects, so at least one of them should be specified.

Note

The function raises an exception if the forces and torques cannot be applied in the backend.

Parameters:
  • force_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of forces with shape (count, 3) where count is the number of rigid objects in the view. The 3 elements of the last dimension are the x, y, z components of the force.

  • torque_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of torques with shape (count, 3) where count is the number of rigid objects in the view. The 3 elements of the last dimension are the x, y, z components of the torque.

  • position_data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of positions with shape (count, 3) where count is the number of rigid objects in the view. The 3 elements of the last dimension are the x, y, z components of the applied position in the local/global frame of reference.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to apply the forces and torques for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

  • is_global (bool) – A boolean flag to indicate if the forces, torques and positions are in the global frame of reference. If set to False, the forces, torques and positions are in the local frame of reference of the link transforms.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> forces_wp = wp.ones(rigid_body_view.count * 3, dtype=wp.float32, device=device) # Create new rigid body force array
>>> rigid_body_view.apply_forces_and_torques_at_position(forces_wp, None, None, all_indices, True) # Apply forces to the rigid body transform considering the global frame of reference
apply_forces(data, indices, is_global=True)#

Applies only forces at the link transforms of the rigid objects indicated by indices.

Note

The function raises an exception if the forces cannot be applied in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of forces with shape (count, 3) where count is the number of rigid objects in the view. The 3 elements of the last dimension are the x, y, z components of the force in either local or global frame of reference depending on the is_global flag.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to apply the forces for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

  • is_global (bool) – A boolean flag to indicate if the forces are in the global frame of reference. If set to False, the forces are in the local frame of reference of the link transforms. Default is True.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> forces_wp = wp.ones(rigid_body_view.count * 3, dtype=wp.float32, device=device) # Create new rigid body force array
>>> rigid_body_view.apply_forces(forces_wp, all_indices, True) # Apply forces to the rigid body transform considering the global frame of reference
get_masses()#

Gets the masses for all rigid objects in the view.

Note

The function raises an exception if the masses cannot be obtained from the backend.

Returns:

An array of masses with shape (count, 1) where count is the number of rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_masses = rigid_body_view.get_masses() # Get the mass for all rigid bodies in the view
get_inv_masses()#

Gets the inverse masses for all rigid objects in the view.

Note

The function raises an exception if the inverse masses cannot be obtained from the backend.

Returns:

An array of inverse masses with shape (count, 1) where count is the number of rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_inv_masses = rigid_body_view.get_inv_masses() # Get the inverse mass for all rigid bodies in the view
get_coms()#

Gets the centers of mass local pose for all rigid objects in the view.

Note

The function raises an exception if the centers of mass cannot be obtained from the backend.

Returns:

An array of centers of mass with shape (count, 7) where count is the number of rigid objects in the view. The 7 elements of the last dimension are the translation and quaternion components of the center of mass local pose, respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_coms = rigid_body_view.get_coms() # Get the transform of the center of mass for all rigid bodies in the view
>>> rb_coms_np = rb_coms.numpy().reshape(rigid_body_view.count, 3) # Reshape the obtained array in a 2D numpy array on the host
get_inertias()#

Gets the inertia tensors for all rigid objects in the view.

The inertia tensor is given in the center of mass local frame.

Note

The function raises an exception if the inertias cannot be obtained from the backend.

Returns:

An array of inertias with shape (count, 9) where count is the number of rigid objects in the view. The 9 elements of the last dimension are the inertia tensor in the object frame.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_inertias = rigid_body_view.get_inertias() # Get the inertia tensor for all rigid bodies in the view
>>> rb_inertias_np = rb_inertias.numpy().reshape(rigid_body_view.count, 9) # Reshape the obtained array in a 2D numpy array on the host
get_inv_inertias()#

Gets the inverse inertia tensors for all rigid objects in the view.

The inertia tensor is given in the center of mass local frame.

Note

The function raises an exception if the inverse inertias cannot be obtained from the backend.

Returns:

An array of inverse inertias with shape (count, 9) where count is the number of rigid objects in the view. The 9 elements of the last dimension are the inverse inertia tensor in the object frame.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_inv_inertias = rigid_body_view.get_inv_inertias() # Get the inverse inertia tensor for all rigid bodies in the view
>>> rb_inv_inertias_np = rb_inv_inertias.numpy().reshape(rigid_body_view.count, 9) # Reshape the obtained array in a 2D numpy array on the host
get_disable_gravities()#

Receives whether the gravity is activated on rigid objects.

Note

The function raises an exception if the disable gravities cannot be obtained from the backend.

Returns:

An array of gravity activation flags (1 for disabled and 0 for enabled) with shape (count, 1) where count is the number of rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_disable_gravities = rigid_body_view.get_disable_gravities() # Get an array of boolean indicating whether the gravity is activated for all rigid bodies in the view
get_disable_simulations()#

Receives whether rigid objects are simulated or not.

Note

The function raises an exception if the disable gravities cannot be obtained from the backend.

Returns:

An array of simulation flags (1 for non-simulated and 0 for simulated) with shape (count, 1) where count is the number of rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_disable_simulations = rigid_body_view.get_disable_simulations() # Get an array of boolean indicating whether the simulation is activated for all rigid bodies in the view
set_masses(data, indices)#

Sets the masses for rigid objects indicated by indices.

Note

The function raises an exception if the masses cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of masses with shape (count, 1) where count is the number of rigid objects in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the masses for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_masses_np = numpy.zeros(rigid_body_view.count) # Create an array with the expected shape
>>> rb_masses_np[0] = 7.5 # Modify the mass of rigid body 0
>>> rb_masses_wp = warp.from_numpy(rb_masses_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_masses(rb_masses_wp, all_indices) # Set the new rigid bodies mass
set_coms(data, indices)#

Sets the centers of mass local pose for rigid objects indicated by indices.

Note

The function raises an exception if the centers of mass cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of centers of mass with shape (count, 7) where count is the number of rigid objects in the view. The 7 elements of the last dimension are the translation and quaternion components of the center of mass local pose.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the centers of mass for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_coms_np = numpy.zeros([rigid_body_view.count, 7]) # Create an array with the expected shape
>>> rb_coms_np[0, 2] = 0.2 # Modify the position in the Z direction of the center of mass of rigid body 0
>>> rb_coms_wp = warp.from_numpy(rb_coms_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_coms(rb_coms_wp, all_indices) # Set the new rigid bodies center of mass
set_inertias(data, indices)#

Sets the inertia tensors for rigid objects indicated by indices.

The inertia tensor should be given in the center of mass local frame.

Note

  • The function raises an exception if the inertias cannot be set in the backend.

  • A value of 0 in an element is interpreted as infinite inertia along that axis, however this is only permitted for rigid bodies and not for articulation links.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of inertias with shape (count, 9) where count is the number of rigid objects in the view. The 9 elements of the last dimension are the inertia tensor in the object frame.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the inertias for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_inertias_np = numpy.zeros([rigid_body_view.count, 9]) # Create an array with the expected shape
>>> rb_inertias_np[0, 2] = 75.0 # Modify the inertia tensor of rigid body 0
>>> rb_inertias_wp = warp.from_numpy(rb_inertias_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_inertias(rb_inertias_wp, all_indices) # Set the new rigid bodies inertia
set_disable_gravities(data, indices)#

Sets the rigid objects gravity activation flag for objects indicated by indices.

Note

The function raises an exception if the disable gravities cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of gravity activation flags (1 for disabled and 0 for enabled) with shape (count, 1) where count is the number of rigid objects in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the disable gravities for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_disable_gravities_np = numpy.zeros(rigid_body_view.count) # Create an array with the expected shape
>>> rb_disable_gravities_np[:] = False # Disable the gravity for all rigid bodies
>>> rb_disable_gravities_wp = warp.from_numpy(rb_disable_gravities_np, dtype=warp.uint8, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_disable_gravities(rb_disable_gravities_wp, all_indices) # Set whether the gravity is enabled or not for all rigid bodies
set_disable_simulations(data, indices)#

Sets the rigid objects simulation activation flag for objects indicated by indices.

Note

The function raises an exception if the disable simulations cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of simulation activation flags (1 for non-simulated and 0 for simulated) with shape (count, 1) where count is the number of rigid objects in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the disable simulations for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_disable_simulations_np = numpy.zeros(rigid_body_view.count) # Create an array with the expected shape
>>> rb_disable_simulations_np[:] = False # Disable the simulation for all rigid bodies
>>> rb_disable_simulations_wp = warp.from_numpy(rb_disable_simulations_np, dtype=warp.uint8, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_disable_simulations(rb_disable_simulations_wp, all_indices) # Set whether the simulation is enabled or not for all rigid bodies
get_material_properties()#

Gets the material properties for all rigid objects in the view.

The material properties array is composed of the following properties (provided in the order of appearance in the array):

  • static friction

  • dynamic friction

  • restitution

Note

The function raises an exception if the material properties cannot be obtained from the backend.

Returns:

An array of material properties with shape (count, max_shapes, 3) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view. The 3 elements of the last dimension are the static friction, dynamic friction, and restitution respectively.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_material_properties = rigid_body_view.get_material_properties() # Get the material properties for all rigid bodies in the view
>>> rb_material_properties_np = rb_material_properties.numpy().reshape(rigid_body_view.count, rigid_body_view.max_shapes, 3) # Reshape the obtained array in a 3D numpy array on the host
get_contact_offsets()#

Gets the contact offsets for all rigid objects in the view.

Note

The function raises an exception if the contact offsets cannot be obtained from the backend.

Returns:

An array of contact offsets with shape (count, max_shapes) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_contact_offsets = rigid_body_view.get_contact_offsets() # Get the contact offsets for all rigid bodies in the view
get_rest_offsets()#

Gets the rest offsets for all rigid objects in the view.

Note

The function raises an exception if the rest offsets cannot be obtained from the backend.

Returns:

An array of rest offsets with shape (count, max_shapes) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rb_rest_offsets = rigid_body_view.get_rest_offsets() # Get the rest offsets for all rigid bodies in the view
set_material_properties(data, indices)#

Sets the material properties for rigid objects indicated by indices.

The material properties array should have the following properties (provided in the order of appearance in the array):

  • static friction

  • dynamic friction

  • restitution

Note

The function raises an exception if the material properties cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of material properties with shape (count, max_shapes, 3) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view. The 3 elements of the last dimension are the static friction, dynamic friction, and restitution respectively.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the material properties for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_material_properties_np = numpy.zeros([rigid_body_view.count, rigid_body_view.max_shapes, 3]) # Create an array with the expected shape
>>> rb_material_properties_np[:, :, 0] = 0.5 # Modify the static friction for all rigid bodies and all shapes
>>> rb_material_properties_np[:, :, 1] = 0.5 # Modify the dynamic friction for all rigid bodies and all shapes
>>> rb_material_properties_np[:, :, 2] = 0.3 # Modify the restitution for all rigid bodies and all shapes
>>> rb_material_properties_wp = warp.from_numpy(rb_material_properties_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_material_properties(rb_material_properties_wp, all_indices) # Set the material properties for all rigid bodies
set_contact_offsets(data, indices)#

Sets the contact offsets for rigid objects indicated by indices.

Note

The function raises an exception if the contact offsets cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of contact offsets with shape (count, max_shapes) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the contact offsets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_contact_offsets_np = numpy.zeros(rigid_body_view.count, rigid_body_view.max_shapes) # Create an array with the expected shape
>>> rb_contact_offsets_np[0, 0] = 0.3 # Modify the contact offset for rigid body 0 and shape 0
>>> rb_contact_offsets_wp = warp.from_numpy(rb_contact_offsets_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_contact_offsets(rb_contact_offsets_wp, all_indices) # Set the contact offsets for all rigid bodies
set_rest_offsets(data, indices)#

Sets the rest offsets for rigid objects indicated by indices.

Note

The function raises an exception if the rest offsets cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of rest offsets with shape (count, max_shapes) where count is the number of rigid objects in the view and max_shapes is the maximum number of shapes in all the rigid objects in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of rigid objects to set the rest offsets for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of rigid objects in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> all_indices = wp_utils.arange(rigid_body_view.count)
>>> rb_rest_offsets_np = numpy.zeros(rigid_body_view.count, rigid_body_view.max_shapes) # Create an array with the expected shape
>>> rb_rest_offsets_np[0, 0] = 0.3 # Modify the rest offset for rigid body 0 and shape 0
>>> rb_rest_offsets_wp = warp.from_numpy(rb_rest_offsets_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> rigid_body_view.set_rest_offsets(rb_rest_offsets_wp, all_indices) # Set the rest offsets for all rigid bodies
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_body_view = sim_view.create_rigid_body_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rigid_body_view.check() # returns False if rigid_body_view is invalid, True otherwise
class omni.physics.tensors.impl.api.SoftBodyView(backend, frontend)#

SoftBodyView class represents a batch of soft bodies.

SoftBodyView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_soft_body_view() method of the SimulationView object which manages all the physics views, the device where the simulation is performed and data resides.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
property count#

The number of soft bodies in the view.

property max_elements_per_body#

The maximum number of elements per soft body in the view.

property max_vertices_per_body#

The maximum number of vertices per soft body in the view.

property max_sim_elements_per_body#

The maximum number of simulated elements per soft body in the view. Simulated elements have a corresponding element in the solver while non-simulated elements are not necessarily part of the simulation mesh.

property max_sim_vertices_per_body#

The maximum number of simulated vertices per soft body in the view. Simulated vertices have a corresponding element in the solver while non-simulated vertices are not necessarily part of the simulation mesh.

get_element_stresses()#

Gets the collision mesh Cauchy stresses for all elements in the soft bodies in the view.

The stresses are computed based on type of the material model being used and the deformation of the elements, where deformation depends on the deformation gradients of the elements.

Note

The function raises an exception if the element stresses cannot be obtained from the backend.

Returns:

An array of element Cauchy stresses with shape (count, max_elements_per_body, 9) where count is the number of soft bodies in the view and max_elements_per_body is the maximum number of elements per soft body in the view. The 9 elements of the last dimension are the components of the Cauchy stress tensors.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> element_stresses = soft_body_view.get_element_stresses() # Get the Cauchy stresses for all elements of all soft bodies in the view
>>> element_stresses_np = element_stresses.numpy().reshape(soft_body_view.count, soft_body_view.max_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_element_deformation_gradients()#

Gets the collision mesh element-wise second-order deformation gradient tensors for the deformable bodies.

Deformation gradient tensor is a second-order tensor that describes the deformation of a body. It is used to compute the stresses and strains in the body and depends on the current configuration, rotation as well as the rest configuration of the body (rest poses)

Note

The function raises an exception if the element deformation gradients cannot be obtained from the backend.

Returns:

An array of element deformation gradients with shape (count, max_elements_per_body, 9) where count is the number of soft bodies in the view and max_elements_per_body is the maximum number of elements per soft body in the view. The 9 elements of the last dimension are the components of the deformation gradient tensors.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> element_deformation_gradients = soft_body_view.get_element_deformation_gradients() # Get the collision mesh element-wise second-order deformation gradient tensors for all soft bodies in the view
>>> element_deformation_gradients_np = element_deformation_gradients.numpy().reshape(soft_body_view.count, soft_body_view.max_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_element_rest_poses()#

Gets the collision mesh element rest poses for the deformable bodies.

Element-wise rest poses define the rest configuration of the elements and are used to compute the deformation gradients of the elements.

Note

The function raises an exception if the element rest poses cannot be obtained from the backend.

Returns:

An array of element rest poses with shape (count, max_elements_per_body * 9) where count is the number of soft bodies in the view and max_elements_per_body is the maximum number of elements per soft body in the view. The 9 in the last dimension refers to the components of the rest pose tensor.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> element_rest_poses = soft_body_view.get_element_rest_poses() # Get the collision mesh element rest poses for all soft bodies in the view
>>> element_rest_poses_np = element_rest_poses.numpy().reshape(soft_body_view.count, soft_body_view.max_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_element_rotations()#

Gets the collision mesh element rotations for the deformable bodies.

Element-wise rotations define the rotation of the elements and are used in computation of the deformation gradients.

Note

The function raises an exception if the element rotations cannot be obtained from the backend.

Returns:

An array of element rotations with shape (count, max_elements_per_body * 4) where count is the number of soft bodies in the view and max_elements_per_body is the maximum number of elements per soft body in the view. The 4 in the last dimension refers to the components of the rotation quaternion.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> element_rotations = soft_body_view.get_element_rotations() # Get the collision mesh element rotations for all soft bodies in the view
>>> element_rotations_np = element_rotations.numpy().reshape(soft_body_view.count, soft_body_view.max_elements_per_body, 4) # Reshape the obtained array in a 3D numpy array on the host
get_nodal_positions()#

Gets the collision mesh nodal positions for the deformable bodies.

Note

The function raises an exception if the nodal positions cannot be obtained from the backend.

Returns:

An array of nodal positions with shape (count, max_vertices_per_body, 3) where count is the number of soft bodies in the view and max_vertices_per_body is the maximum number of vertices per soft body in the view. The 3 elements of the last dimension are the x, y, z components of the nodal positions.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> nodal_positions = soft_body_view.get_nodal_positions() # Get the collision mesh nodal positions for all soft bodies in the view
>>> nodal_positions_np = nodal_positions.numpy().reshape(soft_body_view.count, soft_body_view.max_vertices_per_body, 3) # Reshape the obtained array in a 3D numpy array on the host
get_element_indices()#

Gets the collision mesh element indices for the deformable bodies.

Element indices can be used to obtain the vertices that make up the elements.

Note

The function raises an exception if the element indices cannot be obtained from the backend.

Returns:

An array of element indices with shape (count, max_elements_per_body, 4) where count is the number of soft bodies in the view and max_elements_per_body is the maximum number of elements per soft body in the view. The 4 elements of the last dimension are the indices of the vertices that make up the element.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> element_indices = soft_body_view.get_element_indices() # Get the collision mesh element indices for all soft bodies in the view
>>> element_indices_np = element_indices.numpy().reshape(soft_body_view.count, soft_body_view.max_elements_per_body, 4) # Reshape the obtained array in a 3D numpy array on the host
get_sim_element_indices()#

Gets the simulation mesh element indices for the deformable bodies.

Element indices can be used to obtain the vertices that make up the elements.

Note

The function raises an exception if the simulation mesh element indices cannot be obtained from the backend.

Returns:

An array of simulation mesh element indices with shape (count, max_sim_elements_per_body, 4) where count is the number of soft bodies in the view and max_sim_elements_per_body is the maximum number of simulated elements per soft body in the view. The 4 elements of the last dimension are the indices of the vertices that make up the element.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_element_indices = soft_body_view.get_sim_element_indices() # Get the simulation mesh element indices for all soft bodies in the view
>>> sim_element_indices_np = sim_element_indices.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_elements_per_body, 4) # Reshape the obtained array in a 3D numpy array on the host
get_sim_element_stresses()#

Gets the simulation mesh Cauchy stresses for all elements in the soft bodies in the view.

The stresses are computed based on type of the material model being used and the deformation of the elements, where deformation depends on the deformation gradients of the elements.

Note

The function raises an exception if the simulation mesh element stresses cannot be obtained from the backend.

Returns:

An array of simulation mesh element Cauchy stresses with shape (count, max_sim_elements_per_body, 9) where count is the number of soft bodies in the view and max_sim_elements_per_body is the maximum number of simulated elements per soft body in the view. The 9 elements of the last dimension are the components of the Cauchy stress tensors.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_element_stresses = soft_body_view.get_sim_element_stresses() # Get the simulation mesh Cauchy stresses for all elements of all soft bodies in the view
>>> sim_element_stresses_np = sim_element_stresses.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_sim_element_deformation_gradients()#

Gets the simulation mesh element-wise second-order deformation gradient tensors for the deformable bodies.

Deformation gradient tensor is a second-order tensor that describes the deformation of a body. It is used to compute the stresses and strains in the body and depends on the current configuration, rotation as well as the rest configuration of the body (rest poses)

Note

The function raises an exception if the simulation mesh element deformation gradients cannot be obtained from the backend.

Returns:

An array of simulation mesh element deformation gradients with shape (count, max_sim_elements_per_body, 9) where count is the number of soft bodies in the view and max_sim_elements_per_body is the maximum number of simulated elements per soft body in the view. The 9 elements of the last dimension are the components of the deformation gradient tensors.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_element_deformation_gradients = soft_body_view.get_sim_element_deformation_gradients() # Get the simulation mesh element-wise second-order deformation gradient tensors for all soft bodies in the view
>>> sim_element_deformation_gradients_np = sim_element_deformation_gradients.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_sim_element_rest_poses()#

Gets the simulation mesh element rest poses for the deformable bodies.

Element-wise rest poses define the rest configuration of the elements and are used to compute the deformation gradients of the elements.

Note

The function raises an exception if the simulation mesh element rest poses cannot be obtained from the backend.

Returns:

An array of simulation mesh element rest poses with shape (count, max_sim_elements_per_body * 9) where count is the number of soft bodies in the view and max_sim_elements_per_body is the maximum number of simulated elements per soft body in the view. The 9 in the last dimension refers to the components of the rest pose tensor.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_element_rest_poses = soft_body_view.get_sim_element_rest_poses() # Get the simulation mesh element rest poses for all soft bodies in the view
>>> sim_element_rest_poses_np = sim_element_rest_poses.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_elements_per_body, 9) # Reshape the obtained array in a 3D numpy array on the host
get_sim_element_rotations()#

Gets the simulation mesh element rotations for the deformable bodies.

Element-wise rotations define the rotation of the elements and are used in computation of the deformation gradients.

Note

The function raises an exception if the simulation mesh element rotations cannot be obtained from the backend.

Returns:

An array of simulation mesh element rotations with shape (count, max_sim_elements_per_body * 4) where count is the number of soft bodies in the view and max_sim_elements_per_body is the maximum number of simulated elements per soft body in the view. The 4 in the last dimension refers to the components of the rotation quaternion.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_element_rotations = soft_body_view.get_sim_element_rotations() # Get the simulation mesh element rotations for all soft bodies in the view
>>> sim_element_rotations_np = sim_element_rotations.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_elements_per_body, 4) # Reshape the obtained array in a 3D numpy array on the host
get_sim_nodal_positions()#

Gets the simulation mesh nodal positions for the deformable bodies.

Note

The function raises an exception if the simulation mesh nodal positions cannot be obtained from the backend.

Returns:

An array of simulation mesh nodal positions with shape (count, max_sim_vertices_per_body, 3) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The 3 elements of the last dimension are the x, y, z components of the nodal positions

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_nodal_positions = soft_body_view.get_sim_nodal_positions() # Get the simulation mesh nodal positions for all soft bodies in the view
>>> sim_nodal_positions_np = sim_nodal_positions.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_vertices_per_body, 3) # Reshape the obtained array in a 3D numpy array on the host
set_sim_nodal_positions(data, indices)#

Sets the simulation mesh nodal positions for the deformable bodies.

Note

The function raises an exception if the simulation mesh nodal positions cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of nodal positions with shape (count, max_sim_vertices_per_body, 3) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The 3 elements of the last dimension are the x, y, z components of the nodal positions.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft bodies to set the nodal positions to. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft bodies in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_nodal_positions = soft_body_view.get_sim_nodal_positions() # Get the simulation mesh nodal positions for all soft bodies in the view
>>> # simulate physics for a period of time and then reset the simulation mesh nodal positions to their initial values
>>> all_indices = wp_utils.arange(soft_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> soft_body_view.set_sim_nodal_positions(sim_nodal_positions, all_indices) # Reset the simulation mesh nodal positions for the soft bodies in the view
get_sim_nodal_velocities()#

Gets the simulation mesh nodal velocities for the deformable bodies.

Note

The function raises an exception if the simulation mesh nodal velocities cannot be obtained from the backend.

Returns:

An array of simulation mesh nodal velocities with shape (count, max_sim_vertices_per_body, 3) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The 3 elements of the last dimension are the x, y, z components of the nodal linear velocities.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_nodal_velocities = soft_body_view.get_sim_nodal_velocities() # Get the simulation mesh nodal velocities for all soft bodies in the view
>>> sim_nodal_velocities_np = sim_nodal_velocities.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_vertices_per_body, 3) # Reshape the obtained array in a 3D numpy array on the host
set_sim_nodal_velocities(data, indices)#

Sets the simulation mesh nodal velocities for the deformable bodies.

Note

The function raises an exception if the simulation mesh nodal velocities cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of nodal velocities with shape (count, max_sim_vertices_per_body, 3) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The 3 elements of the last dimension are the x, y, z components of the nodal linear velocities.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft bodies to set the nodal velocities to. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft bodies in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> sim_nodal_velocities_wp = wp.zeros(soft_body_view.count * soft_body_view.max_sim_vertices_per_body * 3, dtype=wp.float32, device=device) # Create new simulation mesh nodal velocity array
>>> soft_body_view.set_sim_nodal_velocities(sim_nodal_velocities_wp, all_indices) # Reset the simulation mesh nodal velocities for the soft bodies in the view
get_sim_kinematic_targets()#

Gets the simulation mesh kinematic targets for the deformable bodies.

Note

The function raises an exception if the simulation mesh kinematic targets cannot be obtained from the backend.

Returns:

An array of simulation mesh kinematic targets with shape (count, max_sim_vertices_per_body, 4) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The first 3 elements of the last dimension are the x, y, z components of the kinematic target positions and the last element activates (0 for kinematically controlled and 1 for dynamic nodes) the kinematic target.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_kinematic_targets = soft_body_view.get_sim_kinematic_targets() # Get the simulation mesh kinematic targets for all soft bodies in the view
>>> sim_kinematic_targets_np = sim_kinematic_targets.numpy().reshape(soft_body_view.count, soft_body_view.max_sim_vertices_per_body, 4) # Reshape the obtained array in a 3D numpy array on the host
set_sim_kinematic_targets(data, indices)#

Sets the simulation mesh kinematic targets for the deformable bodies.

Note

The function raises an exception if the simulation mesh kinematic targets cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of kinematic targets with shape (count, max_sim_vertices_per_body, 4) where count is the number of soft bodies in the view and max_sim_vertices_per_body is the maximum number of simulated vertices per soft body in the view. The first 3 elements of the last dimension are the x, y, z components of the kinematic target positions and the last element activates (0 for kinematically controlled and 1 for dynamic nodes) the kinematic target.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft bodies to set the kinematic targets to. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft bodies in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> sim_kinematic_targets = soft_body_view.get_sim_kinematic_targets() # Get the simulation mesh kinematic targets for all soft bodies in the view
>>> # simulate physics for a period of time and then reset the simulation mesh kinematic targets to their initial values
>>> all_indices = wp_utils.arange(soft_body_view.count, device=device) # device is either cpu or cuda:0 (if using the first GPU)
>>> soft_body_view.set_sim_kinematic_targets(sim_kinematic_targets, all_indices) # Reset the simulation mesh kinematic targets for the soft bodies in the view
get_transforms()#

Gets the soft body transforms for bodies in the view.

Note

The function raises an exception if the soft body transforms cannot be obtained from the backend.

Returns:

An array of soft body transforms with shape (count, 7) where count is the number of soft bodies in the view. The first 3 elements of the last dimension are the x, y, z components of the translation and the last 4 elements are the quaternion components of the rotation.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> transforms = soft_body_view.get_transforms() # Get the transform for all soft bodies in the view
>>> transforms_np = transforms.numpy().reshape(soft_body_view.count, 7) # Reshape the obtained array in a 2D numpy array on the host
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_view = sim_view.create_soft_body_view("/World/Soft_*") # This assumes that the prims referenced by "/World/Soft_*" were already created in the stage
>>> soft_body_view.check() # returns False if soft_body_view is invalid, True otherwise
class omni.physics.tensors.impl.api.SoftBodyMaterialView(backend, frontend)#

SoftBodyMaterialView class represents a batch of soft body materials.

SoftBodyMaterialView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_soft_body_material_view() method of the SimulationView object.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
property count#

The number of soft body materials in the view

get_dynamic_friction()#

Gets the dynamic friction for all materials in the view.

Note

The function raises an exception if the dynamic friction cannot be obtained from the backend.

Returns:

An array of dynamic friction with shape (count, 1) where count is the number of soft body materials in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> sb_dynamic_friction = soft_body_material_view.get_dynamic_friction() # Get the dynamic friction for all soft body materials in the view
set_dynamic_friction(data, indices)#

Sets the dynamic friction for soft body materials indicated by indices.

Note

The function raises an exception if the dynamic friction cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of dynamic friction with shape (count, 1) where count is the number of soft body materials in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft body materials to set the dynamic friction for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft body materials in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_material_view.count)
>>> sb_dynamic_friction_np = numpy.zeros(soft_body_material_view.count) # Create an array with the expected shape
>>> sb_dynamic_friction_np[0] = 0.5 # Modify the dynamic friction for soft body material 0
>>> sb_dynamic_friction_wp = warp.from_numpy(sb_dynamic_friction_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> soft_body_material_view.set_dynamic_friction(sb_dynamic_friction_wp, all_indices) # Set the dynamic friction for all soft body materials
get_damping()#

Gets the damping for all materials in the view.

Note

The function raises an exception if the damping cannot be obtained from the backend.

Returns:

An array of damping with shape (count, 1) where count is the number of soft body materials in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> sb_damping = soft_body_material_view.get_damping() # Get the damping for all soft body materials in the view
set_damping(data, indices)#

Sets the damping scale for soft body materials indicated by indices.

Note

The function raises an exception if the damping scale cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of damping scale with shape (count, 1) where count is the number of soft body materials in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft body materials to set the damping scale for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft body materials in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_material_view.count)
>>> sb_damping_np = numpy.zeros(soft_body_material_view.count) # Create an array with the expected shape
>>> sb_damping_np[0] = 10.0 # Modify the damping for soft body material 0
>>> sb_damping_wp = warp.from_numpy(sb_damping_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> soft_body_material_view.set_damping(sb_damping_wp, all_indices) # Set the damping for all soft body materials
get_damping_scale()#

Gets the damping scale for all materials in the view.

Note

The function raises an exception if the damping scale cannot be obtained from the backend.

Returns:

An array of damping scale with shape (count, 1) where count is the number of soft body materials in the view

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> sb_damping_scale = soft_body_material_view.get_damping_scale() # Get the damping scale for all soft body materials in the view
set_damping_scale(data, indices)#

Sets the damping scale for soft body materials indicated by indices.

Note

The function raises an exception if the damping scale cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of damping scale with shape (count, 1) where count is the number of soft body materials in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft body materials to set the damping scale for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft body materials in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_material_view.count)
>>> sb_damping_scale_np = numpy.zeros(soft_body_material_view.count) # Create an array with the expected shape
>>> sb_damping_scale_np[0] = 0.7 # Modify the damping_scale for soft body material 0
>>> sb_damping_scale_wp = warp.from_numpy(sb_damping_scale_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> soft_body_material_view.set_damping_scale(sb_damping_scale_wp, all_indices) # Set the damping scale for all soft body materials
get_poissons_ratio()#

Gets the Poisson’s ratio for all materials in the view.

Note

The function raises an exception if the Poisson’s ratio cannot be obtained from the backend.

Returns:

An array of Poisson’s ratio with shape (count, 1) where count is the number of soft body materials in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> sb_poisson_ratio = soft_body_material_view.get_poissons_ratio() # Get the Poisson ratio for all soft body materials in the view
set_poissons_ratio(data, indices)#

Sets the Poisson’s ratio for soft body materials indicated by indices.

Note

The function raises an exception if the Poisson’s ratio cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of Poisson’s ratio with shape (count, 1) where count is the number of soft body materials in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft body materials to set the Poisson’s ratio for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft body materials in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_material_view.count)
>>> sb_poisson_ratio_np = numpy.zeros(soft_body_material_view.count) # Create an array with the expected shape
>>> sb_poisson_ratio_np[0] = 0.1 # Modify the Poisson ratio for soft body material 0
>>> sb_poisson_ratio_wp = warp.from_numpy(sb_poisson_ratio_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> soft_body_material_view.set_poissons_ratio(sb_poisson_ratio_wp, all_indices) # Set the Poisson ratio for all soft body materials
get_youngs_modulus()#

Gets the Young’s modulus for all materials in the view.

Note

The function raises an exception if the Young’s modulus cannot be obtained from the backend.

Returns:

An array of Young’s modulus with shape (count, 1) where count is the number of soft body materials in the view.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> sb_young_modulus = soft_body_material_view.get_youngs_modulus() # Get the Young modulus for all soft body materials in the view
set_youngs_modulus(data, indices)#

Sets the Young’s modulus for soft body materials indicated by indices.

Note

The function raises an exception if the Young’s modulus cannot be set in the backend.

Parameters:
  • data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of Young’s modulus with shape (count, 1) where count is the number of soft body materials in the view.

  • indices (Union[np.ndarray, torch.Tensor, wp.array]) – An array of indices of soft body materials to set the Young’s modulus for. The array can have any dimension (user_count, 1) as long as all indices are less than the number of soft body materials in the view (count). Note that providing repeated indices can lead to undefined behavior as the subsitutions may be performed in parallel.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> all_indices = wp_utils.arange(soft_body_material_view.count)
>>> sb_young_modulus_np = numpy.zeros(soft_body_material_view.count) # Create an array with the expected shape
>>> sb_young_modulus_np[0] = 50.0 # Modify the Young modulus for soft body material 0
>>> sb_young_modulus_wp = warp.from_numpy(sb_young_modulus_np, dtype=warp.float32, device="cpu") # Convert back to a format accepted by the tensor API
>>> soft_body_material_view.set_youngs_modulus(sb_young_modulus_wp, all_indices) # Set the Young modulus for all soft body materials
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> soft_body_material_view = sim_view.create_soft_body_material_view("/World/SoftMaterial_*") # This assumes that the prims referenced by "/World/SoftMaterial_*" were already created in the stage
>>> soft_body_material_view.check() # returns False if soft_body_material_view is invalid, True otherwise
class omni.physics.tensors.impl.api.RigidContactView(backend, frontend)#

RigidContactView class represents a batch of rigid contact.

RigidContactView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_rigid_contact_view() method of the SimulationView object.

Note

RigidContactView objects can be used to access contact forces and their relavant quantities in a tensorized way.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
property sensor_count#

The number of sensors in the view. Sensors are the objects whose contacts with other objects are tracked by this view.

property filter_count#

The number of filters in the view. Filters are the objects that allows getting more detailed pair-wise contact forces with sensors. Providing filters is optional, but if filters are not provided, only the net contact forces of the sensor objects can be obtained with the view.

property max_contact_data_count#

The maximum number of contact data that can be stored in the view. Providing a non-zero value for this parameter allows getting detailed contact data for each sensor-filter pair. This is used for managing the underlying memory, so needs to be tuned for each problem depending on expected number of contacts in the environment.

property sensor_paths#

The USD paths of the sensor prims in the view.

property filter_paths#

The USD paths of the filter prims in the view.

property sensor_names#

The names of the sensor prims in the view.

property filter_names#

The names of the filter prims in the view.

get_net_contact_forces(dt)#

Gets the net contact forces acting on the sensors in the view.

This includes all the contact forces from all the prims interacting with the sensors, not only the filter prims.

Note

The function raises an exception if the net contact forces cannot be obtained from the backend.

Parameters:

dt (float) – The time step of the simulation to use to convert impulses to forces.

Returns:

An array of net contact forces with shape (sensor_count, 3) where sensor_count is the number of sensors in the view. The 3 elements of the last dimension are the x, y, z components of the net contact forces.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> net_contact_forces = rigid_contact_view.get_net_contact_forces(dt) # Get the net contact forces acting on the sensors in the view
>>> net_contact_forces_np = net_contact_forces.numpy().reshape(rigid_contact_view.sensor_count, 3) # Reshape the obtained array in a 2D numpy array on the host
get_contact_force_matrix(dt)#

Gets the matrix of pair-wise contact forces between sensors and filter prims.

This only includes the contact forces between the sensors and the filter prims but not other potential contacts between the sensors and non-filter prims.

Note

  • The function raises an exception if the contact force matrix cannot be obtained from the backend.

  • This function can only be used if the view is initialized with a valid filter prims.

  • There could be more than one contact point between a sensor prim and a filter prim, but this function aggregates and reports the sum of all those contact forces between a pair of sensor/filter.

Parameters:

dt (float) – The time step of the simulation to use to convert impulses to forces.

Returns:

An array of contact forces with shape (sensor_count, filter_count, 3) where sensor_count is the number of sensors in the view and filter_count is the number of filter prims in the view. The 3 elements of the last dimension are the x, y, z components of the contact forces between the sensors prims (in the first dimension) and the filter prims (in the second dimension).

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> contact_force_matrix = rigid_contact_view.get_contact_force_matrix(dt) # Get the matrix of pair-wise contact forces between sensors and filter prims
>>> contact_force_matrix_np = contact_force_matrix.numpy().reshape(rigid_contact_view.sensor_count, rigid_contact_view.filter_count, 3) # Reshape the obtained array in a 3D numpy array on the host
get_contact_data(dt)#

Gets the detailed contact data between sensors and filter prims per patch.

This includes the contact forces, contact points, contact normals, and separation distances.

Note that there could be more than one contact point between a sensor prim and a filter prim. This function however, does not report the aggregated values for a pair of sensor/filter prims. This is an important distinction from the RigidContactView.get_contact_force_matrix() function. This is needed because some of the variables reported by this function (such as contact normals, points, and separation) are defined only for contact points and cannot be aggregated accross the shape without further information about the geometry of the contact.

Note also that the structure of the data returned by this function is different from the RigidContactView.get_contact_force_matrix() function. This function returns contacts data in buffers that need to be further processed. Specifically, the last two tensors returned by this function (i.e. contact_count_buffer, and start_indices_buffer) are used to locate the set of contact data for each sensor-filter pair in the first three tensors (i.e. force_buffer, point_buffer, normal_buffer, separation_buffer).

For each sensor-filter pair, contact data (force_buffer, point_buffer, normal_buffer, separation_buffer) for all the contact points between sensor-filter prims are within the range of start_indices_buffer[sensor, filter] to start_indices_buffer[sensor, filter] + contact_count_buffer[sensor, filter].

Note

  • The function raises an exception if the contact data cannot be obtained from the backend.

  • This function can only be used if the view is initialized with a valid filter prims.

  • The function raises an exception if the view is initialized with max_contact_data_count = 0.

Parameters:

dt (float) – The time step of the simulation to use to convert impulses to forces.

Returns:

A tuple of five arrays of contact data:
  • The first array is the contact forces with shape (max_contact_data_count, 1) where max_contact_data_count is the maximum number of contact data that can be stored in the view.

  • The second array is the contact points with shape (max_contact_data_count, 3) where the 3 elements of the last dimension are the x, y, z components of the contact points.

  • The third array is the contact normals with shape (max_contact_data_count, 3) where the 3 elements of the last dimension are the x, y, z components of the contact normals vector.

  • The fourth array is the separation distances with shape (max_contact_data_count, 1).

  • The fifth array is the contact count buffer with shape (sensor_count, filter_count) where sensor_count is the number of sensors in the view and filter_count is the number of filter prims in the view.

  • The sixth array is the start indices buffer with shape (sensor_count, filter_count).

Return type:

Tuple[Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array]]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> forces, points, normals, distances, counts, start_indices = rigid_contact_view.get_contact_data(dt) # Get the detailed contact data between sensors and filter prims per patch

>>> forces_np = forces.numpy().reshape(rigid_contact_view.max_contact_data_count) # Reshape the obtained array in a 1D numpy array on the host
>>> points_np = points.numpy().reshape(rigid_contact_view.max_contact_data_count * 3) # Reshape the obtained array in a 1D numpy array on the host
>>> normals_np = normals.numpy().reshape(rigid_contact_view.max_contact_data_count * 3) # Reshape the obtained array in a 1D numpy array on the host
>>> distances_np = distances.numpy().reshape(rigid_contact_view.max_contact_data_count) # Reshape the obtained array in a 1D numpy array on the host
>>> counts_np = counts.numpy().reshape(rigid_contact_view.sensor_count, rigid_contact_view.filter_count) # Reshape the obtained array in a 2D numpy array on the host
>>> start_indices_np = start_indices.numpy().reshape(rigid_contact_view.sensor_count, rigid_contact_view.filter_count) # Reshape the obtained array in a 2D numpy array on the host

# for given prims i and j, the net pairwise contact force is the sum of individual contact forces
>>> start_indices_ij = start_indices_np[i, j]
>>> count_ij = counts_np[i, j]
>>> if count_ij > 0:
>>>     forces_ij = forces_np[start_indices_ij:start_indices_ij + count_ij] * normals_np[start_indices_ij:start_indices_ij + count_ij]
>>> force_aggregate = numpy.sum(forces_ij, axis=0)
get_friction_data(dt)#

Gets the friction data between sensors and filter prims.

This includes the friction forces and the friction points.

Note that there could be more than one contact point between a sensor prim and a filter prim. This function is similar to RigidContactView.get_contact_force_matrix(), but does not report the aggregated values for a pair of sensor/filter prims. This is needed because some of the variables reported by this function (such as friction points) are defined only for contact points and cannot be aggregated accross the shape without further information about the geometry of the contact.

Note also that the structure of the data returned by this function is different from the RigidContactView.get_contact_force_matrix() function. This function returns contacts data in buffers that need to be further processed. Specifically, the last two tensors returned by this function (i.e. contact_count_buffer, and start_indices_buffer) are used to locate the set of contact data for each sensor-filter pair in the first two tensors (i.e. force_buffer, point_buffer).

For each sensor-filter pair, contact data (force_buffer, point_buffer) for all the contact points between sensor-filter prims are within the range of start_indices_buffer[sensor, filter] to start_indices_buffer[sensor, filter] + contact_count_buffer[sensor, filter].

Note

  • The function raises an exception if the friction data cannot be obtained from the backend.

  • This function can only be used if the view is initialized with a valid filter prims.

  • The function raises an exception if the view is initialized with max_contact_data_count = 0.

Parameters:

dt (float) – The time step of the simulation to use to convert impulses to forces.

Returns:

A tuple of four arrays of friction data:
  • The first array is the friction forces with shape (max_contact_data_count, 3) where max_contact_data_count is the maximum number of contact data that can be stored in the view. The 3 elements of the last dimension are the x, y, z components of the friction forces.

  • The second array is the friction points with shape (max_contact_data_count, 3) where the 3 elements of the last dimension are the x, y, z components of the friction points.

  • The third array is the contact count buffer with shape (sensor_count, filter_count) where sensor_count is the number of sensors in the view and filter_count is the number of filter prims in the view.

  • The fourth array is the start indices buffer with shape (sensor_count, filter_count).

Return type:

Tuple[Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array], Union[np.ndarray, torch.Tensor, wp.array]]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> frictions, points, counts, start_indices = rigid_contact_view.get_friction_data(dt) # Get the detailed friction data between sensors and filter prims

>>> frictions_np = frictions.numpy().reshape(rigid_contact_view.max_contact_data_count * 3) # Reshape the obtained array in a 1D numpy array on the host
>>> points_np = points.numpy().reshape(rigid_contact_view.max_contact_data_count * 3) # Reshape the obtained array in a 1D numpy array on the host
>>> counts_np = counts.numpy().reshape(rigid_contact_view.sensor_count, rigid_contact_view.filter_count) # Reshape the obtained array in a 2D numpy array on the host
>>> start_indices_np = start_indices.numpy().reshape(rigid_contact_view.sensor_count, rigid_contact_view.filter_count) # Reshape the obtained array in a 2D numpy array on the host

# for given prims i and j, the net pairwise friction force is the sum of individual friction forces
>>> start_indices_ij = start_indices_np[i, j]
>>> count_ij = counts_np[i, j]
>>> if count_ij > 0:
>>>     frictions_forces_ij = frictions_np[start_indices_ij:start_indices_ij + count_ij]
>>> frictions_force_aggregate = numpy.sum(frictions_forces_ij, axis=0)
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> rigid_contact_view = sim_view.create_rigid_contact_view("/World/Cube_*") # This assumes that the prims referenced by "/World/Cube_*" were already created in the stage
>>> rigid_contact_view.check() # returns False if rigid_contact_view is invalid, True otherwise
class omni.physics.tensors.impl.api.SdfShapeView(backend, frontend)#

SdfShapeView class represents a batch of SDF shapes.

SdfShapeView binds the concrete implementation of the physics backend with the frontend tensor framework that is used to handle data. This class isn’t meant to be instantiated directly, but rather created using the SimulationView.create_sdf_shape_view() method of the SimulationView object.

Note

SdfShapeView objects can be used to access signed distance functions and their gradients in a tensorized way.

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> sdf_shape_view = sim_view.create_sdf_shape_view("/World/SDF_*", 1000) # This assumes that the prims referenced by "/World/SDF_*" were already created in the stage
property count#

The number of shape with SDF information in the view.

property max_num_points#

The maximum number of points that can be used to query SDF and gradients in the view.

property object_paths#

The USD paths of the shapes in the view.

get_sdf_and_gradients(data)#

Gets the signed distance functions and their gradients for the shapes in the view.

Note

The function raises an exception if the signed distance functions and their gradients cannot be obtained from the backend.

Parameters:

data (Union[np.ndarray, torch.Tensor, wp.array]) – An array of points with shape (count, max_num_points, 3) where count is the number of shapes in the view and max_num_points is the maximum number of points that can be used to query SDF and gradients in the view. The 3 elements of the last dimension are the x, y, z components of the points.

Returns:

An array of signed distance functions and their gradients with shape (count, max_num_points, 4) where count is the number of shapes in the view and max_num_points is the maximum number of points that can be used to query SDF and gradients in the view. The first element of the last dimension is the signed distance function and the last 3 elements are the x, y, z components of the gradient.

Return type:

Union[np.ndarray, torch.Tensor, wp.array]

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> sdf_shape_view = sim_view.create_sdf_shape_view("/World/SDF_*", 1000) # This assumes that the prims referenced by "/World/SDF_*" were already created in the stage
>>> sdf_and_gradients = sdf_shape_view.get_sdf_and_gradients(dt) # Get the signed distance functions and their gradients for the shapes in the view
>>> sdf_and_gradients_np = sdf_and_gradients.numpy().reshape(sdf_shape_view.count, sdf_shape_view.max_num_points, 4) # Reshape the obtained array in a 3D numpy array on the host
check()#

Checks the validity of the underlying physics objects that the view uses.

Returns:

True if all physics objects are valid, False otherwise.

Return type:

bool

Example

>>> import omni.physics.tensors as tensors
>>> sim_view = tensors.create_simulation_view("warp")
>>> sdf_shape_view = sim_view.create_sdf_shape_view("/World/SDF_*", 1000) # This assumes that the prims referenced by "/World/SDF_*" were already created in the stage
>>> sdf_shape_view.check() # returns False if sdf_shape_view is invalid, True otherwise
class omni.physics.tensors.impl.api.ParticleSystemView(backend, frontend)#

Warning

This class and its functionality is deprecated and will be removed in the future.

property count#
get_solid_rest_offsets()#
set_solid_rest_offsets(data, indices)#
get_fluid_rest_offsets()#
set_fluid_rest_offsets(data, indices)#
get_particle_contact_offsets()#
set_particle_contact_offsets(data, indices)#
get_wind()#
set_wind(data, indices)#
check()#
class omni.physics.tensors.impl.api.ParticleClothView(backend, frontend)#

Warning

This class and its functionality is deprecated and will be removed in the future.

property count#
property max_particles_per_cloth#
property max_springs_per_cloth#
get_positions()#
set_positions(data, indices)#
get_velocities()#
set_velocities(data, indices)#
get_masses()#
set_masses(data, indices)#
get_spring_damping()#
set_spring_damping(data, indices)#
get_spring_stiffness()#
set_spring_stiffness(data, indices)#
check()#
class omni.physics.tensors.impl.api.ParticleMaterialView(backend, frontend)#

Warning

This class and its functionality is deprecated and will be removed in the future.

property count#
get_friction()#
set_friction(data, indices)#
get_damping()#
set_damping(data, indices)#
get_gravity_scale()#
set_gravity_scale(data, indices)#
get_lift()#
set_lift(data, indices)#
get_drag()#
set_drag(data, indices)#
check()#