From b0d751101b603289b604e0da839d55a01615bc8e Mon Sep 17 00:00:00 2001 From: Lizhi Yang Date: Sun, 9 Nov 2025 23:32:30 -0800 Subject: [PATCH] add display fps configuration --- src/televuer/televuer.py | 12 +++++++----- src/televuer/tv_wrapper.py | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/televuer/televuer.py b/src/televuer/televuer.py index 5f9c4f1..b61de0a 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): + cert_file=None, key_file=None, webrtc: bool=False, webrtc_url: str=None, display_fps: float=60.0): """ TeleVuer class for OpenXR-based XR teleoperate applications. This class handles the communication with the Vuer server and manages image and pose data. @@ -31,8 +31,10 @@ class TeleVuer: :param key_file: str, path to the SSL key file. :param webrtc: bool, whether to use WebRTC for real-time communication. if False, use ImageBackground. :param webrtc_url: str, URL for the WebRTC offer. + :param display_fps: float, target frames per second for display updates (default: 60.0). """ self.use_hand_tracking = use_hand_tracking + self.display_fps = display_fps self.pass_through = pass_through self.binocular = binocular @@ -309,7 +311,7 @@ class TeleVuer: to="bgChildren", ) # 'jpeg' encoding should give you about 30fps with a 16ms wait in-between. - await asyncio.sleep(0.016) + await asyncio.sleep(1.0 / self.display_fps) async def main_image_monocular(self, session): if self.use_hand_tracking: @@ -350,7 +352,7 @@ class TeleVuer: ], to="bgChildren", ) - await asyncio.sleep(0.016) + await asyncio.sleep(1.0 / self.display_fps) async def main_image_binocular_webrtc(self, session): if self.use_hand_tracking: @@ -389,7 +391,7 @@ class TeleVuer: to="bgChildren", ) - await asyncio.sleep(0.016) + await asyncio.sleep(1.0 / self.display_fps) async def main_image_monocular_webrtc(self, session): if self.use_hand_tracking: @@ -427,7 +429,7 @@ class TeleVuer: to="bgChildren", ) - await asyncio.sleep(0.016) + await asyncio.sleep(1.0 / self.display_fps) # ==================== common data ==================== @property def head_pose(self): diff --git a/src/televuer/tv_wrapper.py b/src/televuer/tv_wrapper.py index 4c9c45e..b9376df 100644 --- a/src/televuer/tv_wrapper.py +++ b/src/televuer/tv_wrapper.py @@ -193,8 +193,8 @@ 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, + 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=60.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. @@ -219,7 +219,7 @@ class TeleVuerWrapper: self.use_hand_tracking = use_hand_tracking self.return_hand_rot_data = return_hand_rot_data self.tvuer = TeleVuer(use_hand_tracking=use_hand_tracking, pass_through=pass_through, binocular=binocular,img_shape=img_shape, - cert_file=cert_file, key_file=key_file, webrtc=webrtc, webrtc_url=webrtc_url) + cert_file=cert_file, key_file=key_file, webrtc=webrtc, webrtc_url=webrtc_url, display_fps=display_fps) def get_tele_data(self): """