Skip to content

[Bug Report] Runtime error when using randomize_joint_parameters event #4050

@GiulioRomualdi

Description

@GiulioRomualdi

Describe the bug

When adding an event using randomize_joint_parameters to randomize actuator parameters at startup, the environment initialization fails with a shape mismatch RuntimeError when writing joint friction coefficients to simulation buffers.

Steps to reproduce

Minimal configuration:

@configclass
class CustomEventsCfg(EventCfg):
    randomize_actuator_parameters = EventTerm(
        func=mdp.randomize_joint_parameters,
        mode="startup",
        params={
            "asset_cfg": SceneEntityCfg("robot"),
            "friction_distribution_params": (0.9, 1.1),
            "armature_distribution_params": (0.9, 1.1),
            "operation": "scale",
            "distribution": "uniform",
        },
    )

The error occurs during environment creation:

RuntimeError: shape mismatch: value tensor of shape [4, 1, 12] 
cannot be broadcast to indexing result of shape [4, 12]

This happens inside:

self.asset.write_joint_friction_coefficient_to_sim(
  ...
  self._data.joint_friction_coeff[env_ids, joint_ids] = joint_friction_coeff

indicating a mismatch between the expected and produced joint parameter tensor shapes.

System Info

Additional context

The failure appears during event_manager.apply(mode="startup").
It seems the randomizer produces a tensor of shape [num_envs, 1, num_joints], but the writer expects shape [num_envs, num_joints]. Possibly missing a squeeze or incorrect broadcast inside randomize_joint_parameters.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Acceptance Criteria

  • The randomize_joint_parameters event runs without errors at startup

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions