update game controllers and keyboard interfaces + example with quadcopter and wheeled robot

This commit is contained in:
Brian Delhaisse
2019-06-21 03:26:36 +02:00
parent f512d42d31
commit c356c062bb
18 changed files with 1475 additions and 164 deletions
+5 -1
View File
@@ -12,6 +12,8 @@ from pyrobolearn.tools.interfaces.mouse_keyboard import MouseKeyboardInterface
sim = prl.simulators.Bullet()
# create mouse keyboard interface
# Note that to give the simulator `sim` to the interface can be optional especially if there is only one simulator.
# The interface will look in the memory to check the instantiated simulators and take the first one if it exists.
interface = MouseKeyboardInterface(sim)
# run interface
@@ -20,8 +22,10 @@ for _ in count():
interface.step()
# print pressed keys
if len(interface.key_pressed) > 0:
print("Keys that are pressed: {}".format(interface.key_pressed))
if len(interface.key_down) > 0:
print("Keys that are pressed: {}".format(interface.key_down))
print("Keys that are down: {}".format(interface.key_down))
# perform a step with the simulator
sim.step(sleep_time=sim.dt)