PyBullet Simulator
PyBullet is a physics simulator. the user describe bodies, joints, gravity, motors, contacts, etc., and PyBullet numerically advances the world step by step. The simulator use in robotics and reinforcement learning.
Simulation step / motion
- Apply gravity
- Apply external force / torque
- Solve joint constrains
- Detect collisions
- Solve contact constrains
- Integrated velocity and position
empty.py

Coordinate frame
- X = red
- Y = green
- Z = blue
PyBullet status bar

- dist: Change the Visual Camera distance from world origin (coordinate frame) change distance using mouse scroll
- Pitch, Yaw: Change Visual Camera orientation hold mouse left and move
Control view
Control
| enable/disable camera views | |
|---|---|
Without GUI (debug)

Nvidia
| force opengl run on nvidia | |
|---|---|
| with nvidia log | |
|---|---|
Rigid body
A rigid body is a object that does not deform likes: - box - sphere - any shape that use as a link
A rigid body can move in 6 degree of freedom - translation: x, y, z - rotation: Roll, Pitch, Yaw
Info
A rigid body is a mathematical physical object
rigid body definition
| Property | Meaning |
|---|---|
| position | where object is |
| orientation | rotation |
| linear velocity | movement speed |
| angular velocity | rotation speed |
| mass | inertia to motion |
| inertia tensor | resistance to rotation |
| collision shape | physics geometry |
| visual shape | rendering geometry |
Visual Collision and Inertia
In rigid_body.py, the box is built from two separate shapes:
createCollisionShape(...)defines the physical geometry used by the simulator for contact, friction, bouncing, and collision tests.createVisualShape(...)defines only how the object is drawn in the GUI, including color and visible size. It does not affect physics.
Both shapes are attached to the body with createMultiBody(...). PyBullet uses baseMass together with the collision shape dimensions to compute the body's default local inertia. Inertia is the body's resistance to rotation: a larger mass or a larger shape is harder to spin.
Briefly:
baseMass > 0creates a dynamic body affected by gravity, forces, collisions, and inertia.baseMass = 0creates a static body. It can collide with dynamic bodies, but it does not move and PyBullet treats its inertia as fixed/infinite for simulation purposes.
rigid body example
Tip
install pyi for intellisense pybulley.pyi download
Demo
- pybullet_data provide many URDF examples.
loadURDFreturn integer that use to refer the robot in other pybullet commands/
Demo: Get Position and Orientation
Demos and ...
- online urdf
- PyBullet
- https://medium.com/@reflectrobotics/scara-robot-modeling-and-simulation-with-pybullet-7bb204958763
- ROS-PyBullet Interface
- akinami3PybulletRobotics
- PyBullet and Control Algorithms Workshop - La Robo Liga Event
- Quick start guide
- How to Control a Robot with Python
- PyBullet workshop for NTU students : Day-1
- PyBullet workshop for NTU students : Day-2
- PyBullet workshop for NTU students : Day-3
- Creating OpenAI Gym Environments with PyBullet (Part 1)
- Creating OpenAI Gym Environments with PyBullet (Part 2)