@@ -23,16 +23,20 @@ def example_modify_existing():
2323 print (f"Available devices: { list (specs .keys ())} " )
2424
2525 # Get connected devices
26- connected = pyspacemouse .get_connected_devices ()
26+ connected = pyspacemouse .get_connected_spacemice ()
2727 if not connected :
2828 print ("No devices connected!" )
2929 return
30+ if len (connected ) > 1 :
31+ print ("This example only works with one device connected." )
32+ return
3033
31- device_name = connected [0 ]
34+ device = connected [0 ]
35+ device_path , device_name = device
3236 print (f"Using device: { device_name } " )
3337
3438 # Get base spec and create modified version
35- base_spec = specs [device_name ]
39+ base_spec = specs [device_path ]
3640 print (f"Original mappings: y scale = { base_spec .mappings ['y' ].scale } " )
3741
3842 # Create modified spec with inverted Y and Z (common for ROS)
@@ -62,18 +66,23 @@ def example_invert_rotations():
6266 print ("Example 2: Fix rotation conventions" )
6367 print ("=" * 60 )
6468
65- connected = pyspacemouse .get_connected_devices ()
69+ connected = pyspacemouse .get_connected_spacemice ()
6670 if not connected :
6771 print ("No devices connected!" )
6872 return
73+ if len (connected ) > 1 :
74+ print ("This example only works with one device connected." )
75+ return
6976
77+ device = connected [0 ]
78+ device_path , device_name = device
7079 specs = pyspacemouse .get_device_specs ()
71- base_spec = specs [connected [ 0 ] ]
80+ base_spec = specs [device_name ]
7281
7382 # Invert roll and yaw for right-handed coordinate system
7483 fixed_spec = pyspacemouse .modify_device_info (
7584 base_spec ,
76- name = f"{ connected [ 0 ] } (Fixed Rotations)" ,
85+ name = f"{ device_name } (Fixed Rotations)" ,
7786 invert_axes = ["roll" , "yaw" ],
7887 )
7988
0 commit comments