Skip to content

[Bug Report] Indexing error in reset_joints_by_offset #2948

@Creampelt

Description

@Creampelt

Describe the bug

Calling reset_joints_by_offset causes the following error:

IndexError: shape mismatch: indexing tensors could not be broadcast together with shapes [4096], [28]

Seems to be caused by this PR, so this likely applies to reset_joints_by_scale as well.

Steps to reproduce

To reproduce, add an event term to your task's EventsCfg that calls reset_joints_by_offset:

reset_joints = EventTerm(
      func=mdp.reset_joints_by_offset,
      mode="reset",
      params={
          "asset_cfg": SceneEntityCfg("robot", joint_names=["<joint names>"]),
          "position_range": (-0.05, 0.05),
          "velocity_range": (-1.0, 1.0),
      },
  )

Full stack trace:

Traceback (most recent call last):
  File "/workspace/isaaclab/source/isaaclab_tasks/isaaclab_tasks/utils/hydra.py", line 101, in hydra_main
    func(env_cfg, agent_cfg, *args, **kwargs)
  File "/workspace/isaaclab/source/hcrl_isaaclab/scripts/train.py", line 159, in main
    env = RslRlVecEnvWrapper(env, clip_actions=agent_cfg.clip_actions)  # type: ignore
  File "/workspace/isaaclab/source/isaaclab_rl/isaaclab_rl/rsl_rl/vecenv_wrapper.py", line 85, in __init__
    self.env.reset()
  File "/isaac-sim/kit/python/lib/python3.10/site-packages/gymnasium/wrappers/common.py", line 400, in reset
    return super().reset(seed=seed, options=options)
  File "/isaac-sim/kit/python/lib/python3.10/site-packages/gymnasium/core.py", line 333, in reset
    return self.env.reset(seed=seed, options=options)
  File "/workspace/isaaclab/source/isaaclab/isaaclab/envs/manager_based_env.py", line 295, in reset
    self._reset_idx(env_ids)
  File "/workspace/isaaclab/source/isaaclab/isaaclab/envs/manager_based_rl_env.py", line 361, in _reset_idx
    self.event_manager.apply(mode="reset", env_ids=env_ids, global_env_step_count=env_step_count)
  File "/workspace/isaaclab/source/isaaclab/isaaclab/managers/event_manager.py", line 244, in apply
    term_cfg.func(self._env, env_ids, **term_cfg.params)
  File "/workspace/isaaclab/source/isaaclab/isaaclab/envs/mdp/events.py", line 1082, in reset_joints_by_offset
    joint_pos = asset.data.default_joint_pos[env_ids, asset_cfg.joint_ids].clone()
IndexError: shape mismatch: indexing tensors could not be broadcast together with shapes [4096], [28]

System Info

  • Commit: f22b5eb
  • Isaac Sim Version: 4.5.0-rc.36
  • OS: Ubuntu 22.04
  • GPU: RTX 4090
  • CUDA: 12.9
  • GPU Driver: 575.57.08

Additional context

N/A

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

  • reset_joints_by_offset no longer raises error, but still indexes the correct envs and joints.

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