From bac8da8a4b033c6b5dab745c40cbe1fecb56054d Mon Sep 17 00:00:00 2001 From: silencht Date: Wed, 12 Nov 2025 10:24:13 +0800 Subject: [PATCH] [update] pem path --- README.md | 87 ++++++++++++++++--- src/televuer/televuer.py | 29 +++++-- src/televuer/tv_wrapper.py | 2 +- test/{_test_televuer.py => test_televuer.py} | 0 ..._test_tv_wrapper.py => test_tv_wrapper.py} | 0 5 files changed, 100 insertions(+), 18 deletions(-) rename test/{_test_televuer.py => test_televuer.py} (100%) rename test/{_test_tv_wrapper.py => test_tv_wrapper.py} (100%) diff --git a/README.md b/README.md index ffc3f7f..6f68ff9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,10 @@ # TeleVuer -The TeleVuer library is a specialized version of the Vuer library, designed to enable XR device-based teleoperation of Unitree Robotics robots. This library acts as a wrapper for Vuer, providing additional adaptations specifically tailored for Unitree Robotics. By integrating XR device capabilities, such as hand tracking and controller tracking, TeleVuer facilitates seamless interaction and control of robotic systems in immersive environments. +The TeleVuer library is a specialized version of the [Vuer](https://github.com/vuer-ai/vuer) library, designed to enable XR device-based teleoperation of Unitree Robotics robots. This library acts as a wrapper for Vuer, providing additional adaptations specifically tailored for Unitree Robotics. By integrating XR device capabilities, such as hand tracking and controller tracking, TeleVuer facilitates seamless interaction and control of robotic systems in immersive environments. Currently, this module serves as a core component of the [xr_teleoperate](https://github.com/unitreerobotics/xr_teleoperate) library, offering advanced functionality for teleoperation tasks. It supports various XR devices, including Apple Vision Pro, Meta Quest3, Pico 4 Ultra Enterprise etc., ensuring compatibility and ease of use for robotic teleoperation applications. ## Release Note -V4.0 brings updates: -0. Fix bugs. - V3.0 brings updates: 1. Added `pass_through` interface to enable/disable the pass-through mode. 2. Support `webrtc` interface to enable/disable the webrtc streaming mode. @@ -22,7 +19,7 @@ V2.0 brings updates: 5. Streamlined the data structure: removed the nested `TeleStateData` and return everything in the unified `TeleData`. 6. Added new image-transport interfaces such as `set_display_image`. -## Diagram +## 1. Diagram

@@ -30,20 +27,88 @@ V2.0 brings updates:

-## Install +## 2. Install + +### 2.1 Install televuer repository ```bash +git clone https://github.com/silencht/televuer cd televuer -pip install -e . +pip install -e . # or pip install . +``` + + +### 2.2 Generate Certificate Files + +The televuer module requires SSL certificates to allow XR devices (such as Pico / Quest / Apple Vision Pro) to connect securely via HTTPS / WebRTC. + +1. For Pico / Quest XR Devices + +```bash openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem +# Check the Generated Files +$ ls +build cert.pem key.pem LICENSE pyproject.toml README.md src test +``` + +2. For Apple Vision Pro + +```bash +openssl genrsa -out rootCA.key 2048 +openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 365 -out rootCA.pem -subj "/CN=xr-teleoperate" +openssl genrsa -out key.pem 2048 +openssl req -new -key key.pem -out server.csr -subj "/CN=localhost" +vim server_ext.cnf +# Add the following content (make sure IP.2 matches your host machine’s IP address, which you can find with ifconfig or similar): +subjectAltName = @alt_names +[alt_names] +DNS.1 = localhost +IP.1 = 192.168.123.164 +IP.2 = 192.168.123.2 +# Then sign the certificate: +openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out cert.pem -days 365 -sha256 -extfile server_ext.cnf +# Check the Generated Files +$ ls +build cert.pem key.pem LICENSE pyproject.toml README.md rootCA.key rootCA.pem rootCA.srl server.csr server_ext.cnf src test +# Use AirDrop to copy rootCA.pem to your Apple Vision Pro device and install it manually as a trusted certificate. +``` + +3. Allow Firewall Access + +```bash +sudo ufw allow 8012 +``` + +### 2.3 Configure Certificate Paths (Choose One Method) + +You can tell televuer where to find the certificate files using either environment variables or a user config directory. + +1. Environment Variable Configuration (Optional) + +```bash +# This makes the configuration persistent for future terminal sessions. +echo 'export XR_TELEOP_CERT="your_file_path/cert.pem"' >> ~/.bashrc +echo 'export XR_TELEOP_KEY="your_file_path/key.pem"' >> ~/.bashrc +source ~/.bashrc ``` +2. User Configuration Directory (Optional) + +```bash +# this repo belongs to xr_teleoperate, so we use its config dir +mkdir -p ~/.config/xr_teleoperate/ +cp cert.pem key.pem ~/.config/xr_teleoperate/ +``` + +3. Default Behavior + +If neither of the above methods is used, televuer will look for the certificate files from the function parameters or fall back to the default paths within the module. -## Test +## 3. Test ```bash -python _test_televuer.py +python test_televuer.py # or -python _test_tv_wrapper.py +python test_tv_wrapper.py # First, use Apple Vision Pro or Pico 4 Ultra Enterprise to connect to the same Wi-Fi network as your computer. # Next, open safari / pico browser, enter https://host machine's ip:8012/?ws=wss://host machine's ip:8012 @@ -53,7 +118,7 @@ python _test_tv_wrapper.py # Press Enter in the terminal to launch the program. ``` -## Version History +## 4. Version History `vuer==0.0.32rc7` diff --git a/src/televuer/televuer.py b/src/televuer/televuer.py index d0ae8f2..068f85c 100644 --- a/src/televuer/televuer.py +++ b/src/televuer/televuer.py @@ -11,7 +11,7 @@ from pathlib import Path class TeleVuer: def __init__(self, use_hand_tracking: bool, pass_through:bool=False, binocular: bool=True, img_shape: tuple=None, - cert_file=None, key_file=None, webrtc: bool=False, webrtc_url: str=None, display_fps: float=30.0): + cert_file: str=None, key_file: str=None, webrtc: bool=False, webrtc_url: str=None, display_fps: float=30.0): """ TeleVuer class for OpenXR-based XR teleoperate applications. This class handles the communication with the Vuer server and manages image and pose data. @@ -46,11 +46,28 @@ class TeleVuer: self.img_width = self.img_shape[1] self.aspect_ratio = self.img_width / self.img_height - current_module_dir = Path(__file__).resolve().parent.parent.parent - if cert_file is None: - cert_file = os.path.join(current_module_dir, "cert.pem") - if key_file is None: - key_file = os.path.join(current_module_dir, "key.pem") + # SSL certificate path resolution + env_cert = os.getenv("XR_TELEOP_CERT") + env_key = os.getenv("XR_TELEOP_KEY") + if cert_file is None or key_file is None: + # 1.Try environment variables + if env_cert and env_key: + cert_file = cert_file or env_cert + key_file = key_file or env_key + else: + # 2.Try ~/.config/xr_teleoperate/ + user_conf_dir = Path.home() / ".config" / "xr_teleoperate" + cert_path_user = user_conf_dir / "cert.pem" + key_path_user = user_conf_dir / "key.pem" + + if cert_path_user.exists() and key_path_user.exists(): + cert_file = cert_file or str(cert_path_user) + key_file = key_file or str(key_path_user) + else: + # 3.Fallback to package root (current logic) + current_module_dir = Path(__file__).resolve().parent.parent.parent + cert_file = cert_file or str(current_module_dir / "cert.pem") + key_file = key_file or str(current_module_dir / "key.pem") self.vuer = Vuer(host='0.0.0.0', cert=cert_file, key=key_file, queries=dict(grid=False), queue_len=3) self.vuer.add_handler("CAMERA_MOVE")(self.on_cam_move) diff --git a/src/televuer/tv_wrapper.py b/src/televuer/tv_wrapper.py index 6bf6a0f..3d818e3 100644 --- a/src/televuer/tv_wrapper.py +++ b/src/televuer/tv_wrapper.py @@ -194,7 +194,7 @@ class TeleData: class TeleVuerWrapper: def __init__(self, use_hand_tracking: bool, pass_through: bool=False, binocular: bool=True, img_shape: tuple=(480, 1280), - cert_file = None, key_file = None, webrtc: bool=False, webrtc_url: str=None, display_fps: float=30.0, + cert_file: str=None, key_file: str=None, webrtc: bool=False, webrtc_url: str=None, display_fps: float=30.0, return_hand_rot_data: bool=False): """ TeleVuerWrapper is a wrapper for the TeleVuer class, which handles XR device's data suit for robot control. diff --git a/test/_test_televuer.py b/test/test_televuer.py similarity index 100% rename from test/_test_televuer.py rename to test/test_televuer.py diff --git a/test/_test_tv_wrapper.py b/test/test_tv_wrapper.py similarity index 100% rename from test/_test_tv_wrapper.py rename to test/test_tv_wrapper.py