Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Fast and easy simulation with Pybullet!

For those of you requiring a simulator for a semestral work I suggest using Pybullet . It's probably the simplest and richest engine to use for python and it is open source. It takes less than a minute to install.

It can be installed by making sure you have the appropriate tools:

apt-get update
apt-get install build-essential

And doing a pip installation

pip install pybullet

You can try a hello-world after installation to check if it's working:

import pybullet as p
import pybullet_data
physicsClient = p.connect(p.GUI)#or p.DIRECT for non-graphical version
p.setAdditionalSearchPath(pybullet_data.getDataPath()) #used by loadURDF
p.setGravity(0,0,-10)
planeId = p.loadURDF("plane.urdf")
cubeStartPos = [0,0,1]
cubeStartOrientation = p.getQuaternionFromEuler([0,0,0])
boxId = p.loadURDF("r2d2.urdf",cubeStartPos, cubeStartOrientation)
for i in range(1000000):
    p.stepSimulation()
cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)
print(cubePos,cubeOrn)
p.disconnect()

Quickstart guide:

A quick tutorial on how to set up a KUKA robot arm.

Several ready robotics examples that can be used:


Note:

Robot models in the simulators are loaded through description files which can be of the format .urdf, .xml, .mjcf, .sdf (and maybe several less popular ones). Pybullet knows how to load all of them although it might not be able to deal with some specifics of mujoco description files (.mjcf) so the model will be incomplete.


Tips:

Such a simulation engine can do many things “for free” other than the actual physical simulation. Some of these include forward and inverse kinematics, forward and inverse dynamics, ray intersection calculation, etc.


Consultation

If anyone is interested in using a simulator in their own project or thesis and has questions or would like to participate in some project which involves the use of a simulator then you can write to me.

courses/b3b33vir/resources/pybullet_simulation/start.txt · Last modified: 2018/12/07 13:55 by azayetey