Skip to content

Commit

Permalink
Merge pull request #63 from dfki-ric/development
Browse files Browse the repository at this point in the history
Add mujoco environments
  • Loading branch information
mlaux1 authored Dec 3, 2024
2 parents 1dbfc1e + bb6c9f3 commit 44a3c63
Show file tree
Hide file tree
Showing 56 changed files with 2,827 additions and 1,514 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install . --user
pip install .[dev,mujoco] --user
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ logs
*.mp4
*.json
.coverage
*MUJOCO_LOG.TXT
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Everyone is welcome to contribute.
There are several ways to contribute to DeformableGym: you could

* send a bug report to the
[bug tracker](https://git.hb.dfki.de/april/learning/deformable_gym)
[issue tracker](https://www.github.com/dfki-ric/deformable_gym)
* work on one of the reported issues
* write documentation
* add a new feature
Expand All @@ -18,17 +18,17 @@ This text is shamelessly copied from
[scikit-learn's](https://scikit-learn.org/stable/developers/contributing.html)
contribution guidelines.

The preferred way to contribute to DefromableGym is to fork the
[repository](https://git.hb.dfki.de/april/learning/deformable_gym) on GitLab,
then submit a "merge request" (MR):
The preferred way to contribute to DefromableGym is to fork this
[repository](https://www.github.com/dfki-ric/deformable_gym),
then submit a "pull request" (PR):

1. Fork the [project repository](https://git.hb.dfki.de/april/learning/deformable_gym):
1. Fork the [project repository](https://www.github.com/dfki-ric/deformable_gym):
click on the 'Fork' button near the top of the page. This creates a copy of
the code under your account on the GitHub server.

2. Clone this copy to your local disk:

$ git clone --recurse-submodules git@git.hb.dfki.de:april/learning/deformable_gym.git
$ git clone git@github.com:dfki-ric/deformable_gym.git

3. Create a branch to hold your changes:

Expand All @@ -47,16 +47,16 @@ then submit a "merge request" (MR):
$ git push -u origin my-feature

Finally, go to the web page of your fork of the deformable_gym repository,
and click 'Merge request' to send your changes to the maintainer for review.
Make sure that your target branch is 'development'.
and click 'Pull request' to send your changes to the maintainer for review.
Make sure that your target branch is `development`.

In the above setup, your `origin` remote repository points to
YourLogin/deformable_gym.git. If you wish to fetch/merge from the main
repository instead of your forked one, you will need to add another remote
to use instead of `origin`. If we choose the name `upstream` for it, the
command will be:

$ git remote add upstream https://git.hb.dfki.de/april/learning/deformable_gym
$ git remote add upstream https://www.github.com/dfki-ric/deformable_gym

(If any of the above seems like magic to you, then look up the
[Git documentation](http://git-scm.com/documentation) on the web.)
Expand Down Expand Up @@ -89,4 +89,4 @@ be discussed and announced in advance with deprecation warnings.
Semantic versioning is used, that is, the major version number will be
incremented when the API changes in a backwards incompatible way, the
minor version will be incremented when new functionality is added in a
backwards compatible manner.
backwards compatible manner.
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[![Tests](https://github.com/dfki-ric/deformable_gym/actions/workflows/test.yaml/badge.svg)](https://github.com/dfki-ric/deformable_gym/actions/workflows/test.yaml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

# DeformableGym

This repository contains a collection of [gymnasium](https://github.com/Farama-Foundation/Gymnasium) environments built with [PyBullet](https://pybullet.org/) and [MuJoCo](https://github.com/google-deepmind/mujoco).
This repository contains a collection of [gymnasium](https://github.com/Farama-Foundation/Gymnasium) environments built with [PyBullet](https://pybullet.org/) and [MuJoCo](https://github.com/google-deepmind/mujoco).
In these environments, the agent needs to learn to grasp deformable 3D objects such as shoe insoles or pillows from sparse reward signals.

<p align="center">
<img src="doc/source/_static/defgym.svg"/>
</p>


## Installation
## Installation

```bash
git clone [email protected]:dfki-ric/deformable_gym.git
Expand All @@ -25,19 +25,16 @@ pip install -e .

## Available environments

| Environment Name | PyBullet | MuJoCo |
|---------------------------|:-------------------:|:------------------:|
| FloatingMiaGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| FloatingShadowGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| FloatingMiaGraspPillow | :heavy_check_mark: | :x: |
| FloatingShadowGraspPillow | :heavy_check_mark: | :x: |
| URMiaGraspInsole | :heavy_check_mark: | :x: |
| URShadowGraspInsole | :heavy_check_mark: | :x: |
| URMiaGraspPillow | :heavy_check_mark: | :x: |
| URShadowGraspPillow | :heavy_check_mark: | :x: |



| Environment Name | PyBullet | MuJoCo |
| ------------------------- | :----------------: | :----------------: |
| FloatingMiaGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| FloatingShadowGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| FloatingMiaGraspPillow | :heavy_check_mark: | :heavy_check_mark: |
| FloatingShadowGraspPillow | :heavy_check_mark: | :heavy_check_mark: |
| URMiaGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| URShadowGraspInsole | :heavy_check_mark: | :heavy_check_mark: |
| URMiaGraspPillow | :heavy_check_mark: | :heavy_check_mark: |
| URShadowGraspPillow | :heavy_check_mark: | :heavy_check_mark: |

### Known Issues

Expand All @@ -49,7 +46,17 @@ libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
```

```
libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: iris
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
/home/kaixing/miniconda3/envs/test/lib/python3.10/site-packages/glfw/__init__.py:914: GLFWError: (65543) b'GLX: Failed to create context: BadValue (integer parameter out of range for operation)'
warnings.warn(message, GLFWError)
ERROR: could not create window
```
In this case, install the following dependency via conda-forge:

```bash
Expand All @@ -72,8 +79,8 @@ import gymnasium
Floating Mia Example
=========
This is an example of how to use the FloatingMiaGraspEnv. A random policy is then
used to generate ten episodes.
This is an example of how to use the FloatingMiaGraspEnv. A random policy is then
used to generate ten episodes.
"""

Expand All @@ -93,19 +100,20 @@ while num_episodes <= 10:
if terminated or truncated:
print(f"Episode finished with return {episode_return}!")
num_episodes += 1

env.reset()

```


## Documentation

The documentation can be found in the directory doc. To build the documentation, run e.g. (on linux):

```bash
cd doc
make html
```

The HTML documentation is now located at doc/build/html/index.html. You need the following packages to build the documentation:

```bash
Expand All @@ -114,14 +122,15 @@ pip install numpydoc sphinx sphinx-gallery sphinx-bootstrap-theme

## Contributing

If you wish to report bugs, please use the [issue tracker](https://github.com/dfki-ric/deformable_gym/issues). If you would like to contribute to DeformableGym, just open an issue or a
[pull request](https://github.com/dfki-ric/deformable_gym/pulls). The target branch for
merge requests is the development branch. The development branch will be merged to main for new releases. If you have
If you wish to report bugs, please use the [issue tracker](https://github.com/dfki-ric/deformable_gym/issues). If you would like to contribute to DeformableGym, just open an issue or a
[pull request](https://github.com/dfki-ric/deformable_gym/pulls). The target branch for
merge requests is the development branch. The development branch will be merged to main for new releases. If you have
questions about the software, you should ask them in the discussion section.

The recommended workflow to add a new feature, add documentation, or fix a bug is the following:

- Push your changes to a branch (e.g. feature/x, doc/y, or fix/z) of your fork of the deformable_gym repository.
- Open a pull request to the latest development branch. There is usually an open merge request from the latest development branch to the main branch.
- Open a pull request to the latest development branch. There is usually an open merge request from the latest development branch to the main branch.
- When the latest development branch is merged to the main branch, a new release will be made.

Note that there is a checklist for new features.
Expand All @@ -143,8 +152,6 @@ url = {https://deformable-workshop.github.io/icra2023/},
}
```



## Releases

### Semantic Versioning
Expand All @@ -155,22 +162,16 @@ version will be incremented when new functionality is added in a backwards
compatible manner, and the patch version is incremented for bugfixes,
documentation, etc.


## Funding

This library has been developed initially at the
[Robotics Innovation Center](http://robotik.dfki-bremen.de/en/startpage.html) of the
[German Research Center for Artificial Intelligence (DFKI)](http://www.dfki.de) in Bremen together with the
[Robotics Group](https://robotik.dfki-bremen.de/en/about-us/university-of-bremen-robotics-group.html) of the
[Robotics Innovation Center](http://robotik.dfki-bremen.de/en/startpage.html) of the
[German Research Center for Artificial Intelligence (DFKI)](http://www.dfki.de) in Bremen together with the
[Robotics Group](https://robotik.dfki-bremen.de/en/about-us/university-of-bremen-robotics-group.html) of the
[University of Bremen](http://www.uni-bremen.de/en.html). At this phase, the work was supported through a grant from the European
Commission (870142).

<p float="left">
<img src="doc/source/_static/DFKI_Logo.png" height="100px" />
<img src="doc/source/_static/Uni_Logo.png" height="100px" />
</p>





3 changes: 1 addition & 2 deletions assets/objects/mjcf/floor.xml → assets/mj_scene_base.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<mujoco>
<!-- <option timestep="0.005"/> -->
<option timestep="0.005" />
<visual>
<rgba haze="0.15 0.25 0.35 1" />
<quality shadowsize="8192" />
<global azimuth="220" elevation="-30" />
</visual>
<asset>
<texture type="skybox" builtin="gradient" rgb1="0.3 0.5 0.7" rgb2="0 0 0" width="512" height="3072" />
Expand Down
18 changes: 9 additions & 9 deletions assets/objects/mjcf/insole_fixed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<plugin plugin="mujoco.elasticity.solid" />
</extension>
<worldbody>
<body name="insole_fixed" pos=".12 -.05 .456">
<body name="insole_fixed">
<flexcomp name="insole" mass=".5" dim="3" type="gmsh" file="insole.msh" rgba=".1 .9 .1 1" radius="0.001">
<edge equality="true" />
<plugin plugin="mujoco.elasticity.solid">
Expand All @@ -17,13 +17,13 @@
</body>
</worldbody>
<equality>
<weld name="fix_1" body1="insole_27" body2="world" />
<weld name="fix_2" body1="insole_44" body2="world" />
<weld name="fix_3" body1="insole_37" body2="world" />
<weld name="fix_4" body1="insole_35" body2="world" />
<weld name="fix_5" body1="insole_43" body2="world" />
<weld name="fix_6" body1="insole_1" body2="world" />
<weld name="fix_7" body1="insole_32" body2="world" />
<weld name="fix_8" body1="insole_69" body2="world" />
<weld name="fix_1" body1="insole_27" body2="insole_fixed" />
<weld name="fix_2" body1="insole_44" body2="insole_fixed" />
<weld name="fix_3" body1="insole_37" body2="insole_fixed" />
<weld name="fix_4" body1="insole_35" body2="insole_fixed" />
<weld name="fix_5" body1="insole_43" body2="insole_fixed" />
<weld name="fix_6" body1="insole_1" body2="insole_fixed" />
<weld name="fix_7" body1="insole_32" body2="insole_fixed" />
<weld name="fix_8" body1="insole_69" body2="insole_fixed" />
</equality>
</mujoco>
24 changes: 12 additions & 12 deletions assets/objects/mjcf/pillow_fixed.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<mujoco>
<!-- <include file="floor.xml"/> -->
<!-- <include file="floor.xml" /> -->
<compiler meshdir="../../meshes/" />
<extension>
<plugin plugin="mujoco.elasticity.solid" />
</extension>
<worldbody>
<body name="pillow_fixed" pos=".12 -.05 .456">
<flexcomp name="pillow" mass=".5" dim="3" type="gmsh" scale=".7 .7 .7" file="pillow_small.msh" rgba=".1 .9 .1 1" radius="0.001">
<body name="pillow_fixed" pos="0 0 1" quat="1 0 0 1">
<flexcomp name="pillow" mass="1" dim="3" type="gmsh" scale=".7 .7 .7" file="pillow_small.msh" rgba=".1 .9 .1 1" radius="0.001">
<edge equality="true" />
<plugin plugin="mujoco.elasticity.solid">
<config key="young" value="1e4" />
<config key="young" value="2000" />
<config key="poisson" value="0.1" />
<config key="damping" value="1e-4" />
</plugin>
</flexcomp>
</body>
</worldbody>
<equality>
<weld name="fix_1" body1="pillow_94" body2="world" />
<weld name="fix_2" body1="pillow_8" body2="world" />
<weld name="fix_3" body1="pillow_9" body2="world" />
<weld name="fix_4" body1="pillow_2" body2="world" />
<weld name="fix_5" body1="pillow_58" body2="world" />
<weld name="fix_6" body1="pillow_69" body2="world" />
<weld name="fix_7" body1="pillow_116" body2="world" />
<weld name="fix_8" body1="pillow_47" body2="world" />
<weld name="fix_1" body1="pillow_94" body2="pillow_fixed" />
<weld name="fix_2" body1="pillow_8" body2="pillow_fixed" />
<weld name="fix_3" body1="pillow_9" body2="pillow_fixed" />
<weld name="fix_4" body1="pillow_2" body2="pillow_fixed" />
<weld name="fix_5" body1="pillow_58" body2="pillow_fixed" />
<weld name="fix_6" body1="pillow_69" body2="pillow_fixed" />
<weld name="fix_7" body1="pillow_116" body2="pillow_fixed" />
<weld name="fix_8" body1="pillow_47" body2="pillow_fixed" />
</equality>
</mujoco>
19 changes: 19 additions & 0 deletions assets/robots/mjcf/include/asset/mia_hand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<mujoco>
<asset>
<mesh name="index_finger" file="stl/index_finger.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="index_tip" file="stl/index_tip.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="little_finger" file="stl/little_finger.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="little_tip" file="stl/little_tip.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="middle_finger" file="stl/middle_finger.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="middle_tip" file="stl/middle_tip.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="dorsum_simple" file="stl/dorsum_simple.stl" scale="0.0766738 0.104275 0.0766738" />
<mesh name="palm_simple" file="stl/palm_simple.stl" scale="0.122027 0.122027 0.122027" />
<mesh name="wrist" file="stl/wrist.stl" scale="0.000999999 0.000999999 0.000999999" />
<mesh name="ring_finger" file="stl/ring_finger.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="ring_tip" file="stl/ring_tip.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="thumb_cover" file="stl/thumb_cover.stl" scale="0.000999988 0.000999987 0.000999987" />
<mesh name="thumb_frame" file="stl/thumb_frame.stl" scale="0.000999988 0.000999987 0.000999987" />
<mesh name="thumb_metacarpus" file="stl/thumb_metacarpus.stl" scale="0.000999987 0.000999987 0.000999987" />
<mesh name="UR_flange" file="stl/UR_flange.stl" scale="0.000999999 0.000999999 0.000999999" />
</asset>
</mujoco>
20 changes: 20 additions & 0 deletions assets/robots/mjcf/include/asset/shadow_hand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<mujoco>
<asset>
<material name="black" specular="0.5" shininess="0.25" rgba="0.16355 0.16355 0.16355 1" />
<material name="gray" specular="0.0" shininess="0.25" rgba="0.80848 0.80848 0.80848 1" />
<material name="metallic" specular="0" shininess="0.25" rgba="0.9 0.9 0.9 1" />
<mesh name="shadow_rh_forearm_0" scale="0.001 0.001 0.001" file="shadow_hand/forearm_0.obj" />
<mesh name="shadow_rh_forearm_1" scale="0.001 0.001 0.001" file="shadow_hand/forearm_1.obj" />
<mesh name="shadow_rh_forearm_collision" scale="0.001 0.001 0.001" file="shadow_hand/forearm_collision.obj" />
<mesh name="shadow_rh_wrist" scale="0.001 0.001 0.001" file="shadow_hand/wrist.obj" />
<mesh name="shadow_rh_palm" scale="0.001 0.001 0.001" file="shadow_hand/palm.obj" />
<mesh name="shadow_rh_f_knuckle" scale="0.001 0.001 0.001" file="shadow_hand/f_knuckle.obj" />
<mesh name="shadow_rh_f_proximal" scale="0.001 0.001 0.001" file="shadow_hand/f_proximal.obj" />
<mesh name="shadow_rh_f_middle" scale="0.001 0.001 0.001" file="shadow_hand/f_middle.obj" />
<mesh name="shadow_rh_f_distal_pst" scale="0.001 0.001 0.001" file="shadow_hand/f_distal_pst.obj" />
<mesh name="shadow_rh_lf_metacarpal" scale="0.001 0.001 0.001" file="shadow_hand/lf_metacarpal.obj" />
<mesh name="shadow_rh_th_proximal" scale="0.001 0.001 0.001" file="shadow_hand/th_proximal.obj" />
<mesh name="shadow_rh_th_middle" scale="0.001 0.001 0.001" file="shadow_hand/th_middle.obj" />
<mesh name="shadow_rh_th_distal_pst" scale="0.001 0.001 0.001" file="shadow_hand/th_distal_pst.obj" />
</asset>
</mujoco>
11 changes: 11 additions & 0 deletions assets/robots/mjcf/include/asset/ur10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mujoco>
<asset>
<mesh name="base" file="ur10/collision/base.stl" />
<mesh name="shoulder" file="ur10/collision/shoulder.stl" />
<mesh name="upperarm" file="ur10/collision/upperarm.stl" />
<mesh name="forearm" file="ur10/collision/forearm.stl" />
<mesh name="wrist1" file="ur10/collision/wrist1.stl" />
<mesh name="wrist2" file="ur10/collision/wrist2.stl" />
<mesh name="wrist3" file="ur10/collision/wrist3.stl" />
</asset>
</mujoco>
11 changes: 11 additions & 0 deletions assets/robots/mjcf/include/asset/ur10e.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mujoco>
<asset>
<mesh name="base" file="ur10e/collision/base.stl" />
<mesh name="shoulder" file="ur10e/collision/shoulder.stl" />
<mesh name="upperarm" file="ur10e/collision/upperarm.stl" />
<mesh name="forearm" file="ur10e/collision/forearm.stl" />
<mesh name="wrist1" file="ur10e/collision/wrist1.stl" />
<mesh name="wrist2" file="ur10e/collision/wrist2.stl" />
<mesh name="wrist3" file="ur10e/collision/wrist3.stl" />
</asset>
</mujoco>
13 changes: 13 additions & 0 deletions assets/robots/mjcf/include/asset/ur10ft.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<mujoco>
<asset>
<mesh name="base" file="ur10/collision/base.stl" />
<mesh name="shoulder" file="ur10/collision/shoulder.stl" />
<mesh name="upperarm" file="ur10/collision/upperarm.stl" />
<mesh name="forearm" file="ur10/collision/forearm.stl" />
<mesh name="wrist1" file="ur10/collision/wrist1.stl" />
<mesh name="wrist2" file="ur10/collision/wrist2.stl" />
<mesh name="wrist3" file="ur10/collision/wrist3.stl" />
<mesh name="robotiq_ft300" file="collision/robotiq/robotiq_ft300.STL" />
<mesh name="robotiq_ft300-G-062-COUPLING_G-50-4M6-1D6_20181119" file="collision/robotiq/mountings/robotiq_ft300-G-062-COUPLING_G-50-4M6-1D6_20181119.STL" />
</asset>
</mujoco>
Loading

0 comments on commit 44a3c63

Please sign in to comment.