mjlab 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. mjlab/__init__.py +17 -0
  2. mjlab/asset_zoo/README.md +6 -0
  3. mjlab/asset_zoo/__init__.py +0 -0
  4. mjlab/asset_zoo/img/g1.png +0 -0
  5. mjlab/asset_zoo/img/go1.png +0 -0
  6. mjlab/asset_zoo/render_robots.py +49 -0
  7. mjlab/asset_zoo/robots/__init__.py +7 -0
  8. mjlab/asset_zoo/robots/unitree_g1/__init__.py +1 -0
  9. mjlab/asset_zoo/robots/unitree_g1/g1_constants.py +296 -0
  10. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/head_link.STL +0 -0
  11. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_ankle_pitch_link.STL +0 -0
  12. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_ankle_roll_link.STL +0 -0
  13. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_elbow_link.STL +0 -0
  14. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_index_0_link.STL +0 -0
  15. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_index_1_link.STL +0 -0
  16. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_middle_0_link.STL +0 -0
  17. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_middle_1_link.STL +0 -0
  18. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_palm_link.STL +0 -0
  19. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_thumb_0_link.STL +0 -0
  20. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_thumb_1_link.STL +0 -0
  21. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hand_thumb_2_link.STL +0 -0
  22. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hip_pitch_link.STL +0 -0
  23. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hip_roll_link.STL +0 -0
  24. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_hip_yaw_link.STL +0 -0
  25. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_knee_link.STL +0 -0
  26. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_rubber_hand.STL +0 -0
  27. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_shoulder_pitch_link.STL +0 -0
  28. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_shoulder_roll_link.STL +0 -0
  29. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_shoulder_yaw_link.STL +0 -0
  30. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_wrist_pitch_link.STL +0 -0
  31. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_wrist_roll_link.STL +0 -0
  32. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/left_wrist_yaw_link.STL +0 -0
  33. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/logo_link.STL +0 -0
  34. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/pelvis.STL +0 -0
  35. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/pelvis_contour_link.STL +0 -0
  36. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_ankle_pitch_link.STL +0 -0
  37. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_ankle_roll_link.STL +0 -0
  38. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_elbow_link.STL +0 -0
  39. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_index_0_link.STL +0 -0
  40. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_index_1_link.STL +0 -0
  41. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_middle_0_link.STL +0 -0
  42. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_middle_1_link.STL +0 -0
  43. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_palm_link.STL +0 -0
  44. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_thumb_0_link.STL +0 -0
  45. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_thumb_1_link.STL +0 -0
  46. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hand_thumb_2_link.STL +0 -0
  47. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hip_pitch_link.STL +0 -0
  48. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hip_roll_link.STL +0 -0
  49. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_hip_yaw_link.STL +0 -0
  50. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_knee_link.STL +0 -0
  51. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_rubber_hand.STL +0 -0
  52. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_shoulder_pitch_link.STL +0 -0
  53. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_shoulder_roll_link.STL +0 -0
  54. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_shoulder_yaw_link.STL +0 -0
  55. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_wrist_pitch_link.STL +0 -0
  56. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_wrist_roll_link.STL +0 -0
  57. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/right_wrist_yaw_link.STL +0 -0
  58. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/torso_link_rev_1_0.STL +0 -0
  59. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/waist_roll_link_rev_1_0.STL +0 -0
  60. mjlab/asset_zoo/robots/unitree_g1/xmls/assets/waist_yaw_link_rev_1_0.STL +0 -0
  61. mjlab/asset_zoo/robots/unitree_g1/xmls/g1.xml +309 -0
  62. mjlab/asset_zoo/robots/unitree_go1/__init__.py +1 -0
  63. mjlab/asset_zoo/robots/unitree_go1/go1_constants.py +159 -0
  64. mjlab/asset_zoo/robots/unitree_go1/xmls/assets/calf.stl +0 -0
  65. mjlab/asset_zoo/robots/unitree_go1/xmls/assets/hip.stl +0 -0
  66. mjlab/asset_zoo/robots/unitree_go1/xmls/assets/thigh.stl +0 -0
  67. mjlab/asset_zoo/robots/unitree_go1/xmls/assets/thigh_mirror.stl +0 -0
  68. mjlab/asset_zoo/robots/unitree_go1/xmls/assets/trunk.stl +0 -0
  69. mjlab/asset_zoo/robots/unitree_go1/xmls/go1.xml +164 -0
  70. mjlab/cli.py +122 -0
  71. mjlab/entity/__init__.py +15 -0
  72. mjlab/entity/data.py +514 -0
  73. mjlab/entity/entity.py +652 -0
  74. mjlab/envs/__init__.py +12 -0
  75. mjlab/envs/manager_based_env.py +198 -0
  76. mjlab/envs/manager_based_rl_env.py +226 -0
  77. mjlab/envs/mdp/__init__.py +5 -0
  78. mjlab/envs/mdp/actions/__init__.py +10 -0
  79. mjlab/envs/mdp/actions/actions_config.py +23 -0
  80. mjlab/envs/mdp/actions/joint_actions.py +103 -0
  81. mjlab/envs/mdp/events.py +415 -0
  82. mjlab/envs/mdp/observations.py +92 -0
  83. mjlab/envs/mdp/rewards.py +174 -0
  84. mjlab/envs/mdp/terminations.py +49 -0
  85. mjlab/envs/types.py +11 -0
  86. mjlab/managers/__init__.py +18 -0
  87. mjlab/managers/action_manager.py +150 -0
  88. mjlab/managers/command_manager.py +193 -0
  89. mjlab/managers/curriculum_manager.py +130 -0
  90. mjlab/managers/event_manager.py +211 -0
  91. mjlab/managers/manager_base.py +93 -0
  92. mjlab/managers/manager_term_config.py +125 -0
  93. mjlab/managers/observation_manager.py +216 -0
  94. mjlab/managers/reward_manager.py +109 -0
  95. mjlab/managers/scene_entity_config.py +177 -0
  96. mjlab/managers/termination_manager.py +121 -0
  97. mjlab/py.typed +0 -0
  98. mjlab/rl/__init__.py +15 -0
  99. mjlab/rl/config.py +110 -0
  100. mjlab/rl/vecenv_wrapper.py +111 -0
  101. mjlab/scene/__init__.py +3 -0
  102. mjlab/scene/scene.py +147 -0
  103. mjlab/scene/scene.xml +12 -0
  104. mjlab/sim/__init__.py +11 -0
  105. mjlab/sim/randomization.py +55 -0
  106. mjlab/sim/sim.py +246 -0
  107. mjlab/sim/sim_data.py +229 -0
  108. mjlab/tasks/__init__.py +5 -0
  109. mjlab/tasks/tracking/__init__.py +1 -0
  110. mjlab/tasks/tracking/config/__init__.py +0 -0
  111. mjlab/tasks/tracking/config/g1/__init__.py +21 -0
  112. mjlab/tasks/tracking/config/g1/flat_env_cfg.py +70 -0
  113. mjlab/tasks/tracking/config/g1/rl_cfg.py +41 -0
  114. mjlab/tasks/tracking/mdp/__init__.py +6 -0
  115. mjlab/tasks/tracking/mdp/commands.py +374 -0
  116. mjlab/tasks/tracking/mdp/observations.py +69 -0
  117. mjlab/tasks/tracking/mdp/rewards.py +137 -0
  118. mjlab/tasks/tracking/mdp/terminations.py +83 -0
  119. mjlab/tasks/tracking/rl/__init__.py +3 -0
  120. mjlab/tasks/tracking/rl/exporter.py +123 -0
  121. mjlab/tasks/tracking/rl/runner.py +56 -0
  122. mjlab/tasks/tracking/tracking_env_cfg.py +300 -0
  123. mjlab/tasks/velocity/__init__.py +1 -0
  124. mjlab/tasks/velocity/config/__init__.py +0 -0
  125. mjlab/tasks/velocity/config/g1/__init__.py +41 -0
  126. mjlab/tasks/velocity/config/g1/flat_env_cfg.py +21 -0
  127. mjlab/tasks/velocity/config/g1/rl_cfg.py +41 -0
  128. mjlab/tasks/velocity/config/g1/rough_env_cfg.py +69 -0
  129. mjlab/tasks/velocity/config/go1/__init__.py +41 -0
  130. mjlab/tasks/velocity/config/go1/flat_env_cfg.py +21 -0
  131. mjlab/tasks/velocity/config/go1/rl_cfg.py +41 -0
  132. mjlab/tasks/velocity/config/go1/rough_env_cfg.py +68 -0
  133. mjlab/tasks/velocity/mdp/__init__.py +5 -0
  134. mjlab/tasks/velocity/mdp/curriculums.py +50 -0
  135. mjlab/tasks/velocity/mdp/rewards.py +234 -0
  136. mjlab/tasks/velocity/mdp/velocity_command.py +187 -0
  137. mjlab/tasks/velocity/rl/__init__.py +11 -0
  138. mjlab/tasks/velocity/rl/exporter.py +66 -0
  139. mjlab/tasks/velocity/rl/runner.py +38 -0
  140. mjlab/tasks/velocity/velocity_env_cfg.py +309 -0
  141. mjlab/terrains/__init__.py +25 -0
  142. mjlab/terrains/box_terrains.py +607 -0
  143. mjlab/terrains/config.py +50 -0
  144. mjlab/terrains/terrain_generator.py +265 -0
  145. mjlab/terrains/terrain_importer.py +238 -0
  146. mjlab/terrains/utils.py +108 -0
  147. mjlab/third_party/README.md +18 -0
  148. mjlab/third_party/__init__.py +0 -0
  149. mjlab/third_party/isaaclab/LICENSE +30 -0
  150. mjlab/third_party/isaaclab/README.vendor.md +8 -0
  151. mjlab/third_party/isaaclab/__init__.py +0 -0
  152. mjlab/third_party/isaaclab/isaaclab/__init__.py +0 -0
  153. mjlab/third_party/isaaclab/isaaclab/terrains/__init__.py +0 -0
  154. mjlab/third_party/isaaclab/isaaclab/terrains/trimesh/__init__.py +0 -0
  155. mjlab/third_party/isaaclab/isaaclab/terrains/trimesh/utils.py +194 -0
  156. mjlab/third_party/isaaclab/isaaclab/utils/__init__.py +0 -0
  157. mjlab/third_party/isaaclab/isaaclab/utils/math.py +1925 -0
  158. mjlab/third_party/isaaclab/isaaclab/utils/string.py +368 -0
  159. mjlab/third_party/isaaclab/isaaclab_rl/__init__.py +0 -0
  160. mjlab/third_party/isaaclab/isaaclab_rl/rsl_rl/__init__.py +0 -0
  161. mjlab/third_party/isaaclab/isaaclab_rl/rsl_rl/exporter.py +214 -0
  162. mjlab/third_party/isaaclab/isaaclab_tasks/__init__.py +0 -0
  163. mjlab/third_party/isaaclab/isaaclab_tasks/utils/__init__.py +0 -0
  164. mjlab/third_party/isaaclab/isaaclab_tasks/utils/importer.py +89 -0
  165. mjlab/third_party/isaaclab/isaaclab_tasks/utils/parse_cfg.py +113 -0
  166. mjlab/utils/__init__.py +0 -0
  167. mjlab/utils/actuator.py +38 -0
  168. mjlab/utils/color.py +223 -0
  169. mjlab/utils/dataclasses.py +15 -0
  170. mjlab/utils/download.py +107 -0
  171. mjlab/utils/mujoco.py +28 -0
  172. mjlab/utils/noise/__init__.py +25 -0
  173. mjlab/utils/noise/noise_cfg.py +136 -0
  174. mjlab/utils/noise/noise_model.py +84 -0
  175. mjlab/utils/os.py +72 -0
  176. mjlab/utils/random.py +26 -0
  177. mjlab/utils/spec.py +40 -0
  178. mjlab/utils/spec_config.py +521 -0
  179. mjlab/utils/string.py +36 -0
  180. mjlab/utils/torch.py +11 -0
  181. mjlab/viewer/__init__.py +16 -0
  182. mjlab/viewer/base.py +318 -0
  183. mjlab/viewer/keys.py +107 -0
  184. mjlab/viewer/native.py +430 -0
  185. mjlab/viewer/viewer_config.py +24 -0
  186. mjlab/viewer/viser.py +487 -0
  187. mjlab/viewer/viser_conversions.py +263 -0
  188. mjlab/viewer/viser_reward_plotter.py +151 -0
  189. mjlab-0.0.0.dist-info/METADATA +201 -0
  190. mjlab-0.0.0.dist-info/RECORD +212 -0
  191. mjlab-0.0.0.dist-info/WHEEL +4 -0
  192. mjlab-0.0.0.dist-info/entry_points.txt +3 -0
  193. mjlab-0.0.0.dist-info/licenses/LICENSE +202 -0
  194. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/README.md +18 -0
  195. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/__init__.py +0 -0
  196. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/LICENSE +30 -0
  197. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/README.vendor.md +8 -0
  198. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/__init__.py +0 -0
  199. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/__init__.py +0 -0
  200. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/terrains/__init__.py +0 -0
  201. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/terrains/trimesh/__init__.py +0 -0
  202. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/terrains/trimesh/utils.py +194 -0
  203. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/utils/__init__.py +0 -0
  204. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/utils/math.py +1925 -0
  205. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab/utils/string.py +368 -0
  206. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_rl/__init__.py +0 -0
  207. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_rl/rsl_rl/__init__.py +0 -0
  208. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_rl/rsl_rl/exporter.py +214 -0
  209. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_tasks/__init__.py +0 -0
  210. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_tasks/utils/__init__.py +0 -0
  211. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_tasks/utils/importer.py +89 -0
  212. mjlab-0.0.0.dist-info/licenses/src/mjlab/third_party/isaaclab/isaaclab_tasks/utils/parse_cfg.py +113 -0
mjlab/__init__.py ADDED
@@ -0,0 +1,17 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import warp as wp
5
+
6
+ MJLAB_SRC_PATH: Path = Path(__file__).parent
7
+
8
+
9
+ def configure_warp() -> None:
10
+ """Configure Warp globally for mjlab."""
11
+ wp.config.enable_backward = False
12
+
13
+ quiet = os.environ.get("MJLAB_WARP_VERBOSE", "").lower() not in ("1", "true", "yes")
14
+ wp.config.quiet = quiet
15
+
16
+
17
+ configure_warp()
@@ -0,0 +1,6 @@
1
+ # Asset Zoo
2
+
3
+ | Robot | Image |
4
+ |-------|-------|
5
+ | **Unitree G1** | <img src="img/g1.png" width="200" height="150" alt="Unitree G1 Humanoid"> |
6
+ | **Unitree Go1** | <img src="img/go1.png" width="200" height="150" alt="Unitree Go1 Quadruped"> |
File without changes
Binary file
Binary file
@@ -0,0 +1,49 @@
1
+ from dataclasses import replace
2
+ from pathlib import Path
3
+
4
+ import mujoco
5
+ from PIL import Image
6
+
7
+ from mjlab.entity import Entity, EntityCfg
8
+ from mjlab.utils.spec_config import TextureCfg
9
+
10
+ _HERE = Path(__file__).parent
11
+ _HEIGHT = 300
12
+ _WIDTH = 400
13
+
14
+
15
+ def render_robots(name: str, cfg: EntityCfg):
16
+ skybox_tex = TextureCfg(
17
+ name="skybox",
18
+ type="skybox",
19
+ builtin="gradient",
20
+ rgb1=(1, 1, 1),
21
+ rgb2=(1, 1, 1),
22
+ width=512,
23
+ height=3072,
24
+ )
25
+ robot = Entity(replace(cfg, textures=(skybox_tex,)))
26
+ model = robot.compile()
27
+ data = mujoco.MjData(model)
28
+ mujoco.mj_resetDataKeyframe(model, data, 0)
29
+ data.qpos[:3] = 0.0
30
+ mujoco.mj_forward(model, data)
31
+ cam = mujoco.MjvCamera()
32
+ mujoco.mjv_defaultCamera(cam)
33
+ cam.elevation = -10
34
+ cam.distance = 1.15 * model.stat.extent
35
+ cam.azimuth = -160
36
+ cam.lookat[2] -= 0.1
37
+ with mujoco.Renderer(model, height=_HEIGHT, width=_WIDTH) as renderer:
38
+ renderer.update_scene(data, cam)
39
+ img = renderer.render()
40
+ img = Image.fromarray(img)
41
+ img.save(_HERE / "img" / f"{name}.png")
42
+
43
+
44
+ if __name__ == "__main__":
45
+ from mjlab.asset_zoo.robots.unitree_g1.g1_constants import G1_ROBOT_CFG
46
+ from mjlab.asset_zoo.robots.unitree_go1.go1_constants import GO1_ROBOT_CFG
47
+
48
+ render_robots("g1", G1_ROBOT_CFG)
49
+ render_robots("go1", GO1_ROBOT_CFG)
@@ -0,0 +1,7 @@
1
+ from mjlab.asset_zoo.robots.unitree_g1.g1_constants import G1_ROBOT_CFG
2
+ from mjlab.asset_zoo.robots.unitree_go1.go1_constants import GO1_ROBOT_CFG
3
+
4
+ __all__ = (
5
+ "G1_ROBOT_CFG",
6
+ "GO1_ROBOT_CFG",
7
+ )
@@ -0,0 +1 @@
1
+ """Unitree G1 humanoid."""
@@ -0,0 +1,296 @@
1
+ """Unitree G1 constants."""
2
+
3
+ from pathlib import Path
4
+
5
+ import mujoco
6
+
7
+ from mjlab import MJLAB_SRC_PATH
8
+ from mjlab.entity import EntityArticulationInfoCfg, EntityCfg
9
+ from mjlab.utils.actuator import (
10
+ ElectricActuator,
11
+ reflected_inertia_from_two_stage_planetary,
12
+ )
13
+ from mjlab.utils.os import update_assets
14
+ from mjlab.utils.spec_config import ActuatorCfg, CollisionCfg
15
+
16
+ ##
17
+ # MJCF and assets.
18
+ ##
19
+
20
+ G1_XML: Path = (
21
+ MJLAB_SRC_PATH / "asset_zoo" / "robots" / "unitree_g1" / "xmls" / "g1.xml"
22
+ )
23
+ assert G1_XML.exists()
24
+
25
+
26
+ def get_assets(meshdir: str) -> dict[str, bytes]:
27
+ assets: dict[str, bytes] = {}
28
+ update_assets(assets, G1_XML.parent / "assets", meshdir)
29
+ return assets
30
+
31
+
32
+ def get_spec() -> mujoco.MjSpec:
33
+ spec = mujoco.MjSpec.from_file(str(G1_XML))
34
+ spec.assets = get_assets(spec.meshdir)
35
+ return spec
36
+
37
+
38
+ ##
39
+ # Actuator config.
40
+ ##
41
+
42
+ # Motor specs (from Unitree).
43
+ ROTOR_INERTIAS_5020 = (
44
+ 0.139e-4,
45
+ 0.017e-4,
46
+ 0.169e-4,
47
+ )
48
+ GEARS_5020 = (
49
+ 1,
50
+ 1 + (46 / 18),
51
+ 1 + (56 / 16),
52
+ )
53
+ ARMATURE_5020 = reflected_inertia_from_two_stage_planetary(
54
+ ROTOR_INERTIAS_5020, GEARS_5020
55
+ )
56
+
57
+ ROTOR_INERTIAS_7520_14 = (
58
+ 0.489e-4,
59
+ 0.098e-4,
60
+ 0.533e-4,
61
+ )
62
+ GEARS_7520_14 = (
63
+ 1,
64
+ 4.5,
65
+ 1 + (48 / 22),
66
+ )
67
+ ARMATURE_7520_14 = reflected_inertia_from_two_stage_planetary(
68
+ ROTOR_INERTIAS_7520_14, GEARS_7520_14
69
+ )
70
+
71
+ ROTOR_INERTIAS_7520_22 = (
72
+ 0.489e-4,
73
+ 0.109e-4,
74
+ 0.738e-4,
75
+ )
76
+ GEARS_7520_22 = (
77
+ 1,
78
+ 4.5,
79
+ 5,
80
+ )
81
+ ARMATURE_7520_22 = reflected_inertia_from_two_stage_planetary(
82
+ ROTOR_INERTIAS_7520_22, GEARS_7520_22
83
+ )
84
+
85
+ ROTOR_INERTIAS_4010 = (
86
+ 0.068e-4,
87
+ 0.0,
88
+ 0.0,
89
+ )
90
+ GEARS_4010 = (
91
+ 1,
92
+ 5,
93
+ 5,
94
+ )
95
+ ARMATURE_4010 = reflected_inertia_from_two_stage_planetary(
96
+ ROTOR_INERTIAS_4010, GEARS_4010
97
+ )
98
+
99
+ ACTUATOR_5020 = ElectricActuator(
100
+ reflected_inertia=ARMATURE_5020,
101
+ velocity_limit=37.0,
102
+ effort_limit=25.0,
103
+ )
104
+ ACTUATOR_7520_14 = ElectricActuator(
105
+ reflected_inertia=ARMATURE_7520_14,
106
+ velocity_limit=32.0,
107
+ effort_limit=88.0,
108
+ )
109
+ ACTUATOR_7520_22 = ElectricActuator(
110
+ reflected_inertia=ARMATURE_7520_22,
111
+ velocity_limit=20.0,
112
+ effort_limit=139.0,
113
+ )
114
+ ACTUATOR_4010 = ElectricActuator(
115
+ reflected_inertia=ARMATURE_4010,
116
+ velocity_limit=22.0,
117
+ effort_limit=5.0,
118
+ )
119
+
120
+ NATURAL_FREQ = 10 * 2.0 * 3.1415926535 # 10Hz
121
+ DAMPING_RATIO = 2.0
122
+
123
+ STIFFNESS_5020 = ARMATURE_5020 * NATURAL_FREQ**2
124
+ STIFFNESS_7520_14 = ARMATURE_7520_14 * NATURAL_FREQ**2
125
+ STIFFNESS_7520_22 = ARMATURE_7520_22 * NATURAL_FREQ**2
126
+ STIFFNESS_4010 = ARMATURE_4010 * NATURAL_FREQ**2
127
+
128
+ DAMPING_5020 = 2.0 * DAMPING_RATIO * ARMATURE_5020 * NATURAL_FREQ
129
+ DAMPING_7520_14 = 2.0 * DAMPING_RATIO * ARMATURE_7520_14 * NATURAL_FREQ
130
+ DAMPING_7520_22 = 2.0 * DAMPING_RATIO * ARMATURE_7520_22 * NATURAL_FREQ
131
+ DAMPING_4010 = 2.0 * DAMPING_RATIO * ARMATURE_4010 * NATURAL_FREQ
132
+
133
+ G1_ACTUATOR_5020 = ActuatorCfg(
134
+ joint_names_expr=[
135
+ ".*_elbow_joint",
136
+ ".*_shoulder_pitch_joint",
137
+ ".*_shoulder_roll_joint",
138
+ ".*_shoulder_yaw_joint",
139
+ ".*_wrist_roll_joint",
140
+ ],
141
+ effort_limit=ACTUATOR_5020.effort_limit,
142
+ armature=ACTUATOR_5020.reflected_inertia,
143
+ stiffness=STIFFNESS_5020,
144
+ damping=DAMPING_5020,
145
+ )
146
+ G1_ACTUATOR_7520_14 = ActuatorCfg(
147
+ joint_names_expr=[".*_hip_pitch_joint", ".*_hip_yaw_joint", "waist_yaw_joint"],
148
+ effort_limit=ACTUATOR_7520_14.effort_limit,
149
+ armature=ACTUATOR_7520_14.reflected_inertia,
150
+ stiffness=STIFFNESS_7520_14,
151
+ damping=DAMPING_7520_14,
152
+ )
153
+ G1_ACTUATOR_7520_22 = ActuatorCfg(
154
+ joint_names_expr=[".*_hip_roll_joint", ".*_knee_joint"],
155
+ effort_limit=ACTUATOR_7520_22.effort_limit,
156
+ armature=ACTUATOR_7520_22.reflected_inertia,
157
+ stiffness=STIFFNESS_7520_22,
158
+ damping=DAMPING_7520_22,
159
+ )
160
+ G1_ACTUATOR_4010 = ActuatorCfg(
161
+ joint_names_expr=[".*_wrist_pitch_joint", ".*_wrist_yaw_joint"],
162
+ effort_limit=ACTUATOR_4010.effort_limit,
163
+ armature=ACTUATOR_4010.reflected_inertia,
164
+ stiffness=STIFFNESS_4010,
165
+ damping=DAMPING_4010,
166
+ )
167
+
168
+ # Waist pitch/roll and ankles are 4-bar linkages with 2 5020 actuators.
169
+ # Due to the parallel linkage, the effective armature at the ankle and waist joints
170
+ # is configuration dependent. Since the exact geometry of the linkage is unknown, we
171
+ # assume a nominal 1:1 gear ratio. Under this assumption, the joint armature in the
172
+ # nominal configuration is approximated as the sum of the 2 actuators' armatures.
173
+ G1_ACTUATOR_WAIST = ActuatorCfg(
174
+ joint_names_expr=["waist_pitch_joint", "waist_roll_joint"],
175
+ effort_limit=ACTUATOR_5020.effort_limit * 2,
176
+ armature=ACTUATOR_5020.reflected_inertia * 2,
177
+ stiffness=STIFFNESS_5020 * 2,
178
+ damping=DAMPING_5020 * 2,
179
+ )
180
+ G1_ACTUATOR_ANKLE = ActuatorCfg(
181
+ joint_names_expr=[".*_ankle_pitch_joint", ".*_ankle_roll_joint"],
182
+ effort_limit=ACTUATOR_5020.effort_limit * 2,
183
+ armature=ACTUATOR_5020.reflected_inertia * 2,
184
+ stiffness=STIFFNESS_5020 * 2,
185
+ damping=DAMPING_5020 * 2,
186
+ )
187
+
188
+ ##
189
+ # Keyframe config.
190
+ ##
191
+
192
+ HOME_KEYFRAME = EntityCfg.InitialStateCfg(
193
+ pos=(0, 0, 0.783675),
194
+ joint_pos={
195
+ ".*_hip_pitch_joint": -0.1,
196
+ ".*_knee_joint": 0.3,
197
+ ".*_ankle_pitch_joint": -0.2,
198
+ ".*_shoulder_pitch_joint": 0.2,
199
+ ".*_elbow_joint": 1.28,
200
+ "left_shoulder_roll_joint": 0.2,
201
+ "right_shoulder_roll_joint": -0.2,
202
+ },
203
+ joint_vel={".*": 0.0},
204
+ )
205
+
206
+ KNEES_BENT_KEYFRAME = EntityCfg.InitialStateCfg(
207
+ pos=(0, 0, 0.76),
208
+ joint_pos={
209
+ ".*_hip_pitch_joint": -0.312,
210
+ ".*_knee_joint": 0.669,
211
+ ".*_ankle_pitch_joint": -0.363,
212
+ ".*_elbow_joint": 0.6,
213
+ "left_shoulder_roll_joint": 0.2,
214
+ "left_shoulder_pitch_joint": 0.2,
215
+ "right_shoulder_roll_joint": -0.2,
216
+ "right_shoulder_pitch_joint": 0.2,
217
+ },
218
+ joint_vel={".*": 0.0},
219
+ )
220
+
221
+ ##
222
+ # Collision config.
223
+ ##
224
+
225
+ # This enables all collisions, including self collisions.
226
+ # Self-collisions are given condim=1 while foot collisions
227
+ # are given condim=3 and custom friction and solimp.
228
+ FULL_COLLISION = CollisionCfg(
229
+ geom_names_expr=[".*_collision"],
230
+ condim={r"^(left|right)_foot[1-7]_collision$": 3},
231
+ priority={r"^(left|right)_foot[1-7]_collision$": 1},
232
+ friction={r"^(left|right)_foot[1-7]_collision$": (0.6,)},
233
+ )
234
+
235
+ FULL_COLLISION_WITHOUT_SELF = CollisionCfg(
236
+ geom_names_expr=[".*_collision"],
237
+ contype=0,
238
+ conaffinity=1,
239
+ condim={r"^(left|right)_foot[1-7]_collision$": 3},
240
+ priority={r"^(left|right)_foot[1-7]_collision$": 1},
241
+ friction={r"^(left|right)_foot[1-7]_collision$": (0.6,)},
242
+ )
243
+
244
+ FEET_ONLY_COLLISION = CollisionCfg(
245
+ geom_names_expr=[r"^(left|right)_foot[1-7]_collision$"],
246
+ contype=0,
247
+ conaffinity=1,
248
+ condim=3,
249
+ priority=1,
250
+ friction=(0.6,),
251
+ )
252
+
253
+ ##
254
+ # Final config.
255
+ ##
256
+
257
+ G1_ARTICULATION = EntityArticulationInfoCfg(
258
+ actuators=(
259
+ G1_ACTUATOR_5020,
260
+ G1_ACTUATOR_7520_14,
261
+ G1_ACTUATOR_7520_22,
262
+ G1_ACTUATOR_4010,
263
+ G1_ACTUATOR_WAIST,
264
+ G1_ACTUATOR_ANKLE,
265
+ ),
266
+ soft_joint_pos_limit_factor=0.9,
267
+ )
268
+
269
+ G1_ROBOT_CFG = EntityCfg(
270
+ init_state=KNEES_BENT_KEYFRAME,
271
+ collisions=(FULL_COLLISION,),
272
+ spec_fn=get_spec,
273
+ articulation=G1_ARTICULATION,
274
+ )
275
+
276
+ G1_ACTION_SCALE: dict[str, float] = {}
277
+ for a in G1_ARTICULATION.actuators:
278
+ e = a.effort_limit
279
+ s = a.stiffness
280
+ names = a.joint_names_expr
281
+ if not isinstance(e, dict):
282
+ e = {n: e for n in names}
283
+ if not isinstance(s, dict):
284
+ s = {n: s for n in names}
285
+ for n in names:
286
+ if n in e and n in s and s[n]:
287
+ G1_ACTION_SCALE[n] = 0.25 * e[n] / s[n]
288
+
289
+ if __name__ == "__main__":
290
+ import mujoco.viewer as viewer
291
+
292
+ from mjlab.entity.entity import Entity
293
+
294
+ robot = Entity(G1_ROBOT_CFG)
295
+
296
+ viewer.launch(robot.spec.compile())