Skip to content

Commit

Permalink
Transition to creating local copy of lerobot and copying overlay files
Browse files Browse the repository at this point in the history
  • Loading branch information
tokk-nv committed Oct 3, 2024
1 parent c51980b commit a204628
Show file tree
Hide file tree
Showing 17 changed files with 21,864 additions and 1,522 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ __pycache__
*.so
*.deb
data/*
data/lerobot/notebooks/outputs
data/lerobot/99-usb-serial.rule
!data/lerobot
logs
test/data
runner
Expand Down
1 change: 0 additions & 1 deletion data/lerobot/.cache/calibration/koch/README.md

This file was deleted.

1,444 changes: 0 additions & 1,444 deletions data/lerobot/notebooks/7-2_real-robot_configure-motors.ipynb

This file was deleted.

60 changes: 0 additions & 60 deletions data/lerobot/notebooks/7-3_real-robot_record-and-visualize.ipynb

This file was deleted.

File renamed without changes.
35 changes: 35 additions & 0 deletions packages/robots/lerobot/clone_lerobot_dir_under_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Get the directory where the script resides
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Define the relative target directory (3 levels up, then into "data" directory based on script location)
RELATIVE_TARGET_DIR="$SCRIPT_DIR/../../../data"

# Resolve the absolute path to the target directory
TARGET_DIR="$(realpath "$RELATIVE_TARGET_DIR")"

# Define the GitHub repository URL
REPO_URL="https://github.com/huggingface/lerobot.git"

# Extract the repo name from the URL
REPO_NAME=$(basename -s .git "$REPO_URL")

# Full path to the target directory where the repo will be cloned
CLONE_PATH="$TARGET_DIR/$REPO_NAME"

# Check if the directory already exists
if [ -d "$CLONE_PATH" ]; then
echo "Directory $CLONE_PATH already exists. Skipping clone."
else
# Clone the repository
git clone "$REPO_URL" "$CLONE_PATH"

# Check if cloning was successful by verifying if the directory exists
if [ ! -d "$CLONE_PATH" ]; then
echo "Error: Failed to clone repository to $CLONE_PATH"
exit 1
else
echo "Repository cloned successfully to $CLONE_PATH."
fi
fi
33 changes: 33 additions & 0 deletions packages/robots/lerobot/copy_overlay_files_in_data_lerobot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Get the directory where the script resides
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Define the overlay source directory (relative to where the script is located)
OVERLAY_DIR="$SCRIPT_DIR/lerobot_overlay"

# Define the relative target directory (3 levels up, then into "data/lerobot")
RELATIVE_TARGET_DIR="$SCRIPT_DIR/../../../data/lerobot"

# Resolve the absolute path to the target directory
TARGET_DIR="$(realpath "$RELATIVE_TARGET_DIR")"

# Check if the overlay directory exists
if [ ! -d "$OVERLAY_DIR" ]; then
echo "Overlay directory $OVERLAY_DIR does not exist."
exit 1
fi

# Check if the target directory exists
if [ ! -d "$TARGET_DIR" ]; then
echo "[Error] Target directory $TARGET_DIR does not exist."
echo " "
echo "Run 'clone_lerobot_dir_under_data.sh' first."
exit 1
fi

# Copy the contents from the overlay directory to the target directory
echo "Copying files from $OVERLAY_DIR to $TARGET_DIR"
cp -r "$OVERLAY_DIR"/* "$TARGET_DIR"

echo "Files copied successfully!"
25 changes: 15 additions & 10 deletions packages/robots/lerobot/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The output should look like this.
lrwxrwxrwx 1 root root 13 Sep 24 13:07 usb-ROBOTIS_OpenRB-150_BA98C8C350304A46462E3120FF121B06-if00 -> ../../ttyACM1
```

Then edit the first line of `./data/lerobot/99-usb-serial.rules` like the following.
Then edit the first line of `./99-usb-serial.rules` like the following.

```
SUBSYSTEM=="tty", ATTRS{idVendor}=="2f5d", ATTRS{idProduct}=="2202", ATTRS{serial}=="BA98C8C350304A46462E3120FF121B06", SYMLINK+="ttyACM_kochleader"
Expand All @@ -86,17 +86,17 @@ lrwxrwxrwx 1 root root 13 Sep 24 13:07 usb-ROBOTIS_OpenRB-150_483F88DC50304A4646
$ vi ./data/lerobot/99-usb-serial.rules
```

You should have `./data/lerobot/99-usb-serial.rules` now looking like this:
You should have `./99-usb-serial.rules` now looking like this:

```
SUBSYSTEM=="tty", ATTRS{idVendor}=="2f5d", ATTRS{idProduct}=="2202", ATTRS{serial}=="BA98C8C350304A46462E3120FF121B06", SYMLINK+="ttyACM_kochleader"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2f5d", ATTRS{idProduct}=="2202", ATTRS{serial}=="483F88DC50304A46462E3120FF0C081A", SYMLINK+="ttyACM_kochfollower"
```

Finally copy this under `/etc/udev/rules.d/`, and restart Jetson.
Finally copy this under `/etc/udev/rules.d/` (of host), and restart Jetson.

```
sudo cp ./data/lerobot/99-usb-serial.rules /etc/udev/rules.d/
sudo cp ./99-usb-serial.rules /etc/udev/rules.d/
sudo reboot
```

Expand All @@ -115,15 +115,20 @@ lrwxrwxrwx 1 root root 7 Sep 24 17:20 /dev/ttyACM_kochfollower -> ttyACM
lrwxrwxrwx 1 root root 7 Sep 24 16:13 /dev/ttyACM_kochleader -> ttyACM1
```

### Start the container
### Create the local copy of lerobot on host (under `jetson-containers/data` dir)

```bash
cd jetson-containers
./packages/robots/lerobot/clone_lerobot_dir_under_data.sh
./packages/robots/lerobot/copy_overlay_files_in_data_lerobot.sh
```

### Start the container with local lerobot dir mounted

```bash
./run.sh \
--csi2webcam --csi-capture-res='1640x1232@30' --csi-output-res='640x480@30' \
-v ${PWD}/data/lerobot/.cache/calibration/koch:/opt/lerobot/.cache/calibration/koch \
-v ${PWD}/data/lerobot/lerobot/configs/robot/koch.yaml:/opt/lerobot/lerobot/configs/robot/koch.yaml \
-v ${PWD}/data/lerobot/notebooks/:/opt/lerobot/notebooks \
-v ${PWD}/data/lerobot/data/:/opt/lerobot/data \
-v ${PWD}/data/lerobot/:/opt/lerobot/ \
$(./autotag lerobot)
```

Expand All @@ -140,7 +145,7 @@ JupyterLab logs: /data/logs/jupyter.log

Copy and paste the address on your web browser and access the Jupyter Lab server.

Navigate to `./notebooks/` and open `7_get_started_with_real_robot.ipynb`.
Navigate to `./notebooks/` and open the first notebook.

Now follow the Jupyter notebook contents.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"homing_offset": [
2048, 3072, 3072, 2048, -1024, 2048
],
"drive_mode": [
1, 1, 1, 1, 0, 1
],
"start_pos": [
2024, 3067, 2987, 2079, 1012, 2080
],
"end_pos": [
-1034, -2065, -2047, -1013, 1979, -1072
],
"calib_mode": [
"DEGREE", "DEGREE", "DEGREE", "DEGREE", "DEGREE", "DEGREE"
],
"motor_names": [
"shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll", "gripper"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"homing_offset": [
2048, 3072, -1024, -2048, 1024, -2048
],
"drive_mode": [
1, 1, 0, 0, 0, 0
],
"start_pos": [
2033, 2957, 1119, 1967, -1037, 1920
],
"end_pos": [
-1054, -2034, 2095, 3063, -63, 2680
],
"calib_mode": [
"DEGREE", "DEGREE", "DEGREE", "DEGREE", "DEGREE", "DEGREE"
],
"motor_names": [
"shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll", "gripper"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ follower_arms:
cameras:
laptop:
_target_: lerobot.common.robot_devices.cameras.opencv.OpenCVCamera
camera_index: 0
fps: 30
camera_index: 3
fps: 25
width: 640
height: 480
phone:
_target_: lerobot.common.robot_devices.cameras.opencv.OpenCVCamera
camera_index: 1
fps: 30
camera_index: 2
fps: 25
width: 640
height: 480

Expand Down
Loading

0 comments on commit a204628

Please sign in to comment.