mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-12 12:50:08 +00:00
add reduced deformable torus. minor clean up in btReducedSoftBodyHelpers
This commit is contained in:
parent
8c118515b8
commit
0279a5a500
BIN
data/reduced_torus/K_r_diag_mat.bin
Normal file
BIN
data/reduced_torus/K_r_diag_mat.bin
Normal file
Binary file not shown.
BIN
data/reduced_torus/M_diag_mat.bin
Normal file
BIN
data/reduced_torus/M_diag_mat.bin
Normal file
Binary file not shown.
BIN
data/reduced_torus/M_r_diag_mat.bin
Normal file
BIN
data/reduced_torus/M_r_diag_mat.bin
Normal file
Binary file not shown.
BIN
data/reduced_torus/eigenvalues.bin
Normal file
BIN
data/reduced_torus/eigenvalues.bin
Normal file
Binary file not shown.
BIN
data/reduced_torus/modes.bin
Normal file
BIN
data/reduced_torus/modes.bin
Normal file
Binary file not shown.
14
data/reduced_torus/reduced_torus.urdf
Normal file
14
data/reduced_torus/reduced_torus.urdf
Normal 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>
|
9917
data/reduced_torus/torus_mesh.vtk
Normal file
9917
data/reduced_torus/torus_mesh.vtk
Normal file
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user