Skip to content

Commit

Permalink
[update] add package bunny teleop
Browse files Browse the repository at this point in the history
  • Loading branch information
yzqin committed May 6, 2024
1 parent 8635702 commit 448ac2b
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ imgui.ini
/.idea
/log
/site/
/bunny_teleop.egg-info/
159 changes: 58 additions & 101 deletions docs/advanced/initialization.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Teleoperation Initialization

In teleoperation, we map the motion of human to the motion of robot. For example, you move your right hand 0.1m forward
and expect the robot also move the right end effector 0.1m forward. But the question is, which direction is forward for
both human and robot. Initialization step is necessary to precisely define the motion coordinates in 3D space.
Teleoperation systems map human movements to robotic actions. For instance, advancing your right hand by 0.1 meters
should correspondingly move the robot's right end effector forward by the same distance. Establishing a clear definition
of coordinate system for both human and robot through an initialization step is crucial to accurately translating
human motion to robot in three-dimensional space.

## Calibration Between Human and Robot

During initialization, we define a 3D frame in the human space (initial human frame) and a 3D frame in the robot space (
initial robot frame). Then, when the human operator is moving, we compute the relative motion in the initialize initial
human frame, and the robot should move the same relative motion in the initial robot frame. This is the basic principle
of how teleoperation works.
### Initialization Process

In our system, the position and orientation of initial frames for both human and robot is determined when
the `TeleopClient` calls the following api.
During the initialization phase, we establish a three-dimensional frame in both human and robot coordinate systems,
referred to as the **initial human frame** and the **initial robot frame**, respectively.
Movements by the human operator are measured relative to the initial human frame, and the robot mimics these relative
movements within its corresponding initial robot frame.

### System Configuration

The positions and orientations of these initial frames are configured via the `TeleopClient` API as shown below:

```python
import numpy as np

from bunny_teleop.init_config import BimanualAlignmentMode


Expand All @@ -30,48 +33,53 @@ class TeleopClient:
align_gravity_dir=True,
bimanual_alignment_mode=BimanualAlignmentMode.ALIGN_CENTER,
):
# Implementation skipped for doc purpose
pass
```

## Determine the Initial Robot Frame
!!! tip "Checking Initialization Status"
Use `teleop_client.started` or `teleop_client.wait_for_server_start()` to confirm if the initialization has completed.


## Initializing the Robot Frame

Upon successful operation of the `bunny_teleop_server`, the teleop initialization is triggered by the `send_init_config`
API call. This function requires the initial pose of the robot (`init_qpos`), which represents the joint positions for
both the left and right robotic arms. The teleop server computes the end effector poses using forward kinematics to
determine the initial robot frame.

!!! note "Be Careful about Joint Orders"
Ensure the joint names are correctly specified as the teleop server may parse the robot model differently, affecting the
joint order.

If the `bunny_teleop_server` is running normally, the teleop initialization process will start immediately when
the `TeleopClient` call this `send_init_config` api. To use this function, you need to tell the teleoperation system
what is the initial pose of your robot. This information is contained in the `init_qpos`, which is Tuple of joint
position for both left arm robot and right arm robot. When this information is sent to the teleop server, it will
compute the pose of both left and right end effectors using forward kinematics. The initial robot frame is determined by
these end effector poses.
## Initializing the Human Frame

Note that the teleop server may parse the robot model in a different way, leading to different joint orders. So that you
also need to specify the joint order by joint names for your `init_qpos`. During teleoperation, the joint position
command received from teleop server will also be in the same order as specified by `joint_names`.
Post the API call, the VisionPro system begins tracking the operator's hand poses. To mitigate noise in hand pose
estimation, an average pose is calculated from 200 frames following the initialization call. The initialization
completes once these poses are processed, allowing the teleop server to begin streaming commands.

## Determine the Initial Human Frame
!!! note "Good Hand Poses are Important for Initialization"
The frame counter resets to 0 if the operator's hands are not held still or if the fingers are not spread out flat.
If the teleop_server has not started within 5 seconds after initialization, check the position and condition of both
hands.

After the `send_init_config` function call. The VisionPro will start tracking the left and right hand pose of human
operator for several seconds before the initialization process is finished. All hand pose estimation algorithms has
noise, so does VisionPro. To avoid several noisy hand poses to dominate the initialize frame calibration, we use the
averaged pose from `200` frames after the `send_init_config` function call. After the teleop server receives `200`
bimanual human hand poses, the initialization process is finished and the teleop server will start streaming teleop
command.
An example of a proper hand pose is shown below:

In practice, you can use `teleop_client.started` to check whether the initialization is finished on the client side or
using `teleop_client.wait_for_server_start()` to block the program until the initialization is finished.
![good init pose](../assets/images/good_init_pose.jpg){: style="width:50%"}

Note that the frame counter will be reset to 0 if the hands of human operator is not kept static or the fingers are not
spread in a flatten way. If you find your teleop_server is not started after 5 seconds of initialization, maybe you
should check whether your left and right hand are in good status. A good hand pose is illustrated as follows:

![]()
## Bimanual Alignment Modes

## Bimanual Alignment Modes for Left and Right Hand
### Overview


In the tutorial above, we skip how to determine the initial frames for the left and right hands.
Essentially, we can treat each hand as a separate entity with its own frame, similar to individual robots,
or use a single frame for controlling both hands in bimanual operations.
Depending on the task, different configurations might be preferable.
Our system allows users to select the desired mode through the `bimanual_alignment_mode` variable in the
`send_init_config` function, offering various options to best suit specific task requirements.

In the above tutorial, we skip an important question: how to determine the initial frame for both left and right hands?
In principle, we can define two initial frames for both hands separately, just like they are two separate robots, or we
can define a single frame to control bimanual robots. In practice, for different tasks we may desire different modes. In
our system, the client api can choose mode using `bimanual_alignment_mode` variable in the `send_init_config` function
call. We offer a variety of modes to accommodate diverse task needs, allowing users to select the most suitable
option for the specific purposes.

```python
class BimanualAlignmentMode(Enum):
Expand All @@ -81,67 +89,16 @@ class BimanualAlignmentMode(Enum):
ALIGN_SEPARATELY = 3
```

Here we will detail each of the bimanual alignment mode as follows

### ALIGN_SEPARATELY Mode

This mode is most straight forward, it behaves like your left and right arm are two separate robot. Both of them has a
individual initial frame, for both human and robot. The advantage is that both hands will stay in the original pose
right after initialization is finished and begin move after receiving the teleoperation command.

The disadvantage is that it ignore the spatial relationship of the left and right robots. The distance between left and
right robot hands is determined by the mechanical installation of robots, while the distance between left and right
human hands is decided by human. These two can be quiet different. It means that when left and right hand of human is
touched, the left and right robot hands can be far from each other or already collide. This is no guarantee that these
bimanual relationship is preserved.

### ALIGN_CENTER Mode

For instance, in handover tasks where the proximity of hands is critical, it is necessary to align the distance
between the two robot end effector to match the distance between the human hands. To support it, we provide several
other alignment mode.

In `ALIGN_CENTER` mode, we compute the center of two robot end effector as the initial robot frame while using the
center of two human hands as the initial human frame. To inform the teleop server about where the two robot arms are, we
can specify the base pose of both robot arms using `robot_base_pose` variable. Thus, the server can know how far the
left and right hands is during initialization and compute the initial robot frame.

In this mode, both robot arms may move instantly after initialization is finished even if the human operator keeps
static. For example, if the initial right robot hand is 0.8m righter than the left robot hand while the distance of two
hands for human operator is 0.6, then the right robot hand move 0.1m lefter and left robot move 0.1m righter after
initialization is finished. This can be dangers on real robot if you are not aware what will happen after
initialization. Try first on our simulation version before deploying on the real robot.

Note that the position of initial frame is the center of both hands but the orientation of initial frame comes from the
right hand in this mode.

### ALIGN_LEFT and ALIGN_RIGHT Mode

Similar as ALIGN_CENTER mode, these modes also respect the distance between left and right hands. Different from using
the center of both hands as the initial frame. These modes simply use the position and orientation of one hand.

For example, in ALIGN_LEFT mode, the right robot may move instantly after initialization while the left robot may stay
unmoved.

## Visualization of Initialization

To provide an intuitive user interface to let the human operator know about the process of initialization and which
alignment mode is using, we also provide a web interface to show that based
on [sim_web_visualizer](https://github.com/NVlabs/sim-web-visualizer).

A large 3D cursor will appear after the `send_init_config` function call as follow. During initialization
process, the cursor becomes more and more transparent. We use the alpha value of curso to indicate the initialization
progress. It will be replaced by two small 3D gizmo after the initialization is finished, which shows the end effector
pose of two robots.

![]()

For different alignment mode, the cursor will look different.

| ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) |
|:------------------------------------------------:|:------------------------------------------------:|:------------------------------------------------:|:------------------------------------------------:|
| ALIGN_CENTER | ALIGN_LEFT | ALIGN_RIGHT | ALIGN_SEPARATELY |

### Mode Descriptions

- **ALIGN_SEPARATELY**: Treats each arm as an independent entity, ideal for tasks requiring distinct movements.
- **ALIGN_CENTER**: Calculates a center between the two robot end effectors, aligning this with the midpoint between
the human hands.
- **ALIGN_LEFT** and **ALIGN_RIGHT**: Focuses on one hand's position and orientation, useful for tasks prioritizing one
side.

!!! danger
For modes except `ALIGN_SEPARATELY` Robot arms may move instantly after initialization is finished even if the human operator keeps static.This can be
dangers on real robot if you are not aware what will happen after initialization. Try first on our simulation version
before deploying on the real robot.

12 changes: 12 additions & 0 deletions docs/advanced/visualization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Visualization Tools

To provide an intuitive user interface of the initialization and teleoperation, a web-based GUI visualizes these
processes in real-time. This feature utilizes the [sim_web_visualizer](https://github.com/NVlabs/sim-web-visualizer).

During initialization, a large 3D cursor displayed on the interface becomes increasingly transparent to reflect
progress, transitioning to two smaller 3D gizmos indicating the end effector positions upon completion.

| ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) | ![center](../assets/images/teleop_framework.png) |
|:------------------------------------------------:|:------------------------------------------------:|:------------------------------------------------:|:------------------------------------------------:|
| ALIGN_CENTER | ALIGN_LEFT | ALIGN_RIGHT | ALIGN_SEPARATELY |

Binary file added docs/assets/images/good_init_pose.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/logo/bunny.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/getstarted/install.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation

DexVisionPro is designed as a distributed system to facilitate robot teleoperation. The system consists of a server and a client that communicate via data streaming, leveraging the Apple Vision Pro as hand pose tracking device. To interact with Vision Pro, download the [Tracking Streamer](https://apps.apple.com/us/app/tracking-streamer/id6478969032) app on your device. The server can be installed and run inside a Docker container, while the client can be installed using pip.
BunnyVisionPro is designed as a distributed system to facilitate robot teleoperation. The system consists of a server and a client that communicate via data streaming, leveraging the Apple Vision Pro as hand pose tracking device. To interact with Vision Pro, download the [Tracking Streamer](https://apps.apple.com/us/app/tracking-streamer/id6478969032) app on your device. The server can be installed and run inside a Docker container, while the client can be installed using pip.


## Server Installation
Expand All @@ -25,7 +25,7 @@ docker build -t <your_image_name> .
The client can be easily installed using Python's pip package manager:
```bash
git clone https://github.com/Dingry/BunnyVisionPro.git
cd DexVisionPro
cd BunnyVisionPro
pip install -e .
```
By following these steps, you will have both the server and client components of DexVisionPro installed and ready for robot teleoperation tasks.
By following these steps, you will have both the server and client components of BunnyVisionPro installed and ready for robot teleoperation tasks.
2 changes: 1 addition & 1 deletion docs/getstarted/usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic Usage

Once the server and client of DexVisionPro are configured, along with the integration of Apple Vision Pro, it's
Once the server and client of BunnyVisionPro are configured, along with the integration of Apple Vision Pro, it's
essential to ensure they communicate effectively for seamless robot teleoperation.

## Establishing Communication
Expand Down
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DexVisionPro - Overview
# BunnyVisionPro - Overview

DexVisionPro is a robot teleoperation system integrated with Apple Vision Pro as pose tracking device, specifically
BunnyVisionPro is a robot teleoperation system integrated with Apple Vision Pro as pose tracking device, specifically
tailored for bimanual dexterous manipulation. The system boasts a highly modular architecture, simplifying deployment
and enhancing flexibility. Key features of the system include:

Expand All @@ -10,14 +10,14 @@ and enhancing flexibility. Key features of the system include:
- Containization: The server and client components of the system are containerized, ensuring easy deployment and
management.

<!-- In addition to the current features, we are actively developing more advanced functionalities to enhance the DexVisionPro system further. Planned enhancements include: -->
<!-- In addition to the current features, we are actively developing more advanced functionalities to enhance the BunnyVisionPro system further. Planned enhancements include: -->

## Citing DexVisionPro
## Citing BunnyVisionPro

If you find DexVisionPro helpful in your work, please consider cite:
If you find this codebase helpful in your work, please consider cite:

```bibtex
@article{dexvisionpro,
@article{Bunny-VisionPro: Bimanual Dexterous Teleoperation with Real-Time Retargeting using VisionPro,
author = {},
title = {},
url = {}
Expand Down
22 changes: 12 additions & 10 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project information
site_name: DexVisionPro
site_name: BunnyVisionPro

# Repository
repo_name: dingry/BunnyVisionPro
Expand Down Expand Up @@ -48,7 +48,8 @@ theme:
font:
text: Roboto
code: Roboto Mono
favicon: assets/favicon.png
favicon: assets/logo/bunny.png
logo: assets/logo/bunny.png
icon:
logo: logo

Expand Down Expand Up @@ -78,11 +79,11 @@ extra:
- icon: fontawesome/brands/twitter
link: xxx
- icon: fontawesome/brands/github
link: https://github.com/dingry/DexVisionPro
link: https://github.com/dingry/BunnyVisionPro


# Copyright
copyright: Copyright &copy; 2024, DexVisionPro. All rights reserved.
copyright: Copyright &copy; 2024, BunnyVisionPro. All rights reserved.

# Extensions
markdown_extensions:
Expand Down Expand Up @@ -138,10 +139,11 @@ markdown_extensions:
nav:
- Home: index.md
- Getting Started:
- Installation: getstarted/install.md
- Basic Usage: getstarted/usage.md
- Installation: getstarted/install.md
- Basic Usage: getstarted/usage.md
- System Design:
- system/overview.md
- advanced/initialization.md
- Reference:
- reference/index.md
- system/overview.md
- advanced/initialization.md
- advanced/visualization.md
# - Reference:
# - reference/index.md

0 comments on commit 448ac2b

Please sign in to comment.