Rotation around an axis.

82 views
Skip to first unread message

Massimiliano Marcianesi

unread,
Mar 11, 2024, 9:03:21 AM3/11/24
to ProjectChrono
Hello everyone, I'm new to Project Chrono and I'm trying to rotate a body around an axis, but so far I have obtained results that are not what I would have liked. I created a chlinklockrevolute and then a ChLinkMotorRotationSpeed to which I imposed a constant angle function of the value of Pi. Although the body rotates around the axis I have chosen, it does so following a trajectory that appears to be a spiral which moves it further and further away from the constraint. Where am I wrong?

Thanks for the help.

Dario Mangoni

unread,
Mar 11, 2024, 9:48:42 AM3/11/24
to ProjectChrono
Hi Massimiliano,
did you get a look at demos?

demo_MBS_motors, case A-1

Please mind that ChLinkMotorRotationSpeed includes by default the revolute link (if you don't disable it). You can change its behaviour through ::SetSpindleConstraint, but I would recommend you to remove the ChLinkLockRevolute instead.

ChLinkMotors are indeed still links (i.e. joints) so please consider that there are two different kind of initialization:
- giving just one absolute frame: this will place the joint frame(s) at that given position and there will be no violation whatsoever
- giving the position of the link relative to both bodies, like this or this: this will require you to place the bodies in a feasible position (i.e. so to not violate joints); this is not strictly required, but not doing it could lead to crash

Dario

Massimiliano Marcianesi

unread,
Mar 22, 2024, 9:21:03 AM3/22/24
to ProjectChrono
Goodmorning Dario,

    I'm answering this with so much delay because of job. Anyway: I've given a look at the example you've pointed me out and it seems to me that I've done all things correctly, so I'll paste some code:

    // Creating the system
    ChSystemNSC phSys;
    phSys.SetCollisionSystemType(ChCollisionSystem::Type::BULLET);
    phSys.Set_G_acc(ChVector<>(0.0, 0.0, 0.0));
    auto mat = chrono_types::make_shared<ChMaterialSurfaceNSC>();
    auto ground = chrono_types::make_shared<ChBodyEasyBox>(10.0, 3.0, 10.0, 100.0, mat);
    ground->SetBodyFixed(true);
    ground->SetPos(Vector(0.0, -1.50, 0.0));
    if (auto vs = ground->GetVisualShape(0u); vs.get() != nullptr)
ground->GetVisualShape(0)->SetColor(ChColor(0.2f, 0.3f, 0.6f));
    phSys.AddBody(ground);
    auto pareteCls = std::make_shared<chrono::ChBodyEasyBox>(4, 2.7, 0.5, 1000, true, false, mat);
    phSys.AddBody(pareteCls);
    pareteCls->SetName("PareteCls");
    pareteCls->SetPos(Vector(2, 2.7 / 2.0, 0.25));
    auto rotation = chrono_types::make_shared<ChLinkMotorRotationSpeed>();
     rotation->Initialize(ground, pareteCls, ChFrame<>(Vector(0.0, 0.0, 0.0), Q_from_Euler123(chrono::Vector(0.0, CH_C_PI_2, 0.0))));
     rotation->SetSpeedFunction(chrono_types::make_shared<ChFunction_Const>(CH_C_PI));
    phSys.AddLink(rotazione);
     // Irrlicht stuff...
    while (vis->Run()) {
         // Irrlicht stuff...
        phSys.DoStepDynamics(time_step);
        realtime_timer.Spin(time_step);
    }

Again: the rotation axis seems right, but after some simulation time this is the situation: rotating.png
Any hint?
Reply all
Reply to author
Forward
0 new messages