> For the complete documentation index, see [llms.txt](https://anonymous-humanoid.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anonymous-humanoid.gitbook.io/docs/getting-started-software/quick-start-demos/bimanual-arm-model-based-control.md).

# Bimanual Arm (Model-Based Control)

## Bimanual Arm Control

The `bimanual_arm` package provides model-based control for the two **4-DoF arms**.

The controller subscribes to:

* `/arms/dm_motor_data`
* `gamepad_cmd`

and publishes:

* `/arms/dm_motor_cmd`

Pinocchio is used for the robot model and gravity-compensation calculation.

## Gamepad Controls

Each arm supports the following control modes:

* `btn_up`: **ACTIVE\_CONTROLLER**
* `btn_down`: **HOLD\_POSITION**
* `btn_left`: **ZERO\_TORQUE**
* `btn_right`: **DAMPING**
* `btn_rstick`: **RETURN\_HOME**
* `params[1]`: active-controller selection, adjusted using **D-pad Left/Right**

By default, commands apply to both arms. Hold:

* `btn_lb` to scope the command to one arm
* `btn_rb` to scope the command to the other arm

## Active Controllers

The available active controllers are:

* **Gravity compensation**
* **Gravity compensation + joint-space PD control**
* **Cartesian end-effector control**

For Cartesian control, the gamepad commands are mapped as follows:

* `vx` → TCP x
* `vy` → TCP y
* `pitch` → TCP z
* `wz` → shoulder yaw

The Cartesian controller supports either:

* closed-form inverse kinematics
* ProxQP-based inverse kinematics

Before running any ROS 2 command, each terminal must enter the `humanoid-control` workspace and source the workspace setup:

```bash
cd ~/projects/humanoid-control
source install/setup.bash
```

## A. Pure Simulation

In pure simulation mode, `arc-bridge` runs the MuJoCo arm simulation using the `arcadian_arm_8dof` robot model.

Open four terminals.

**Terminal 0 — MuJoCo Simulation**

```bash
conda activate arcpy
arc-bridge
```

Select `arcadian_arm_8dof` when prompted.

**Terminal 1 — Gamepad**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch gamepad gamepad_publisher.launch.py
```

**Terminal 2 — ROS 2 ↔ arc-bridge**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch arc_bridge arc_bridge_arm.launch.py
```

**Terminal 3 — Bimanual Arm Controller**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch bimanual_arm bimanual_arm.launch.py launch_motor_driver:=false
```

Alternatively, the bridge and controller can be launched together:

**Terminal 2 — Combined Simulation Launch**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch bimanual_arm bimanual_arm.launch.py sim:=true
```

With `sim:=true`, the real motor driver is not started.

***

## B. Real Robot

For operation on the real robot, open two terminals.

**Terminal 1 — Gamepad**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch gamepad gamepad_publisher.launch.py
```

**Terminal 2 — Bimanual Arm Controller + Motor Driver**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch bimanual_arm bimanual_arm.launch.py
```

This launch file also starts the motor driver for the `/arms` motor interface.

***

## C. Real Robot + arc-bridge Replay Viewer

This mode uses the same setup as **B. Real Robot**, while additionally forwarding `/arms/dm_motor_data` to `arc-bridge` for visualization.

First, start `arc-bridge` in replay mode:

```bash
conda activate arcpy
arc-bridge --replay
```

Then open two ROS 2 terminals.

**Terminal 1 — Gamepad**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch gamepad gamepad_publisher.launch.py
```

**Terminal 2 — Bimanual Arm Controller + Replay Bridge**

```bash
cd ~/projects/humanoid-control
source install/setup.bash

ros2 launch bimanual_arm bimanual_arm.launch.py replay:=true
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://anonymous-humanoid.gitbook.io/docs/getting-started-software/quick-start-demos/bimanual-arm-model-based-control.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
