isaac-sim / IsaacLab

Unified framework for robot learning built on NVIDIA Isaac Sim
https://isaac-sim.github.io/IsaacLab
Other
1.62k stars 526 forks source link

[Question] Only during training, encounter "PhysX error: PxRigidBody::setMass(): mass must be non-negative!" despite non-negative/non-zero masses #518

Closed Easternspork closed 1 month ago

Easternspork commented 1 month ago

Quesiton

During training only, I encounter a PhysX error: PxRigidBody::setMass(): mass must be non-negative! error despite having non-negative/non-zero masses. The training does start, however, but the mean episode length is 1, so no there is no training being done, and thus I am assuming that this is the culprit.

I have tried to isolate the issue by creating a seperate scene with all of the same configs as the training environment and running it, and I have no issues running there. (So I assume this is not an issue with my configs/USD file?)

Please let me know if this is a Isaac Sim bug instead, so I can ask in their forums - however because it only occurs during training, I am suspecting it is an issue with Isaac Sim.

Steps to reproduce

Because of such a vague error message, I can't really trace it to anything, so I'm having a hard time coming up with a minimal example, so I have listed the output, USD files, as well as some code snippets that are maybe relevant to the issue. Please let me know if there are other pieces of code/outputs I should submit.

terminal_out.txt mistletoe_usd.zip

Articulation Config

HAA_ACTUATOR_CFG = DCMotorCfg(
    joint_names_expr=[".*HAA"],
    saturation_effort=24,
    effort_limit=24,
    velocity_limit=7.5,
    stiffness={".*": 40.0},
    damping={".*": 5.0},
)

KFE_ACTUATOR_CFG = DCMotorCfg(
    joint_names_expr=[".*KFE"],
    saturation_effort=9,
    effort_limit=9,
    velocity_limit=7.5,
    stiffness={".*": 40.0},
    damping={".*": 5.0},
)

HFE_ACTUATOR_CFG = DCMotorCfg(
    joint_names_expr=[".*HFE"],
    saturation_effort=9,
    effort_limit=9,
    velocity_limit=7.5,
    stiffness={".*": 40.0},
    damping={".*": 5.0},
)

#Articulation Configs

MISTLETOE_CFG = ArticulationCfg(
    spawn=sim_utils.UsdFileCfg(
        usd_path= dirname + '/assets/mistletoe_usd/mistletoe.usd',

        # Adapted from Anymal Velocity Tracking Example's Config
        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=1000.0,
            max_angular_velocity=1000.0,
            max_depenetration_velocity=1.0,
        ),

        articulation_props=sim_utils.ArticulationRootPropertiesCfg(
            enabled_self_collisions=True, solver_position_iteration_count=4, solver_velocity_iteration_count=0
        ),

    ),
    init_state=ArticulationCfg.InitialStateCfg(
        pos=(0.0, 0.0, 0.15),
        joint_pos={
            ".*HAA": 0.0,  # all HAA
            "LEG_[14]_HFE": 0.8,  # both front HFE
            "LEG_[23]_HFE": -0.8,  # both hind HFE
            "LEG_[23]_KFE": -0.8,  # both front KFE
            "LEG_[14]_KFE": 0.8,  # both hind KFE
        },
    ),

    actuators={
        "HAA": HAA_ACTUATOR_CFG,
        "HFE": HFE_ACTUATOR_CFG,
        "KFE": KFE_ACTUATOR_CFG
    },

    soft_joint_pos_limit_factor=0.95
)

Environment Config

@configclass
class MistletoeRoughEnvCfg(LocomotionVelocityRoughEnvCfg):
    def __post_init__(self):
        # post init of parent
        super().__post_init__()
        # switch robot to anymal-c
        self.scene.robot = MISTLETOE_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")

@configclass
class MistletoeRoughEnvCfg_PLAY(MistletoeRoughEnvCfg):
    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
        # 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

        # disable randomization for play
        self.observations.policy.enable_corruption = False
        # remove random pushing event
        self.events.base_external_force_torque = None
        self.events.push_robot = None

rsl_rl_cfg

class MistletoeRoughPPORunnerCfg(RslRlOnPolicyRunnerCfg):
    num_steps_per_env = 24
    max_iterations = 1500
    save_interval = 50
    experiment_name = "mistloe_rough"
    empirical_normalization = False
    policy = RslRlPpoActorCriticCfg(
        init_noise_std=1.0,
        actor_hidden_dims=[512, 256, 128],
        critic_hidden_dims=[512, 256, 128],
        activation="elu",
    )
    algorithm = RslRlPpoAlgorithmCfg(
        value_loss_coef=1.0,
        use_clipped_value_loss=True,
        clip_param=0.2,
        entropy_coef=0.005,
        num_learning_epochs=5,
        num_mini_batches=4,
        learning_rate=1.0e-3,
        schedule="adaptive",
        gamma=0.99,
        lam=0.95,
        desired_kl=0.01,
        max_grad_norm=1.0,
    )

System Info

Describe the characteristic of your environment:

Additional context

The code I wrote is very similar to that of Anymal's environment, but running Anymal's environment seems to work, but mine doesn't.

Checklist

Easternspork commented 1 month ago

Stupid mistake - the mass distribution parameter for randomizing rigid body mass was too large, causing the mass to be negative.