Skip to content

Adds body_pose_w and body_projected_gravity_b observations #2212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/isaaclab/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.36.23"
version = "0.37.0"

# Description
title = "Isaac Lab framework for Robot Learning"
10 changes: 10 additions & 0 deletions source/isaaclab/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
---------

0.37.0 (2025-04-01)
~~~~~~~~~~~~~~~~~~~

Added
^^^^^

* Added :meth:`~isaaclab.envs.mdp.observations.body_pose_w`
* Added :meth:`~isaaclab.envs.mdp.observations.body_projected_gravity_b`


0.36.23 (2025-04-24)
~~~~~~~~~~~~~~~~~~~~

52 changes: 52 additions & 0 deletions source/isaaclab/isaaclab/envs/mdp/observations.py
Original file line number Diff line number Diff line change
@@ -96,6 +96,58 @@ def root_ang_vel_w(env: ManagerBasedEnv, asset_cfg: SceneEntityCfg = SceneEntity
return asset.data.root_ang_vel_w


"""
Body state
"""


def body_pose_w(
env: ManagerBasedEnv,
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
) -> torch.Tensor:
"""The flattened body poses of the asset w.r.t the env.scene.origin.

Note: Only the bodies configured in :attr:`asset_cfg.body_ids` will have their poses returned.

Args:
env: The environment.
asset_cfg: The SceneEntity associated with this observation.

Returns:
The poses of bodies in articulation [num_env, 7*num_bodies]. Pose order is [x,y,z,qw,qx,qy,qz]. Output is
stacked horizontally per body.
"""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]
pose = asset.data.body_state_w[:, asset_cfg.body_ids, :7]
pose[..., :3] = pose[..., :3] - env.scene.env_origins.unsqueeze(1)
return pose.reshape(env.num_envs, -1)


def body_projected_gravity_b(
env: ManagerBasedEnv,
asset_cfg: SceneEntityCfg = SceneEntityCfg("robot"),
) -> torch.Tensor:
"""The direction of gravity projected on to bodies of an Articulation.

Note: Only the bodies configured in :attr:`asset_cfg.body_ids` will have their poses returned.

Args:
env: The environment.
asset_cfg: The Articulation associated with this observation.

Returns:
The unit vector direction of gravity projected onto body_name's frame. Gravity projection vector order is
[x,y,z]. Output is stacked horizontally per body.
"""
# extract the used quantities (to enable type-hinting)
asset: Articulation = env.scene[asset_cfg.name]

body_quat = asset.data.body_quat_w[:, asset_cfg.body_ids]
gravity_dir = asset.data.GRAVITY_VEC_W.unsqueeze(1)
return math_utils.quat_rotate_inverse(body_quat, gravity_dir).view(env.num_envs, -1)


"""
Joint state.
"""