mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-24 04:59:47 +00:00
039de254ea
* Fix imports * Add feetech write tests * Nit * Add autoclosing fixture * Assert ping stub called * Add CalibrationMode * Add Motor in dxl robots * Simplify split_int_bytes * Rename read/write -> sync_read/write, refactor, add write * Rename tests * Refactor dxl tests by functionality * Add dxl write test * Refactor _is_comm_success * Refactor feetech tests by functionality * Add feetech write test * Simplify _is_comm_success & _is_error * Move mock_serial patch to dedicated file * Remove test skips & fix docstrings * Nit * Add dxl operating modes * Add is_connected in robots and teleops * Update Koch * Add feetech operating modes * Caps dxl OperatingMode * Update ensure_safe_goal_position * Update so100 * Privatize methods & renames * Fix dict * Add _configure_motors & move ping methods * Return models (str) with pings * Implement feetech broadcast ping * Add raw_values option * Rename idx -> id_ * Improve errors * Fix feetech ping tests * Ensure motors exist at connection time * Update tests * Add test_motors_bus * Move DriveMode & TorqueMode * Update Koch imports * Update so100 imports * Fix visualize_motors_bus * Fix imports * Add calibration * Rename idx -> id_ * Rename idx -> id_ * (WIP) _async_read * Add new calibration method for robot refactor (#896) Co-authored-by: Simon Alibert <simon.alibert@huggingface.co> * Remove deprecated scripts * Rename CalibrationMode -> MotorNormMode * Fix calibration functions * Remove todo * Add scan_port utility * Add calibration utilities * Move encoding functions to encoding_utils * Add test_encoding_utils * Rename test * Add more calibration utilities * Format baudrate tables * Implement SO-100 leader calibration * Implement SO-100 follower calibration * Implement Koch calibration * Add test_scan_port (TODO) * Fix calibration * Hack feetech firmware bug * Update tests * Update Koch & SO-100 * Improve format * Rename SO-100 classes * Rename Koch classes * Add calibration tests * Remove old calibration tests * Revert feetech hack and monkeypatch instead * Simplify motors mocks * Add is_calibrated test * Update viperx & widowx * Rename viperx & widowx * Remove old calibration * feat(teleop): thread-safe keyboard teleop implementation (#869) Co-authored-by: Simon Alibert <75076266+aliberts@users.noreply.github.com> * Add support for feetech scs series + various fixes * Update dynamixel with motors bus & tables changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * (WIP) Add Hope Jr * Rename arm -> hand * (WIP) Add homonculus arm & glove * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add Feetech protocol version * Implement read * Use constants from sdks * (nit) move write * Fix broadcast ping type hint * Add protocol 1 broadcast ping * Refactor & add _serialize_data * Add feetech sm8512bl * Make feetech broadcast ping faster in protocol 1 * Cleanup * Add support for feetech protocol 1 to _split_into_byte_chunks * Fix unormalize * Remove test_motors_bus fixtures * Add more segmented tests (base motor bus & feetech), add feetech protocol 1 support * Add more segmented tests (dynamixel) * Refactor tests * Add handshake, fix feetech _read_firmware_version * Fix tests * Motors config & disconnect fixes * Add torque_disabled context * Update branch & fix pre-commit errors * Fix hand & glove readings * Update feetech tables * Move read/write_calibration implementations * Add setup_motor * Fix calibration msg display * Fix setup_motor & add it to robots * Fix _find_single_motor * Remove deprecated configure_motor * Remove deprecated dynamixel_calibration * Remove names * Remove deprecated import * refactor/lekiwi robot (#863) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Simon Alibert <simon.alibert@huggingface.co> Co-authored-by: Simon Alibert <75076266+aliberts@users.noreply.github.com> * fix(teleoperators): use property is_connected (#1075) * Remove deprecated manipulator * Update robot features & naming * Update teleop features & naming * Add make_teleoperator_from_config * Rename find_port * Fix config parsing * Remove app script * Add setup_motors * Add teleoperate * Add record * Add replay * Fix test_datasets * Add mock robot & teleop * Add new test_control_robot * Add test_record_and_resume * Remove deprecated scripts & tests * Add calibrate * Add docstrings * Fix tests (no-extras install) * Add SO101 * Remove pynput from optional deps * Rename example 7 * Remove unecessary id * Add MotorsBus docstrings * Rename arm -> bus * Remove Moss arm * Fix setup_motors & calibrate configs * Fix test_calibrate * Add copyrights * Update hand & arm * Update homonculus hand & arm * Fix dxl _find_single_motor * Update glove * Add setup_motors for lekiwi * Fix glove calibration * Complete docstring * Add check for same min and max during calibration * Move MockMotorsBus * Add so100_follower tests * (WIP) add calibration gui * Fix test * Add setup_motors * Update calibration gui * Remove old .cache folder * Replace deprecated abc.abstractproperty * Fix feetech protocol 1 configure * Cleanup gui & add copyrights * Anatomically precise joint names * (WIP) Add glove to hand joints translation * Move make_robot_config * Add drive_mode & norm_mode in glove calibration * Fix joints translation * Fix normalization drive_mode * nit * Fix glove to hand conversion * Adapt feetech calibration * Remove pygame prompt * Implement arm calibration (hacks) * Better MotorsBus error messages * Update feetech read_calibration * Fix feetech test_is_calibrated * Cleanup glove * (WIP) Update arm * Add changes from #1117 * refactor(cameras): cameras implementations + tests improvements (#1108) Co-authored-by: Simon Alibert <simon.alibert@huggingface.co> Co-authored-by: Simon Alibert <75076266+aliberts@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Fix arm joints order * Add timeout/event logic * Fix arm & glove * Fix predict_action from record * fix(cameras): update docstring + handle sn when starts with 0 + update timeouts to more reasonable value (#1154) * fix(scripts): parser instead of draccus in record + add __get_path_fields__() to RecordConfig (#1155) * Left/Right sides + other fixes * Arm fixes and add config * More hacks * Add control scripts * Fix merge errors * push changes to calibration, teleop and docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Move readme to docs * update readme Signed-off-by: Martino Russi <77496684+nepyope@users.noreply.github.com> * Add files via upload Signed-off-by: Martino Russi <77496684+nepyope@users.noreply.github.com> * Update image sources * Symlink doc * Compress image * Move image * Update docs link * fix docs * simplify teleop scripts * fix variable names * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address code review * add EMA to glove * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * integrate teleoperation for hand * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * import hopejr/homunculus in teleoperate * update docs for teleoperate, record, replay, train and inference * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(hopejr): address comments * chore(hopejr): address coments 2 * chore(docs): update teleoperation instructions for the hand/glove * fix(hopejr): calibration int + update docs --------- Signed-off-by: Martino Russi <77496684+nepyope@users.noreply.github.com> Signed-off-by: Simon Alibert <75076266+aliberts@users.noreply.github.com> Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com> Co-authored-by: Steven Palma <imstevenpmwork@ieee.org> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: nepyope <nopyeps@gmail.com> Co-authored-by: Martino Russi <77496684+nepyope@users.noreply.github.com> Co-authored-by: Steven Palma <steven.palma@huggingface.co>
269 lines
8.5 KiB
Plaintext
269 lines
8.5 KiB
Plaintext
# HopeJR
|
|
|
|
## Prerequisites
|
|
|
|
- [Hardware Setup](https://github.com/TheRobotStudio/HOPEJr)
|
|
|
|
## Install LeRobot
|
|
|
|
Follow the [installation instructions](https://github.com/huggingface/lerobot#installation) to install LeRobot.
|
|
|
|
Install LeRobot with HopeJR dependencies:
|
|
```bash
|
|
pip install -e ".[hopejr]"
|
|
```
|
|
|
|
## Device Configuration
|
|
|
|
Before starting calibration and operation, you need to identify the USB ports for each HopeJR component. Run this script to find the USB ports for the arm, hand, glove, and exoskeleton:
|
|
|
|
```bash
|
|
python -m lerobot.find_port
|
|
```
|
|
|
|
This will display the available USB ports and their associated devices. Make note of the port paths (e.g., `/dev/tty.usbmodem58760433331`, `/dev/tty.usbmodem11301`) as you'll need to specify them in the `--robot.port` and `--teleop.port` parameters when recording data, replaying episodes, or running teleoperation scripts.
|
|
|
|
## Step 1: Calibration
|
|
|
|
Before performing teleoperation, HopeJR's limbs need to be calibrated. Calibration files will be saved in `~/.cache/huggingface/lerobot/calibration`
|
|
|
|
### 1.1 Calibrate Robot Hand
|
|
|
|
```bash
|
|
python -m lerobot.calibrate \
|
|
--robot.type=hope_jr_hand \
|
|
--robot.port=/dev/tty.usbmodem58760432281 \
|
|
--robot.id=blue \
|
|
--robot.side=right
|
|
```
|
|
|
|
When running the calibration script, a calibration GUI will pop up. Finger joints are named as follows:
|
|
|
|
**Thumb**:
|
|
- **CMC**: base joint connecting thumb to hand
|
|
- **MCP**: knuckle joint
|
|
- **PIP**: first finger joint
|
|
- **DIP** : fingertip joint
|
|
|
|
**Index, Middle, Ring, and Pinky fingers**:
|
|
- **Radial flexor**: Moves base of finger towards the thumb
|
|
- **Ulnar flexor**: Moves base of finger towards the pinky
|
|
- **PIP/DIP**: Flexes the distal and proximal phalanx of the finger
|
|
|
|
Each one of these will need to be calibrated individually via the GUI.
|
|
Note that ulnar and radial flexors should have ranges of the same size (but with different offsets) in order to get symmetric movement.
|
|
|
|
<p align="center">
|
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lerobot/calibration_gui_1.png"
|
|
alt="Setting boundaries in the hand calibration GUI"
|
|
title="Setting boundaries in the hand calibration GUI"
|
|
width="100%">
|
|
</img>
|
|
</p>
|
|
|
|
Use the calibration interface to set the range boundaries for each joint as shown above.
|
|
|
|
<p align="center">
|
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lerobot/calibration_gui_2.png"
|
|
alt="Saving calibration values"
|
|
title="Saving calibration values"
|
|
width="100%">
|
|
</img>
|
|
</p>
|
|
|
|
Once you have set the appropriate boundaries for all joints, click "Save" to save the calibration values to the motors.
|
|
|
|
### 1.2 Calibrate Teleoperator Glove
|
|
|
|
```bash
|
|
python -m lerobot.calibrate \
|
|
--teleop.type=homunculus_glove \
|
|
--teleop.port=/dev/tty.usbmodem11201 \
|
|
--teleop.id=red \
|
|
--teleop.side=right
|
|
```
|
|
|
|
Move each finger through its full range of motion, starting from the thumb.
|
|
|
|
```
|
|
Move thumb through its entire range of motion.
|
|
Recording positions. Press ENTER to stop...
|
|
|
|
-------------------------------------------
|
|
NAME | MIN | POS | MAX
|
|
thumb_cmc | 1790 | 1831 | 1853
|
|
thumb_mcp | 1497 | 1514 | 1528
|
|
thumb_pip | 1466 | 1496 | 1515
|
|
thumb_dip | 1463 | 1484 | 1514
|
|
```
|
|
|
|
Continue with each finger:
|
|
|
|
```
|
|
Move middle through its entire range of motion.
|
|
Recording positions. Press ENTER to stop...
|
|
|
|
-------------------------------------------
|
|
NAME | MIN | POS | MAX
|
|
middle_mcp_abduction | 1598 | 1718 | 1820
|
|
middle_mcp_flexion | 1512 | 1658 | 2136
|
|
middle_dip | 1484 | 1500 | 1547
|
|
```
|
|
|
|
Once calibration is complete, the system will save the calibration to `/Users/your_username/.cache/huggingface/lerobot/calibration/teleoperators/homunculus_glove/red.json`
|
|
|
|
### 1.3 Calibrate Robot Arm
|
|
|
|
```bash
|
|
python -m lerobot.calibrate \
|
|
--robot.type=hope_jr_arm \
|
|
--robot.port=/dev/tty.usbserial-1110 \
|
|
--robot.id=white
|
|
```
|
|
|
|
This will open a calibration GUI where you can set the range limits for each motor. The arm motions are organized as follows:
|
|
- **Shoulder**: pitch, yaw, and roll
|
|
- **Elbow**: flex
|
|
- **Wrist**: pitch, yaw, and roll
|
|
|
|
<p align="center">
|
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/lerobot/calibration_gui_2.png"
|
|
alt="Setting boundaries in the arm calibration GUI"
|
|
title="Setting boundaries in the arm calibration GUI"
|
|
width="100%">
|
|
</img>
|
|
</p>
|
|
|
|
Use the calibration interface to set the range boundaries for each joint. Move each joint through its full range of motion and adjust the minimum and maximum values accordingly. Once you have set the appropriate boundaries for all joints, save the calibration.
|
|
|
|
### 1.4 Calibrate Teleoperator Exoskeleton
|
|
|
|
```bash
|
|
python -m lerobot.calibrate \
|
|
--teleop.type=homunculus_arm \
|
|
--teleop.port=/dev/tty.usbmodem11201 \
|
|
--teleop.id=black
|
|
```
|
|
|
|
The exoskeleton allows one to control the robot arm. During calibration, you'll be prompted to move all joints through their full range of motion:
|
|
|
|
```
|
|
Move all joints through their entire range of motion.
|
|
Recording positions. Press ENTER to stop...
|
|
|
|
-------------------------------------------
|
|
-------------------------------------------
|
|
NAME | MIN | POS | MAX
|
|
shoulder_pitch | 586 | 736 | 895
|
|
shoulder_yaw | 1257 | 1374 | 1390
|
|
shoulder_roll | 449 | 1034 | 2564
|
|
elbow_flex | 3023 | 3117 | 3134
|
|
wrist_roll | 3073 | 3096 | 3147
|
|
wrist_yaw | 2143 | 2171 | 2185
|
|
wrist_pitch | 1975 | 1993 | 2074
|
|
Calibration saved to /Users/your_username/.cache/huggingface/lerobot/calibration/teleoperators/homunculus_arm/black.json
|
|
```
|
|
|
|
## Step 2: Teleoperation
|
|
|
|
Due to global variable conflicts in the Feetech middleware, teleoperation for arm and hand must run in separate shell sessions:
|
|
|
|
### Hand
|
|
```bash
|
|
python -m lerobot.teleoperate \
|
|
--robot.type=hope_jr_hand \
|
|
--robot.port=/dev/tty.usbmodem58760432281 \
|
|
--robot.id=blue \
|
|
--robot.side=right \
|
|
--teleop.type=homunculus_glove \
|
|
--teleop.port=/dev/tty.usbmodem11201 \
|
|
--teleop.id=red \
|
|
--teleop.side=right \
|
|
--display_data=true \
|
|
--fps=30
|
|
```
|
|
|
|
### Arm
|
|
```bash
|
|
python -m lerobot.teleoperate \
|
|
--robot.type=hope_jr_arm \
|
|
--robot.port=/dev/tty.usbserial-1110 \
|
|
--robot.id=white \
|
|
--teleop.type=homunculus_arm \
|
|
--teleop.port=/dev/tty.usbmodem11201 \
|
|
--teleop.id=black \
|
|
--display_data=true \
|
|
--fps=30
|
|
```
|
|
|
|
## Step 3: Record, Replay, Train
|
|
|
|
Record, Replay and Train with Hope-JR is still experimental.
|
|
|
|
### Record
|
|
|
|
This step records the dataset, which can be seen as an example [here](https://huggingface.co/datasets/nepyope/hand_record_test_with_video_data/settings).
|
|
|
|
```bash
|
|
python -m lerobot.record \
|
|
--robot.type=hope_jr_hand \
|
|
--robot.port=/dev/tty.usbmodem58760432281 \
|
|
--robot.id=right \
|
|
--robot.side=right \
|
|
--robot.cameras='{"main": {"type": "opencv", "index_or_path": 0, "width": 640, "height": 480, "fps": 30}}' \
|
|
--teleop.type=homunculus_glove \
|
|
--teleop.port=/dev/tty.usbmodem1201 \
|
|
--teleop.id=right \
|
|
--teleop.side=right \
|
|
--dataset.repo_id=nepyope/hand_record_test_with_video_data \
|
|
--dataset.single_task="Hand recording test with video data" \
|
|
--dataset.num_episodes=1 \
|
|
--dataset.episode_time_s=5 \
|
|
--dataset.push_to_hub=true \
|
|
--dataset.private=true \
|
|
--display_data=true
|
|
```
|
|
|
|
### Replay
|
|
|
|
```bash
|
|
python -m lerobot.replay \
|
|
--robot.type=hope_jr_hand \
|
|
--robot.port=/dev/tty.usbmodem58760432281 \
|
|
--robot.id=right \
|
|
--robot.side=right \
|
|
--dataset.repo_id=nepyope/hand_record_test_with_camera \
|
|
--dataset.episode=0
|
|
```
|
|
|
|
### Train
|
|
|
|
```bash
|
|
python -m lerobot.scripts.train \
|
|
--dataset.repo_id=nepyope/hand_record_test_with_video_data \
|
|
--policy.type=act \
|
|
--output_dir=outputs/train/hopejr_hand \
|
|
--job_name=hopejr \
|
|
--policy.device=mps \
|
|
--wandb.enable=true \
|
|
--policy.repo_id=nepyope/hand_test_policy
|
|
```
|
|
|
|
### Evaluate
|
|
|
|
This training run can be viewed as an example [here](https://wandb.ai/tino/lerobot/runs/rp0k8zvw?nw=nwusertino).
|
|
|
|
```bash
|
|
python -m lerobot.record \
|
|
--robot.type=hope_jr_hand \
|
|
--robot.port=/dev/tty.usbmodem58760432281 \
|
|
--robot.id=right \
|
|
--robot.side=right \
|
|
--robot.cameras='{"main": {"type": "opencv", "index_or_path": 0, "width": 640, "height": 480, "fps": 30}}' \
|
|
--display_data=false \
|
|
--dataset.repo_id=nepyope/eval_hopejr \
|
|
--dataset.single_task="Evaluate hopejr hand policy" \
|
|
--dataset.num_episodes=10 \
|
|
--policy.path=outputs/train/hopejr_hand/checkpoints/last/pretrained_model
|
|
```
|