Commit 05f5d1eb authored by Mayank Mittal's avatar Mayank Mittal Committed by Mayank Mittal

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
parent c37c50e1
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
noise noise
string string
timer timer
types
warp warp
.. Rubric:: Functions .. Rubric:: Functions
...@@ -123,6 +124,13 @@ Timer operations ...@@ -123,6 +124,13 @@ Timer operations
:members: :members:
:show-inheritance: :show-inheritance:
Type operations
~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.lab.utils.types
:members:
:show-inheritance:
Warp operations Warp operations
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
......
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.27.8" version = "0.27.9"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.27.9 (2024-11-01)
~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added the :class:`omni.isaac.lab.utils.types.ArticulationActions` class to store the joint actions
for an articulation. Earlier, the class from Isaac Sim was being used. However, it used a different
type for the joint actions which was not compatible with the Isaac Lab framework.
0.27.8 (2024-11-01) 0.27.8 (2024-11-01)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
...@@ -91,7 +102,7 @@ Added ...@@ -91,7 +102,7 @@ Added
:attr:`omni.isaac.lab.envs.ManagerBasedRLEnvCfg.commands` as None. Before, this had to be done using :attr:`omni.isaac.lab.envs.ManagerBasedRLEnvCfg.commands` as None. Before, this had to be done using
the class :class:`omni.isaac.lab.command_generators.NullCommandGenerator`. the class :class:`omni.isaac.lab.command_generators.NullCommandGenerator`.
* Moved the ``meshes`` attribute in the :class:`omni.isaac.lab.sensors.RayCaster` class from class variable to instance variable. * Moved the ``meshes`` attribute in the :class:`omni.isaac.lab.sensors.RayCaster` class from class variable to instance variable.
This prevents the meshes to overwrite each other. This prevents the meshes to overwrite each other.
0.26.0 (2024-10-16) 0.26.0 (2024-10-16)
......
...@@ -10,9 +10,8 @@ from abc import ABC, abstractmethod ...@@ -10,9 +10,8 @@ from abc import ABC, abstractmethod
from collections.abc import Sequence from collections.abc import Sequence
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from omni.isaac.core.utils.types import ArticulationActions
import omni.isaac.lab.utils.string as string_utils import omni.isaac.lab.utils.string as string_utils
from omni.isaac.lab.utils.types import ArticulationActions
if TYPE_CHECKING: if TYPE_CHECKING:
from .actuator_cfg import ActuatorBaseCfg from .actuator_cfg import ActuatorBaseCfg
......
...@@ -18,9 +18,8 @@ import torch ...@@ -18,9 +18,8 @@ import torch
from collections.abc import Sequence from collections.abc import Sequence
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from omni.isaac.core.utils.types import ArticulationActions
from omni.isaac.lab.utils.assets import read_file from omni.isaac.lab.utils.assets import read_file
from omni.isaac.lab.utils.types import ArticulationActions
from .actuator_pd import DCMotor from .actuator_pd import DCMotor
......
...@@ -9,9 +9,8 @@ import torch ...@@ -9,9 +9,8 @@ import torch
from collections.abc import Sequence from collections.abc import Sequence
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from omni.isaac.core.utils.types import ArticulationActions
from omni.isaac.lab.utils import DelayBuffer, LinearInterpolation from omni.isaac.lab.utils import DelayBuffer, LinearInterpolation
from omni.isaac.lab.utils.types import ArticulationActions
from .actuator_base import ActuatorBase from .actuator_base import ActuatorBase
...@@ -63,7 +62,22 @@ class ImplicitActuator(ActuatorBase): ...@@ -63,7 +62,22 @@ class ImplicitActuator(ActuatorBase):
def compute( def compute(
self, control_action: ArticulationActions, joint_pos: torch.Tensor, joint_vel: torch.Tensor self, control_action: ArticulationActions, joint_pos: torch.Tensor, joint_vel: torch.Tensor
) -> ArticulationActions: ) -> ArticulationActions:
"""Compute the aproximmate torques for the actuated joint (physX does not compute this explicitly).""" """Process the actuator group actions and compute the articulation actions.
In case of implicit actuator, the control action is directly returned as the computed action.
This function is a no-op and does not perform any computation on the input control action.
However, it computes the approximate torques for the actuated joint since PhysX does not compute
this quantity explicitly.
Args:
control_action: The joint action instance comprising of the desired joint positions, joint velocities
and (feed-forward) joint efforts.
joint_pos: The current joint positions of the joints in the group. Shape is (num_envs, num_joints).
joint_vel: The current joint velocities of the joints in the group. Shape is (num_envs, num_joints).
Returns:
The computed desired joint positions, joint velocities and joint efforts.
"""
# store approximate torques for reward computation # store approximate torques for reward computation
error_pos = control_action.joint_positions - joint_pos error_pos = control_action.joint_positions - joint_pos
error_vel = control_action.joint_velocities - joint_vel error_vel = control_action.joint_velocities - joint_vel
......
...@@ -16,13 +16,13 @@ from typing import TYPE_CHECKING ...@@ -16,13 +16,13 @@ from typing import TYPE_CHECKING
import omni.isaac.core.utils.stage as stage_utils import omni.isaac.core.utils.stage as stage_utils
import omni.log import omni.log
import omni.physics.tensors.impl.api as physx import omni.physics.tensors.impl.api as physx
from omni.isaac.core.utils.types import ArticulationActions
from pxr import PhysxSchema, UsdPhysics from pxr import PhysxSchema, UsdPhysics
import omni.isaac.lab.sim as sim_utils import omni.isaac.lab.sim as sim_utils
import omni.isaac.lab.utils.math as math_utils import omni.isaac.lab.utils.math as math_utils
import omni.isaac.lab.utils.string as string_utils import omni.isaac.lab.utils.string as string_utils
from omni.isaac.lab.actuators import ActuatorBase, ActuatorBaseCfg, ImplicitActuator from omni.isaac.lab.actuators import ActuatorBase, ActuatorBaseCfg, ImplicitActuator
from omni.isaac.lab.utils.types import ArticulationActions
from ..asset_base import AssetBase from ..asset_base import AssetBase
from .articulation_data import ArticulationData from .articulation_data import ArticulationData
......
...@@ -13,3 +13,4 @@ from .interpolation import * ...@@ -13,3 +13,4 @@ from .interpolation import *
from .modifiers import * from .modifiers import *
from .string import * from .string import *
from .timer import Timer from .timer import Timer
from .types import *
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Sub-module for different data types."""
from __future__ import annotations
import torch
from collections.abc import Sequence
from dataclasses import dataclass
@dataclass
class ArticulationActions:
"""Data container to store articulation's joints actions.
This class is used to store the actions of the joints of an articulation.
It is used to store the joint positions, velocities, efforts, and indices.
If the actions are not provided, the values are set to None.
"""
joint_positions: torch.Tensor | None = None
"""The joint positions of the articulation. Defaults to None."""
joint_velocities: torch.Tensor | None = None
"""The joint velocities of the articulation. Defaults to None."""
joint_efforts: torch.Tensor | None = None
"""The joint efforts of the articulation. Defaults to None."""
joint_indices: torch.Tensor | Sequence[int] | slice | None = None
"""The joint indices of the articulation. Defaults to None.
If the joint indices are a slice, this indicates that the indices are continuous and correspond
to all the joints of the articulation. We use a slice to make the indexing more efficient.
"""
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