1 # Rigid Body Dynamics (RBD)
3 iMSTK provides its own implementation of a rigid body model. However, this has been replaced with our PBD model which now does all rigid bodies, soft bodies/deformables, and fluids.
5 > **Note:** The `RigidBodyModel2` is being deprecated, it is no longer supported by us and will most likely be removed in the next release. Use PBD Rigids instead.
7 The `RigidBodyModel2` in iMSTK is a linear constraint based system. It is solved with projceted-gauss-seidel (PGS). The constraints are polymorphic meaning it is easy to extend. This system solves for impulses/instant changes in velocities to separate bodies in contact.
11 Rigid body simulations in iMSTK mostly find their use with tools.
14 <img src="../media/rbd1.gif"/>
19 Unlike PBD, FEM, SPH the RigidBodyModel & RigidBodyModel2 deal with multiple differing geometries in the same model for implicit solves. RigidBodyModel2 can be configured like so:
22 // This model is shared among interacting rigid bodies
23 auto rbdModel = std::make_shared<RigidBodyModel2>();
24 rbdModel->getConfig()->m_gravity = Vec3d(0.0, -2500.0, 0.0);
25 rbdModel->getConfig()->m_maxNumIterations = 10;
27 std::shared_ptr<RigidBody> body1 = rbdModel->getRigidBody();
28 body1->m_mass = 100.0;
29 body1->m_initPos = Vec3d(0.0, 8.0, 0.0);
30 body1->m_initOrientation = Quatd(Rotd(0.4, Vec3d(1.0, 0.0, 0.0)));
31 body1->m_inertiaTensor = Mat3d::Identity();
33 std::shared_ptr<RigidBody> body2 = rbdModel->getRigidBody();
38 However, if using a RigidObject2 in the scene it will create its RigidBody, usage then looks like the following:
41 // This model is shared among interacting rigid bodies
42 imstkNew<RigidBodyModel2> rbdModel;
43 auto rbdModel = std::make_shared<RigidBodyModel2>();
44 rbdModel->getConfig()->m_gravity = Vec3d(0.0, -2500.0, 0.0);
45 rbdModel->getConfig()->m_maxNumIterations = 10;
47 // Object setup for the scene
48 auto cubeObj = std::make_shared<RigidObject2>();
49 cubeObj->setDynamicalModel(rbdModel);
50 cubeObj->setPhysicsGeometry(subdivide->getOutputMesh());
51 cubeObj->setCollidingGeometry(subdivide->getOutputMesh());
52 cubeObj->addVisualModel(visualModel);
54 // We can deal with the rigid body properties like so
55 cubeObj->getRigidBody()->m_mass = 100.0;
56 cubeObj->getRigidBody()->m_initPos = Vec3d(0.0, 8.0, 0.0);
57 cubeObj->getRigidBody()->m_initOrientation = Quatd(Rotd(0.4, Vec3d(1.0, 0.0, 0.0)));
58 cubeObj->getRigidBody()->m_intertiaTensor = Mat3d::Identity();