can pybullet simulate air friction or other types of friction?

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
deepcode
Posts: 8
Joined: Sat Aug 26, 2017 2:04 am

can pybullet simulate air friction or other types of friction?

Post by deepcode »

I am trying to emulate a demo with objects falling out of the sky at different speeds:
http://brm.io/matter-js/demo/#airFriction
Reading through the documentation, It doesn't seem like pybullet has friction except for joint friction. is this possible to do in pybullet?
how can I change the parameters to the spheres so they fall at different speeds?

Code: Select all

import pybullet as p
import random
p.connect(p.GUI)
p.setGravity(0,0,-0.001)
p.setRealTimeSimulation(0)
objects = {}
def create_snow():
  for i in range(50):
    objects[i] = p.createCollisionShape(p.GEOM_SPHERE)
    p.changeVisualShape(objects[i],-1,rgbaColor=[random.random(),random.random(),0,1])
    p.createMultiBody(random.randint(1,10),objects[i],-1,basePosition=[random.randint(-10,10),random.randint(-10,10),random.randint(2,5)])
for i in range(1000000000):
  p.stepSimulation()
  if i % 100000 == 0:
    create_snow()
    
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: can pybullet simulate air friction or other types of friction?

Post by Erwin Coumans »

You can change the linear damping to emulate very simple air resistence.
Use pybullet.changeDynamics for this, see the pybullet quickstart guide.

More advanced force fields need to be written as custom code, either in python or as a pybullet C/C++ plugin.
Post Reply