Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions examples/lerobot/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,37 @@ def main():
break

# Get hand data
left: schema.HandPoseT = hand_tracker.get_left_hand(session)
right: schema.HandPoseT = hand_tracker.get_right_hand(session)
head: schema.HeadPoseT = head_tracker.get_head(session)
left_tracked: schema.HandPoseTrackedT = hand_tracker.get_left_hand(
session
)
right_tracked: schema.HandPoseTrackedT = (
hand_tracker.get_right_hand(session)
)
head_tracked: schema.HeadPoseTrackedT = head_tracker.get_head(
session
)

# Extract positions and orientations (with defaults for invalid data)
left_pos = np.zeros(3, dtype=np.float32)
right_pos = np.zeros(3, dtype=np.float32)

if left.is_active and left.joints:
wrist = left.joints[deviceio.JOINT_WRIST]
if left_tracked.data is not None and left_tracked.data.joints:
wrist = left_tracked.data.joints.poses(deviceio.JOINT_WRIST)
if wrist.is_valid:
pos = wrist.pose.position
left_pos = np.array([pos.x, pos.y, pos.z], dtype=np.float32)

if right.is_active and right.joints:
wrist = right.joints[deviceio.JOINT_WRIST]
if right_tracked.data is not None and right_tracked.data.joints:
wrist = right_tracked.data.joints.poses(deviceio.JOINT_WRIST)
if wrist.is_valid:
pos = wrist.pose.position
right_pos = np.array(
[pos.x, pos.y, pos.z], dtype=np.float32
)

head_pos = np.zeros(3, dtype=np.float32)
if head.is_valid and head.pose:
pos = head.pose.position
if head_tracked.data is not None and head_tracked.data.is_valid:
pos = head_tracked.data.pose.position
head_pos = np.array([pos.x, pos.y, pos.z], dtype=np.float32)

# STEP 3: Record frame to dataset
Expand Down
12 changes: 6 additions & 6 deletions examples/oxr/cpp/oxr_session_sharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ try
}

// Get data from both trackers
const auto& left = hand_tracker->get_left_hand(*session1);
const auto& head = head_tracker->get_head(*session2);
const auto& left_tracked = hand_tracker->get_left_hand(*session1);
const auto& head_tracked = head_tracker->get_head(*session2);

if (i % 3 == 0)
{
std::cout << "Frame " << i << ": "
<< "Hands=" << (left.is_active ? "ACTIVE" : "INACTIVE") << " | "
<< "Head=" << (head.is_valid ? "VALID" : "INVALID");
if (head.is_valid && head.pose)
<< "Hands=" << (left_tracked.data ? "ACTIVE" : "INACTIVE") << " | "
<< "Head=" << ((head_tracked.data && head_tracked.data->is_valid) ? "VALID" : "INVALID");
if (head_tracked.data && head_tracked.data->is_valid && head_tracked.data->pose)
{
const auto& pos = head.pose->position();
const auto& pos = head_tracked.data->pose->position();
std::cout << " [" << pos.x() << ", " << pos.y() << ", " << pos.z() << "]";
}
std::cout << std::endl;
Expand Down
17 changes: 9 additions & 8 deletions examples/oxr/cpp/oxr_simple_api_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ try
}

// External user only uses public query methods
const auto& left = hand_tracker->get_left_hand(*session);
const auto& right = hand_tracker->get_right_hand(*session);
const auto& head = head_tracker->get_head(*session);
const auto& left_tracked = hand_tracker->get_left_hand(*session);
const auto& right_tracked = hand_tracker->get_right_hand(*session);
const auto& head_tracked = head_tracker->get_head(*session);

std::cout << "Frame " << i << ":" << std::endl;
std::cout << " Left hand: " << (left.is_active ? "ACTIVE" : "INACTIVE") << std::endl;
std::cout << " Right hand: " << (right.is_active ? "ACTIVE" : "INACTIVE") << std::endl;
std::cout << " Head pose: " << (head.is_valid ? "VALID" : "INVALID") << std::endl;
std::cout << " Left hand: " << (left_tracked.data ? "ACTIVE" : "INACTIVE") << std::endl;
std::cout << " Right hand: " << (right_tracked.data ? "ACTIVE" : "INACTIVE") << std::endl;
std::cout << " Head pose: " << ((head_tracked.data && head_tracked.data->is_valid) ? "VALID" : "INVALID")
<< std::endl;

if (head.is_valid && head.pose)
if (head_tracked.data && head_tracked.data->is_valid && head_tracked.data->pose)
{
const auto& pos = head.pose->position();
const auto& pos = head_tracked.data->pose->position();
std::cout << " Position: [" << pos.x() << ", " << pos.y() << ", " << pos.z() << "]" << std::endl;
}
std::cout << std::endl;
Expand Down
52 changes: 33 additions & 19 deletions examples/oxr/python/modular_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import time
import isaacteleop.deviceio as deviceio
import isaacteleop.oxr as oxr
import isaacteleop.schema as schema


def main():
Expand Down Expand Up @@ -70,31 +71,44 @@ def main():
print(f"[{elapsed:4.1f}s] Frame {frame_count}")

# Get hand data
left = hand_tracker.get_left_hand(session)
right = hand_tracker.get_right_hand(session)

print(
f" Hands: Left={'ACTIVE' if left.is_active else 'INACTIVE':8s} | "
f"Right={'ACTIVE' if right.is_active else 'INACTIVE':8s}"
left_tracked: schema.HandPoseTrackedT = (
hand_tracker.get_left_hand(session)
)
right_tracked: schema.HandPoseTrackedT = (
hand_tracker.get_right_hand(session)
)

if left.is_active:
wrist = left.joints[deviceio.JOINT_WRIST]
if wrist.is_valid:
pos = wrist.pose.position
print(
f" Left wrist: [{pos.x:6.3f}, {pos.y:6.3f}, {pos.z:6.3f}]"
)
if left_tracked.data is not None:
pos = left_tracked.data.joints.poses(
deviceio.JOINT_WRIST
).pose.position
print(
f" Left wrist: [{pos.x:6.3f}, {pos.y:6.3f}, {pos.z:6.3f}]"
)
else:
print(" Left hand: inactive")

# Get head data (returns HeadPoseT from schema)
head = head_tracker.get_head(session)
print(f" Head: {'VALID' if head.is_valid else 'INVALID':8s}")
if right_tracked.data is not None:
pos = right_tracked.data.joints.poses(
deviceio.JOINT_WRIST
).pose.position
print(
f" Right wrist: [{pos.x:6.3f}, {pos.y:6.3f}, {pos.z:6.3f}]"
)
else:
print(" Right hand: inactive")

if head.is_valid and head.pose:
pos = head.pose.position
# Get head data
head_tracked: schema.HeadPoseTrackedT = head_tracker.get_head(
session
)
if head_tracked.data is not None:
pos = head_tracked.data.pose.position
print(
f" Head position: [{pos.x:6.3f}, {pos.y:6.3f}, {pos.z:6.3f}]"
f" Head pos: [{pos.x:6.3f}, {pos.y:6.3f}, {pos.z:6.3f}]"
)
else:
print(" Head: inactive")

print()

Expand Down
133 changes: 50 additions & 83 deletions examples/oxr/python/test_controller_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,20 @@

# Test 5: Check initial controller state
print("[Test 5] Checking controller state...")
left_snapshot = controller_tracker.get_left_controller(session)
right_snapshot = controller_tracker.get_right_controller(session)
print(
f" Left controller: {'ACTIVE' if left_snapshot.is_active else 'INACTIVE'}"
)
print(
f" Right controller: {'ACTIVE' if right_snapshot.is_active else 'INACTIVE'}"
)

if left_snapshot.is_active and left_snapshot.grip_pose.is_valid:
pos = left_snapshot.grip_pose.pose.position
print(f" Left grip position: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")

if right_snapshot.is_active and right_snapshot.grip_pose.is_valid:
pos = right_snapshot.grip_pose.pose.position
print(f" Right grip position: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")
left_tracked = controller_tracker.get_left_controller(session)
right_tracked = controller_tracker.get_right_controller(session)

if left_tracked.data is not None and left_tracked.data.grip_pose.is_valid:
pos = left_tracked.data.grip_pose.pose.position
print(f" Left grip: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")
else:
print(" Left: inactive")

if right_tracked.data is not None and right_tracked.data.grip_pose.is_valid:
pos = right_tracked.data.grip_pose.pose.position
print(f" Right grip: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")
else:
print(" Right: inactive")
print()

# Test 6: Available inputs
Expand Down Expand Up @@ -100,48 +98,32 @@
current_time = time.time()
if current_time - last_status_print >= 0.5: # Print every 0.5 seconds
elapsed = current_time - start_time
left_snapshot = controller_tracker.get_left_controller(session)
right_snapshot = controller_tracker.get_right_controller(session)

# Show current state
left_trigger = left_snapshot.inputs.trigger_value
left_squeeze = left_snapshot.inputs.squeeze_value
left_stick_x = left_snapshot.inputs.thumbstick_x
left_stick_y = left_snapshot.inputs.thumbstick_y
left_primary = left_snapshot.inputs.primary_click
left_secondary = left_snapshot.inputs.secondary_click

right_trigger = right_snapshot.inputs.trigger_value
right_squeeze = right_snapshot.inputs.squeeze_value
right_stick_x = right_snapshot.inputs.thumbstick_x
right_stick_y = right_snapshot.inputs.thumbstick_y
right_primary = right_snapshot.inputs.primary_click
right_secondary = right_snapshot.inputs.secondary_click

# Build status strings
left_status = f"Trig={left_trigger:.2f} Sq={left_squeeze:.2f}"
if abs(left_stick_x) > 0.1 or abs(left_stick_y) > 0.1:
left_status += (
f" Stick=({left_stick_x:+.2f},{left_stick_y:+.2f})"
left_tracked = controller_tracker.get_left_controller(session)
right_tracked = controller_tracker.get_right_controller(session)

print(f" [{elapsed:5.2f}s] Frame {frame_count:4d}")

left_data = left_tracked.data
if left_data is not None:
li = left_data.inputs
print(
f" L: Trig={li.trigger_value:.2f} Sq={li.squeeze_value:.2f}"
f" Stick=({li.thumbstick_x:+.2f},{li.thumbstick_y:+.2f})"
f" Btn=[{int(li.primary_click)}{int(li.secondary_click)}{int(li.thumbstick_click)}]"
)
if left_primary:
left_status += " [X]"
if left_secondary:
left_status += " [Y]"

right_status = f"Trig={right_trigger:.2f} Sq={right_squeeze:.2f}"
if abs(right_stick_x) > 0.1 or abs(right_stick_y) > 0.1:
right_status += (
f" Stick=({right_stick_x:+.2f},{right_stick_y:+.2f})"
else:
print(" L: INACTIVE")

right_data = right_tracked.data
if right_data is not None:
ri = right_data.inputs
print(
f" R: Trig={ri.trigger_value:.2f} Sq={ri.squeeze_value:.2f}"
f" Stick=({ri.thumbstick_x:+.2f},{ri.thumbstick_y:+.2f})"
f" Btn=[{int(ri.primary_click)}{int(ri.secondary_click)}{int(ri.thumbstick_click)}]"
)
if right_primary:
right_status += " [A]"
if right_secondary:
right_status += " [B]"

print(
f" [{elapsed:5.2f}s] Frame {frame_count:4d} | L: {left_status} | R: {right_status}"
)
else:
print(" R: INACTIVE")
last_status_print = current_time

frame_count += 1
Expand All @@ -157,29 +139,14 @@
# Test 8: Show final statistics
print("[Test 8] Final controller state...")

def print_controller_summary(hand_name, snapshot):
def print_controller_summary(hand_name, tracked):
print(f" {hand_name} Controller:")
if snapshot.is_active:
print(" Status: ACTIVE")

# Poses from snapshot
grip = snapshot.grip_pose
aim = snapshot.aim_pose

if grip.is_valid:
pos = grip.pose.position
print(
f" Grip position: [{pos.x:+.3f}, {pos.y:+.3f}, {pos.z:+.3f}]"
)

if aim.is_valid:
pos = aim.pose.position
print(
f" Aim position: [{pos.x:+.3f}, {pos.y:+.3f}, {pos.z:+.3f}]"
)

# Input values
inputs = snapshot.inputs
if tracked.data is not None:
pos = tracked.data.grip_pose.pose.position
print(f" Grip position: [{pos.x:+.3f}, {pos.y:+.3f}, {pos.z:+.3f}]")
pos = tracked.data.aim_pose.pose.position
print(f" Aim position: [{pos.x:+.3f}, {pos.y:+.3f}, {pos.z:+.3f}]")
inputs = tracked.data.inputs
print(f" Trigger: {inputs.trigger_value:.2f}")
print(f" Squeeze: {inputs.squeeze_value:.2f}")
print(
Expand All @@ -192,13 +159,13 @@ def print_controller_summary(hand_name, snapshot):
f" Secondary: {'PRESSED' if inputs.secondary_click else 'released'}"
)
else:
print(" Status: INACTIVE")
print(" inactive")

left_snapshot = controller_tracker.get_left_controller(session)
right_snapshot = controller_tracker.get_right_controller(session)
print_controller_summary("Left", left_snapshot)
left_tracked = controller_tracker.get_left_controller(session)
right_tracked = controller_tracker.get_right_controller(session)
print_controller_summary("Left", left_tracked)
print()
print_controller_summary("Right", right_snapshot)
print_controller_summary("Right", right_tracked)
print()

# Cleanup
Expand Down
16 changes: 12 additions & 4 deletions examples/oxr/python/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@

# Quick update test
if session.update():
left = hand.get_left_hand(session)
head_pose = head.get_head(session)
left_tracked = hand.get_left_hand(session)
head_tracked = head.get_head(session)
print(" ✅ Update successful")
print(f" Hands: {'ACTIVE' if left.is_active else 'INACTIVE'}")
print(f" Head: {'VALID' if head_pose.is_valid else 'INVALID'}")
if left_tracked.data is not None:
pos = left_tracked.data.joints.poses(deviceio.JOINT_WRIST).pose.position
print(f" Left wrist: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")
else:
print(" Left hand: inactive")
if head_tracked.data is not None:
pos = head_tracked.data.pose.position
print(f" Head pos: [{pos.x:.3f}, {pos.y:.3f}, {pos.z:.3f}]")
else:
print(" Head: inactive")

# Session will be cleaned up when exiting 'with' block (RAII)

Expand Down
Loading