I recently started using PyBullet and want to thank you for this awesome piece of software. However, during some trials I found some weird behavior when dropping a simple cube from 100 meters: The velocity seems to stall asymptotically. This probably has to do with some stabilization of the simulation, but I could not find any information on this in the documentation. Could you give me a hint please? I attached the code and a plot.
Thank you in advance.
Best regards

Code: Select all
import pybullet as p
import pybullet_data
import numpy as np
import matplotlib.pyplot as plt
timestep = 1 / 240
g = -10
physicsClient = p.connect(p.DIRECT)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.setGravity(0, 0, g)
planeId = p.loadURDF("plane.urdf")
cubeStartPos = [0, 0, 100]
cubeStartOrientation = p.getQuaternionFromEuler([0, 0, 0])
boxId = p.loadURDF("cube.urdf", cubeStartPos, cubeStartOrientation)
p.setTimeStep(timestep)
simulated_velocity_list = []
physical_velocity_list = []
time = []
i = 0
while True:
time.append(i * timestep)
physical_velocity_list.append(g * i * timestep)
simulated_velocity_list.append(p.getBaseVelocity(boxId)[0][2])
if (p.getBasePositionAndOrientation(boxId)[0][2] <= 0.05):
print(i * timestep)
break
p.stepSimulation()
i += 1
plt.plot(time, simulated_velocity_list)
plt.plot(time, physical_velocity_list)
plt.grid()
plt.xlabel("Time [s]")
plt.ylabel("Velocity [mps]")
plt.legend(["PyBullet", "v=a t"])
plt.show()
p.disconnect()