Rigid Bodies

ChBody is the base class for all the rigid bodies in Chrono and, as such, it carries a mass and a rotational inertia and has the capability to move in the 3D space.

Its location and rotation, as well as their derivatives, always refer to the Center of Mass (COM) while visual and collision shapes, on the contrary, are attached to a secondary reference frame (Ref).
Please mind that in ChBody base class the COM and Ref always coincide, while only in ChBodyAuxRef and derived classes the Ref frame might be placed elsewhere.

Methods like GetPos() / SetPos(), GetRot() / SetRot() and their derivatives always refer to COM frame.
The auxiliary frame is handled through dedicated methods of the kind [Get|Set]FrameRefTo____ | [Get|Set]Frame____ToRef wherever it makes sense.

Rigid bodies can also:

  • be involved in collisions, if a collision model is provided (see collisions) and the collision is enabled on the body;
  • be visualized, if a visual model is provided and a proper visualization system is available (see visualization);
  • be constrained by means of ChLink objects (see links);
  • be loaded by ChLoad objects (see loads);
  • be used in coordinate transformation, being themselves inherited from ChFrameMoving;

ChBody and ChBodyAuxRef bodies do not come with any visual or collision model, thus requiring the user to specify them as well as providing valid mass and inertia parameters.
However, in the case the rigid body could be described through a primitive shape, a set classes of the type ChBodyEasy can simplify this task, by calculating mass, inertia and by optionally creating a visual and collision shape:

Rigid bodies are not the only option. Chrono can simulate also flexible finite-elements bodies. Please refer to FEA manual for a description of the FEA capabilities.

Usage

Creating/Setting up a ChBody object typically involves the following steps:

  1. Create the rigid body;
    auto mybody = chrono_types::make_shared<ChBody>();
    mybody->SetMass(10);
    mybody->SetInertiaXX( ChVector3d(4,4,4) );
    mybody->SetPos( ChVector3d(0.2,0.4,2) );
    mybody->SetPosDt( ChVector3d(0.1,0,0) );
    my_system.Add(mybody);
  2. Optional: add visual shapes
    auto visshape = chrono_types::make_shared<ChVisualShapeBox>(20, 1, 20);
    visshape->SetColor(ChColor(0.2f, 0.3f, 1.0f));
    mybody->AddVisualShape(visshape, ChFramed(ChVector3d(0, -1, 0), QUNIT));
  3. Optional: add collision shapes and material
    auto collmat = chrono_types::make_shared<ChContactMaterialNSC>();
    auto collshape = chrono_types::make_shared<ChCollisionShapeBox>(collmat, 0.1, 0.2, 0.3);
    mybody->AddCollisionShape(collshape);
    mybody->EnableCollision(true);

Please refer to the dedicate pages for collision and visualization to complete the configuration of the system.

For bodies of the class ChBodyEasy the constructor is richer:

auto mySphere = chrono_types::make_shared<ChBodyEasySphere>(4, // radius
8000, // density
true, // visualization enabled
true, // collision enabled
collmat // collision material
);
my_system.Add(mySphere);

Demos

See:

ChFrame< double > ChFramed
Alias for double-precision coordinate frames.
Definition: ChFrame.h:348
ChVector3< double > ChVector3d
Alias for double-precision vectors.
Definition: ChVector3.h:283