mirror of
https://github.com/wassname/pyrobolearn.git
synced 2026-09-11 12:31:07 +08:00
update game controllers and keyboard interfaces + example with quadcopter and wheeled robot
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user