Skip to content

Conversation

@fan-ziqi
Copy link
Contributor

Description

Fix terrain_out_of_bounds to return tensor instead of bool

Ensure the function always returns a PyTorch tensor (shape [num_envs]) rather than a Python boolean when terrain_type is "plane", preventing AttributeError in termination_manager.

Before:

Error executing job with overrides: []
Traceback (most recent call last):
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab_tasks/isaaclab_tasks/utils/hydra.py", line 101, in hydra_main
    func(env_cfg, agent_cfg, *args, **kwargs)
  File "/home/ubuntu/workspaces/robot_lab/scripts/reinforcement_learning/rsl_rl/train.py", line 165, in main
    runner.learn(num_learning_iterations=agent_cfg.max_iterations, init_at_random_ep_len=True)
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/rsl_rl/runners/on_policy_runner.py", line 206, in learn
    obs, rewards, dones, infos = self.env.step(actions.to(self.env.device))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab_rl/isaaclab_rl/rsl_rl/vecenv_wrapper.py", line 176, in step
    obs_dict, rew, terminated, truncated, extras = self.env.step(actions)
                                                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/gymnasium/wrappers/common.py", line 393, in step
    return super().step(action)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/gymnasium/core.py", line 327, in step
    return self.env.step(action)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab/isaaclab/envs/manager_based_rl_env.py", line 204, in step
    self.reset_buf = self.termination_manager.compute()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab/isaaclab/managers/termination_manager.py", line 172, in compute
    rows = value.nonzero(as_tuple=True)[0]  # indexing is cheaper than boolean advance indexing
           ^^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'nonzero'

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@fan-ziqi fan-ziqi requested a review from Mayankm96 as a code owner August 16, 2025 07:53
@ooctipus ooctipus changed the title Fix terrain_out_of_bounds to return tensor instead of bool Fixes terrain_out_of_bounds to return tensor instead of bool Aug 21, 2025
@Mayankm96 Mayankm96 merged commit 1b2d6ea into isaac-sim:main Aug 28, 2025
6 of 8 checks passed
@Mayankm96
Copy link
Contributor

Thank you for the fix!

george-nehma pushed a commit to george-nehma/DreamLander-IsaacLab that referenced this pull request Oct 24, 2025
…-sim#3180)

# Description

Fix terrain_out_of_bounds to return tensor instead of bool

Ensure the function always returns a PyTorch tensor (shape [num_envs])
rather than a Python boolean when terrain_type is "plane", preventing
AttributeError in termination_manager.

Before:

```bash
Error executing job with overrides: []
Traceback (most recent call last):
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab_tasks/isaaclab_tasks/utils/hydra.py", line 101, in hydra_main
    func(env_cfg, agent_cfg, *args, **kwargs)
  File "/home/ubuntu/workspaces/robot_lab/scripts/reinforcement_learning/rsl_rl/train.py", line 165, in main
    runner.learn(num_learning_iterations=agent_cfg.max_iterations, init_at_random_ep_len=True)
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/rsl_rl/runners/on_policy_runner.py", line 206, in learn
    obs, rewards, dones, infos = self.env.step(actions.to(self.env.device))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab_rl/isaaclab_rl/rsl_rl/vecenv_wrapper.py", line 176, in step
    obs_dict, rew, terminated, truncated, extras = self.env.step(actions)
                                                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/gymnasium/wrappers/common.py", line 393, in step
    return super().step(action)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/miniconda3/envs/lab/lib/python3.11/site-packages/gymnasium/core.py", line 327, in step
    return self.env.step(action)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab/isaaclab/envs/manager_based_rl_env.py", line 204, in step
    self.reset_buf = self.termination_manager.compute()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/workspaces/IsaacLab/source/isaaclab/isaaclab/managers/termination_manager.py", line 172, in compute
    rows = value.nonzero(as_tuple=True)[0]  # indexing is cheaper than boolean advance indexing
           ^^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'nonzero'
```

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Co-authored-by: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants