Instructions to use k-valentin/unitree-g1-mujoco with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use k-valentin/unitree-g1-mujoco with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Import lerobot/unitree-g1-mujoco@68459ed6 + 23dof (rev_1_0) body variant, defaults BODY=23dof END_EFFECTOR=dummy
257dded verified Download sim/sim_utils.py from k-valentin/unitree-g1-mujoco: direct link, hf CLI and curl.
- Browser
- Download file 2.65 kB
-
https://huggingface.co/k-valentin/unitree-g1-mujoco/resolve/main/sim/sim_utils.py
- Command line
-
hf download hf://k-valentin/unitree-g1-mujoco/sim/sim_utils.py
-
curl -L -o sim_utils.py https://huggingface.co/k-valentin/unitree-g1-mujoco/resolve/main/sim/sim_utils.py
2.65 kB
| """ | |
| Utility functions for working with Mujoco models. | |
| copied from https://github.com/kevinzakka/mink/blob/main/mink/utils.py | |
| """ | |
| from typing import List | |
| import mujoco | |
| def get_body_body_ids(model: mujoco.MjModel, body_id: int) -> List[int]: | |
| """Get immediate children bodies belonging to a given body. | |
| Args: | |
| model: Mujoco model. | |
| body_id: ID of body. | |
| Returns: | |
| A List containing all child body ids. | |
| """ | |
| return [ | |
| i | |
| for i in range(model.nbody) | |
| if model.body_parentid[i] == body_id and body_id != i # Exclude the body itself. | |
| ] | |
| def get_subtree_body_ids(model: mujoco.MjModel, body_id: int) -> List[int]: | |
| """Get all bodies belonging to subtree starting at a given body. | |
| Args: | |
| model: Mujoco model. | |
| body_id: ID of body where subtree starts. | |
| Returns: | |
| A List containing all subtree body ids. | |
| """ | |
| body_ids: List[int] = [] | |
| stack = [body_id] | |
| while stack: | |
| body_id = stack.pop() | |
| body_ids.append(body_id) | |
| stack += get_body_body_ids(model, body_id) | |
| return body_ids | |
| def get_subtree_body_names(model: mujoco.MjModel, body_id: int) -> List[str]: | |
| """Get all bodies belonging to subtree starting at a given body. | |
| Args: | |
| model: Mujoco model. | |
| body_id: ID of body where subtree starts. | |
| Returns: | |
| A List containing all subtree body names. | |
| """ | |
| return [model.body(i).name for i in get_subtree_body_ids(model, body_id)] | |
| def get_body_geom_ids(model: mujoco.MjModel, body_id: int) -> List[int]: | |
| """Get immediate geoms belonging to a given body. | |
| Here, immediate geoms are those directly attached to the body and not its | |
| descendants. | |
| Args: | |
| model: Mujoco model. | |
| body_id: ID of body. | |
| Returns: | |
| A list containing all body geom ids. | |
| """ | |
| geom_start = model.body_geomadr[body_id] | |
| geom_end = geom_start + model.body_geomnum[body_id] | |
| return list(range(geom_start, geom_end)) | |
| def get_subtree_geom_ids(model: mujoco.MjModel, body_id: int) -> List[int]: | |
| """Get all geoms belonging to subtree starting at a given body | |
| Here, a subtree is defined as the kinematic tree starting at the body and including | |
| all its descendants. | |
| Args: | |
| model: Mujoco model. | |
| body_id: ID of body where subtree starts. | |
| Returns: | |
| A list containing all subtree geom ids. | |
| """ | |
| geom_ids: List[int] = [] | |
| stack = [body_id] | |
| while stack: | |
| body_id = stack.pop() | |
| geom_ids.extend(get_body_geom_ids(model, body_id)) | |
| stack += get_body_body_ids(model, body_id) | |
| return geom_ids | |