• Louis LE LAY's avatar
    Fixes tensor construction warning in `events.py` (#3251) · 649ad88b
    Louis LE LAY authored
    # Description
    
    This PR removes a `UserWarning` from PyTorch about using
    `torch.tensor()` on an existing tensor in `events.py`. It replaces
    `torch.tensor(actuator.joint_indices, device=asset.device)` with
    `.to(device)` to avoid unnecessary copies.
    
    Warning mentionned:
    
    ```bash
    /home/spring/IsaacLab/source/isaaclab/isaaclab/envs/mdp/events.py:542: 
    UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor). actuator_joint_indices = torch.tensor(actuator.joint_indices, device=asset.device)
    ```
    
    ## 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
    
    ---------
    Signed-off-by: 's avatarLouis LE LAY <le.lay.louis@gmail.com>
    Co-authored-by: 's avatarooctipus <zhengyuz@nvidia.com>
    Co-authored-by: 's avatarMayank Mittal <12863862+Mayankm96@users.noreply.github.com>
    649ad88b
Name
Last commit
Last update
..
isaaclab Loading commit data...
isaaclab_assets Loading commit data...
isaaclab_mimic Loading commit data...
isaaclab_rl Loading commit data...
isaaclab_tasks Loading commit data...