> 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.md).

# Quick Start Demos

This section provides several quick demos for testing different parts of the `humanoid-control` system.

* **Gamepad Motor Demo** — Command all motors defined in a selected configuration file using gamepad input.
* **Arm Test** — Control a 4-DoF left arm with DM4310 motors using gamepad-based joint velocity commands.
* **Leg Test** — Control the knee and ankle motors of a single leg through USB2CANFD.
* **Body Joint Control** — Manually command the full lower body, including both legs and the torso, using a gamepad.
* **Locomotion (RL Inference)** — Run the 11-DoF lower-body reinforcement-learning locomotion controller in simulation or on the real robot.
* **Whole-Body Locomotion (RL Inference)** — Run the 19-DoF whole-body locomotion setup, with the policy observing all joints and actuating the lower body.
* **Bimanual Arm Control** — Control both 4-DoF arms using model-based controllers with gravity compensation, joint-space control, and Cartesian end-effector control.

{% tabs %}
{% tab title="Gamepad Motor Demo" %}
End-to-end test flow to command all motors configured in the selected .yaml config via a gamepad.

* `dm_motor`: Low-level CAN driver node that communicates with Damiao motors (enable, send commands, receive feedback)
* `dm_motor_demo`: High-level command node that subscribes to gamepad input and sends the same target angle to all configured motors
* `arc-gamepad`: Reads gamepad input and publishes it to LCM via arc-bridge

Open 4 terminals and run the following in order:

{% stepper %}
{% step %}

#### Terminal 1: Enable CAN transceivers & initialize CAN bus

```bash
# Pull GPIO low to enable CAN transceivers
# sudo may be required unless your user is already in the gpio group
gpioset --mode=wait 0 106=0   # enable CAN1
gpioset --mode=wait 0 43=0    # enable CAN0
```

{% endstep %}

{% step %}

#### Terminal 2: Launch motor driver node

```bash
source install/setup.bash
sudo bash scripts/can0_setup.sh
ros2 launch dm_motor motor_driver.launch.py
```

{% endstep %}

{% step %}

#### Terminal 3: Launch demo node

```bash
source install/setup.bash
ros2 run dm_motor_demo dm_motor_demo_node
```

{% endstep %}

{% step %}

#### Terminal 4: Launch gamepad bridge

```bash
conda activate arcpy
arc-gamepad

# (Optional, in separate terminal) Verify CAN bus traffic
candump can0
```

{% endstep %}
{% endstepper %}

Once all four terminals are running, you can command the motors with the gamepad.
{% endtab %}

{% tab title="Arm Test" %}
Single left arm test with 4x DM4310 motors on CAN0 (IDs 0x01–0x04). Gamepad stick position acts as angular velocity, each control tick, the target angle is incremented by stick\_value \* scale \* dt:

* vx - joint 1, vy - joint 2, wz - joint 3, pitch - joint 4

Open 4 terminals and run the following in order:

{% stepper %}
{% step %}

#### Terminal 1: Enable CAN transceivers & initialize CAN bus

```bash
gpioset --mode=wait 0 43=0    # enable CAN0
```

{% endstep %}

{% step %}

#### Terminal 2: Launch motor driver node (arm config)

```bash
source install/setup.bash
sudo bash scripts/can0_setup.sh
ros2 launch dm_motor motor_driver.launch.py config:=arm_test.yaml
```

{% endstep %}

{% step %}

#### Terminal 3: Launch arm control node

```bash
source install/setup.bash
ros2 run dm_motor_arm dm_motor_arm_node
```

{% endstep %}

{% step %}

#### Terminal 4: Launch gamepad bridge (all axes scaled to \[-pi, pi])

```bash
conda activate arcpy
arc-gamepad --vel-scale-x 3.14159 --vel-scale-y 3.14159 --vel-scale-rot 3.14159 --scale-pitch 3.14159
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Leg Test" %}
Single leg test with 2 motors (DM8009 knee + DM6006 ankle) on USB2CANFD. Gamepad stick position acts as angular velocity, each control tick, the target joint angle is incremented by stick\_value \* scale \* dt:

* vx - knee joint angle (limits: 0 to 2π)
* pitch - ankle joint angle (limits: -π to π)

Open 3 terminals and run the following in order:

{% stepper %}
{% step %}

#### Terminal 1: Launch motor driver node (USB2CANFD leg config)

```bash
source install/setup.bash
ros2 launch dm_motor motor_driver.launch.py config:=leg_test_usb2canfd.yaml
```

{% endstep %}

{% step %}

#### Terminal 2: Launch leg control node

```bash
source install/setup.bash
ros2 run dm_motor_leg dm_motor_leg_node
```

{% endstep %}

{% step %}

#### Terminal 3: Launch gamepad bridge

```bash
conda activate arcpy
arc-gamepad --vel-scale-x 3.14159 --vel-scale-y 3.14159 --vel-scale-rot 3.14159 --scale-pitch 3.14159
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Body Joint Control" %}
End-to-end flow for commanding the full lower body (11 motors: 1 torso\_yaw + 5 left leg + 5 right leg) with a gamepad. The joint-space controller maps sticks/triggers to joint-angle increments for the currently selected leg and maps params\[1] directly to torso yaw.

Gamepad mapping (of the currently selected leg):

* vx - ankle\_pitch, vy - hip\_abad, pitch - knee, wz - hip\_yaw, rt - lt - hip\_pitch
* params\[1] (-n..+n, center 0) - torso\_yaw (direct mapping to +/-torso\_yaw\_max)
* btn\_left / btn\_right - switch control to LEFT / RIGHT leg

The default config `modules/motor/dm_motor/config/motor.yaml` uses USB2CANFD for all 11 motors. Per-joint PD gains, joint-space limits, and per-leg joystick sign inversions live in `applications/body_joint_ctrl/config/body_joint_ctrl.yaml`.

Open 3 terminals and run the following in order:

{% stepper %}
{% step %}

#### Terminal 1: Launch motor driver node (full-body USB2CANFD config)

```bash
source install/setup.bash
ros2 launch dm_motor motor_driver.launch.py
```

{% endstep %}

{% step %}

#### Terminal 2: Launch body joint controller

```bash
source install/setup.bash
ros2 launch body_joint_ctrl body_joint_ctrl.launch.py
```

{% endstep %}

{% step %}

#### Terminal 3: Launch gamepad bridge

```bash
conda activate arcpy
arc-gamepad --vel-scale-x 3.14159 --vel-scale-y 3.14159 --vel-scale-rot 3.14159 --scale-pitch 3.14159
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="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.

{% stepper %}
{% step %}

#### Terminal 0 — MuJoCo Simulation

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

Select `arcadian_arm_8dof` when prompted.
{% endstep %}

{% step %}

#### Terminal 1 — Gamepad

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

ros2 launch gamepad gamepad_publisher.launch.py
```

{% endstep %}

{% step %}

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

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

ros2 launch arc_bridge arc_bridge_arm.launch.py
```

{% endstep %}

{% step %}

#### 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
```

{% endstep %}
{% endstepper %}

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.

{% stepper %}
{% step %}

#### Terminal 1 — Gamepad

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

ros2 launch gamepad gamepad_publisher.launch.py
```

{% endstep %}

{% step %}

#### 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.
{% endstep %}
{% endstepper %}

#### 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.

{% stepper %}
{% step %}

#### Terminal 0 — Start arc-bridge in replay mode

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

Then open two ROS 2 terminals.
{% endstep %}

{% step %}

#### Terminal 1 — Gamepad

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

ros2 launch gamepad gamepad_publisher.launch.py
```

{% endstep %}

{% step %}

#### 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
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}


---

# 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.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.
