Skip to content

Conversation

@fan-ziqi
Copy link
Contributor

@fan-ziqi fan-ziqi commented Nov 28, 2024

Description

This PR adds support for action clip to all mdp/actions. Clip ranges can be specified as a dictionary of joint names and tuple for the lower and upper bounds of the clip in the ActionTermCfg.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

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

@jtigue-bdai
Copy link
Collaborator

Currently limits are handled by the actuators. Primarily this is done on the effort.

@fan-ziqi
Copy link
Contributor Author

fan-ziqi commented Dec 5, 2024

So how can I clip actions in isaaclab like in legged_gym?

@jtigue-bdai
Copy link
Collaborator

Hmm I guess if you are using joint position commands the actuator limits won't really handle that. Actuator limits really only do effort.

I will take another look at the current api and get back to you.

@fan-ziqi
Copy link
Contributor Author

fan-ziqi commented Dec 5, 2024

Thanks for reply!
Yes, I use Δjoint_pos as actions

@kellyguo11
Copy link
Contributor

The discussion in this PR may be relevant - #984. This seems like something that would make more sense for the wrappers.

@fan-ziqi
Copy link
Contributor Author

fan-ziqi commented Dec 5, 2024

Which method is better? I don't know if this should be an env feature or an action feature

@jtigue-bdai
Copy link
Collaborator

jtigue-bdai commented Dec 5, 2024

Yeah #984 makes the clip for all actions where this PR will makes the clip configurable for each action separately. To me it makes sense to have the action handle the clipping rather than the environment.

@jtigue-bdai
Copy link
Collaborator

I guess this one only handles the joint_actions.

@fan-ziqi
Copy link
Contributor Author

fan-ziqi commented Dec 5, 2024

For me, this allows more flexibility in configuring each joint individually.

So is this PR necessary?
Should we adopt this or #984?

@kellyguo11
Copy link
Contributor

That's a good point, this could be useful for configuring the joints separately, but only applicable for joint actions. Perhaps there's value in adopting both approaches.

@jtigue-bdai
Copy link
Collaborator

I could see both and also adding the clip configuration at the base ActionTerm/Cfg. It would just require that the actual processing be added to all provided actions.

@jtigue-bdai
Copy link
Collaborator

Hey @fan-ziqi would you be willing to add the clipping cfg to the top level ActionTermCfg, the clip checking in the top level ActionTerm.init , and then add the clipping execution to all the provided actions in the envs/mdp/actions directory?

@fan-ziqi fan-ziqi requested a review from jtigue-bdai as a code owner December 7, 2024 03:45
@fan-ziqi
Copy link
Contributor Author

fan-ziqi commented Dec 7, 2024

I have added clip to ActionTermCfg and added clip action to all mdp/actions

But I have a question, is clip: dict[str, tuple] necessary?

@configclass
class ActionsCfg:
    """Action specifications for the MDP."""

    joint_pos = mdp.JointPositionActionCfg(
        asset_name="robot", joint_names=[".*"], scale=0.5, use_default_offset=True, clip={".*": (-100.0, 100.0)}
    )

or clip: tuple[float, float] is enough

@configclass
class ActionsCfg:
    """Action specifications for the MDP."""

    joint_pos = mdp.JointPositionActionCfg(
        asset_name="robot", joint_names=[".*"], scale=0.5, use_default_offset=True, clip=(-100.0, 100.0)
    )

@jtigue-bdai
Copy link
Collaborator

I think being able to do clip=dict[str,tuple] is necessary to be able to set clips on a per joint basis.

@kellyguo11
Copy link
Contributor

Thanks a lot for the feature! would it be possible to add some unit tests for it as well?

@fan-ziqi
Copy link
Contributor Author

The preprocessing of clip has been moved to init @kellyguo11

@kellyguo11
Copy link
Contributor

The preprocessing of clip has been moved to init @kellyguo11

Thanks! Please also run the formatter and would be great if you can add some tests.

@fan-ziqi
Copy link
Contributor Author

The preprocessing of clip has been moved to init @kellyguo11

Thanks! Please also run the formatter and would be great if you can add some tests.

Code formatter has run.

I am not familiar with the unit testing of this project. If you need me to write one, can you give me a reference?

@kellyguo11
Copy link
Contributor

The preprocessing of clip has been moved to init @kellyguo11

Thanks! Please also run the formatter and would be great if you can add some tests.

Code formatter has run.

I am not familiar with the unit testing of this project. If you need me to write one, can you give me a reference?

Great, thanks! Unit tests are generally implemented here: https://github.com/isaac-sim/IsaacLab/tree/main/source/extensions/omni.isaac.lab/test. We can maybe copy one of the manager ones and apply it to the ActionManager with ActionTerms that have a clipping parameter.

@fan-ziqi
Copy link
Contributor Author

I noticed that there are no unit tests for ActionManager. I'm not familiar with it, and I have other work to handle at the moment, so I think I’ll have to leave it to you to add the tests.

@kellyguo11 kellyguo11 changed the title feat: add clip range of JointAction Adds clip range for JointAction Dec 15, 2024
@kellyguo11 kellyguo11 merged commit ee3f022 into isaac-sim:main Dec 15, 2024
5 checks passed
SevenFo pushed a commit to SevenFo/IsaacLab that referenced this pull request May 19, 2025
# Description

This PR adds support for action clip to all mdp/actions. Clip ranges can
be specified as a dictionary of joint names and tuple for the lower and
upper bounds of the clip in the ActionTermCfg.

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update


## 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
- [x] 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: Kelly Guo <[email protected]>
Co-authored-by: Kelly Guo <[email protected]>
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.

3 participants