Difference between ChBodyEasyCylinder and AddCylinderGeometry

81 views
Skip to first unread message

Gianni Curti

unread,
Nov 20, 2024, 1:25:35 PM11/20/24
to ProjectChrono
Hi,
I have a question regarding the difference between the commands "ChBodyEasyCylinder" and "AddCylinderGeometry". For what I have understood, the first one automatically calculates the mass and inertia of a body depending on the sizes and density given, while the second one provides only the collision shape of a cylinder (neither mass nor density if they are not manually given). However, I saw that there is the possibility of assigning the "Position on body" when using "AddCylinderGeometry" through a ChVector3d but the result is pretty different from what I obtain by using "SetPos" when I also apply a rotation to the body. What does this command do exactly? 
Thank you in advance for yout patience and kindness.

Best Regards

Gianni

Maksym Riabov

unread,
Nov 25, 2024, 7:21:03 PM11/25/24
to ProjectChrono
From my memory, it's a util function. Check the implementation details...

```
void ChBodyEasySphere::SetupBody(double radius,
                                 double density,
                                 bool visualize,
                                 bool collide,
                                 std::shared_ptr<ChContactMaterial> material) {
    double mmass = density * ((4.0 / 3.0) * CH_PI * std::pow(radius, 3));
    double inertia = (2.0 / 5.0) * mmass * std::pow(radius, 2);

    SetMass(mmass);
    SetInertiaXX(ChVector3d(inertia, inertia, inertia));

    if (collide) {
        assert(material);
        auto cshape = chrono_types::make_shared<ChCollisionShapeSphere>(material, radius);
        AddCollisionShape(cshape);
        EnableCollision(true);
    }
    if (visualize) {
        auto vshape = chrono_types::make_shared<ChVisualShapeSphere>(radius);
        AddVisualShape(vshape);
    }
}

```

Radu Serban

unread,
Nov 29, 2024, 7:26:01 AM11/29/24
to ProjectChrono

Hi Gianni,

 

ChBodyEasyCylinder creates a body representing a solid cylinder centered at the body COM and aligned along the specified axis of the COM frame.  The body mass and inertia is set automatically assuming the cylinder is solid and has constant density.

AddCylinderGeometry allows you to attach a cylindrical shape (for collision and, optionally also visualization) to an existing body. This utility function allows you to position this cylinder arbitrarily relative to the body COM. This is what “Position on body” represents (a translation of the cylinder shape from the body COM and expressed in the body COM frame.  It is your responsibility to construct the body (including setting its inertial properties).

 

Note that ChBody::SetPos() sets the origin of the body COM frame relative to the absolute coordinate.  It is important to understand well all the frames involved and in what frame various quantities are relative to and expressed in.

See for example the first figure on this Chrono documentation page: https://api.projectchrono.org/development/collisions.html#collision_models_shapes.

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/projectchrono/10d9deb5-26b4-4ebe-a37b-41e1fdec1037n%40googlegroups.com.

Gianni Curti

unread,
Dec 16, 2024, 6:56:19 AM12/16/24
to ProjectChrono
Hi Radu and Maksym,

thank you for your answer and kindness.
Lately, I was also trying to use the command "RemoveBody()" in the Multicore environment to remove two bodies that falls out of my volume of interest. Otherwise, as they increase their distance from the other bodies, the simulation visibly slows down. However, when I implement this command I get the following error message at the beginning of the simulation.
Screenshot 2024-12-15 194044.png
Is there any other way to remove these two bodies from the simulation?
Thanks in advance.

Gianni

Radu Serban

unread,
Dec 16, 2024, 7:56:04 AM12/16/24
to ProjectChrono

Hi Gianni,

 

Because of the data structures used in Chrono::Multicore, removing elements after system construction is more complicated and expensive, so we opted to not provide this capability.

 

To address the type of issues you are seeing (indeed, as collision shapes move farther and farther apart, the computational cost of the collision broadphase in Chrono::Multicore increases), you can define a region around the computational domain of interest.  With that option enabled, bodies located outside that region will be frozen (in that their state is not updated anymore)

You do that by (1) enabling this option and (2) providing the corners of an axis-aligned bounding box that defines the “active” domain.

An illustration of this setting is in demo_MCORE_mixerNSC in the commented-out lines 168-170.

 

--Radu

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Gianni Curti
Sent: Monday, December 16, 2024 12:56 PM
To: ProjectChrono <projec...@googlegroups.com>
Subject: Re: [chrono] Difference between ChBodyEasyCylinder and AddCylinderGeometry

 

Hi Radu and Maksym,

 

thank you for your answer and kindness.

Lately, I was also trying to use the command "RemoveBody()" in the Multicore environment to remove two bodies that falls out of my volume of interest. Otherwise, as they increase their distance from the other bodies, the simulation visibly slows down. However, when I implement this command I get the following error message at the beginning of the simulation.

Gianni Curti

unread,
Dec 26, 2024, 2:52:58 PM12/26/24
to ProjectChrono
Hi Radu,

thank you for your suggestion. In the end it worked by limiting the simulating volume of interest!
Now, I am facing an issue with the command GetAppliedTorque() and GetAppliedForce(). I have defined the ChBody object in my simulation which is subjected to different loads and I need to verify if this ones are in line with what is predicted by theory. However, as soon as I start the application, the simulation crashes without any output error. I am sure that the problem is related to this commands since as soon as I comment them out everything works. Has anybody else ever experienced something similar?

Thank you in advance for your help!

Gianni

Radu Serban

unread,
Dec 27, 2024, 4:08:18 AM12/27/24
to ProjectChrono

Hi Gianni,

 

First of all, which Chrono version are you using? If possible, I suggest using the latest code in the ‘main’ branch of the Chrono GitHub repository since it is a lot easier for us to help resolve issues based on the latest code.

 

Did you try running demo_MCORE_mixerNSC with lines 195-197 uncommented? This works just fine on my end.

Do you see the same issues with use of these two functions in demo_MCORE_mixerNSC?

Did you run this through a debugger? That will tell you exactly where and why the code crashes.

Gianni Curti

unread,
Dec 28, 2024, 6:45:54 AM12/28/24
to ProjectChrono
Hi Radu,

I run the "demo_MCORE_mixerNSC" without encountering the same issues and in the end I found the problem. In short, I was calling the function before "DoStepDynamics()" in the for loop and this was causing the code to crash. It is strange because all the other functions like "GetPos()" and "GetPosDt2()" work properly in that position outputting "0, 0, 0" at the first timestep thus I was expecting the same from "GetAppliedForce()".

Thank you again for your help and patience!

Gianni
Reply all
Reply to author
Forward
0 new messages