mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-06-08 08:13:55 +00:00
add mass scaling for reduced deformable model
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
<robot name="reduced_cube">
|
||||
<reduced_deformable name="reduced_cube">
|
||||
<num_modes value="20"/>
|
||||
<mass value="1"/>
|
||||
<mass value="10"/>
|
||||
<stiffness_scale value="100"/>
|
||||
<collision_margin value="0.01"/>
|
||||
<erp value= "0.2"/>
|
||||
<cfm value= "0.2"/>
|
||||
<friction value= "0.5"/>
|
||||
<damping_coefficient value="0.0001"/>
|
||||
<damping_coefficient value="0.0"/>
|
||||
<visual filename="cube_mesh.vtk"/>
|
||||
</reduced_deformable>
|
||||
</robot>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
// static btScalar E = 50;
|
||||
// static btScalar nu = 0.3;
|
||||
static btScalar damping_alpha = 0.0;
|
||||
static btScalar damping_beta = 0.001;
|
||||
static btScalar damping_beta = 0.0;
|
||||
static btScalar COLLIDING_VELOCITY = 4;
|
||||
static int start_mode = 6;
|
||||
static int num_modes = 20;
|
||||
@@ -75,11 +75,10 @@ public:
|
||||
|
||||
void Ctor_RbUpStack()
|
||||
{
|
||||
// float mass = 28;
|
||||
float mass = 8;
|
||||
float mass = 10;
|
||||
|
||||
// btCollisionShape* shape = new btBoxShape(btVector3(0.5, 0.5, 0.5));
|
||||
btCollisionShape* shape = new btBoxShape(btVector3(1, 1, 1));
|
||||
btCollisionShape* shape = new btBoxShape(btVector3(0.5, 0.5, 0.5));
|
||||
// btCollisionShape* shape = new btBoxShape(btVector3(1, 1, 1));
|
||||
btVector3 localInertia(0, 0, 0);
|
||||
if (mass != 0.f)
|
||||
shape->calculateLocalInertia(mass, localInertia);
|
||||
@@ -102,7 +101,7 @@ public:
|
||||
|
||||
void rigidBar()
|
||||
{
|
||||
float mass = 8;
|
||||
float mass = 10;
|
||||
|
||||
btCollisionShape* shape = new btBoxShape(btVector3(0.5, 0.25, 2));
|
||||
btVector3 localInertia(0, 0, 0);
|
||||
@@ -206,7 +205,7 @@ void ReducedCollide::initPhysics()
|
||||
|
||||
// create volumetric reduced deformable body
|
||||
{
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedBeam(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), start_mode, num_modes);
|
||||
|
||||
getDeformableDynamicsWorld()->addSoftBody(rsb);
|
||||
rsb->getCollisionShape()->setMargin(0.1);
|
||||
@@ -221,6 +220,8 @@ void ReducedCollide::initPhysics()
|
||||
rsb->setStiffnessScale(100);
|
||||
rsb->setDamping(damping_alpha, damping_beta);
|
||||
|
||||
rsb->setTotalMass(15);
|
||||
|
||||
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;
|
||||
|
||||
@@ -9525,6 +9525,8 @@ bool PhysicsServerCommandProcessor::processReducedDeformable(const UrdfReducedDe
|
||||
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);
|
||||
// set total mass
|
||||
rsb->setTotalMass(reduced_deformable.m_mass);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ p.setGravity(0, 0, -10)
|
||||
tex = p.loadTexture("uvmap.png")
|
||||
planeId = p.loadURDF("plane.urdf", [0,0,-2])
|
||||
|
||||
p.startStateLogging(p.STATE_LOGGING_VIDEO_MP4, "reduced_cube.mp4")
|
||||
# p.startStateLogging(p.STATE_LOGGING_VIDEO_MP4, "reduced_cube.mp4")
|
||||
cube = p.loadURDF("reduced_cube/reduced_cube.urdf", [1,1,1])
|
||||
p.changeVisualShape(cube, -1, rgbaColor=[1,1,1,1], textureUniqueId=tex, flags=0)
|
||||
p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25)
|
||||
|
||||
@@ -463,7 +463,26 @@ void btReducedSoftBody::scale(const btVector3& scl)
|
||||
|
||||
void btReducedSoftBody::setTotalMass(btScalar mass, bool fromfaces)
|
||||
{
|
||||
//
|
||||
btScalar scale_ratio = mass / m_mass;
|
||||
|
||||
// update nodal mass
|
||||
for (int i = 0; i < m_nFull; ++i)
|
||||
{
|
||||
m_nodalMass[i] *= scale_ratio;
|
||||
}
|
||||
m_mass = mass;
|
||||
m_inverseMass = mass > 0 ? 1.0 / mass : 0;
|
||||
|
||||
// update inertia tensors
|
||||
updateLocalInertiaTensorFromNodes();
|
||||
|
||||
btMatrix3x3 id;
|
||||
id.setIdentity();
|
||||
updateInitialInertiaTensor(id); // there is no rotation, but the local inertia tensor has changed
|
||||
updateInertiaTensor();
|
||||
m_interpolateInvInertiaTensorWorld = m_invInertiaTensorWorld;
|
||||
|
||||
internalInitialization();
|
||||
}
|
||||
|
||||
void btReducedSoftBody::updateRestNodalPositions()
|
||||
|
||||
Reference in New Issue
Block a user