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

Full MuJoCo Grasping Environment #61

Open
wants to merge 32 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f0c9def
Change relative body of equality constraints
xkiixkii Sep 10, 2024
452dfed
Remove initial position
xkiixkii Sep 10, 2024
702589e
Add default position and orientation for pose
xkiixkii Sep 10, 2024
07635ca
Refactor asset manager into modules
xkiixkii Sep 10, 2024
299e1cb
Add new robots
xkiixkii Sep 10, 2024
19a85e9
Support mocap body control
xkiixkii Sep 17, 2024
b8cc066
Add mocap body control
xkiixkii Sep 17, 2024
c9b287e
Load init pose from init_pose and add pillow object
xkiixkii Sep 17, 2024
fb100dc
Add mocap control and arm descriptions
xkiixkii Sep 17, 2024
1d09e86
Add new robots
xkiixkii Sep 17, 2024
fc5d275
Add mocap body and rotation utils
xkiixkii Sep 17, 2024
c60c0e9
Set None as initial value of Pose
xkiixkii Sep 19, 2024
8500d28
Use pose defined in mjcf if pos or quat is not specified in given pose
xkiixkii Sep 19, 2024
a697981
Change relative weld body
xkiixkii Sep 30, 2024
14bce13
Register all mujoco grasp environments
xkiixkii Sep 30, 2024
e8b7dfa
Add mujoco environment scene base
xkiixkii Sep 30, 2024
268e668
Use gymnasium style render method
xkiixkii Sep 30, 2024
86f7b6e
Adapt initial pose for UR5ShadowGraspPillow
xkiixkii Sep 30, 2024
11bf6e8
Use only GraspEnv for all mujoco grasp environments
xkiixkii Sep 30, 2024
fa91ecb
Reset equality constraint after reset mocap pose
xkiixkii Sep 30, 2024
dc2bc13
Add tests for mocap control
xkiixkii Sep 30, 2024
9718608
Update README
xkiixkii Sep 30, 2024
2eb34e2
Add mjSpec utils
xkiixkii Oct 1, 2024
65fc70e
Use native mujoco viewer for "human" render mode
xkiixkii Oct 4, 2024
a5a02ef
Update dependencies
xkiixkii Oct 4, 2024
49f5012
Fix annotation issue
xkiixkii Oct 4, 2024
b15f926
Update dependencies
xkiixkii Oct 4, 2024
24a2cb0
Set render mode to "human"
xkiixkii Oct 4, 2024
54e96fc
Update README
xkiixkii Oct 4, 2024
e994b4a
Update docstring
xkiixkii Oct 4, 2024
73c4248
Add docstring
xkiixkii Oct 4, 2024
65f2a02
Update setup
xkiixkii Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 git@github.com: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>
11 changes: 11 additions & 0 deletions assets/robots/mjcf/include/asset/ur5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mujoco>
<asset>
<mesh name="base" file="ur5/collision/base.stl" />
<mesh name="shoulder" file="ur5/collision/shoulder.stl" />
<mesh name="upperarm" file="ur5/collision/upperarm.stl" />
<mesh name="forearm" file="ur5/collision/forearm.stl" />
<mesh name="wrist1" file="ur5/collision/wrist1.stl" />
<mesh name="wrist2" file="ur5/collision/wrist2.stl" />
<mesh name="wrist3" file="ur5/collision/wrist3.stl" />
</asset>
</mujoco>
16 changes: 16 additions & 0 deletions assets/robots/mjcf/include/default/mia_hand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<mujoco>
<default>
<default class="mia_hand_finger">
<position forcerange="-1.75 1.75" />
<default class="mia_thumb">
<position ctrlrange="0 1.1345" forcerange="-3.5 3.5" />
</default>
<default class="mia_index">
<position ctrlrange="-1.4 1.4" />
</default>
<default class="mia_mrl">
<position ctrlrange="0 1.39626" />
</default>
</default>
</default>
</mujoco>
Loading
Loading