[Question] How to get the randomized friction, base mass and push velocity in ObsTerm as privileged information for manager-based workflow? #1154
Replies: 3 comments
-
Hello, thanks for the question! Your proposed approach makes sense to me. If you would like to cache the results of friction and mass, a workaround would be to cache the results in the env and simply return the cached buffers in future calls. Although I would recommend your current implementation as a cleaner approach. |
Beta Was this translation helpful? Give feedback.
-
Hi, is there more info about get_material_properties()? I wonder why torch.mean is used to get the friction? How to get the friction of a specific body of an articulation? |
Beta Was this translation helpful? Give feedback.
-
The whole idea of manager-based is to have self-containerized snippets of code that can be shared and resued across projects. You can make your own manager term class for observations where you cache these values at init. This is what I do for my use-case: # Copyright (c) 2022-2024, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from __future__ import annotations
import torch
from typing import TYPE_CHECKING
import omni.usd
from pxr import UsdGeom, Gf, Usd
from omni.isaac.lab.managers import SceneEntityCfg, ManagerTermBase, ObservationTermCfg
from omni.isaac.lab.assets import RigidObject
import omni.isaac.lab.sim as sim_utils
if TYPE_CHECKING:
from omni.isaac.lab.envs import ManagerBasedRLEnv
class asset_mass(ManagerTermBase):
"""Provides the mass of the asset."""
def __init__(self, cfg: ObservationTermCfg, env: ManagerBasedRLEnv):
super().__init__(cfg, env)
# extract the used quantities (to enable type-hinting)
self.asset_cfg: SceneEntityCfg = cfg.params["asset_cfg"]
self.asset: RigidObject = env.scene[self.asset_cfg.name]
if not isinstance(self.asset, RigidObject):
raise ValueError(
f"Observation term {self.__class__.__name__} expects a RigidObject asset, but got {type(self.asset)}"
)
# parse scale of the object
self.mass = self.asset.root_physx_view.get_masses()[:, asset_cfg.body_ids].to(env.device)
def __call__(self, env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg) -> torch.Tensor:
return self.mass Note: Above will not work if you randomize masses at every few iterations (i.e. event for randomizing masses is anything but |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
Hello, first of all thanks for your amazing framework.
I'm currently working on asymmetric actor-critic architectures using manager-based workflow. In CriticCfg(ObsGroup) class, I add two ObsTerm w.r.t. the static friction and base mass as
In the implementation, I use the phyx api to get the friction and mass infomation as
I wonder if is the best way to do this since the
physics_material
andadd_base_mass
event are mode of "startup", there is no need to query the material properties and mass each time.What's more, for the random pushes with
push_by_setting_velocity
, whether it's right to just get theroot_lin_vel_w
androot_ang_vel_w
as the privileged state:Beta Was this translation helpful? Give feedback.
All reactions