Simulation

PyBullet

PyBullet supplies a Python interface to Bullet physics for robot models, collision queries, kinematics and small simulation experiments. The GUI and DIRECT backends serve different workflows; a successful URDF load does not guarantee correct joint dynamics.

Practical engineering guide

What you can build with PyBullet and where problems start

PyBullet supplies a Python interface to Bullet physics for robot models, collision queries, kinematics and small simulation experiments. The GUI and DIRECT backends serve different workflows; a successful URDF load does not guarantee correct joint dynamics.

Download, install and launch PyBullet

Install from PyPI in an isolated Python environment. Run this tiny headless exercise to verify the package, sample assets and physics stepping. A successful headless run needs no robot or graphics card.

Download PyBullet
python -m venv .venv
# Activate the environment first
python -m pip install pybullet
python -c "import pybullet as p, pybullet_data; p.connect(p.DIRECT); p.setAdditionalSearchPath(pybullet_data.getDataPath()); p.setGravity(0,0,-9.81); p.loadURDF('plane.urdf'); p.stepSimulation(); p.disconnect()"

A first test you can reproduce

  1. 01.Install PyBullet using the project guide and connect with pybullet.GUI for inspection or pybullet.DIRECT for headless loops.
  2. 02.Load a plane and a simple URDF with the built-in pybullet_data examples and set gravity explicitly.
  3. 03.Inspect getNumJoints and getJointInfo before applying setJointMotorControl2 commands.
  4. 04.Use a fixed step and log the state after each stepSimulation call.

Questions that come up during real implementation

Why does PyBullet show a static robot despite running my code?

Check whether the code advances the physics with stepSimulation, whether the motor is in position, velocity or torque mode and whether the joint is fixed. A DIRECT connection does not show a GUI. Verify motor force bounds and gravity explicitly.

Can I use PyBullet for reinforcement learning on a server without graphics?

Yes. DIRECT mode runs physics without an interactive OpenGL window. Some rendering options depend on software rendering or separate graphics support. Keep physics time step and random seeds documented for comparisons.

Why do URDF collision contacts look wrong?

Visual geometry, collision geometry and inertial parameters are independent. Inspect link scales, collision meshes, joint origins and dynamics values. Tiny collision shapes or inaccurate inertias can cause penetration and unstable grasp behavior.

Checks before using it on a robot

  • Run a single contact test against a plane before evaluating manipulation.
  • Compare collision queries and contact forces against measured behavior if deploying controllers.

Official technical reference

https://github.com/bulletphysics/bullet3/blob/master/docs/pybullet_quickstart_guide/PyBulletQuickstartGuide.md.html

Compatibility and installation

Developer
Bullet Physics
License
Open source
Operating systems
Linux, Windows, macOS
ROS support
No official ROS support recorded
Languages
C++, Python
Installation method
Official Python package or source build

Profile sources

Explore the connected robotics directories