Skip to content

Commit 05f5d1e

Browse files
committed
Adds ArticulationActions type to the core framework (#1292)
Earlier, we were depending on Isaac Sim's for the articulation action type. The type-hinting for the attributes in there used numpy and list. However, the Isaac Lab framework uses torch tensors everywhere so this led to pylance complaining about the types. The MR makes a drop in replacement with the correct types for our usecases. - New feature (non-breaking change which adds functionality) - [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 c37c50e commit 05f5d1e

File tree

9 files changed

+81
-10
lines changed

9 files changed

+81
-10
lines changed

docs/source/api/lab/omni.isaac.lab.utils.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
noise
1919
string
2020
timer
21+
types
2122
warp
2223

2324
.. Rubric:: Functions
@@ -123,6 +124,13 @@ Timer operations
123124
:members:
124125
:show-inheritance:
125126

127+
Type operations
128+
~~~~~~~~~~~~~~~
129+
130+
.. automodule:: omni.isaac.lab.utils.types
131+
:members:
132+
:show-inheritance:
133+
126134
Warp operations
127135
~~~~~~~~~~~~~~~
128136

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.27.8"
4+
version = "0.27.9"
55

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

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
---------
33

4+
0.27.9 (2024-11-01)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Added
8+
^^^^^
9+
10+
* Added the :class:`omni.isaac.lab.utils.types.ArticulationActions` class to store the joint actions
11+
for an articulation. Earlier, the class from Isaac Sim was being used. However, it used a different
12+
type for the joint actions which was not compatible with the Isaac Lab framework.
13+
14+
415
0.27.8 (2024-11-01)
516
~~~~~~~~~~~~~~~~~~~
617

@@ -91,7 +102,7 @@ Added
91102
:attr:`omni.isaac.lab.envs.ManagerBasedRLEnvCfg.commands` as None. Before, this had to be done using
92103
the class :class:`omni.isaac.lab.command_generators.NullCommandGenerator`.
93104
* Moved the ``meshes`` attribute in the :class:`omni.isaac.lab.sensors.RayCaster` class from class variable to instance variable.
94-
This prevents the meshes to overwrite each other.
105+
This prevents the meshes to overwrite each other.
95106

96107

97108
0.26.0 (2024-10-16)

source/extensions/omni.isaac.lab/omni/isaac/lab/actuators/actuator_base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
from collections.abc import Sequence
1111
from typing import TYPE_CHECKING
1212

13-
from omni.isaac.core.utils.types import ArticulationActions
14-
1513
import omni.isaac.lab.utils.string as string_utils
14+
from omni.isaac.lab.utils.types import ArticulationActions
1615

1716
if TYPE_CHECKING:
1817
from .actuator_cfg import ActuatorBaseCfg

source/extensions/omni.isaac.lab/omni/isaac/lab/actuators/actuator_net.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
from collections.abc import Sequence
1919
from typing import TYPE_CHECKING
2020

21-
from omni.isaac.core.utils.types import ArticulationActions
22-
2321
from omni.isaac.lab.utils.assets import read_file
22+
from omni.isaac.lab.utils.types import ArticulationActions
2423

2524
from .actuator_pd import DCMotor
2625

source/extensions/omni.isaac.lab/omni/isaac/lab/actuators/actuator_pd.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
from collections.abc import Sequence
1010
from typing import TYPE_CHECKING
1111

12-
from omni.isaac.core.utils.types import ArticulationActions
13-
1412
from omni.isaac.lab.utils import DelayBuffer, LinearInterpolation
13+
from omni.isaac.lab.utils.types import ArticulationActions
1514

1615
from .actuator_base import ActuatorBase
1716

@@ -63,7 +62,22 @@ def reset(self, *args, **kwargs):
6362
def compute(
6463
self, control_action: ArticulationActions, joint_pos: torch.Tensor, joint_vel: torch.Tensor
6564
) -> ArticulationActions:
66-
"""Compute the aproximmate torques for the actuated joint (physX does not compute this explicitly)."""
65+
"""Process the actuator group actions and compute the articulation actions.
66+
67+
In case of implicit actuator, the control action is directly returned as the computed action.
68+
This function is a no-op and does not perform any computation on the input control action.
69+
However, it computes the approximate torques for the actuated joint since PhysX does not compute
70+
this quantity explicitly.
71+
72+
Args:
73+
control_action: The joint action instance comprising of the desired joint positions, joint velocities
74+
and (feed-forward) joint efforts.
75+
joint_pos: The current joint positions of the joints in the group. Shape is (num_envs, num_joints).
76+
joint_vel: The current joint velocities of the joints in the group. Shape is (num_envs, num_joints).
77+
78+
Returns:
79+
The computed desired joint positions, joint velocities and joint efforts.
80+
"""
6781
# store approximate torques for reward computation
6882
error_pos = control_action.joint_positions - joint_pos
6983
error_vel = control_action.joint_velocities - joint_vel

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import omni.isaac.core.utils.stage as stage_utils
1717
import omni.log
1818
import omni.physics.tensors.impl.api as physx
19-
from omni.isaac.core.utils.types import ArticulationActions
2019
from pxr import PhysxSchema, UsdPhysics
2120

2221
import omni.isaac.lab.sim as sim_utils
2322
import omni.isaac.lab.utils.math as math_utils
2423
import omni.isaac.lab.utils.string as string_utils
2524
from omni.isaac.lab.actuators import ActuatorBase, ActuatorBaseCfg, ImplicitActuator
25+
from omni.isaac.lab.utils.types import ArticulationActions
2626

2727
from ..asset_base import AssetBase
2828
from .articulation_data import ArticulationData

source/extensions/omni.isaac.lab/omni/isaac/lab/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
from .modifiers import *
1414
from .string import *
1515
from .timer import Timer
16+
from .types import *
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
"""Sub-module for different data types."""
7+
8+
from __future__ import annotations
9+
10+
import torch
11+
from collections.abc import Sequence
12+
from dataclasses import dataclass
13+
14+
15+
@dataclass
16+
class ArticulationActions:
17+
"""Data container to store articulation's joints actions.
18+
19+
This class is used to store the actions of the joints of an articulation.
20+
It is used to store the joint positions, velocities, efforts, and indices.
21+
22+
If the actions are not provided, the values are set to None.
23+
"""
24+
25+
joint_positions: torch.Tensor | None = None
26+
"""The joint positions of the articulation. Defaults to None."""
27+
28+
joint_velocities: torch.Tensor | None = None
29+
"""The joint velocities of the articulation. Defaults to None."""
30+
31+
joint_efforts: torch.Tensor | None = None
32+
"""The joint efforts of the articulation. Defaults to None."""
33+
34+
joint_indices: torch.Tensor | Sequence[int] | slice | None = None
35+
"""The joint indices of the articulation. Defaults to None.
36+
37+
If the joint indices are a slice, this indicates that the indices are continuous and correspond
38+
to all the joints of the articulation. We use a slice to make the indexing more efficient.
39+
"""

0 commit comments

Comments
 (0)