# xArm

## Gripper hardware setup

Follow this guide to assemble the gripper: [Assembly Guide](https://nyu-gripper.pages.dev/robot-gripper)

Have the following materials ready:

* Download and print the [gripper mount](https://nyu-gripper.pages.dev/cad/Robot%20_Gripper/xarm7_print%20with%20tpu.stl) in **TPU**
* 4 M6 x 10mm Screws
* 4 M2.5 x 10mm Screws
* The [Dynamixel Starter Set](https://www.robotis.us/dynamixel-starter-set-us/), which includes parts 2-6 in the photo below:

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-c34d519c14f92acd5d398653eef4b24c95fde4d8%2FLabeledParts.jpg?alt=media" alt=""><figcaption></figcaption></figure>

1. Connect the Dynamixel Motor to the U2D2 Power Hub. You will hear a clicking sound when connected:

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-00ffe53b60d38905ed5b5a787112c4d19df330c3%2FMotor2PowerHubOutline.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

2. Connect the Power Hub to the U2D2 Board

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-0edaecb1855515c0cde52a41ccb2f9d0dbcc8223%2FU2D2ConnectionsOutline.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

3. Connect the U2D2 and your computer with the USB cable. A red light will turn on.

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-afd407d51d20bc587543ea522381408b18985e16%2FU2D2On.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

4. Plug the 12V 5A power supply into the U2D2 Power Hub board and switch on the power. A red LED should turn on.

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-7f3181b7da23f675a788199dff4ceec74c9ad90e%2FU2D2PowerHubOn.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Go to the `robot-server` directory and run this script to initialize the gripper:

```bash
cd robot-server
python gripper_init.py
```

## Hardware Setup

1. **Power on** the xArm.
2. Ensure the **safety button is disengaged**:

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-238712120ca86a8da65ef687a3cfba650245e07c%2FLabeledxArmButtons.png?alt=media" alt=""><figcaption></figcaption></figure>

3. **Attach gripper to the mount** with M2.5 x 10mm screws

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-b8a56b2556ec8e4ac93e9d371e09097036dedf4d%2FxArmGripperMount.jpg?alt=media" alt="" width="375"><figcaption></figcaption></figure>

4. **Mount your 3D printed TPU xArm mount** with M6 x 10mm screws

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-36f56f5f440a6ee06f4523d4223681f2855ea36e%2FxArmScrews.jpg?alt=media" alt="" width="375"><figcaption></figcaption></figure>

## Deploying a Trained Policy

1. **Set up the iPhone** on the robot:
   * Slide the iPhone into the gripper mount until the camera block hits the mount, then tighten the knob (snug, not over-tight).

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-2ab8b76d2d37b31908cfcc1b66231651179aba92%2FxArmIphoneFront.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* Connect the iPhone to the robot via USB.

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-2b41a2065597e2fa34b52f6506779be07eaf88e2%2FxArmIphoneUSBtrust.jpg?alt=media" alt="" width="563"><figcaption></figcaption></figure>

* In **Record3D** app settings: set **RGBD Streaming** mode to **USB** and **FPS** to **30**.

<figure><img src="https://1062622575-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fhk470ucohNkzUZJCG1We%2Fuploads%2Fgit-blob-b3abb1c5dfbb0046a12112a24feeabe39eaee598%2Frecord3D_optionsOutline.PNG?alt=media" alt="" width="375"><figcaption></figcaption></figure>

* Press **Record** to enter “stream-ready” mode.

2. **Calibrate Gripper**:

   ```bash
   cd robot-server
   conda activate home_robot
   python auto_calibrate_gripper.py
   ```
3. **Start the robot server**:(Make sure to edit xArm IP):

   ```bash
   python3 start_server.py controller=xarm network.xarm_ip=???
   ```

   This starts streaming images from the iPhone and the robot begins listening for action commands. If you have missing imports, try `pip3 install hydra-core record3d` (and any other missing packages).
4. **Run the policy** in another terminal (requires display):

   ```bash
   cd imitation-in-homes
   conda activate home_robot
   python run.py
   ```
5. Head to the [Playbook](https://docs.google.com/document/d/1nq0DX-a31FvFr1TDDIrt1seIKJJO8ftYRcByZvWp9IE/edit?tab=t.0)

### Available Policy Checkpoints

When running `python run.py`, you can select from these preconfigured checkpoints:

* **`run_vqbet_pick`**: default checkpoint for picking task.
* **`run_vqbet_open`**: default checkpoint for opening task.
* **`run_vqbet_close`**: default checkpoint for closing task.
* **`run_vqbet_pick_exp`**: experimental pick checkpoint.

Choose the config that matches your task and substitute it in:

```bash
python run.py --config-name=<one_of_the_above>
```

***
