mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-06-08 00:03:53 +00:00
no longer need to use start_modes, because all the rigid modes are not saved in .bin files in the preprocessor
This commit is contained in:
@@ -248,7 +248,6 @@ struct UrdfDeformable
|
||||
struct UrdfReducedDeformable
|
||||
{
|
||||
std::string m_name;
|
||||
int m_startMode;
|
||||
int m_numModes;
|
||||
|
||||
double m_mass;
|
||||
@@ -264,8 +263,7 @@ struct UrdfReducedDeformable
|
||||
btHashMap<btHashString, std::string> m_userData;
|
||||
|
||||
UrdfReducedDeformable()
|
||||
: m_startMode(6), // for most of cases, the first 6 modes (rigid modes) are ignored
|
||||
m_numModes(1),
|
||||
: m_numModes(1),
|
||||
m_erp(0.2), // generally, 0.2 is a good value for erp and cfm
|
||||
m_cfm(0.2),
|
||||
m_friction(0),
|
||||
|
||||
@@ -216,7 +216,7 @@ void ConservationTest::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.1);
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.00001;
|
||||
static btScalar COLLIDING_VELOCITY = 0;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class FreeFall : public CommonDeformableBodyBase
|
||||
@@ -109,10 +108,10 @@ public:
|
||||
// {
|
||||
// deformableWorld->getDebugDrawer()->drawSphere(rsb->m_nodes[rsb->m_fixedNodes[p]].m_x, 0.2, btVector3(1, 0, 0));
|
||||
// }
|
||||
for (int p = 0; p < rsb->m_nodeRigidContacts.size(); ++p)
|
||||
{
|
||||
deformableWorld->getDebugDrawer()->drawSphere(rsb->m_nodes[rsb->m_contactNodesList[p]].m_x, 0.2, btVector3(0, 1, 0));
|
||||
}
|
||||
// for (int p = 0; p < rsb->m_nodeRigidContacts.size(); ++p)
|
||||
// {
|
||||
// deformableWorld->getDebugDrawer()->drawSphere(rsb->m_nodes[rsb->m_contactNodesList[p]].m_x, 0.2, btVector3(0, 1, 0));
|
||||
// }
|
||||
|
||||
// deformableWorld->getDebugDrawer()->drawSphere(btVector3(0, 0, 0), 0.1, btVector3(1, 1, 1));
|
||||
// deformableWorld->getDebugDrawer()->drawSphere(btVector3(0, 5, 0), 0.1, btVector3(1, 1, 1));
|
||||
@@ -147,7 +146,7 @@ void FreeFall::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.01);
|
||||
@@ -162,6 +161,8 @@ void FreeFall::initPhysics()
|
||||
rsb->setStiffnessScale(100);
|
||||
rsb->setDamping(damping_alpha, damping_beta);
|
||||
|
||||
rsb->setTotalMass(10);
|
||||
|
||||
rsb->m_cfg.kKHR = 1; // collision hardness with kinematic objects
|
||||
rsb->m_cfg.kCHR = 1; // collision hardness with rigid body
|
||||
rsb->m_cfg.kDF = 0;
|
||||
@@ -175,7 +176,7 @@ void FreeFall::initPhysics()
|
||||
// rsb->setRigidAngularVelocity(btVector3(1, 0, 0));
|
||||
}
|
||||
// add a few rigid bodies
|
||||
Ctor_RbUpStack();
|
||||
// Ctor_RbUpStack();
|
||||
// create a static rigid box as the ground
|
||||
{
|
||||
// btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50), btScalar(50), btScalar(50)));
|
||||
@@ -264,7 +265,7 @@ void FreeFall::initPhysics()
|
||||
getDeformableDynamicsWorld()->setUseProjection(false);
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_deformable_erp = 0.2;
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_deformable_cfm = 0.2;
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_friction = 1;
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_friction = 0.5;
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_deformable_maxErrorReduction = btScalar(200);
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_leastSquaresResidualThreshold = 1e-6;
|
||||
getDeformableDynamicsWorld()->getSolverInfo().m_splitImpulse = false;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.001;
|
||||
static btScalar COLLIDING_VELOCITY = 0;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class FrictionSlope : public CommonDeformableBodyBase
|
||||
@@ -188,7 +187,7 @@ void FrictionSlope::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.01);
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "../Utils/b3ResourcePath.h"
|
||||
|
||||
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
static btScalar visualize_mode = 0;
|
||||
static btScalar frequency_scale = 1;
|
||||
@@ -136,7 +135,7 @@ void ModeVisualizer::initPhysics()
|
||||
|
||||
// create volumetric soft body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.1);
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.0;
|
||||
static btScalar COLLIDING_VELOCITY = 4;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class ReducedCollide : public CommonDeformableBodyBase
|
||||
@@ -205,7 +204,7 @@ void ReducedCollide::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.1);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
// static btScalar nu = 0.3;
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.0001;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class ReducedGrasp : public CommonDeformableBodyBase
|
||||
@@ -279,7 +278,7 @@ void ReducedGrasp::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.015);
|
||||
|
||||
@@ -40,7 +40,6 @@ static btScalar sGripperVerticalVelocity = 0.f;
|
||||
static btScalar sGripperClosingTargetVelocity = 0.f;
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.0001;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
static float friction = 1.;
|
||||
struct TetraCube
|
||||
@@ -317,7 +316,7 @@ void ReducedMotorGrasp::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.01);
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
///The BasicTest shows the contact between volumetric deformable objects and rigid objects.
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.0;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class ReducedPress : public CommonDeformableBodyBase
|
||||
@@ -189,7 +188,7 @@ void ReducedPress::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.015);
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.0001;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
|
||||
class Springboard : public CommonDeformableBodyBase
|
||||
@@ -142,7 +141,7 @@ void Springboard::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.1);
|
||||
|
||||
@@ -9521,7 +9521,7 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfReducedDe
|
||||
}
|
||||
|
||||
// load modes, reduced stiffness matrix
|
||||
rsb->setReducedModes(reduced_deformable.m_startMode, reduced_deformable.m_numModes, rsb->m_nodes.size());
|
||||
rsb->setReducedModes(reduced_deformable.m_numModes, rsb->m_nodes.size());
|
||||
rsb->setStiffnessScale(reduced_deformable.m_stiffnessScale);
|
||||
rsb->setDamping(0, reduced_deformable.m_damping); // damping alpha is set to 0 by default
|
||||
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, pathPrefix);
|
||||
|
||||
@@ -12,7 +12,6 @@ btReducedSoftBody::btReducedSoftBody(btSoftBodyWorldInfo* worldInfo, int node_co
|
||||
|
||||
// reduced deformable
|
||||
m_reducedModel = true;
|
||||
m_startMode = 0;
|
||||
m_nReduced = 0;
|
||||
m_nFull = 0;
|
||||
|
||||
@@ -43,9 +42,8 @@ btReducedSoftBody::btReducedSoftBody(btSoftBodyWorldInfo* worldInfo, int node_co
|
||||
m_rigidTransformWorld.setIdentity();
|
||||
}
|
||||
|
||||
void btReducedSoftBody::setReducedModes(int start_mode, int num_modes, int full_size)
|
||||
void btReducedSoftBody::setReducedModes(int num_modes, int full_size)
|
||||
{
|
||||
m_startMode = start_mode;
|
||||
m_nReduced = num_modes;
|
||||
m_nFull = full_size;
|
||||
m_reducedDofs.resize(m_nReduced, 0);
|
||||
|
||||
@@ -71,7 +71,6 @@ class btReducedSoftBody : public btSoftBody
|
||||
//
|
||||
|
||||
// reduced space
|
||||
int m_startMode;
|
||||
int m_nReduced;
|
||||
int m_nFull;
|
||||
tDenseMatrix m_modes; // modes of the reduced deformable model. Each inner array is a mode, outer array size = n_modes
|
||||
@@ -105,7 +104,7 @@ class btReducedSoftBody : public btSoftBody
|
||||
//
|
||||
void internalInitialization();
|
||||
|
||||
void setReducedModes(int start_mode, int num_modes, int full_size);
|
||||
void setReducedModes(int num_modes, int full_size);
|
||||
|
||||
void setMassProps(const tDenseArray& mass_array);
|
||||
|
||||
|
||||
@@ -4,39 +4,39 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes)
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes)
|
||||
{
|
||||
std::string filepath("../../../examples/SoftDemo/beam/");
|
||||
std::string filename = filepath + "mesh.vtk";
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
|
||||
|
||||
rsb->setReducedModes(start_mode, num_modes, rsb->m_nodes.size());
|
||||
rsb->setReducedModes(num_modes, rsb->m_nodes.size());
|
||||
btVector3 half_extents(0.5, 0.25, 2);
|
||||
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str(), half_extents);
|
||||
|
||||
return rsb;
|
||||
}
|
||||
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedCube(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes)
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes)
|
||||
{
|
||||
std::string filepath("../../../examples/SoftDemo/cube/");
|
||||
std::string filename = filepath + "mesh.vtk";
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
|
||||
|
||||
rsb->setReducedModes(start_mode, num_modes, rsb->m_nodes.size());
|
||||
rsb->setReducedModes(num_modes, rsb->m_nodes.size());
|
||||
btVector3 half_extents(0.5, 0.5, 0.5);
|
||||
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str(), half_extents);
|
||||
|
||||
return rsb;
|
||||
}
|
||||
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedSponge(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes)
|
||||
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedSponge(btSoftBodyWorldInfo& worldInfo, const int num_modes)
|
||||
{
|
||||
std::string filepath("../../../examples/SoftDemo/sponge/");
|
||||
std::string filename = filepath + "mesh.vtk";
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
|
||||
|
||||
rsb->setReducedModes(start_mode, num_modes, rsb->m_nodes.size());
|
||||
rsb->setReducedModes(num_modes, rsb->m_nodes.size());
|
||||
btVector3 half_extents(0.025, 0.025, 0.025); //TODO: fix
|
||||
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str(), half_extents);
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
struct btReducedSoftBodyHelpers
|
||||
{
|
||||
// create a beam
|
||||
static btReducedSoftBody* createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes);
|
||||
static btReducedSoftBody* createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes);
|
||||
// create a cube
|
||||
static btReducedSoftBody* createReducedCube(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes);
|
||||
static btReducedSoftBody* createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes);
|
||||
// create a sponge (small rectangular cuboid)
|
||||
static btReducedSoftBody* createReducedSponge(btSoftBodyWorldInfo& worldInfo, const int start_mode, const int num_modes);
|
||||
static btReducedSoftBody* createReducedSponge(btSoftBodyWorldInfo& worldInfo, const int num_modes);
|
||||
|
||||
// read in geometry info from Vtk file
|
||||
static btReducedSoftBody* createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file);
|
||||
|
||||
Reference in New Issue
Block a user