bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

Unreliable velocity and angular velocity for softbody

Open danielpmorton opened this issue 1 year ago • 2 comments

Calling getBaseVelocity on a softbody does not seem to produce meaningful results in Pybullet. Interestingly, I tried printing this info via modifying the C++ source, and I was able to get velocity values out of the soft torus example in the ExampleBrowser. I tried modifying the source but could not figure out precisely how this is communicated from the C++ to Python

This issue also exists when I build pybullet from source rather than using pip

Here is a minimal example of printing the velocity information that just returns vec3's of zeros, despite the body accelerating under gravity

import time
import pybullet
import pybullet_data

pybullet.connect(pybullet.GUI)
pybullet.resetSimulation(pybullet.RESET_USE_DEFORMABLE_WORLD)
pybullet.setGravity(0, 0, -9.81)
pybullet.setAdditionalSearchPath(pybullet_data.getDataPath())
sb = pybullet.loadSoftBody(
    "/home/dan/software/bullet3/data/bread.vtk",  # Could not use pybullet_data path for some reason
    mass=3,
    useNeoHookean=1,
    NeoHookeanMu=180,
    NeoHookeanLambda=600,
    NeoHookeanDamping=0.01,
    collisionMargin=0.006,
    useSelfCollision=1,
    frictionCoeff=0.5,
    repulsionStiffness=800,
)
pybullet.loadURDF("plane.urdf", basePosition=[0, 0, -2])
while True:
    pybullet.stepSimulation()
    time.sleep(1 / 120)
    vel, ang_vel = pybullet.getBaseVelocity(sb)
    print("Velocity: ", vel)
    print("Angular velocity: ", ang_vel)

Output:

Velocity:  (0.0, 0.0, 0.0)
Angular velocity:  (0.0, -0.006118293851613998, -8.297943676766718e-17)
Velocity:  (0.0, 0.0, 0.0)
Angular velocity:  (0.0, -0.006118293851613998, -8.297943676766718e-17)
Velocity:  (0.0, 0.0, 0.0)
Angular velocity:  (0.0, -0.006118293851613998, -8.297943676766718e-17)
Velocity:  (0.0, 0.0, 0.0)
Angular velocity:  (0.0, -0.006118293851613998, -8.297943676766718e-17)
...

danielpmorton avatar Apr 11 '23 21:04 danielpmorton