add reduced deformable torus. minor clean up in btReducedSoftBodyHelpers

This commit is contained in:
jingyuc 2021-11-17 01:09:18 -05:00
parent 8c118515b8
commit 0279a5a500
11 changed files with 9960 additions and 80 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<robot name="reduced_cube">
<reduced_deformable name="reduced_cube">
<num_modes value="20"/>
<mass value="10"/>
<stiffness_scale value="10"/>
<collision_margin value="0.01"/>
<erp value= "0.2"/>
<cfm value= "0.2"/>
<friction value= "0.5"/>
<damping_coefficient value="0.00001"/>
<visual filename="torus_mesh.vtk"/>
</reduced_deformable>
</robot>

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,7 @@
// static btScalar E = 50;
// static btScalar nu = 0.3;
static btScalar damping_alpha = 0.0;
static btScalar damping_beta = 0.00001;
static btScalar damping_beta = 0.0001;
static btScalar COLLIDING_VELOCITY = 0;
static int num_modes = 20;
@ -55,8 +55,8 @@ public:
void resetCamera()
{
float dist = 10;
float pitch = -20;
float dist = 6;
float pitch = -10;
float yaw = 90;
float targetPos[3] = {0, 2, 0};
// float dist = 20;
@ -77,7 +77,7 @@ public:
// btRigidBody* rb0 = createRigidBody(mass, startTransform, shape);
// rb0->setLinearVelocity(btVector3(0, 0, 0));
startTransform.setOrigin(btVector3(0,4,0));
startTransform.setOrigin(btVector3(0,10,0));
// startTransform.setRotation(btQuaternion(btVector3(1, 0, 1), SIMD_PI / 4.0));
btRigidBody* rb1 = createRigidBody(mass, startTransform, shape);
rb1->setActivationState(DISABLE_DEACTIVATION);
@ -146,7 +146,7 @@ void FreeFall::initPhysics()
// create volumetric reduced deformable body
{
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedCube(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createReducedTorus(getDeformableDynamicsWorld()->getWorldInfo(), num_modes);
getDeformableDynamicsWorld()->addSoftBody(rsb);
rsb->getCollisionShape()->setMargin(0.01);
@ -154,11 +154,11 @@ void FreeFall::initPhysics()
btTransform init_transform;
init_transform.setIdentity();
init_transform.setOrigin(btVector3(0, 10, 0));
// init_transform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI / 6.0));
init_transform.setOrigin(btVector3(0, 4, 0));
init_transform.setRotation(btQuaternion(SIMD_PI / 2.0, SIMD_PI / 2.0, 0));
rsb->transformTo(init_transform);
rsb->setStiffnessScale(100);
rsb->setStiffnessScale(5);
rsb->setDamping(damping_alpha, damping_beta);
rsb->setTotalMass(10);
@ -176,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)));
@ -195,70 +195,6 @@ void FreeFall::initPhysics()
createRigidBody(mass, groundTransform, groundShape, btVector4(0,0,0,0));
}
}
// {
// // btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50), btScalar(50), btScalar(50)));
// btBoxShape* groundShape = createBoxShape(btVector3(btScalar(2), btScalar(0.5), btScalar(1)));
// m_collisionShapes.push_back(groundShape);
// btTransform groundTransform;
// groundTransform.setIdentity();
// // groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI / 6.0));
// groundTransform.setOrigin(btVector3(0, 2, 3.1));
// // groundTransform.setOrigin(btVector3(0, 0, 6));
// // groundTransform.setOrigin(btVector3(0, -50, 0));
// {
// btScalar mass(0.);
// createRigidBody(mass, groundTransform, groundShape, btVector4(0,0,0,0));
// }
// }
// {
// // btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50), btScalar(50), btScalar(50)));
// btBoxShape* groundShape = createBoxShape(btVector3(btScalar(2), btScalar(0.5), btScalar(1)));
// m_collisionShapes.push_back(groundShape);
// btTransform groundTransform;
// groundTransform.setIdentity();
// // groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI / 6.0));
// groundTransform.setOrigin(btVector3(0, 2, -3.1));
// // groundTransform.setOrigin(btVector3(0, 0, 6));
// // groundTransform.setOrigin(btVector3(0, -50, 0));
// {
// btScalar mass(0.);
// createRigidBody(mass, groundTransform, groundShape, btVector4(0,0,0,0));
// }
// }
// {
// // btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50), btScalar(50), btScalar(50)));
// btBoxShape* groundShape = createBoxShape(btVector3(btScalar(1), btScalar(0.5), btScalar(2)));
// m_collisionShapes.push_back(groundShape);
// btTransform groundTransform;
// groundTransform.setIdentity();
// // groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI / 6.0));
// groundTransform.setOrigin(btVector3(2, 2, 0));
// // groundTransform.setOrigin(btVector3(0, 0, 6));
// // groundTransform.setOrigin(btVector3(0, -50, 0));
// {
// btScalar mass(0.);
// createRigidBody(mass, groundTransform, groundShape, btVector4(0,0,0,0));
// }
// }
// {
// // btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50), btScalar(50), btScalar(50)));
// btBoxShape* groundShape = createBoxShape(btVector3(btScalar(1), btScalar(0.5), btScalar(2)));
// m_collisionShapes.push_back(groundShape);
// btTransform groundTransform;
// groundTransform.setIdentity();
// // groundTransform.setRotation(btQuaternion(btVector3(1, 0, 0), SIMD_PI / 6.0));
// groundTransform.setOrigin(btVector3(-2, 2, 0));
// // groundTransform.setOrigin(btVector3(0, 0, 6));
// // groundTransform.setOrigin(btVector3(0, -50, 0));
// {
// btScalar mass(0.);
// createRigidBody(mass, groundTransform, groundShape, btVector4(0,0,0,0));
// }
// }
getDeformableDynamicsWorld()->setImplicit(false);
getDeformableDynamicsWorld()->setLineSearch(false);

View File

@ -54,7 +54,8 @@ int main(int argc, char* argv[])
sim->loadURDF("plane.urdf");
{
int deformableUID = sim->loadURDF("reduced_cube/reduced_cube.urdf");
// int deformableUID = sim->loadURDF("reduced_cube/reduced_cube.urdf");
int deformableUID = sim->loadURDF("reduced_torus/reduced_torus.urdf");
// int deformableUID = sim->loadURDF("torus_deform.urdf");
btVector3 basePosition = btVector3(0, 0, 2);
btQuaternion baseOrientation = btQuaternion(0, 0, 0, 1);

View File

@ -11,8 +11,7 @@ btReducedSoftBody* btReducedSoftBodyHelpers::createReducedBeam(btSoftBodyWorldIn
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
rsb->setReducedModes(num_modes, rsb->m_nodes.size());
btVector3 half_extents(0.5, 0.25, 2);
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str(), half_extents);
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str());
return rsb;
}
@ -24,8 +23,19 @@ btReducedSoftBody* btReducedSoftBodyHelpers::createReducedCube(btSoftBodyWorldIn
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
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);
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str());
return rsb;
}
btReducedSoftBody* btReducedSoftBodyHelpers::createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes)
{
std::string filepath("../../../data/reduced_torus/");
std::string filename = filepath + "torus_mesh.vtk";
btReducedSoftBody* rsb = btReducedSoftBodyHelpers::createFromVtkFile(worldInfo, filename.c_str());
rsb->setReducedModes(num_modes, rsb->m_nodes.size());
btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(rsb, filepath.c_str());
return rsb;
}
@ -138,7 +148,7 @@ btReducedSoftBody* btReducedSoftBodyHelpers::createFromVtkFile(btSoftBodyWorldIn
return rsb;
}
void btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path, const btVector3& half_extents)
void btReducedSoftBodyHelpers::readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path)
{
// read in eigenmodes, stiffness and mass matrices
std::string eigenvalues_file = std::string(file_path) + "eigenvalues.bin";

View File

@ -9,11 +9,13 @@ struct btReducedSoftBodyHelpers
static btReducedSoftBody* createReducedBeam(btSoftBodyWorldInfo& worldInfo, const int num_modes);
// create a cube
static btReducedSoftBody* createReducedCube(btSoftBodyWorldInfo& worldInfo, const int num_modes);
// create a torus
static btReducedSoftBody* createReducedTorus(btSoftBodyWorldInfo& worldInfo, const int num_modes);
// read in geometry info from Vtk file
static btReducedSoftBody* createFromVtkFile(btSoftBodyWorldInfo& worldInfo, const char* vtk_file);
// read in all reduced files
static void readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path, const btVector3& half_extents = btVector3(0, 0, 0));
static void readReducedDeformableInfoFromFiles(btReducedSoftBody* rsb, const char* file_path);
// read in a binary vector
static void readBinaryVec(btReducedSoftBody::tDenseArray& vec, const unsigned int n_size, const char* file);
// read in a binary matrix