mirror of
https://github.com/wassname/pyrobolearn.git
synced 2026-09-11 12:31:07 +08:00
add spacemouse interface + example (+add haptic skeleton code)
This commit is contained in:
@@ -12,5 +12,6 @@ Here are few examples that depict the various interfaces available to the user:
|
||||
5. `asus_xtion.py`: use the Asus Xtion interface
|
||||
6. `openpose.py`: use the Openpose interface
|
||||
7. `speech.py`: use the speech (recognizer/translator) interface
|
||||
8. `spacemouse.py`: use the (3Dconnexion) SpaceMouse interface
|
||||
|
||||
**Note**: some interfaces require to install different libraries, and possibly to configure them. Check the raised errors.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python
|
||||
"""Run the Space mouse interface.
|
||||
|
||||
Make sure that the `spnav` library is installed, and the space mouse (by 3Dconnexion) is connected to the computer
|
||||
before running this code.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import time
|
||||
|
||||
from pyrobolearn.tools.interfaces.mouse_keyboard.spacemouse import SpaceMouseInterface
|
||||
|
||||
|
||||
# create parser
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-t', '--use_thread', help='If we should run the webcam interface in a thread.', type=bool,
|
||||
default=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# create webcam interface
|
||||
if args.use_thread:
|
||||
# create and run interface in a thread
|
||||
interface = SpaceMouseInterface(use_thread=True, sleep_dt=0.001, verbose=True)
|
||||
raw_input('Press key to stop the space mouse interface')
|
||||
else:
|
||||
# create interface
|
||||
interface = SpaceMouseInterface(use_thread=False, verbose=True)
|
||||
|
||||
while True:
|
||||
# perform a `step` with the interface
|
||||
interface.step()
|
||||
time.sleep(0.001)
|
||||
Reference in New Issue
Block a user