update interfaces, manipulability, robots, world (+add/update corresponding examples)

This commit is contained in:
Brian Delhaisse
2019-06-20 01:13:46 +02:00
parent 1f4764d923
commit f512d42d31
80 changed files with 902 additions and 203 deletions
+9 -2
View File
@@ -1,4 +1,11 @@
## Interfaces
## Interfaces and Bridges
In this folder, you will find examples on what interfaces you can use and on how you can collect the data from them.
You will also be able to connect an interface with an element of the world (in this case, a robot) using bridges, and see that different bridges can lead to different behaviors while getting the data from the same interface.
You will also be able to connect an interface with an element of the world (in this case, a robot) using bridges,
and see that different bridges can lead to different behaviors while getting the data from the same interface.
Here are few examples that depict the various interfaces:
1. `mouse_keyboard.py`: use the mouse keyboard interface
2. `webcam.py`: use the webcam interface
3. `playstation.py`: use the Playstation joystick controller interface
4. `xbox.py`: use the Xbox joystick controller interface
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env python
"""Load the mouse keyboard interface.
"""
from itertools import count
import pyrobolearn as prl
from pyrobolearn.tools.interfaces.mouse_keyboard import MouseKeyboardInterface
# create simulator
sim = prl.simulators.Bullet()
# create mouse keyboard interface
interface = MouseKeyboardInterface(sim)
# run interface
for _ in count():
# perform a step with the interface
interface.step()
# print pressed keys
if len(interface.key_down) > 0:
print("Keys that are pressed: {}".format(interface.key_down))
# perform a step with the simulator
sim.step(sleep_time=sim.dt)
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python
"""Load the Playstation game controller interface
"""
import time
from itertools import count
import argparse
from pyrobolearn.tools.interfaces.controllers.playstation import PS3ControllerInterface, PS4ControllerInterface
# create parser to select the game controller
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--controller', help='The Playstation game controller to use (ps3 or ps4)', type=str,
choices=['ps3', 'ps4'], default='ps4')
args = parser.parse_args()
# load corresponding Playstation controller interface
if args.controller == 'ps3':
controller = PS3ControllerInterface(verbose=True)
elif args.controller == 'ps4':
controller = PS4ControllerInterface(verbose=False)
else:
raise NotImplementedError("Unknown game controller")
# run controller
print('Running controller...')
for _ in count():
# run one step with the interface
controller.run() # same as `step()` if we are not using threads
# get the last update and print it
b = controller.X
print("X: {}".format(b)) # , controller[b]))
# sleep a bit
time.sleep(0.01)
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python
"""Load the Xbox game controller interface
"""
import time
from itertools import count
import argparse
from pyrobolearn.tools.interfaces.controllers.xbox import Xbox360ControllerInterface, XboxOneControllerInterface
# create parser to select the game controller
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--controller', help='The Xbox game controller to use (xbox one or xbox 360)', type=str,
choices=['360', 'one'], default='one')
args = parser.parse_args()
# load corresponding Xbox controller interface
if args.controller == '360':
controller = Xbox360ControllerInterface(verbose=True)
elif args.controller == 'one':
controller = XboxOneControllerInterface(verbose=True)
else:
raise NotImplementedError("Unknown game controller")
# run controller
print('Running controller...')
for _ in count():
# run one step with the interface
controller.run() # same as `step()` if we are not using threads
# get the last update and print it
b = controller.last_updated_button
print("Last updated button: {} with value: {}".format(b, controller[b]))
# sleep a bit
time.sleep(0.01)