Hi there!
I am trying to visualise spring elements (ChElementSpring) on irrlicht app, but it has been quite impossible for me. I found some examples and I could replicate them and visualise some links as springs (ChLinkTSDA), but it is not what I need because this kind of links need two bodies to be created, and that is so inefficient for my model.
I was looking for a way to visualise the spring created between two nodes, my system is currently working. For simple models is possible to understand what is happening just with the representation of the nodes as dots, but if I want to make it more complex, will be so much easier to comprehend if I can see the springs on the irrlicht app.
On my script, first of all, I create some nodes and elements:
Then I represent the nodes as dots, as you can see in the following code:
auto visGlyph = chrono_types::make_shared<ChVisualizationFEAmesh>(*(mesh.get()));
I also tried to represent the springs, as I did it before for other kind of elements (for example with ChBeamEulerAdvance) but I do not know how to configurate them. Is there any option or function to do it? I do not need something complex, with a simple line is enough.
Thanks!
Fran
Hi Fran,
If rendering a line between the two nodes is good enough, you can simply call the function drawSegment() within your simulation loop (before the call to EndScene) and pass it the locations of the two nodes you want connected.
As an example, look at
demo_IRR_gears.
--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 on the web visit
https://groups.google.com/d/msgid/projectchrono/e5a30dc1-37ed-4d2e-b0e9-607c9186279fn%40googlegroups.com.
Fran,
Not with the current Chrono code.
But why not do something like:
std::vector<std::shared_ptr<ChElementSpring>> springs;
// Create spring elements, add to mesh, add to list
auto spring1 = chrono_types::make_shared<ChElementSpring>();
spring1->SetNodes(nodeA, nodeB);
mesh->AddElement(spring1);
springs.push_back(spring1);
auto spring2 = …
…
springs.push_back(spring2);
// Simulation loop
while(…) {
…
for (const auto& s : spring) {
tools::drawSegment(vis.get(), s->GetNode(0)->GetPos(), s->GetNode(1)->GetPos());
}
…
}
--Radu
P.S. Please continue conversations on the user mailing list. Thanks
From: Fran Bottero <franb...@gmail.com>
Sent: Tuesday, June 7, 2022 10:12 AM
To: Radu Serban <ser...@wisc.edu>
Subject: Mensaje privado sobre: [chrono] ChElementSpring visualization
Great,
Yes its good enough and it's working, just one more question, as I have to join several number of nodes following an predefined order (that I indicated when I create the springs), is it possible to do it outside the while loop (for example, adding another propertie to the ChElementSpring)?
Thanks,
Fran
Fran,
Indeed.
GetNodeN must return a ChNodeFEAbase because it is a virtual method of the base class ChElementBase.
You need to cast the nodes to the proper type to get their positions. Something like:
for (const auto& s : spring) {
tools::drawSegment(vis.get(),
std::static_pointer_cast<ChNodeFEAxyz>(s->GetNode(0))->GetPos(),
std::static_pointer_cast<ChNodeFEAxyz>(s->GetNode(1))->GetPos());
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/c94f531f-f002-4d8e-8189-2be1eb178c42n%40googlegroups.com.