Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Migrating the base IsaacEnv #59

Closed
1 task done
Mayankm96 opened this issue Apr 12, 2023 · 1 comment
Closed
1 task done

[Proposal] Migrating the base IsaacEnv #59

Mayankm96 opened this issue Apr 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Mayankm96
Copy link
Contributor

Mayankm96 commented Apr 12, 2023

Proposal

Gymnasium is the maintained version of OpenAI Gym that is now handled by Farama Foundation. It is currently the definition used in libraries such as rllib and tianshou, while others like stable-baselines3 will also update soon.

More recently, there has been an interesting proposal on RL environment definition in the framework torchrl which would fit well for our targetted applications.

This thread aims to serve as a voting/staging on what would be the best environment definition to use.

Motivation

Migrating to Gym 0.28

The current Gym definition (from 0.21.0) is outdated and depends on older libraries such as importlib-meta==4.1 package. This creates conflicts with new updated packages and it would be best to switch to the new Gym definition.

Related issues: OIGE #28, Sb3 #1327

Once SB3 also upgrades to Gymnasium, then it would be best to update everything to use the latest definitions.

More information on Gymnasium:

Migrating to TorchRL definition

The environment definition EnvBase which relies heavily on using tensordict.

The advantages of their base class are:

  • tensordict makes it easier to work with given the scaling possible with Isaac Sim and should be more efficient/flexible than dict of torch.Tensor
  • It allows having complex datatypes (continuous/discrete, images/proprioception) for both observation and action spaces. This helps generalize to a wider audience (such as multi-agent learning)

Related Issues: torchrl #883

Effect on the remaining framework

Since there are wrappers for other RL frameworks (RL-Games and RSL-RL), this probably won't cause any breaking changes on that side. We will just need to adapt them based on the chosen IsaacEnv definition.

Checklist

  • I have checked that there is no similar issue in the repo (required)
@Mayankm96 Mayankm96 added the enhancement New feature or request label Apr 12, 2023
@Mayankm96 Mayankm96 changed the title [Proposal] Migrating the base IsaacEnv to follow Gymnasium [Proposal] Migrating the base IsaacEnv Apr 15, 2023
@romesco
Copy link
Contributor

romesco commented May 2, 2023

A third option to consider:

Simply define it as a Protocol. Something like EnvCompatible.

Over the years, I have run into countless issues I can trace back to the "kitchen sink" structure of gym. Don't get me wrong, I am extremely grateful for the step towards standardization that it catalyzed, but it's clear that when it was originally formulated, it was meant to be a standalone repository. I'm always looking to shy away from taking on unneeded dependencies since this can do a lot of harm to the lifecycle of the codebase.

I believe in the modern days, gym is used more like an interface to ensure that libraries for RL (both on the algorithmic side and on the dynamics side) agree on the correct "protocol" of methods that should be made available.

The best part is using a Protocol definition is also backward compatible as well as compatible with libraries that depend on gymnasium or whichever other flavor.

Something as simple as:

from typing import Protocol, runtime_checkable, Any, SupportsFloat, Optional

@dataclass
class StepReturn:
    observation: Any
    reward: SupportsFloat
    terminated: bool
    truncated: bool
    #info: Info | None

@dataclass
class ResetReturn:
    observation: Any
    #info: Info | None

@runtime_checkable
class EnvCompatible(Protocol):
    def step( self,  action: Any ) -> StepReturn:
        """Step."""

    def reset( self, seed: Optional[Any], options: Optional[Any]) -> ResetReturn:
        """Reset."""

Edit: You can also make something IsaacEnvCompatible or RLGamesEnvCompatible to specify additional behavior that must be satisfied. Multiple-implementation of protocols is seamless since there is no MRO to contend with (as is the case with abstract base classes).

Anyways, just something to think about.

Mayankm96 pushed a commit that referenced this issue Jul 24, 2023
Mayankm96 added a commit that referenced this issue Feb 29, 2024
Added relative joint position actions and moving average joint actions.
These are useful for "smoothened" out action spaces for environments
such as in-hand manipulation.

- New feature (non-breaking change which adds functionality)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] 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 run all the tests with `./orbit.sh --test` and they pass
- [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

---------

Co-authored-by: Mayank Mittal <[email protected]>
fatimaanes pushed a commit to fatimaanes/omniperf that referenced this issue Aug 8, 2024
…sim#59)

Added relative joint position actions and moving average joint actions.
These are useful for "smoothened" out action spaces for environments
such as in-hand manipulation.

- New feature (non-breaking change which adds functionality)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] 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 run all the tests with `./orbit.sh --test` and they pass
- [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

---------

Co-authored-by: Mayank Mittal <[email protected]>
iamdrfly pushed a commit to iamdrfly/IsaacLab that referenced this issue Nov 21, 2024
…sim#59)

Added relative joint position actions and moving average joint actions.
These are useful for "smoothened" out action spaces for environments
such as in-hand manipulation.

- New feature (non-breaking change which adds functionality)

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] 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 run all the tests with `./orbit.sh --test` and they pass
- [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

---------

Co-authored-by: Mayank Mittal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants