diff --git a/build_cmake_pybullet_double.sh b/build_cmake_pybullet_double.sh index 8817311f0..ac40b1702 100755 --- a/build_cmake_pybullet_double.sh +++ b/build_cmake_pybullet_double.sh @@ -5,7 +5,7 @@ if [ -e CMakeCache.txt ]; then fi mkdir -p build_cmake cd build_cmake -cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=ON -DUSE_DOUBLE_PRECISION=ON -DBT_USE_EGL=ON -DCMAKE_BUILD_TYPE=Release .. || exit 1 +cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=ON -DUSE_DOUBLE_PRECISION=ON -DBT_USE_EGL=ON -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE:FILEPATH=/opt/homebrew/Caskroom/miniforge/base/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/opt/homebrew/Caskroom/miniforge/base/include/python3.9 -DPYTHON_LIBRARY:FILEPATH=/opt/homebrew/Caskroom/miniforge/base/lib/libpython3.9.dylib .. || exit 1 make -j $(command nproc 2>/dev/null || echo 12) || exit 1 cd examples cd pybullet diff --git a/examples/RobotSimulator/RobotSimulatorMain.cpp b/examples/RobotSimulator/RobotSimulatorMain.cpp index e1628584e..556d877ce 100644 --- a/examples/RobotSimulator/RobotSimulatorMain.cpp +++ b/examples/RobotSimulator/RobotSimulatorMain.cpp @@ -51,17 +51,12 @@ int main(int argc, char* argv[]) //b3BodyInfo bodyInfo; //sim->getBodyInfo(blockId,&bodyInfo); - { - int planeUID = sim->loadURDF("plane.urdf"); - btVector3 basePosition = btVector3(0, 0, -5); - btQuaternion baseOrientation = btQuaternion(0, 0, 0, 1); - sim->resetBasePositionAndOrientation(planeUID, basePosition, baseOrientation); - } + sim->loadURDF("plane.urdf"); { int deformableUID = sim->loadURDF("reduced_cube/reduced_cube.urdf"); // int deformableUID = sim->loadURDF("torus_deform.urdf"); - btVector3 basePosition = btVector3(0, 0, 10); + btVector3 basePosition = btVector3(0, 0, 2); btQuaternion baseOrientation = btQuaternion(0, 0, 0, 1); sim->resetBasePositionAndOrientation(deformableUID, basePosition, baseOrientation); } diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 55140def9..664ec9513 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -9503,7 +9503,6 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl out_found_sim_filename = out_found_filename; } - std::cout << "out_sim_type: " << out_sim_type << "\n"; if (out_sim_type == UrdfGeometry::FILE_OBJ) { // std::vector shapes; @@ -9580,7 +9579,8 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl } // load modes, reduced stiffness matrix - rsb->setReducedModes(6, 1, rsb->m_nodes.size()); + rsb->setReducedModes(6, 20, rsb->m_nodes.size()); // TODO: add modes info to URDF + rsb->setStiffnessScale(100); btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, pathPrefix); // btScalar corotated_mu(0.), corotated_lambda(0.); @@ -9616,7 +9616,6 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl } #endif } - std::cout << "finished here\n"; b3ImportMeshData meshData; if (rsb != NULL) @@ -9708,7 +9707,6 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl { rsb->m_renderNodes.resize(0); } - std::cout << "checkpoint 1\n"; #endif #ifndef SKIP_DEFORMABLE_BODY btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld(); @@ -9734,12 +9732,12 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl // turn on the collision flag for deformable // collision between deformable and rigid rsb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD; + /// turn on node contact for rigid body + rsb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDN; // turn on face contact for multibodies - rsb->m_cfg.collisions |= btSoftBody::fCollision::SDF_MDF; - /// turn on face contact for rigid body - rsb->m_cfg.collisions |= btSoftBody::fCollision::SDF_RDF; + // rsb->m_cfg.collisions |= btSoftBody::fCollision::SDF_MDF; // collion between deformable and deformable and self-collision - rsb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD; + // rsb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD; rsb->setCollisionFlags(0); rsb->setTotalMass(deformable.m_mass); rsb->setSelfCollision(useSelfCollision); @@ -9748,7 +9746,6 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl rsb->setCacheBarycenter(deformable.m_cache_barycenter); rsb->initializeFaceTree(); } - std::cout << "checkpoint 2\n"; #endif //SKIP_DEFORMABLE_BODY #ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD btSoftMultiBodyDynamicsWorld* softWorld = getSoftWorld(); @@ -9780,6 +9777,8 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl if (deformWorld) { deformWorld->addSoftBody(rsb); + deformWorld->getSolverInfo().m_deformable_erp = 0.2; + deformWorld->getSolverInfo().m_deformable_cfm = 0.2; } else #endif //SKIP_DEFORMABLE_BODY @@ -9790,7 +9789,6 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfDeformabl softWorld->addSoftBody(rsb); } } - std::cout << "get here!!!\n"; *bodyUniqueId = m_data->m_bodyHandles.allocHandle(); std::cout << "bodyUniqueId: " << *bodyUniqueId; diff --git a/examples/pybullet/examples/reduced_deformable_cube.py b/examples/pybullet/examples/reduced_deformable_cube.py new file mode 100644 index 000000000..218c5ccb7 --- /dev/null +++ b/examples/pybullet/examples/reduced_deformable_cube.py @@ -0,0 +1,29 @@ +import pybullet as p +from time import sleep +import pybullet_data + +physicsClient = p.connect(p.GUI) + +p.setAdditionalSearchPath(pybullet_data.getDataPath()) + +p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) +p.resetDebugVisualizerCamera(3,-420,-30,[0.3,0.9,-2]) +p.setGravity(0, 0, -10) + +tex = p.loadTexture("uvmap.png") +planeId = p.loadURDF("plane.urdf", [0,0,-2]) + +# boxId = p.loadURDF("cube.urdf", [0,3,2],useMaximalCoordinates = True) + +# bunnyId = p.loadSoftBody("torus/torus_textured.obj", simFileName="torus.vtk", mass = 3, useNeoHookean = 1, NeoHookeanMu = 180, NeoHookeanLambda = 600, NeoHookeanDamping = 0.01, collisionMargin = 0.006, useSelfCollision = 1, frictionCoeff = 0.5, repulsionStiffness = 800) +# p.changeVisualShape(bunnyId, -1, rgbaColor=[1,1,1,1], textureUniqueId=tex, flags=0) + +bunny2 = p.loadURDF("reduced_cube/reduced_cube.urdf", [0,1,0.5], flags=p.URDF_USE_SELF_COLLISION) +p.changeVisualShape(bunny2, -1, rgbaColor=[1,1,1,1], textureUniqueId=tex, flags=0) +p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) +p.setRealTimeSimulation(0) + +while p.isConnected(): + p.stepSimulation() + p.getCameraImage(320,200) + p.setGravity(0,0,-10) diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp index 1d295b656..1220c4cb4 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBody.cpp @@ -311,7 +311,6 @@ void btReducedSoftBody::mapToFullVelocity(const btTransform& ref_trans) // } // m_linearVelocityFromReduced = 1.0 / m_mass * (ref_trans.getBasis() * sum_linear); // m_angularVelocityFromReduced = m_interpolateInvInertiaTensorWorld * sum_angular; - // std::cout << "-----end here------\n"; // m_linearVelocity -= m_linearVelocityFromReduced; // m_angularVelocity -= m_angularVelocityFromReduced; diff --git a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp b/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp index a56ee212a..b851ee2af 100644 --- a/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp +++ b/src/BulletSoftBody/BulletReducedSoftBody/btReducedSoftBodySolver.cpp @@ -178,6 +178,9 @@ void btReducedSoftBodySolver::applyTransforms(btScalar timeStep) // end of time step clean up and update rsb->endOfTimeStepZeroing(); + + // update the rendering mesh + rsb->interpolateRenderMesh(); } // static int count = 0;