Unverified Commit da34688b authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Removes the use of body view inside the asset classes (#643)

# Description

The deprecation notice has been out for a while. The MR removes the body
PhysX view from the rigid object and articulation classes. This is no
longer needed as their respective root views expose all the data needed
for them.

This is a breaking change, and we lose compatibility with Isaac Sim
2023.1.1.

Fixes #237

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent 5ffff16f
...@@ -19,7 +19,7 @@ Installation Guide ...@@ -19,7 +19,7 @@ Installation Guide
.. caution:: .. caution::
We have dropped support for Isaac Sim versions 2023.1.0 and below. We recommend using the latest We have dropped support for Isaac Sim versions 2023.1.1 and below. We recommend using the latest
Isaac Sim 4.0 release to benefit from the latest features and improvements. Isaac Sim 4.0 release to benefit from the latest features and improvements.
For more information, please refer to the For more information, please refer to the
......
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.18.6" version = "0.19.0"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.19.0 (2024-07-04)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed parsing of articulations with nested rigid links while using the :class:`omni.isaac.lab.assets.Articulation`
class. Earlier, the class initialization failed when the articulation had nested rigid links since the rigid
links were not being parsed correctly by the PhysX view.
Removed
^^^^^^^
* Removed the attribute :attr:`body_physx_view` from the :class:`omni.isaac.lab.assets.Articulation` and
:class:`omni.isaac.lab.assets.RigidObject` classes. These were causing confusions when used with articulation
view since the body names were not following the same ordering.
* Dropped support for Isaac Sim 2023.1.1. The minimum supported version is now Isaac Sim 4.0.0.
0.18.6 (2024-07-01) 0.18.6 (2024-07-01)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
from __future__ import annotations from __future__ import annotations
import torch import torch
import warnings
from collections.abc import Sequence from collections.abc import Sequence
from prettytable import PrettyTable from prettytable import PrettyTable
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
...@@ -156,25 +155,6 @@ class Articulation(RigidObject): ...@@ -156,25 +155,6 @@ class Articulation(RigidObject):
""" """
return self._root_physx_view return self._root_physx_view
@property
def body_physx_view(self) -> physx.RigidBodyView:
"""Rigid body view for the asset (PhysX).
.. deprecated:: v0.3.0
In previous versions, this attribute returned the rigid body view over all the links of the articulation.
However, this led to confusion with the link ordering as they were not ordered in the same way as the
articulation view.
Therefore, this attribute will be removed in v0.4.0. Please use the :attr:`root_physx_view` attribute
instead.
"""
dep_msg = "The attribute 'body_physx_view' will be removed in v0.4.0. Please use 'root_physx_view' instead."
warnings.warn(dep_msg, DeprecationWarning)
carb.log_error(dep_msg)
return self._body_physx_view
""" """
Operations. Operations.
""" """
...@@ -194,16 +174,8 @@ class Articulation(RigidObject): ...@@ -194,16 +174,8 @@ class Articulation(RigidObject):
If any explicit actuators are present, then the actuator models are used to compute the If any explicit actuators are present, then the actuator models are used to compute the
joint commands. Otherwise, the joint commands are directly set into the simulation. joint commands. Otherwise, the joint commands are directly set into the simulation.
""" """
# write external wrench
if self.has_external_wrench:
# apply external forces and torques # apply external forces and torques
self._body_physx_view.apply_forces_and_torques_at_position( super().write_data_to_sim()
force_data=self._external_force_body_view_b.view(-1, 3),
torque_data=self._external_torque_body_view_b.view(-1, 3),
position_data=None,
indices=self._ALL_BODY_INDICES,
is_global=False,
)
# apply actuator models # apply actuator models
self._apply_actuator_model() self._apply_actuator_model()
...@@ -260,24 +232,6 @@ class Articulation(RigidObject): ...@@ -260,24 +232,6 @@ class Articulation(RigidObject):
# find tendons # find tendons
return string_utils.resolve_matching_names(name_keys, tendon_subsets, preserve_order) return string_utils.resolve_matching_names(name_keys, tendon_subsets, preserve_order)
"""
Operations - Setters.
"""
def set_external_force_and_torque(
self,
forces: torch.Tensor,
torques: torch.Tensor,
body_ids: Sequence[int] | slice | None = None,
env_ids: Sequence[int] | None = None,
):
# call parent to set the external forces and torques into buffers
super().set_external_force_and_torque(forces, torques, body_ids, env_ids)
# reordering of the external forces and torques to match the body view ordering
if self.has_external_wrench:
self._external_force_body_view_b = self._external_force_b[:, self._body_view_ordering]
self._external_torque_body_view_b = self._external_torque_b[:, self._body_view_ordering]
""" """
Operations - Writers. Operations - Writers.
""" """
...@@ -332,6 +286,7 @@ class Articulation(RigidObject): ...@@ -332,6 +286,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -364,6 +319,7 @@ class Articulation(RigidObject): ...@@ -364,6 +319,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -394,6 +350,7 @@ class Articulation(RigidObject): ...@@ -394,6 +350,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -422,6 +379,7 @@ class Articulation(RigidObject): ...@@ -422,6 +379,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# move tensor to cpu if needed # move tensor to cpu if needed
...@@ -453,6 +411,7 @@ class Articulation(RigidObject): ...@@ -453,6 +411,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -480,6 +439,7 @@ class Articulation(RigidObject): ...@@ -480,6 +439,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -508,6 +468,7 @@ class Articulation(RigidObject): ...@@ -508,6 +468,7 @@ class Articulation(RigidObject):
physx_env_ids = self._ALL_INDICES physx_env_ids = self._ALL_INDICES
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set into internal buffers # set into internal buffers
...@@ -538,6 +499,7 @@ class Articulation(RigidObject): ...@@ -538,6 +499,7 @@ class Articulation(RigidObject):
env_ids = slice(None) env_ids = slice(None)
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set targets # set targets
...@@ -562,6 +524,7 @@ class Articulation(RigidObject): ...@@ -562,6 +524,7 @@ class Articulation(RigidObject):
env_ids = slice(None) env_ids = slice(None)
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set targets # set targets
...@@ -586,6 +549,7 @@ class Articulation(RigidObject): ...@@ -586,6 +549,7 @@ class Articulation(RigidObject):
env_ids = slice(None) env_ids = slice(None)
if joint_ids is None: if joint_ids is None:
joint_ids = slice(None) joint_ids = slice(None)
# broadcast env_ids if needed to allow double indexing
if env_ids != slice(None) and joint_ids != slice(None): if env_ids != slice(None) and joint_ids != slice(None):
env_ids = env_ids[:, None] env_ids = env_ids[:, None]
# set targets # set targets
...@@ -821,24 +785,6 @@ class Articulation(RigidObject): ...@@ -821,24 +785,6 @@ class Articulation(RigidObject):
root_prim_path_expr = self.cfg.prim_path + root_prim_path[len(template_prim_path) :] root_prim_path_expr = self.cfg.prim_path + root_prim_path[len(template_prim_path) :]
# -- articulation # -- articulation
self._root_physx_view = self._physics_sim_view.create_articulation_view(root_prim_path_expr.replace(".*", "*")) self._root_physx_view = self._physics_sim_view.create_articulation_view(root_prim_path_expr.replace(".*", "*"))
# -- link views
# note: we use the root view to get the body names, but we use the body view to get the
# actual data. This is mainly needed to apply external forces to the bodies.
physx_body_names = self.root_physx_view.shared_metatype.link_names
body_names_regex = r"(" + "|".join(physx_body_names) + r")"
body_names_regex = f"{self.cfg.prim_path}/{body_names_regex}"
self._body_physx_view = self._physics_sim_view.create_rigid_body_view(body_names_regex.replace(".*", "*"))
# create ordering from articulation view to body view for body names
# note: we need to do this since the body view is not ordered in the same way as the articulation view
# -- root view
root_view_body_names = self.body_names
# -- body view
prim_paths = self._body_physx_view.prim_paths[: self.num_bodies]
body_view_body_names = [path.split("/")[-1] for path in prim_paths]
# -- mapping from articulation view to body view
self._body_view_ordering = [root_view_body_names.index(name) for name in body_view_body_names]
self._body_view_ordering = torch.tensor(self._body_view_ordering, dtype=torch.long, device=self.device)
# log information about the articulation # log information about the articulation
carb.log_info(f"Articulation initialized at: {self.cfg.prim_path} with root '{root_prim_path_expr}'.") carb.log_info(f"Articulation initialized at: {self.cfg.prim_path} with root '{root_prim_path_expr}'.")
...@@ -848,9 +794,6 @@ class Articulation(RigidObject): ...@@ -848,9 +794,6 @@ class Articulation(RigidObject):
carb.log_info(f"Number of joints: {self.num_joints}") carb.log_info(f"Number of joints: {self.num_joints}")
carb.log_info(f"Joint names: {self.joint_names}") carb.log_info(f"Joint names: {self.joint_names}")
carb.log_info(f"Number of fixed tendons: {self.num_fixed_tendons}") carb.log_info(f"Number of fixed tendons: {self.num_fixed_tendons}")
# -- assert that parsing was successful
if set(physx_body_names) != set(self.body_names):
raise RuntimeError("Failed to parse all bodies properly in the articulation.")
# container for data access # container for data access
self._data = ArticulationData(self.root_physx_view, self.device) self._data = ArticulationData(self.root_physx_view, self.device)
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
from __future__ import annotations from __future__ import annotations
import torch import torch
import warnings
from collections.abc import Sequence from collections.abc import Sequence
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
...@@ -89,20 +88,6 @@ class RigidObject(AssetBase): ...@@ -89,20 +88,6 @@ class RigidObject(AssetBase):
""" """
return self._root_physx_view return self._root_physx_view
@property
def body_physx_view(self) -> physx.RigidBodyView:
"""Rigid body view for the asset (PhysX).
.. deprecated:: v0.3.0
The attribute 'body_physx_view' will be removed in v0.4.0. Please use :attr:`root_physx_view` instead.
"""
dep_msg = "The attribute 'body_physx_view' will be removed in v0.4.0. Please use 'root_physx_view' instead."
warnings.warn(dep_msg, DeprecationWarning)
carb.log_error(dep_msg)
return self.root_physx_view
""" """
Operations. Operations.
""" """
...@@ -128,7 +113,7 @@ class RigidObject(AssetBase): ...@@ -128,7 +113,7 @@ class RigidObject(AssetBase):
force_data=self._external_force_b.view(-1, 3), force_data=self._external_force_b.view(-1, 3),
torque_data=self._external_torque_b.view(-1, 3), torque_data=self._external_torque_b.view(-1, 3),
position_data=None, position_data=None,
indices=self._ALL_BODY_INDICES, indices=self._ALL_INDICES,
is_global=False, is_global=False,
) )
...@@ -253,26 +238,17 @@ class RigidObject(AssetBase): ...@@ -253,26 +238,17 @@ class RigidObject(AssetBase):
# resolve all indices # resolve all indices
# -- env_ids # -- env_ids
if env_ids is None: if env_ids is None:
env_ids = self._ALL_INDICES env_ids = slice(None)
elif not isinstance(env_ids, torch.Tensor):
env_ids = torch.tensor(env_ids, dtype=torch.long, device=self.device)
# -- body_ids # -- body_ids
if body_ids is None: if body_ids is None:
body_ids = torch.arange(self.num_bodies, dtype=torch.long, device=self.device) body_ids = slice(None)
elif isinstance(body_ids, slice): # broadcast env_ids if needed to allow double indexing
body_ids = torch.arange(self.num_bodies, dtype=torch.long, device=self.device)[body_ids] if env_ids != slice(None) and body_ids != slice(None):
elif not isinstance(body_ids, torch.Tensor): env_ids = env_ids[:, None]
body_ids = torch.tensor(body_ids, dtype=torch.long, device=self.device)
# note: we need to do this complicated indexing since torch doesn't support multi-indexing
# create global body indices from env_ids and env_body_ids
# (env_id * total_bodies_per_env) + body_id
indices = body_ids.repeat(len(env_ids), 1) + env_ids.unsqueeze(1) * self.num_bodies
indices = indices.view(-1)
# set into internal buffers # set into internal buffers
# note: these are applied in the write_to_sim function self._external_force_b[env_ids, body_ids] = forces
self._external_force_b.flatten(0, 1)[indices] = forces.flatten(0, 1) self._external_torque_b[env_ids, body_ids] = torques
self._external_torque_b.flatten(0, 1)[indices] = torques.flatten(0, 1)
else: else:
self.has_external_wrench = False self.has_external_wrench = False
...@@ -332,9 +308,7 @@ class RigidObject(AssetBase): ...@@ -332,9 +308,7 @@ class RigidObject(AssetBase):
"""Create buffers for storing data.""" """Create buffers for storing data."""
# constants # constants
self._ALL_INDICES = torch.arange(self.num_instances, dtype=torch.long, device=self.device) self._ALL_INDICES = torch.arange(self.num_instances, dtype=torch.long, device=self.device)
self._ALL_BODY_INDICES = torch.arange(
self.root_physx_view.count * self.num_bodies, dtype=torch.long, device=self.device
)
# external forces and torques # external forces and torques
self.has_external_wrench = False self.has_external_wrench = False
self._external_force_b = torch.zeros((self.num_instances, self.num_bodies, 3), device=self.device) self._external_force_b = torch.zeros((self.num_instances, self.num_bodies, 3), device=self.device)
......
...@@ -98,10 +98,6 @@ class TestArticulation(unittest.TestCase): ...@@ -98,10 +98,6 @@ class TestArticulation(unittest.TestCase):
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]] prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
self.assertListEqual(prim_path_body_names, robot.body_names) self.assertListEqual(prim_path_body_names, robot.body_names)
# Check that the body_physx_view is deprecated
with self.assertWarns(DeprecationWarning):
robot.body_physx_view
# Simulate physics # Simulate physics
for _ in range(10): for _ in range(10):
# perform rendering # perform rendering
...@@ -141,10 +137,6 @@ class TestArticulation(unittest.TestCase): ...@@ -141,10 +137,6 @@ class TestArticulation(unittest.TestCase):
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]] prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
self.assertListEqual(prim_path_body_names, robot.body_names) self.assertListEqual(prim_path_body_names, robot.body_names)
# Check that the body_physx_view is deprecated
with self.assertWarns(DeprecationWarning):
robot.body_physx_view
# Simulate physics # Simulate physics
for _ in range(10): for _ in range(10):
# perform rendering # perform rendering
...@@ -184,10 +176,6 @@ class TestArticulation(unittest.TestCase): ...@@ -184,10 +176,6 @@ class TestArticulation(unittest.TestCase):
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]] prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
self.assertListEqual(prim_path_body_names, robot.body_names) self.assertListEqual(prim_path_body_names, robot.body_names)
# Check that the body_physx_view is deprecated
with self.assertWarns(DeprecationWarning):
robot.body_physx_view
# Simulate physics # Simulate physics
for _ in range(10): for _ in range(10):
# perform rendering # perform rendering
...@@ -242,10 +230,6 @@ class TestArticulation(unittest.TestCase): ...@@ -242,10 +230,6 @@ class TestArticulation(unittest.TestCase):
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]] prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
self.assertListEqual(prim_path_body_names, robot.body_names) self.assertListEqual(prim_path_body_names, robot.body_names)
# Check that the body_physx_view is deprecated
with self.assertWarns(DeprecationWarning):
robot.body_physx_view
# Simulate physics # Simulate physics
for _ in range(10): for _ in range(10):
# perform rendering # perform rendering
...@@ -324,10 +308,6 @@ class TestArticulation(unittest.TestCase): ...@@ -324,10 +308,6 @@ class TestArticulation(unittest.TestCase):
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]] prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
self.assertListEqual(prim_path_body_names, robot.body_names) self.assertListEqual(prim_path_body_names, robot.body_names)
# Check that the body_physx_view is deprecated
with self.assertWarns(DeprecationWarning):
robot.body_physx_view
# Root state should be at the default state # Root state should be at the default state
robot.write_root_state_to_sim(robot.data.default_root_state.clone()) robot.write_root_state_to_sim(robot.data.default_root_state.clone())
# Simulate physics # Simulate physics
......
...@@ -48,8 +48,7 @@ def generate_cubes_scene( ...@@ -48,8 +48,7 @@ def generate_cubes_scene(
device: Device to use for the simulation. device: Device to use for the simulation.
Returns: Returns:
RigidObject: The rigid object representing the cubes. A tuple containing the rigid object representing the cubes and the origins of the cubes.
origins: The origins of the cubes.
""" """
origins = torch.tensor([(i * 1.0, 0, height) for i in range(num_cubes)]).to(device) origins = torch.tensor([(i * 1.0, 0, height) for i in range(num_cubes)]).to(device)
...@@ -93,6 +92,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -93,6 +92,7 @@ class TestRigidObject(unittest.TestCase):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
with build_simulation_context(device=device, auto_add_lighting=True) as sim: with build_simulation_context(device=device, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device)
# Check that boundedness of rigid object is correct # Check that boundedness of rigid object is correct
...@@ -122,6 +122,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -122,6 +122,7 @@ class TestRigidObject(unittest.TestCase):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
with build_simulation_context(device=device, auto_add_lighting=True) as sim: with build_simulation_context(device=device, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, origins = generate_cubes_scene( cube_object, origins = generate_cubes_scene(
num_cubes=num_cubes, kinematic_enabled=True, device=device num_cubes=num_cubes, kinematic_enabled=True, device=device
) )
...@@ -157,6 +158,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -157,6 +158,7 @@ class TestRigidObject(unittest.TestCase):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
with build_simulation_context(device=device, auto_add_lighting=True) as sim: with build_simulation_context(device=device, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, has_api=False, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, has_api=False, device=device)
# Check that boundedness of rigid object is correct # Check that boundedness of rigid object is correct
...@@ -178,6 +180,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -178,6 +180,7 @@ class TestRigidObject(unittest.TestCase):
for num_cubes in (2, 4): for num_cubes in (2, 4):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
# Generate cubes scene
with build_simulation_context(device=device, add_ground_plane=True, auto_add_lighting=True) as sim: with build_simulation_context(device=device, add_ground_plane=True, auto_add_lighting=True) as sim:
cube_object, origins = generate_cubes_scene(num_cubes=num_cubes, device=device) cube_object, origins = generate_cubes_scene(num_cubes=num_cubes, device=device)
...@@ -239,6 +242,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -239,6 +242,7 @@ class TestRigidObject(unittest.TestCase):
# Turn off gravity for this test as we don't want any external forces acting on the object # Turn off gravity for this test as we don't want any external forces acting on the object
# to ensure state remains static # to ensure state remains static
with build_simulation_context(device=device, gravity_enabled=False, auto_add_lighting=True) as sim: with build_simulation_context(device=device, gravity_enabled=False, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device)
# Play the simulator # Play the simulator
...@@ -297,6 +301,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -297,6 +301,7 @@ class TestRigidObject(unittest.TestCase):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
with build_simulation_context(device=device, gravity_enabled=True, auto_add_lighting=True) as sim: with build_simulation_context(device=device, gravity_enabled=True, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device)
# Play the simulator # Play the simulator
...@@ -334,7 +339,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -334,7 +339,7 @@ class TestRigidObject(unittest.TestCase):
with build_simulation_context( with build_simulation_context(
device=device, gravity_enabled=True, add_ground_plane=True, auto_add_lighting=True device=device, gravity_enabled=True, add_ground_plane=True, auto_add_lighting=True
) as sim: ) as sim:
# Create rigid object(s) # Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, device=device)
# Play sim # Play sim
...@@ -369,6 +374,7 @@ class TestRigidObject(unittest.TestCase): ...@@ -369,6 +374,7 @@ class TestRigidObject(unittest.TestCase):
for device in ("cuda:0", "cpu"): for device in ("cuda:0", "cpu"):
with self.subTest(num_cubes=num_cubes, device=device): with self.subTest(num_cubes=num_cubes, device=device):
with build_simulation_context(device=device, auto_add_lighting=True) as sim: with build_simulation_context(device=device, auto_add_lighting=True) as sim:
# Generate cubes scene
cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, height=0.0, device=device) cube_object, _ = generate_cubes_scene(num_cubes=num_cubes, height=0.0, device=device)
# Create ground plane with no friction # Create ground plane with no friction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment