add spacemouse interface + example (+add haptic skeleton code)

This commit is contained in:
Brian Delhaisse
2019-06-22 23:23:37 +02:00
parent 1926238a64
commit 17bb7579c5
8 changed files with 357 additions and 2 deletions
+1
View File
@@ -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.
+33
View File
@@ -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)