From 36a2f306f638d6935bf53201c72214f75541330a Mon Sep 17 00:00:00 2001 From: Chuyuan Fu Date: Thu, 31 Oct 2019 14:31:51 -0700 Subject: [PATCH 1/5] update example to use absolute path --- examples/DeformableDemo/GraspDeformable.cpp | 40 +++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/DeformableDemo/GraspDeformable.cpp b/examples/DeformableDemo/GraspDeformable.cpp index ddb47954b..d96394435 100644 --- a/examples/DeformableDemo/GraspDeformable.cpp +++ b/examples/DeformableDemo/GraspDeformable.cpp @@ -28,6 +28,7 @@ #include "../Importers/ImportURDFDemo/BulletUrdfImporter.h" #include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h" #include "../Importers/ImportURDFDemo/URDF2Bullet.h" +#include "../Utils/b3BulletDefaultFileIO.h" #include "../CommonInterfaces/CommonMultiBodyBase.h" #include "../CommonInterfaces/CommonGraphicsAppInterface.h" #include "../CommonInterfaces/CommonParameterInterface.h" @@ -270,25 +271,26 @@ void GraspDeformable::initPhysics() } // create a soft block - if(1) - { - char relative_path[1024]; -// b3FileUtils::findFile("banana.vtk", relative_path, 1024); -// b3FileUtils::findFile("ball.vtk", relative_path, 1024); -// b3FileUtils::findFile("deformable_crumpled_napkin_sim.vtk", relative_path, 1024); -// b3FileUtils::findFile("single_tet.vtk", relative_path, 1024); -// b3FileUtils::findFile("tube.vtk", relative_path, 1024); -// b3FileUtils::findFile("torus.vtk", relative_path, 1024); -// b3FileUtils::findFile("paper_roll.vtk", relative_path, 1024); -// b3FileUtils::findFile("bread.vtk", relative_path, 1024); - b3FileUtils::findFile("ditto.vtk", relative_path, 1024); -// b3FileUtils::findFile("boot.vtk", relative_path, 1024); -// btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(), -// TetraCube::getElements(), -// 0, -// TetraCube::getNodes(), -// false, true, true); - btSoftBody* psb = btSoftBodyHelpers::CreateFromVtkFile(getDeformableDynamicsWorld()->getWorldInfo(), relative_path); + if (1) + { + // b3FileUtils::findFile("banana.vtk", relative_path, 1024); + // b3FileUtils::findFile("ball.vtk", relative_path, 1024); + // b3FileUtils::findFile("deformable_crumpled_napkin_sim.vtk", relative_path, 1024); + // b3FileUtils::findFile("single_tet.vtk", relative_path, 1024); + // b3FileUtils::findFile("tube.vtk", relative_path, 1024); + // b3FileUtils::findFile("torus.vtk", relative_path, 1024); + // b3FileUtils::findFile("paper_roll.vtk", relative_path, 1024); + // b3FileUtils::findFile("bread.vtk", relative_path, 1024); + char absolute_path[1024]; + b3BulletDefaultFileIO fileio; + fileio.findResourcePath("ditto.vtk", absolute_path, 1024); + // b3FileUtils::findFile("boot.vtk", relative_path, 1024); + // btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(), + // TetraCube::getElements(), + // 0, + // TetraCube::getNodes(), + // false, true, true); + btSoftBody* psb = btSoftBodyHelpers::CreateFromVtkFile(getDeformableDynamicsWorld()->getWorldInfo(), absolute_path); // psb->scale(btVector3(30, 30, 30)); // for banana psb->scale(btVector3(.7, .7, .7)); From 7f310e6124b1152cc3e3e6e7b3350df9e4b50eb1 Mon Sep 17 00:00:00 2001 From: Chuyuan Fu Date: Thu, 31 Oct 2019 15:07:10 -0700 Subject: [PATCH 2/5] make consistent for other models --- examples/DeformableDemo/GraspDeformable.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/DeformableDemo/GraspDeformable.cpp b/examples/DeformableDemo/GraspDeformable.cpp index d96394435..a1952169d 100644 --- a/examples/DeformableDemo/GraspDeformable.cpp +++ b/examples/DeformableDemo/GraspDeformable.cpp @@ -273,18 +273,18 @@ void GraspDeformable::initPhysics() // create a soft block if (1) { - // b3FileUtils::findFile("banana.vtk", relative_path, 1024); - // b3FileUtils::findFile("ball.vtk", relative_path, 1024); - // b3FileUtils::findFile("deformable_crumpled_napkin_sim.vtk", relative_path, 1024); - // b3FileUtils::findFile("single_tet.vtk", relative_path, 1024); - // b3FileUtils::findFile("tube.vtk", relative_path, 1024); - // b3FileUtils::findFile("torus.vtk", relative_path, 1024); - // b3FileUtils::findFile("paper_roll.vtk", relative_path, 1024); - // b3FileUtils::findFile("bread.vtk", relative_path, 1024); char absolute_path[1024]; b3BulletDefaultFileIO fileio; fileio.findResourcePath("ditto.vtk", absolute_path, 1024); - // b3FileUtils::findFile("boot.vtk", relative_path, 1024); + // fileio.findResourcePath("banana.vtk", absolute_path, 1024); + // fileio.findResourcePath("ball.vtk", absolute_path, 1024); + // fileio.findResourcePath("deformable_crumpled_napkin_sim.vtk", absolute_path, 1024); + // fileio.findResourcePath("single_tet.vtk", absolute_path, 1024); + // fileio.findResourcePath("tube.vtk", absolute_path, 1024); + // fileio.findResourcePath("torus.vtk", absolute_path, 1024); + // fileio.findResourcePath("paper_roll.vtk", absolute_path, 1024); + // fileio.findResourcePath("bread.vtk", absolute_path, 1024); + // fileio.findResourcePath("boot.vtk", absolute_path, 1024); // btSoftBody* psb = btSoftBodyHelpers::CreateFromTetGenData(getDeformableDynamicsWorld()->getWorldInfo(), // TetraCube::getElements(), // 0, From 1bd0eee0fff3b30586d032973cfc58a77ecb0fe8 Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Sun, 3 Nov 2019 12:44:45 -0800 Subject: [PATCH 3/5] fix indexing bug in deformable sleeping --- src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp | 1 + src/BulletSoftBody/btDeformableBodySolver.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp index fee353a60..1b247641a 100644 --- a/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp +++ b/src/BulletSoftBody/btDeformableBackwardEulerObjective.cpp @@ -103,6 +103,7 @@ void btDeformableBackwardEulerObjective::applyForce(TVStack& force, bool setZero btSoftBody* psb = m_softBodies[i]; if (!psb->isActive()) { + counter += psb->m_nodes.size(); continue; } for (int j = 0; j < psb->m_nodes.size(); ++j) diff --git a/src/BulletSoftBody/btDeformableBodySolver.cpp b/src/BulletSoftBody/btDeformableBodySolver.cpp index 9af8e3f77..0fb18080f 100644 --- a/src/BulletSoftBody/btDeformableBodySolver.cpp +++ b/src/BulletSoftBody/btDeformableBodySolver.cpp @@ -251,6 +251,7 @@ void btDeformableBodySolver::updateVelocity() psb->m_maxSpeedSquared = 0; if (!psb->isActive()) { + counter += psb->m_nodes.size(); continue; } for (int j = 0; j < psb->m_nodes.size(); ++j) @@ -275,6 +276,7 @@ void btDeformableBodySolver::updateTempPosition() btSoftBody* psb = m_softBodies[i]; if (!psb->isActive()) { + counter += psb->m_nodes.size(); continue; } for (int j = 0; j < psb->m_nodes.size(); ++j) @@ -307,6 +309,7 @@ void btDeformableBodySolver::setupDeformableSolve(bool implicit) btSoftBody* psb = m_softBodies[i]; if (!psb->isActive()) { + counter += psb->m_nodes.size(); continue; } for (int j = 0; j < psb->m_nodes.size(); ++j) From 4347c03459888f192bb72ce9d642cdf0750ec74e Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Sun, 3 Nov 2019 12:47:08 -0800 Subject: [PATCH 4/5] turn on SVD and use fewer CG iterations --- src/BulletSoftBody/btDeformableBodySolver.cpp | 2 +- src/BulletSoftBody/btDeformableNeoHookeanForce.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BulletSoftBody/btDeformableBodySolver.cpp b/src/BulletSoftBody/btDeformableBodySolver.cpp index 0fb18080f..7b4c06303 100644 --- a/src/BulletSoftBody/btDeformableBodySolver.cpp +++ b/src/BulletSoftBody/btDeformableBodySolver.cpp @@ -18,7 +18,7 @@ #include "btDeformableBodySolver.h" #include "btSoftBodyInternals.h" #include "LinearMath/btQuickprof.h" -static const int kMaxConjugateGradientIterations = 200; +static const int kMaxConjugateGradientIterations = 50; btDeformableBodySolver::btDeformableBodySolver() : m_numNodes(0) , m_cg(kMaxConjugateGradientIterations) diff --git a/src/BulletSoftBody/btDeformableNeoHookeanForce.h b/src/BulletSoftBody/btDeformableNeoHookeanForce.h index f607b8662..d9bb3be61 100644 --- a/src/BulletSoftBody/btDeformableNeoHookeanForce.h +++ b/src/BulletSoftBody/btDeformableNeoHookeanForce.h @@ -175,7 +175,8 @@ public: btSoftBody::Tetra& tetra = psb->m_tetras[j]; btMatrix3x3 P; firstPiola(psb->m_tetraScratches[j],P); -#if USE_SVD +#define USE_SVD 1 +#ifdef USE_SVD if (max_p > 0) { // since we want to clamp the principal stress to max_p, we only need to From 9068b7ed912c45e48a877b14a7161de7f93a5563 Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Tue, 5 Nov 2019 18:16:13 -0800 Subject: [PATCH 5/5] turn off SVD --- src/BulletSoftBody/btDeformableNeoHookeanForce.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BulletSoftBody/btDeformableNeoHookeanForce.h b/src/BulletSoftBody/btDeformableNeoHookeanForce.h index d9bb3be61..3d06e304d 100644 --- a/src/BulletSoftBody/btDeformableNeoHookeanForce.h +++ b/src/BulletSoftBody/btDeformableNeoHookeanForce.h @@ -175,7 +175,6 @@ public: btSoftBody::Tetra& tetra = psb->m_tetras[j]; btMatrix3x3 P; firstPiola(psb->m_tetraScratches[j],P); -#define USE_SVD 1 #ifdef USE_SVD if (max_p > 0) {