Skip to content
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

[Question] ValueError: No contact sensors added to the prim: '/World/envs/env_0/Robot'. This means that no rigid bodies are present under this prim. Please check the prim path. #1536

Open
jh-s5974 opened this issue Dec 13, 2024 · 2 comments

Comments

@jh-s5974
Copy link

jh-s5974 commented Dec 13, 2024

./isaaclab.sh -p source/standalone/workflows/rsl_rl/train.py --task Isaac-Velocity-Rough-robotnl-v0

i use this commend.

2024-12-13 08:17:52 [12,356ms] [Warning] [omni.usd] Warning: in _ReportErrors at line 2890 of /builds/omniverse/usd-ci/USD/pxr/usd/usd/stage.cpp -- In </World/envs/env_0/Robot>: Unresolved reference prim path @/home/jh/IsaacLab/source/extensions/omni.isaac.lab_assets/data/Robots/robot_nl/robot_nl.usd@<defaultPrim> introduced by @anon:0x378b0450:World0.usd@</World/envs/env_0/Robot> (recomposing stage on stage @anon:0x378b0450:World0.usd@ <0x35df3b60>)

2024-12-13 08:17:52 [12,393ms] [Warning] [omni.isaac.lab.sim.utils] Could not perform 'modify_rigid_body_properties' on any prims under: '/World/envs/env_0/Robot'. This might be because of the following reasons:
	(1) The desired attribute does not exist on any of the prims.
	(2) The desired attribute exists on an instanced prim.
		Discovered list of instanced prim paths: []
2024-12-13 08:17:52 [12,393ms] [Warning] [omni.isaac.lab.sim.utils] Could not perform 'modify_articulation_root_properties' on any prims under: '/World/envs/env_0/Robot'. This might be because of the following reasons:
	(1) The desired attribute does not exist on any of the prims.
	(2) The desired attribute exists on an instanced prim.
		Discovered list of instanced prim paths: []
[INFO]: Time taken for scene creation : 0.040183 seconds
Error executing job with overrides: []
Traceback (most recent call last):
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab_tasks/omni/isaac/lab_tasks/utils/hydra.py", line 99, in hydra_main
    func(env_cfg, agent_cfg, *args, **kwargs)
  File "/home/jh/IsaacLab/source/standalone/workflows/rsl_rl/train.py", line 101, in main
    env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)
  File "/home/jh/.local/share/ov/pkg/isaac-sim-4.2.0/exts/omni.isaac.ml_archive/pip_prebundle/gymnasium/envs/registration.py", line 802, in make
    env = env_creator(**env_spec_kwargs)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/manager_based_rl_env.py", line 75, in __init__
    super().__init__(cfg=cfg)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/envs/manager_based_env.py", line 121, in __init__
    self.scene = InteractiveScene(self.cfg.scene)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/scene/interactive_scene.py", line 150, in __init__
    self._add_entities_from_cfg()
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/scene/interactive_scene.py", line 584, in _add_entities_from_cfg
    self._articulations[asset_name] = asset_cfg.class_type(asset_cfg)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/assets/articulation/articulation.py", line 99, in __init__
    super().__init__(cfg)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/assets/asset_base.py", line 77, in __init__
    self.cfg.spawn.func(
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/utils.py", line 276, in wrapper
    schemas.activate_contact_sensors(prim_paths[0], cfg.activate_contact_sensors)
  File "/home/jh/IsaacLab/source/extensions/omni.isaac.lab/omni/isaac/lab/sim/schemas/schemas.py", line 517, in activate_contact_sensors
    raise ValueError(
ValueError: No contact sensors added to the prim: '/World/envs/env_0/Robot'. This means that no rigid bodies are present under this prim. Please check the prim path.

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

but, i got this error.
and scene is shutdown.

how can i solve this error.

my code is this.
i copied and used h1 code in isaaclab.

robotnl.py

from __future__ import annotations

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.actuators import ImplicitActuatorCfg
from omni.isaac.lab.assets.articulation import ArticulationCfg

robotnl_CFG = ArticulationCfg(
    spawn=sim_utils.UsdFileCfg(
        usd_path="/home/jh/IsaacLab/source/extensions/omni.isaac.lab_assets/data/Robots/robot_nl/robot_nl.usd",
        activate_contact_sensors=True,
        rigid_props=sim_utils.RigidBodyPropertiesCfg(
            disable_gravity=False,
            retain_accelerations=False,
            linear_damping=0.0,
            angular_damping=0.0,
            max_linear_velocity=100.0,
            max_angular_velocity=100.0,
            max_depenetration_velocity=1.0,
        ),
        articulation_props=sim_utils.ArticulationRootPropertiesCfg(
            enabled_self_collisions=False, solver_position_iteration_count=4, solver_velocity_iteration_count=4
        ),
    ),
    init_state=ArticulationCfg.InitialStateCfg(
        pos=(0.0, 0.0, 0.8),
        joint_pos={
            'left_hip_yaw':0,
            'left_hip_roll':0,
            'left_hip_pitch':0,
            'left_knee':0,
            'left_ankle_pitch':0,
            'left_ankle_roll':0,

            'right_hip_yaw':0,
            'right_hip_roll':0,
            'right_hip_pitch':0,
            'right_knee':0,
            'right_ankle_pitch':0,
            'right_ankle_roll':0,
        },
        joint_vel={".*": 0.0},
    ),
    soft_joint_pos_limit_factor=0.9,
    actuators={
        "hips": ImplicitActuatorCfg(
            joint_names_expr=[".*_hip_yaw", ".*_hip_roll"],
            effort_limit=30.0,
            velocity_limit=4.188790204786399,
            stiffness={
                '.*_hip_yaw': 240.0, 
                '.*-hip_roll': 240.0
            },
            damping={
                '.*_hip_yaw': 5., 
                '.*_hip_roll': 5.
            },
        ),
        "pitchs": ImplicitActuatorCfg(
            joint_names_expr=[".*_hip_pitch", ".*_knee"],
            effort_limit=50.0,
            velocity_limit=5.236,
            stiffness={
                '.*_hip_pitch': 100., 
                '.*_knee': 15.
            },
            damping={
                '.*_hip_pitch': 2.5, 
                '.*_knee': 1.1
            },
        ),
        "toes": ImplicitActuatorCfg(
            joint_names_expr=[".*_ankle_pitch", ".*_ankle_roll"],
            effort_limit=8,
            velocity_limit=41.88790204786399,
            stiffness={
                '.*_ankle_pitch': 10.,
                '.*_ankle_roll': 10.
            },
            damping={
                '.*_ankle_pitch': 1,
                '.*_ankle_roll': 1
            },
        ),
    },
)

robotnl_env.py

from __future__ import annotations

import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.assets import ArticulationCfg
from omni.isaac.lab.envs import DirectRLEnvCfg
from omni.isaac.lab.scene import InteractiveSceneCfg
from omni.isaac.lab.sim import SimulationCfg
from omni.isaac.lab.terrains import TerrainImporterCfg
from omni.isaac.lab.utils import configclass

from omni.isaac.lab_tasks.direct.locomotion.locomotion_env import LocomotionEnv

from omni.isaac.lab_assets import robotnl_CFG

@configclass
class robotnlEnvCfg(DirectRLEnvCfg):
    # env
    episode_length_s = 15.0
    decimation = 2
    action_scale = 1.0
    action_space = 19
    observation_space = 69
    state_space = 0

    # simulation
    sim: SimulationCfg = SimulationCfg(dt=1 / 120, render_interval=decimation)
    terrain = TerrainImporterCfg(
        prim_path="/World/ground",
        terrain_type="plane",
        collision_group=-1,
        physics_material=sim_utils.RigidBodyMaterialCfg(
            friction_combine_mode="average",
            restitution_combine_mode="average",
            static_friction=1.0,
            dynamic_friction=1.0,
            restitution=0.0,
        ),
        debug_vis=False,
    )

    # scene
    scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=4.0, replicate_physics=True)

    # robot
    robot: ArticulationCfg = robotnl_CFG.replace(prim_path="/World/envs/env_.*/Robot")
    
    joint_gears: list = [
        36.0,  # 'hip_yaw_left'
        36.0,  # 'hip_roll_left'
        36.0,  # 'hip_pitch_left'
        36.0,  # 'knee_left'
        6.0 ,  # 'ankle_pitch_left'
        6.0 ,  # 'ankle_roll_left'
        36.0,  # 'hip_yaw_right'
        36.0,  # 'hip_roll_right'
        36.0,  # 'hip_pitch_right'
        36.0,  # 'knee_right'
        6.0 ,  # 'ankle_pitch_right'
        6.0 ,  # 'ankle_roll_right'
    ]

    heading_weight: float = 0.5
    up_weight: float = 0.1

    energy_cost_scale: float = 0.05
    actions_cost_scale: float = 0.01
    alive_reward_scale: float = 2.0
    dof_vel_scale: float = 0.1

    death_cost: float = -1.0
    termination_height: float = 0.8

    angular_velocity_scale: float = 0.25
    contact_force_scale: float = 0.01


class robotnlEnv(LocomotionEnv):
    cfg: robotnlEnvCfg

    def __init__(self, cfg: robotnlEnvCfg, render_mode: str | None = None, **kwargs):
        super().__init__(cfg, render_mode, **kwargs)

rough_env_cfg.py

from omni.isaac.lab.managers import RewardTermCfg as RewTerm
from omni.isaac.lab.managers import SceneEntityCfg
from omni.isaac.lab.utils import configclass

import omni.isaac.lab_tasks.manager_based.locomotion.velocity.mdp as mdp
from omni.isaac.lab_tasks.manager_based.locomotion.velocity.velocity_env_cfg import (
    LocomotionVelocityRoughEnvCfg,
    RewardsCfg,
)

from omni.isaac.lab_assets import robotnl_CFG

@configclass
class robotnlRewards(RewardsCfg):
    """Reward terms for the MDP."""

    termination_penalty = RewTerm(func=mdp.is_terminated, weight=-200.0)
    lin_vel_z_l2 = None
    track_lin_vel_xy_exp = RewTerm(
        func=mdp.track_lin_vel_xy_yaw_frame_exp,
        weight=1.0,
        params={"command_name": "base_velocity", "std": 0.5},
    )
    track_ang_vel_z_exp = RewTerm(
        func=mdp.track_ang_vel_z_world_exp, weight=1.0, params={"command_name": "base_velocity", "std": 0.5}
    )
    feet_air_time = RewTerm(
        func=mdp.feet_air_time_positive_biped,
        weight=0.25,
        params={
            "command_name": "base_velocity",
            "sensor_cfg": SceneEntityCfg("contact_forces", body_names=".*foot_link"),
            "threshold": 0.4,
        },
    )
    feet_slide = RewTerm(
        func=mdp.feet_slide,
        weight=-0.25,
        params={
            "sensor_cfg": SceneEntityCfg("contact_forces", body_names=".*foot_link"),
            "asset_cfg": SceneEntityCfg("robot", body_names=".*foot_link"),
        },
    )
    # Penalize ankle joint limits
    dof_pos_limits = RewTerm(
        func=mdp.joint_pos_limits, weight=-1.0, params={"asset_cfg": SceneEntityCfg("robot", joint_names=".*_ankle_pitch")}
    )
    # Penalize deviation from default of the joints that are not essential for locomotion
    joint_deviation_hip = RewTerm(
        func=mdp.joint_deviation_l1,
        weight=-0.2,
        params={"asset_cfg": SceneEntityCfg("robot", joint_names=[".*_hip_yaw", ".*_hip_roll"])},
    )
    joint_deviation_torso = RewTerm(
        func=mdp.joint_deviation_l1, weight=-0.1, params={"asset_cfg": SceneEntityCfg("robot", joint_names="base")}
    )


@configclass
class robotnlRoughEnvCfg(LocomotionVelocityRoughEnvCfg):
    rewards: robotnlRewards = robotnlRewards()

    def __post_init__(self):
        # post init of parent
        super().__post_init__()
        # Scene
        self.scene.robot = robotnl_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
        if self.scene.height_scanner:
            self.scene.height_scanner.prim_path = "{ENV_REGEX_NS}/Robot/base_link"

        # Randomization
        self.events.push_robot = None
        self.events.add_base_mass = None
        self.events.reset_robot_joints.params["position_range"] = (1.0, 1.0)
        self.events.base_external_force_torque.params["asset_cfg"].body_names = [".*base_link"]
        self.events.reset_base.params = {
            "pose_range": {"x": (-0.5, 0.5), "y": (-0.5, 0.5), "yaw": (-3.14, 3.14)},
            "velocity_range": {
                "x": (0.0, 0.0),
                "y": (0.0, 0.0),
                "z": (0.0, 0.0),
                "roll": (0.0, 0.0),
                "pitch": (0.0, 0.0),
                "yaw": (0.0, 0.0),
            },
        }

        # Terminations
        self.terminations.base_contact.params["sensor_cfg"].body_names = [".*base_link"]

        # Rewards
        self.rewards.undesired_contacts = None
        self.rewards.flat_orientation_l2.weight = -1.0
        self.rewards.dof_torques_l2.weight = 0.0
        self.rewards.action_rate_l2.weight = -0.005
        self.rewards.dof_acc_l2.weight = -1.25e-7

        # Commands
        self.commands.base_velocity.ranges.lin_vel_x = (0.0, 1.0)
        self.commands.base_velocity.ranges.lin_vel_y = (0.0, 0.0)
        self.commands.base_velocity.ranges.ang_vel_z = (-1.0, 1.0)

        # terminations
        self.terminations.base_contact.params["sensor_cfg"].body_names = ".*base_link"


@configclass
class robotnlRoughEnvCfg_PLAY(robotnlRoughEnvCfg):
    def __post_init__(self):
        # post init of parent
        super().__post_init__()

        # make a smaller scene for play
        self.scene.num_envs = 50
        self.scene.env_spacing = 2.5
        self.episode_length_s = 40.0
        # spawn the robot randomly in the grid (instead of their terrain levels)
        self.scene.terrain.max_init_terrain_level = None
        # reduce the number of terrains to save memory
        if self.scene.terrain.terrain_generator is not None:
            self.scene.terrain.terrain_generator.num_rows = 5
            self.scene.terrain.terrain_generator.num_cols = 5
            self.scene.terrain.terrain_generator.curriculum = False

        self.commands.base_velocity.ranges.lin_vel_x = (1.0, 1.0)
        self.commands.base_velocity.ranges.lin_vel_y = (0.0, 0.0)
        self.commands.base_velocity.ranges.ang_vel_z = (-1.0, 1.0)
        self.commands.base_velocity.ranges.heading = (0.0, 0.0)
        # disable randomization for play
        self.observations.policy.enable_corruption = False
        # remove random pushing
        self.events.base_external_force_torque = None
        self.events.push_robot = None

flat_env_cfg.py

# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

from omni.isaac.lab.utils import configclass

from .rough_env_cfg import robotnlRoughEnvCfg


@configclass
class robotnlFlatEnvCfg(robotnlRoughEnvCfg):
    def __post_init__(self):
        # post init of parent
        super().__post_init__()

        # change terrain to flat
        self.scene.terrain.terrain_type = "plane"
        self.scene.terrain.terrain_generator = None
        # no height scan
        self.scene.height_scanner = None
        self.observations.policy.height_scan = None
        # no terrain curriculum
        self.curriculum.terrain_levels = None
        self.rewards.feet_air_time.weight = 1.0
        self.rewards.feet_air_time.params["threshold"] = 0.6


class robotnlFlatEnvCfg_PLAY(robotnlFlatEnvCfg):
    def __post_init__(self) -> None:
        # post init of parent
        super().__post_init__()

        # make a smaller scene for play
        self.scene.num_envs = 50
        self.scene.env_spacing = 2.5
        # disable randomization for play
        self.observations.policy.enable_corruption = False
        # remove random pushing
        self.events.base_external_force_torque = None
        self.events.push_robot = None

Thank you.

@jh-s5974
Copy link
Author

my robot link and joint is this.

table

@ozhanozen
Copy link
Contributor

Is the "robot_nl.usd" file your own asset? It seems there might be an issue with it. The initial warnings, such as Could not perform 'modify_rigid_body_properties'/'modify_articulation_root_properties', suggest that some settings are not being correctly applied.

Could you verify the following for the "robot_nl.usd" file in Isaac Sim?

  1. Ensure that all Xforms with the _link postfix have a rigid body attached and are not instanceable.
  2. Confirm that the robotnl parent Xform has an articulation root attached, and that no other prims have an articulation root.
  3. Choose robotnl default prim to make sure it is the one imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants