Free fall violates 2nd Newton’s Law?

Post Reply
Zagnnoqan
Posts: 2
Joined: Thu Dec 12, 2019 11:03 pm

Free fall violates 2nd Newton’s Law?

Post by Zagnnoqan » Fri Dec 13, 2019 2:52 pm

Dear all,

I try to figure out how the dynamics in pybullet works but without success. I created simple demo with cube and gravity force.

When observing the velocity of the box, I see It slows down until it reaches some constant value.
This violates the movement equation F=ma where the acceleration is constant (for F=G=mg=>a=g) and velocity should be linearly growing.

Where am I wrong? Is there any default environment friction or resistance?

Thanks a lot,
Stan

My code in Python3 looks as follows:

Code: Select all


import numpy as np
import pybullet as p
import pylab as plt

from time import sleep

physicsClient = p.connect(p.DIRECT)    # p.GUI or p.DIRECT for non-graphical version
p.setGravity(0,0,-10)

cubeStartPos = [0,0,1]
cubeStartOrientation = p.getQuaternionFromEuler([0,0,0])

boxId = p.createCollisionShape(p.GEOM_BOX, halfExtents=[1,1,1])
p.createMultiBody(baseMass=1, baseCollisionShapeIndex=boxId, basePosition=cubeStartPos, baseOrientation=cubeStartOrientation)

p.setRealTimeSimulation(0)
pos, vel = [], []
for _ in range(10000):
    p.stepSimulation()
    cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId)
    lin, ang = p.getBaseVelocity(bodyUniqueId=boxId)
    #print(cubePos, cubeOrn, lin, ang)
    vx, vy, vz = lin
    px, py, pz = cubePos
    pos.append(pz)
    vel.append(vz)
p.disconnect()

plt.subplot(211)
plt.xlabel('Simulation step')
plt.ylabel('Distance')
plt.plot(pos)
plt.subplot(212)
plt.xlabel('Simulation step')
plt.ylabel('Velocity')
plt.plot(vel)
plt.show()

Attachments
freefall.png
freefall.png (34.61 KiB) Viewed 775 times

User avatar
drleviathan
Posts: 597
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Free fall violates 2nd Newton’s Law?

Post by drleviathan » Fri Dec 13, 2019 6:17 pm

My first guess is the box has non-zero linearDamping coefficient by default. Maybe try:

Code: Select all

p.changeDynamics(boxId, -1, linearDamping=0, angularDamping=0)

Zagnnoqan
Posts: 2
Joined: Thu Dec 12, 2019 11:03 pm

Re: Free fall violates 2nd Newton’s Law?

Post by Zagnnoqan » Sat Dec 14, 2019 4:23 pm

Thanks this seems to work.

Is there any documentation regarding those internal variables as damping, friction and elasticity and how to use this variables to create adequate simulation model for the real system?

User avatar
drleviathan
Posts: 597
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Free fall violates 2nd Newton’s Law?

Post by drleviathan » Mon Dec 16, 2019 4:28 pm

Per-object velocity damping is a feature of most real-time physics engines, primarily as a way to help it settle down by dissipating energy. It is always done as an approximate way (first order function of velocity) and works fine for approximating "friction through a fluid" at low world-frame speeds but not for high.

I don't know of official Bullet documentation about damping, friction, and restitution (what you probably mean by "elasticity"), although there are several threads in these forums about them. These are very common concepts in real-time physics simulations so you might want to research them in general rather than for Bullet specifically. They are often referred to as the "material properties" of the object.

Post Reply