Skip to content

Commit 4ab0ad8

Browse files
authored
Merge pull request #38 from rohanpsingh/topic/new-updates
Massive new updates
2 parents 7c65a23 + 3e6c58f commit 4ab0ad8

30 files changed

+1542
-966
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "models/cassie_mj_description"]
55
path = models/cassie_mj_description
66
url = [email protected]:rohanpsingh/cassie_mj_description.git
7+
[submodule "models/mujoco_menagerie"]
8+
path = models/mujoco_menagerie
9+
url = [email protected]:google-deepmind/mujoco_menagerie

README.md

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# LearningHumanoidWalking
22

3+
<p align="center">
4+
<a href="https://www.youtube.com/watch?v=ZgfNzGAkk2Q"><img src="https://github.com/user-attachments/assets/5211cdcd-2267-497b-bd66-ac833703a134" alt="humanoid-walk" style="width:1000px"/></a>
5+
</p>
6+
37
Code for the papers:
4-
- [**Learning Bipedal Walking On Planned Footsteps For Humanoid Robots**](https://arxiv.org/pdf/2207.12644.pdf) (Humanoids2022)
8+
- [**Robust Humanoid Walking on Compliant and Uneven Terrain with Deep Reinforcement Learning**](https://ieeexplore.ieee.org/abstract/document/10769793)
9+
[Rohan P. Singh](https://rohanpsingh.github.io), [Mitsuharu Morisawa](https://unit.aist.go.jp/jrl-22022/en/members/member-morisawa.html), [Mehdi Benallegue](https://unit.aist.go.jp/jrl-22022/en/members/member-benalleguem.html), [Zhaoming Xie](https://zhaomingxie.github.io/), [Fumio Kanehiro](https://unit.aist.go.jp/jrl-22022/en/members/member-kanehiro.html)
10+
11+
- [**Learning Bipedal Walking for Humanoids with Current Feedback**](https://arxiv.org/pdf/2303.03724.pdf)
12+
[Rohan P. Singh](https://rohanpsingh.github.io), [Zhaoming Xie](https://zhaomingxie.github.io/), [Pierre Gergondet](https://unit.aist.go.jp/jrl-22022/en/members/member-gergondet.html), [Fumio Kanehiro](https://unit.aist.go.jp/jrl-22022/en/members/member-kanehiro.html)
13+
14+
- [**Learning Bipedal Walking On Planned Footsteps For Humanoid Robots**](https://arxiv.org/pdf/2207.12644.pdf)
515
[Rohan P. Singh](https://rohanpsingh.github.io), [Mehdi Benallegue](https://unit.aist.go.jp/jrl-22022/en/members/member-benalleguem.html), [Mitsuharu Morisawa](https://unit.aist.go.jp/jrl-22022/en/members/member-morisawa.html), [Rafael Cisneros](https://unit.aist.go.jp/jrl-22022/en/members/member-cisneros.html), [Fumio Kanehiro](https://unit.aist.go.jp/jrl-22022/en/members/member-kanehiro.html)
616

7-
- [**Learning Bipedal Walking for Humanoids with Current Feedback**](https://arxiv.org/pdf/2303.03724.pdf) (arxiv)
8-
[Rohan P. Singh](https://rohanpsingh.github.io), [Zhaoming Xie](https://zhaomingxie.github.io/), [Pierre Gergondet](https://unit.aist.go.jp/jrl-22022/en/members/member-gergondet.html), [Fumio Kanehiro](https://unit.aist.go.jp/jrl-22022/en/members/member-kanehiro.html)
9-
(WIP on branch `topic/omnidirectional-walk`)
1017

1118
## Code structure:
1219
A rough outline for the repository that might be useful for adding your own robot:
@@ -16,19 +23,18 @@ LearningHumanoidWalking/
1623
├── tasks/ <-- Reward function, termination conditions, and more...
1724
├── rl/ <-- Code for PPO, actor/critic networks, observation normalization process...
1825
├── models/ <-- MuJoCo model files: XMLs/meshes/textures
19-
├── trained/ <-- Contains pretrained model for JVRC
2026
└── scripts/ <-- Utility scripts, etc.
2127
```
2228

2329
## Requirements:
24-
- Python version: 3.7.11
25-
- [Pytorch](https://pytorch.org/)
30+
- Python version: 3.12.4
2631
- pip install:
27-
- mujoco==2.2.0
32+
- mujoco==3.2.2
33+
- ray==2.40.0
34+
- pytorch=2.5.1
35+
- intel-openmp
2836
- [mujoco-python-viewer](https://github.com/rohanpsingh/mujoco-python-viewer)
29-
- ray==1.9.2
3037
- transforms3d
31-
- matplotlib
3238
- scipy
3339

3440
## Usage:
@@ -37,6 +43,7 @@ Environment names supported:
3743

3844
| Task Description | Environment name |
3945
| ----------- | ----------- |
46+
| Basic Standing Task | 'h1' |
4047
| Basic Walking Task | 'jvrc_walk' |
4148
| Stepping Task (using footsteps) | 'jvrc_step' |
4249

@@ -69,7 +76,35 @@ $ PYTHONPATH=.:$PYTHONPATH python scripts/debug_stepper.py --path <path_to_exp_d
6976

7077

7178
## Citation
72-
If you find this work useful in your own research:
79+
If you find this work useful in your own research, please cite the following works:
80+
81+
For omnidirectional walking:
82+
```
83+
@inproceedings{singh2024robust,
84+
title={Robust Humanoid Walking on Compliant and Uneven Terrain with Deep Reinforcement Learning},
85+
author={Singh, Rohan P and Morisawa, Mitsuharu and Benallegue, Mehdi and Xie, Zhaoming and Kanehiro, Fumio},
86+
booktitle={2024 IEEE-RAS 23rd International Conference on Humanoid Robots (Humanoids)},
87+
pages={497--504},
88+
year={2024},
89+
organization={IEEE}
90+
}
91+
```
92+
93+
For simulating "back-emf" effect and other randomizations:
94+
```
95+
@article{xie2023learning,
96+
title={Learning bipedal walking for humanoids with current feedback},
97+
author={Xie, Zhaoming and Gergondet, Pierre and Kanehiro, Fumio and others},
98+
journal={IEEE Access},
99+
volume={11},
100+
pages={82013--82023},
101+
year={2023},
102+
publisher={IEEE}
103+
}
104+
```
105+
106+
For walking on footsteps:
107+
73108
```
74109
@inproceedings{singh2022learning,
75110
title={Learning Bipedal Walking On Planned Footsteps For Humanoid Robots},

envs/common/config_builder.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import yaml
2+
3+
class Configuration:
4+
def __init__(self, **kwargs):
5+
for key, value in kwargs.items():
6+
if isinstance(value, dict):
7+
setattr(self, key, Configuration(**value))
8+
else:
9+
setattr(self, key, value)
10+
11+
def __repr__(self):
12+
return str(self.__dict__)
13+
14+
def load_yaml(file_path):
15+
with open(file_path, 'r') as file:
16+
config_data = yaml.safe_load(file)
17+
return Configuration(**config_data)

envs/common/mujoco_env.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import contextlib
12
import os
23
import numpy as np
34
import mujoco
@@ -16,7 +17,10 @@ def __init__(self, model_path, sim_dt, control_dt):
1617
raise Exception("Provide full path to robot description package.")
1718
if not os.path.exists(fullpath):
1819
raise IOError("File %s does not exist" % fullpath)
19-
self.model = mujoco.MjModel.from_xml_path(fullpath)
20+
21+
self.spec = mujoco.MjSpec()
22+
self.spec.from_file(fullpath)
23+
self.model = self.spec.compile()
2024
self.data = mujoco.MjData(self.model)
2125
self.viewer = None
2226

@@ -48,24 +52,71 @@ def viewer_setup(self):
4852
self.viewer.cam.lookat[2] = 1.5
4953
self.viewer.cam.lookat[0] = 2.0
5054
self.viewer.cam.elevation = -20
51-
self.viewer.vopt.geomgroup[0] = 1
55+
self.viewer.vopt.geomgroup[2] = 0
5256
self.viewer._render_every_frame = True
5357

5458
def viewer_is_paused(self):
5559
return self.viewer._paused
5660

5761
# -----------------------------
62+
# (some methods are taken directly from dm_control)
63+
64+
@contextlib.contextmanager
65+
def disable(self, *flags):
66+
"""Context manager for temporarily disabling MuJoCo flags.
67+
68+
Args:
69+
*flags: Positional arguments specifying flags to disable. Can be either
70+
lowercase strings (e.g. 'gravity', 'contact') or `mjtDisableBit` enum
71+
values.
72+
73+
Yields:
74+
None
75+
76+
Raises:
77+
ValueError: If any item in `flags` is neither a valid name nor a value
78+
from `mujoco.mjtDisableBit`.
79+
"""
80+
old_bitmask = self.model.opt.disableflags
81+
new_bitmask = old_bitmask
82+
for flag in flags:
83+
if isinstance(flag, str):
84+
try:
85+
field_name = "mjDSBL_" + flag.upper()
86+
flag = getattr(mujoco.mjtDisableBit, field_name)
87+
except AttributeError:
88+
valid_names = [
89+
field_name.split("_")[1].lower()
90+
for field_name in list(mujoco.mjtDisableBit.__members__)[:-1]
91+
]
92+
raise ValueError("'{}' is not a valid flag name. Valid names: {}"
93+
.format(flag, ", ".join(valid_names))) from None
94+
elif isinstance(flag, int):
95+
flag = mujoco.mjtDisableBit(flag)
96+
new_bitmask |= flag.value
97+
self.model.opt.disableflags = new_bitmask
98+
try:
99+
yield
100+
finally:
101+
self.model.opt.disableflags = old_bitmask
58102

59103
def reset(self):
60104
mujoco.mj_resetData(self.model, self.data)
61105
ob = self.reset_model()
62106
return ob
63107

64108
def set_state(self, qpos, qvel):
65-
assert qpos.shape == (self.model.nq,) and qvel.shape == (self.model.nv,)
109+
assert qpos.shape == (self.model.nq,), \
110+
f"qpos shape {qpos.shape} is expected to be {(self.model.nq,)}"
111+
assert qvel.shape == (self.model.nv,), \
112+
f"qvel shape {qvel.shape} is expected to be {(self.model.nv,)}"
66113
self.data.qpos[:] = qpos
67114
self.data.qvel[:] = qvel
68-
mujoco.mj_forward(self.model, self.data)
115+
self.data.act = []
116+
self.data.plugin_state = []
117+
# Disable actuation since we don't yet have meaningful control inputs.
118+
with self.disable('actuation'):
119+
mujoco.mj_forward(self.model, self.data)
69120

70121
@property
71122
def dt(self):

0 commit comments

Comments
 (0)