Skip to content

Commit c05a279

Browse files
Mayankm96mohanksriram
authored andcommitted
Removes the use of body view inside the asset classes (isaac-sim#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 isaac-sim#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
1 parent a7f486e commit c05a279

File tree

7 files changed

+52
-130
lines changed

7 files changed

+52
-130
lines changed

docs/source/setup/installation/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Installation Guide
1919

2020
.. caution::
2121

22-
We have dropped support for Isaac Sim versions 2023.1.0 and below. We recommend using the latest
22+
We have dropped support for Isaac Sim versions 2023.1.1 and below. We recommend using the latest
2323
Isaac Sim 4.0 release to benefit from the latest features and improvements.
2424

2525
For more information, please refer to the

source/extensions/omni.isaac.lab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.18.6"
4+
version = "0.19.0"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/extensions/omni.isaac.lab/docs/CHANGELOG.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Changelog
22
---------
33

4+
0.19.0 (2024-07-04)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Fixed
8+
^^^^^
9+
10+
* Fixed parsing of articulations with nested rigid links while using the :class:`omni.isaac.lab.assets.Articulation`
11+
class. Earlier, the class initialization failed when the articulation had nested rigid links since the rigid
12+
links were not being parsed correctly by the PhysX view.
13+
14+
Removed
15+
^^^^^^^
16+
17+
* Removed the attribute :attr:`body_physx_view` from the :class:`omni.isaac.lab.assets.Articulation` and
18+
:class:`omni.isaac.lab.assets.RigidObject` classes. These were causing confusions when used with articulation
19+
view since the body names were not following the same ordering.
20+
* Dropped support for Isaac Sim 2023.1.1. The minimum supported version is now Isaac Sim 4.0.0.
21+
22+
423
0.18.6 (2024-07-01)
524
~~~~~~~~~~~~~~~~~~~
625

source/extensions/omni.isaac.lab/omni/isaac/lab/assets/articulation/articulation.py

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from __future__ import annotations
1010

1111
import torch
12-
import warnings
1312
from collections.abc import Sequence
1413
from prettytable import PrettyTable
1514
from typing import TYPE_CHECKING
@@ -156,25 +155,6 @@ def root_physx_view(self) -> physx.ArticulationView:
156155
"""
157156
return self._root_physx_view
158157

159-
@property
160-
def body_physx_view(self) -> physx.RigidBodyView:
161-
"""Rigid body view for the asset (PhysX).
162-
163-
.. deprecated:: v0.3.0
164-
165-
In previous versions, this attribute returned the rigid body view over all the links of the articulation.
166-
However, this led to confusion with the link ordering as they were not ordered in the same way as the
167-
articulation view.
168-
169-
Therefore, this attribute will be removed in v0.4.0. Please use the :attr:`root_physx_view` attribute
170-
instead.
171-
172-
"""
173-
dep_msg = "The attribute 'body_physx_view' will be removed in v0.4.0. Please use 'root_physx_view' instead."
174-
warnings.warn(dep_msg, DeprecationWarning)
175-
carb.log_error(dep_msg)
176-
return self._body_physx_view
177-
178158
"""
179159
Operations.
180160
"""
@@ -194,16 +174,8 @@ def write_data_to_sim(self):
194174
If any explicit actuators are present, then the actuator models are used to compute the
195175
joint commands. Otherwise, the joint commands are directly set into the simulation.
196176
"""
197-
# write external wrench
198-
if self.has_external_wrench:
199-
# apply external forces and torques
200-
self._body_physx_view.apply_forces_and_torques_at_position(
201-
force_data=self._external_force_body_view_b.view(-1, 3),
202-
torque_data=self._external_torque_body_view_b.view(-1, 3),
203-
position_data=None,
204-
indices=self._ALL_BODY_INDICES,
205-
is_global=False,
206-
)
177+
# apply external forces and torques
178+
super().write_data_to_sim()
207179

208180
# apply actuator models
209181
self._apply_actuator_model()
@@ -260,24 +232,6 @@ def find_fixed_tendons(
260232
# find tendons
261233
return string_utils.resolve_matching_names(name_keys, tendon_subsets, preserve_order)
262234

263-
"""
264-
Operations - Setters.
265-
"""
266-
267-
def set_external_force_and_torque(
268-
self,
269-
forces: torch.Tensor,
270-
torques: torch.Tensor,
271-
body_ids: Sequence[int] | slice | None = None,
272-
env_ids: Sequence[int] | None = None,
273-
):
274-
# call parent to set the external forces and torques into buffers
275-
super().set_external_force_and_torque(forces, torques, body_ids, env_ids)
276-
# reordering of the external forces and torques to match the body view ordering
277-
if self.has_external_wrench:
278-
self._external_force_body_view_b = self._external_force_b[:, self._body_view_ordering]
279-
self._external_torque_body_view_b = self._external_torque_b[:, self._body_view_ordering]
280-
281235
"""
282236
Operations - Writers.
283237
"""
@@ -332,6 +286,7 @@ def write_joint_state_to_sim(
332286
physx_env_ids = self._ALL_INDICES
333287
if joint_ids is None:
334288
joint_ids = slice(None)
289+
# broadcast env_ids if needed to allow double indexing
335290
if env_ids != slice(None) and joint_ids != slice(None):
336291
env_ids = env_ids[:, None]
337292
# set into internal buffers
@@ -364,6 +319,7 @@ def write_joint_stiffness_to_sim(
364319
physx_env_ids = self._ALL_INDICES
365320
if joint_ids is None:
366321
joint_ids = slice(None)
322+
# broadcast env_ids if needed to allow double indexing
367323
if env_ids != slice(None) and joint_ids != slice(None):
368324
env_ids = env_ids[:, None]
369325
# set into internal buffers
@@ -394,6 +350,7 @@ def write_joint_damping_to_sim(
394350
physx_env_ids = self._ALL_INDICES
395351
if joint_ids is None:
396352
joint_ids = slice(None)
353+
# broadcast env_ids if needed to allow double indexing
397354
if env_ids != slice(None) and joint_ids != slice(None):
398355
env_ids = env_ids[:, None]
399356
# set into internal buffers
@@ -422,6 +379,7 @@ def write_joint_effort_limit_to_sim(
422379
physx_env_ids = self._ALL_INDICES
423380
if joint_ids is None:
424381
joint_ids = slice(None)
382+
# broadcast env_ids if needed to allow double indexing
425383
if env_ids != slice(None) and joint_ids != slice(None):
426384
env_ids = env_ids[:, None]
427385
# move tensor to cpu if needed
@@ -453,6 +411,7 @@ def write_joint_armature_to_sim(
453411
physx_env_ids = self._ALL_INDICES
454412
if joint_ids is None:
455413
joint_ids = slice(None)
414+
# broadcast env_ids if needed to allow double indexing
456415
if env_ids != slice(None) and joint_ids != slice(None):
457416
env_ids = env_ids[:, None]
458417
# set into internal buffers
@@ -480,6 +439,7 @@ def write_joint_friction_to_sim(
480439
physx_env_ids = self._ALL_INDICES
481440
if joint_ids is None:
482441
joint_ids = slice(None)
442+
# broadcast env_ids if needed to allow double indexing
483443
if env_ids != slice(None) and joint_ids != slice(None):
484444
env_ids = env_ids[:, None]
485445
# set into internal buffers
@@ -508,6 +468,7 @@ def write_joint_limits_to_sim(
508468
physx_env_ids = self._ALL_INDICES
509469
if joint_ids is None:
510470
joint_ids = slice(None)
471+
# broadcast env_ids if needed to allow double indexing
511472
if env_ids != slice(None) and joint_ids != slice(None):
512473
env_ids = env_ids[:, None]
513474
# set into internal buffers
@@ -538,6 +499,7 @@ def set_joint_position_target(
538499
env_ids = slice(None)
539500
if joint_ids is None:
540501
joint_ids = slice(None)
502+
# broadcast env_ids if needed to allow double indexing
541503
if env_ids != slice(None) and joint_ids != slice(None):
542504
env_ids = env_ids[:, None]
543505
# set targets
@@ -562,6 +524,7 @@ def set_joint_velocity_target(
562524
env_ids = slice(None)
563525
if joint_ids is None:
564526
joint_ids = slice(None)
527+
# broadcast env_ids if needed to allow double indexing
565528
if env_ids != slice(None) and joint_ids != slice(None):
566529
env_ids = env_ids[:, None]
567530
# set targets
@@ -586,6 +549,7 @@ def set_joint_effort_target(
586549
env_ids = slice(None)
587550
if joint_ids is None:
588551
joint_ids = slice(None)
552+
# broadcast env_ids if needed to allow double indexing
589553
if env_ids != slice(None) and joint_ids != slice(None):
590554
env_ids = env_ids[:, None]
591555
# set targets
@@ -821,24 +785,6 @@ def _initialize_impl(self):
821785
root_prim_path_expr = self.cfg.prim_path + root_prim_path[len(template_prim_path) :]
822786
# -- articulation
823787
self._root_physx_view = self._physics_sim_view.create_articulation_view(root_prim_path_expr.replace(".*", "*"))
824-
# -- link views
825-
# note: we use the root view to get the body names, but we use the body view to get the
826-
# actual data. This is mainly needed to apply external forces to the bodies.
827-
physx_body_names = self.root_physx_view.shared_metatype.link_names
828-
body_names_regex = r"(" + "|".join(physx_body_names) + r")"
829-
body_names_regex = f"{self.cfg.prim_path}/{body_names_regex}"
830-
self._body_physx_view = self._physics_sim_view.create_rigid_body_view(body_names_regex.replace(".*", "*"))
831-
832-
# create ordering from articulation view to body view for body names
833-
# note: we need to do this since the body view is not ordered in the same way as the articulation view
834-
# -- root view
835-
root_view_body_names = self.body_names
836-
# -- body view
837-
prim_paths = self._body_physx_view.prim_paths[: self.num_bodies]
838-
body_view_body_names = [path.split("/")[-1] for path in prim_paths]
839-
# -- mapping from articulation view to body view
840-
self._body_view_ordering = [root_view_body_names.index(name) for name in body_view_body_names]
841-
self._body_view_ordering = torch.tensor(self._body_view_ordering, dtype=torch.long, device=self.device)
842788

843789
# log information about the articulation
844790
carb.log_info(f"Articulation initialized at: {self.cfg.prim_path} with root '{root_prim_path_expr}'.")
@@ -848,9 +794,6 @@ def _initialize_impl(self):
848794
carb.log_info(f"Number of joints: {self.num_joints}")
849795
carb.log_info(f"Joint names: {self.joint_names}")
850796
carb.log_info(f"Number of fixed tendons: {self.num_fixed_tendons}")
851-
# -- assert that parsing was successful
852-
if set(physx_body_names) != set(self.body_names):
853-
raise RuntimeError("Failed to parse all bodies properly in the articulation.")
854797

855798
# container for data access
856799
self._data = ArticulationData(self.root_physx_view, self.device)

source/extensions/omni.isaac.lab/omni/isaac/lab/assets/rigid_object/rigid_object.py

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from __future__ import annotations
77

88
import torch
9-
import warnings
109
from collections.abc import Sequence
1110
from typing import TYPE_CHECKING
1211

@@ -89,20 +88,6 @@ def root_physx_view(self) -> physx.RigidBodyView:
8988
"""
9089
return self._root_physx_view
9190

92-
@property
93-
def body_physx_view(self) -> physx.RigidBodyView:
94-
"""Rigid body view for the asset (PhysX).
95-
96-
.. deprecated:: v0.3.0
97-
98-
The attribute 'body_physx_view' will be removed in v0.4.0. Please use :attr:`root_physx_view` instead.
99-
100-
"""
101-
dep_msg = "The attribute 'body_physx_view' will be removed in v0.4.0. Please use 'root_physx_view' instead."
102-
warnings.warn(dep_msg, DeprecationWarning)
103-
carb.log_error(dep_msg)
104-
return self.root_physx_view
105-
10691
"""
10792
Operations.
10893
"""
@@ -128,7 +113,7 @@ def write_data_to_sim(self):
128113
force_data=self._external_force_b.view(-1, 3),
129114
torque_data=self._external_torque_b.view(-1, 3),
130115
position_data=None,
131-
indices=self._ALL_BODY_INDICES,
116+
indices=self._ALL_INDICES,
132117
is_global=False,
133118
)
134119

@@ -253,26 +238,17 @@ def set_external_force_and_torque(
253238
# resolve all indices
254239
# -- env_ids
255240
if env_ids is None:
256-
env_ids = self._ALL_INDICES
257-
elif not isinstance(env_ids, torch.Tensor):
258-
env_ids = torch.tensor(env_ids, dtype=torch.long, device=self.device)
241+
env_ids = slice(None)
259242
# -- body_ids
260243
if body_ids is None:
261-
body_ids = torch.arange(self.num_bodies, dtype=torch.long, device=self.device)
262-
elif isinstance(body_ids, slice):
263-
body_ids = torch.arange(self.num_bodies, dtype=torch.long, device=self.device)[body_ids]
264-
elif not isinstance(body_ids, torch.Tensor):
265-
body_ids = torch.tensor(body_ids, dtype=torch.long, device=self.device)
266-
267-
# note: we need to do this complicated indexing since torch doesn't support multi-indexing
268-
# create global body indices from env_ids and env_body_ids
269-
# (env_id * total_bodies_per_env) + body_id
270-
indices = body_ids.repeat(len(env_ids), 1) + env_ids.unsqueeze(1) * self.num_bodies
271-
indices = indices.view(-1)
244+
body_ids = slice(None)
245+
# broadcast env_ids if needed to allow double indexing
246+
if env_ids != slice(None) and body_ids != slice(None):
247+
env_ids = env_ids[:, None]
248+
272249
# set into internal buffers
273-
# note: these are applied in the write_to_sim function
274-
self._external_force_b.flatten(0, 1)[indices] = forces.flatten(0, 1)
275-
self._external_torque_b.flatten(0, 1)[indices] = torques.flatten(0, 1)
250+
self._external_force_b[env_ids, body_ids] = forces
251+
self._external_torque_b[env_ids, body_ids] = torques
276252
else:
277253
self.has_external_wrench = False
278254

@@ -332,9 +308,7 @@ def _create_buffers(self):
332308
"""Create buffers for storing data."""
333309
# constants
334310
self._ALL_INDICES = torch.arange(self.num_instances, dtype=torch.long, device=self.device)
335-
self._ALL_BODY_INDICES = torch.arange(
336-
self.root_physx_view.count * self.num_bodies, dtype=torch.long, device=self.device
337-
)
311+
338312
# external forces and torques
339313
self.has_external_wrench = False
340314
self._external_force_b = torch.zeros((self.num_instances, self.num_bodies, 3), device=self.device)

source/extensions/omni.isaac.lab/test/assets/test_articulation.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ def test_initialization_floating_base_non_root(self):
9898
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
9999
self.assertListEqual(prim_path_body_names, robot.body_names)
100100

101-
# Check that the body_physx_view is deprecated
102-
with self.assertWarns(DeprecationWarning):
103-
robot.body_physx_view
104-
105101
# Simulate physics
106102
for _ in range(10):
107103
# perform rendering
@@ -141,10 +137,6 @@ def test_initialization_floating_base(self):
141137
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
142138
self.assertListEqual(prim_path_body_names, robot.body_names)
143139

144-
# Check that the body_physx_view is deprecated
145-
with self.assertWarns(DeprecationWarning):
146-
robot.body_physx_view
147-
148140
# Simulate physics
149141
for _ in range(10):
150142
# perform rendering
@@ -184,10 +176,6 @@ def test_initialization_fixed_base(self):
184176
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
185177
self.assertListEqual(prim_path_body_names, robot.body_names)
186178

187-
# Check that the body_physx_view is deprecated
188-
with self.assertWarns(DeprecationWarning):
189-
robot.body_physx_view
190-
191179
# Simulate physics
192180
for _ in range(10):
193181
# perform rendering
@@ -242,10 +230,6 @@ def test_initialization_fixed_base_single_joint(self):
242230
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
243231
self.assertListEqual(prim_path_body_names, robot.body_names)
244232

245-
# Check that the body_physx_view is deprecated
246-
with self.assertWarns(DeprecationWarning):
247-
robot.body_physx_view
248-
249233
# Simulate physics
250234
for _ in range(10):
251235
# perform rendering
@@ -324,10 +308,6 @@ def test_initialization_floating_base_made_fixed_base(self):
324308
prim_path_body_names = [path.split("/")[-1] for path in robot.root_physx_view.link_paths[0]]
325309
self.assertListEqual(prim_path_body_names, robot.body_names)
326310

327-
# Check that the body_physx_view is deprecated
328-
with self.assertWarns(DeprecationWarning):
329-
robot.body_physx_view
330-
331311
# Root state should be at the default state
332312
robot.write_root_state_to_sim(robot.data.default_root_state.clone())
333313
# Simulate physics

0 commit comments

Comments
 (0)