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()