Browse Source

Add VP connection timestamp tracking for LED status indicator

Add last_data_time_shared timestamp updated in all three Vuer event
handlers (CAMERA_MOVE, HAND_MOVE, CONTROLLER_MOVE). Exposes
last_data_time property for the main teleop loop to detect VP
connection freshness (connected if data received within 1 second).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
main
Joe DiPrima 1 month ago
parent
commit
0ea96e5f51
  1. 15
      src/televuer/televuer.py

15
src/televuer/televuer.py

@ -6,6 +6,7 @@ import asyncio
import threading
import cv2
import os
import time as _time
from pathlib import Path
from typing import Literal
@ -138,6 +139,8 @@ class TeleVuer:
self.vuer.spawn(start=False)(fn)
self.last_data_time_shared = Value('d', 0.0, lock=True)
self.head_pose_shared = Array('d', 16, lock=True)
self.left_arm_pose_shared = Array('d', 16, lock=True)
self.right_arm_pose_shared = Array('d', 16, lock=True)
@ -225,6 +228,8 @@ class TeleVuer:
try:
with self.head_pose_shared.get_lock():
self.head_pose_shared[:] = event.value["camera"]["matrix"]
with self.last_data_time_shared.get_lock():
self.last_data_time_shared.value = _time.time()
except:
pass
@ -264,6 +269,8 @@ class TeleVuer:
extract_controllers(left_controller, "left")
extract_controllers(right_controller, "right")
with self.last_data_time_shared.get_lock():
self.last_data_time_shared.value = _time.time()
except:
pass
@ -310,6 +317,8 @@ class TeleVuer:
extract_hand_poses(right_hand_data, self.right_arm_pose_shared, self.right_hand_position_shared, self.right_hand_orientation_shared)
extract_hands(left_hand, "left")
extract_hands(right_hand, "right")
with self.last_data_time_shared.get_lock():
self.last_data_time_shared.value = _time.time()
except:
pass
@ -679,6 +688,12 @@ class TeleVuer:
await asyncio.sleep(1.0 / self.display_fps)
# ==================== common data ====================
@property
def last_data_time(self):
"""float, timestamp of last VP data received (0.0 = never)."""
with self.last_data_time_shared.get_lock():
return self.last_data_time_shared.value
@property
def head_pose(self):
"""np.ndarray, shape (4, 4), head SE(3) pose matrix from Vuer (basis OpenXR Convention)."""

Loading…
Cancel
Save