Skip to content
New issue

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

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

Already on GitHub? # to your account

[MuJoCo] Add support for relative paths with xml_file arguments #536

Merged

Conversation

Kallinteris-Andreas
Copy link
Collaborator

@Kallinteris-Andreas Kallinteris-Andreas commented Jun 5, 2023

Description

Adds support for using "." and "~" relative paths for the xml_file argument in mujoco-v3+ environments.
Previously one had to only full paths "/home/..."

Manual testing

>>> import gymnasium
>>> env = gymnasium.make('Humanoid-v5', xml_file="~/op3-scene.xml")
>>> env = gymnasium.make('Humanoid-v5', xml_file="./op3-scene.xml")

I have also added

def test_xml_file():
    """Verify that the loading of a custom XML file works"""
    env = PointEnv(xml_file="./tests/envs/mujoco/assets/walker2d_v5_uneven_feet.xml")
    assert env.unwrapped.data.qpos.size == 9

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • [DNA] I have commented my code, particularly in hard-to-understand areas
  • [DNA] 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
  • New and existing unit tests pass locally with my changes

@Kallinteris-Andreas Kallinteris-Andreas marked this pull request as draft June 5, 2023 10:58
@Kallinteris-Andreas Kallinteris-Andreas marked this pull request as ready for review June 5, 2023 14:31
Copy link
Member

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@pseudo-rnd-thoughts pseudo-rnd-thoughts merged commit 4096c53 into Farama-Foundation:main Jun 6, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants