> For the complete documentation index, see [llms.txt](https://doc.ancorasir.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.ancorasir.com/2026spring/simulation-and-interaction/class-06-unitree-g1-simulation-in-mujoco.md).

# Class 06: Unitree G1 Simulation in MuJoCo

This folder demonstrates the Unitree G1 robot in MuJoCo across multiple configurations (various degrees of freedom). It includes example XMLs and notebooks that show how to load each XML, display it, and run teleoperation via the asMagic app.

### Included demos (common XML names)

* Head yaw (1 DoF): `g1_head_1dof.xml`
* Single arm (5 DoF): `g1_one_arm_5dof.xml`
* Dual arms (14 DoF): `g1_two_arms_14dof.xml`
* Waist (3 DoF): `g1_waist_3dof.xml`
* Two legs (12 DoF): `g1_two_legs_12dof.xml`
* Full robot (29 DoF): `g1_29dof.xml`

### Notebooks

* `g1_mujoco.ipynb` — displays the XMLs above for different DoF setups, builds a `mujoco.MjModel`, and launches the MuJoCo viewer.
* `teleop_g1_mujoco_asmagic.ipynb` — maps phone pose input to IK targets and drives the MuJoCo model in a live loop.
* `teleop_g1_mujoco_asmagic_object.ipynb` — extends teleoperation with an object-interaction scene.

### Quick Installation

These steps match the environment used by the notebooks in this folder.

1. Create/activate the Python environment you want to use (recommended: venv or conda).

```bash
conda create -n asHumanoids python=3.11
conda activate asHumanoids
```

2. Install Python packages (MuJoCo + runtime libs used in the notebooks):

```bash
pip install mujoco mink loop-rate-limiters asmagic scipy
```

Note: the notebooks also use `IPython` display utilities (Jupyter) if you run them interactively. If you run in a Jupyter notebook, ensure the kernel matches the environment where you installed the packages.

### How to run

* From Jupyter Notebook: open `g1_mujoco.ipynb` to explore the XML configurations and viewer.
* For teleoperation: open `teleop_g1_mujoco_asmagic.ipynb`, connect the asMagic app, then run the cells to stream phone poses into the IK loop.

### Teleoperation example (asMagic)

The teleoperation notebook integrates `mink` IK, `asmagic` phone input, and mocap targets. The code example demonstrates:

* constructing a `mink.Configuration` from a loaded `mujoco.MjModel`
* defining `mink.FrameTask`, `mink.PostureTask`, and other tasks
* receiving phone poses using `asmagic.ARDataSubscriber`
* converting phone poses and applying deltas to hand targets
* running a control loop that solves IK and updates the MuJoCo viewer

See `teleop_g1_mujoco_asmagic.ipynb` for the full implementation and parameter choices.

### Model files

* `unitree_g1/` contains the MJCF models, scene variants, meshes, and their upstream license.
* `unitree_g1/g1_29dof_scene.xml` is the standard full-body scene.
* `unitree_g1/g1_29dof_scene_wbc.xml` adds the scene configuration used by whole-body-control examples.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.ancorasir.com/2026spring/simulation-and-interaction/class-06-unitree-g1-simulation-in-mujoco.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
