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: [image: rotating.png]
Any hint?
Il giorno lunedì 11 marzo 2024 alle 14:48:42 UTC+1 [email protected] ha
scritto:
> 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
> <https://api.projectchrono.org/development/classchrono_1_1_ch_link_mate_generic.html#a872f0a5387924a85878f72b7a333a9cc>:
>
> 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
> <https://api.projectchrono.org/development/classchrono_1_1_ch_link_mate_generic.html#aff5d77b53b56cbf948eee07608de045d>or
>
> this
> <https://api.projectchrono.org/development/classchrono_1_1_ch_link_mate_generic.html#aa5c055bacc93ea4d37e71622f2e22c62>:
>
> 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
>
> Il giorno lunedì 11 marzo 2024 alle 14:03:21 UTC+1 [email protected]
> ha scritto:
>
>> 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.
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/projectchrono/3aefe823-e71c-49ce-8c3d-0e88d7036fb9n%40googlegroups.com.