-
Notifications
You must be signed in to change notification settings - Fork 37
Tutorials: Setup
The simulation can be launched using two different modes, as pictured below.
The simulation can be launched using a SimulationManager object:
from qibullet import SimulationManager
if __name__ == "__main__":
simulation_manager = SimulationManager()
client_id = simulation_manager.launchSimulation(gui=True)
# Your code here...
This code snippet will launch a simulated instance, and will spawn an OpenGL rendering window. The gui parameter allows the user to choose between the GUI or DIRECT mode. You can theoretically launch an unlimited amount of simulated instance in DIRECT mode (the limit is set by the computing power available), but only one at a time in GUI mode.
from qibullet import SimulationManager
if __name__ == "__main__":
simulation_manager = SimulationManager()
client_gui = simulation_manager.launchSimulation(gui=True)
client_direct_0 = simulation_manager.launchSimulation(gui=False)
client_direct_1 = simulation_manager.launchSimulation(gui=False)
###
client_direct_n = simulation_manager.launchSimulation(gui=False)
# Your code here...
In this snippet, we launch a simulation instance in GUI mode, and n instances in DIRECT mode. Note that the launchSimulation method will return the id of the created instance. The SimulationManager object can also be used to reset or stop a simulated instance:
simulation_manager = SimulationManager()
client_id = simulation_manager.launchSimulation(gui=True)
simulation_manager.resetSimulation(client_id)
simulation_manager.stopSimulation(client_id)
# Your code here...
The methods can be called independently, resetSimulation will remove all of the simulated objects in an instance but leave the instance running, while stopSimulation will stop the instance.
A Virtual Pepper can be spawned using the simulation manager:
from qibullet import SimulationManager
from qibullet import PepperVirtual
if __name__ == "__main__":
simulation_manager = SimulationManager()
client_id = simulation_manager.launchSimulation(gui=True)
pepper = simulation_manager.spawnPepper(
client_id,
translation=[0, 0, 0],
quaternion=[0, 0, 0, 1],
spawn_ground_plane=True)
# Your code here...
In this snippet, a virtual Pepper will be spawned in the client_id instance, at the origin of the simulation world frame with no rotation on its base. A ground will also be spawned at the same time. By default, the translation and quaternion parameters are the one specified in the snippet: We could remove them from the example, it would not alter the code's output.
A virtual Pepper can also be spawned using the PepperVirtual class directly, but the virtual environment needs to be launched first:
pepper = PepperVirtual()
pepper.loadRobot(
translation=[0, 0, 0],
quaternion=[0, 0, 0, 1],
physicsClientId=client_id)
# Your code here...
qibullet is under the Apache-2.0 License