5757
5858 # Test 5: Check initial controller state
5959 print ("[Test 5] Checking controller state..." )
60- left_snapshot = controller_tracker .get_left_controller (session )
61- right_snapshot = controller_tracker .get_right_controller (session )
60+ tracked_left = controller_tracker .get_left_controller (session )
61+ tracked_right = controller_tracker .get_right_controller (session )
6262 print (
63- f" Left controller: { 'ACTIVE' if left_snapshot . is_active else 'INACTIVE' } "
63+ f" Left controller: { 'ACTIVE' if tracked_left . data is not None else 'INACTIVE' } "
6464 )
6565 print (
66- f" Right controller: { 'ACTIVE' if right_snapshot . is_active else 'INACTIVE' } "
66+ f" Right controller: { 'ACTIVE' if tracked_right . data is not None else 'INACTIVE' } "
6767 )
6868
69- if left_snapshot . is_active and left_snapshot .grip_pose .is_valid :
70- pos = left_snapshot .grip_pose .pose .position
69+ if tracked_left . data is not None and tracked_left . data .grip_pose .is_valid :
70+ pos = tracked_left . data .grip_pose .pose .position
7171 print (f" Left grip position: [{ pos .x :.3f} , { pos .y :.3f} , { pos .z :.3f} ]" )
7272
73- if right_snapshot . is_active and right_snapshot .grip_pose .is_valid :
74- pos = right_snapshot .grip_pose .pose .position
73+ if tracked_right . data is not None and tracked_right . data .grip_pose .is_valid :
74+ pos = tracked_right . data .grip_pose .pose .position
7575 print (f" Right grip position: [{ pos .x :.3f} , { pos .y :.3f} , { pos .z :.3f} ]" )
7676 print ()
7777
100100 current_time = time .time ()
101101 if current_time - last_status_print >= 0.5 : # Print every 0.5 seconds
102102 elapsed = current_time - start_time
103- left_snapshot = controller_tracker .get_left_controller (session )
104- right_snapshot = controller_tracker .get_right_controller (session )
103+ tracked_left = controller_tracker .get_left_controller (session )
104+ tracked_right = controller_tracker .get_right_controller (session )
105105
106106 # Show current state
107- left_trigger = left_snapshot .inputs .trigger_value
108- left_squeeze = left_snapshot .inputs .squeeze_value
109- left_stick_x = left_snapshot .inputs .thumbstick_x
110- left_stick_y = left_snapshot .inputs .thumbstick_y
111- left_primary = left_snapshot .inputs .primary_click
112- left_secondary = left_snapshot .inputs .secondary_click
113-
114- right_trigger = right_snapshot .inputs .trigger_value
115- right_squeeze = right_snapshot .inputs .squeeze_value
116- right_stick_x = right_snapshot .inputs .thumbstick_x
117- right_stick_y = right_snapshot .inputs .thumbstick_y
118- right_primary = right_snapshot .inputs .primary_click
119- right_secondary = right_snapshot .inputs .secondary_click
107+ left_trigger = (
108+ tracked_left .data .inputs .trigger_value
109+ if tracked_left .data is not None
110+ else 0.0
111+ )
112+ left_squeeze = (
113+ tracked_left .data .inputs .squeeze_value
114+ if tracked_left .data is not None
115+ else 0.0
116+ )
117+ left_stick_x = (
118+ tracked_left .data .inputs .thumbstick_x
119+ if tracked_left .data is not None
120+ else 0.0
121+ )
122+ left_stick_y = (
123+ tracked_left .data .inputs .thumbstick_y
124+ if tracked_left .data is not None
125+ else 0.0
126+ )
127+ left_primary = (
128+ tracked_left .data .inputs .primary_click
129+ if tracked_left .data is not None
130+ else False
131+ )
132+ left_secondary = (
133+ tracked_left .data .inputs .secondary_click
134+ if tracked_left .data is not None
135+ else False
136+ )
137+
138+ right_trigger = (
139+ tracked_right .data .inputs .trigger_value
140+ if tracked_right .data is not None
141+ else 0.0
142+ )
143+ right_squeeze = (
144+ tracked_right .data .inputs .squeeze_value
145+ if tracked_right .data is not None
146+ else 0.0
147+ )
148+ right_stick_x = (
149+ tracked_right .data .inputs .thumbstick_x
150+ if tracked_right .data is not None
151+ else 0.0
152+ )
153+ right_stick_y = (
154+ tracked_right .data .inputs .thumbstick_y
155+ if tracked_right .data is not None
156+ else 0.0
157+ )
158+ right_primary = (
159+ tracked_right .data .inputs .primary_click
160+ if tracked_right .data is not None
161+ else False
162+ )
163+ right_secondary = (
164+ tracked_right .data .inputs .secondary_click
165+ if tracked_right .data is not None
166+ else False
167+ )
120168
121169 # Build status strings
122170 left_status = f"Trig={ left_trigger :.2f} Sq={ left_squeeze :.2f} "
157205 # Test 8: Show final statistics
158206 print ("[Test 8] Final controller state..." )
159207
160- def print_controller_summary (hand_name , snapshot ):
208+ def print_controller_summary (hand_name , tracked ):
161209 print (f" { hand_name } Controller:" )
162- if snapshot . is_active :
210+ if tracked . data is not None :
163211 print (" Status: ACTIVE" )
164212
165213 # Poses from snapshot
166- grip = snapshot .grip_pose
167- aim = snapshot .aim_pose
214+ grip = tracked . data .grip_pose
215+ aim = tracked . data .aim_pose
168216
169217 if grip .is_valid :
170218 pos = grip .pose .position
@@ -179,7 +227,7 @@ def print_controller_summary(hand_name, snapshot):
179227 )
180228
181229 # Input values
182- inputs = snapshot .inputs
230+ inputs = tracked . data .inputs
183231 print (f" Trigger: { inputs .trigger_value :.2f} " )
184232 print (f" Squeeze: { inputs .squeeze_value :.2f} " )
185233 print (
@@ -194,11 +242,11 @@ def print_controller_summary(hand_name, snapshot):
194242 else :
195243 print (" Status: INACTIVE" )
196244
197- left_snapshot = controller_tracker .get_left_controller (session )
198- right_snapshot = controller_tracker .get_right_controller (session )
199- print_controller_summary ("Left" , left_snapshot )
245+ tracked_left = controller_tracker .get_left_controller (session )
246+ tracked_right = controller_tracker .get_right_controller (session )
247+ print_controller_summary ("Left" , tracked_left )
200248 print ()
201- print_controller_summary ("Right" , right_snapshot )
249+ print_controller_summary ("Right" , tracked_right )
202250 print ()
203251
204252 # Cleanup
0 commit comments