How to remove a module

88 views
Skip to first unread message

Jay Sun

unread,
Jan 13, 2024, 3:13:51 AM1/13/24
to ProjectChrono
Hello everyone.

I custom modeled a wheelbarrow in solidwork and installed a motor on each wheel. As shown in the picture below. Where A,B, and C are the parts of the wheel and body. 1️⃣ and 2️⃣ indicate universal joints.
After the modeling is complete, simulate in the pychrono simulator. I want to delete 2️⃣ and C at some point in the car's motion. Using this method Chsystem. Removebody () (HTTP: / / https://api.projectchrono.org/classchrono_1_1_ch_system.html#a6bcfccb9a810168596f0a53e02a8 7b58). When I used it, it seemed to delete the unexpected "body" except for 2️⃣ and C. And the simulation freezes. Am I using it in a wrong way?
I use the official documentation spiders code examples (https://api.projectchrono.org/tutorial_pychrono_demo_spider_robot.html). I found that this problem also occurred, I deleted "bbody", but only left bbody. Remove the arm part of spider, it will also get stuck.
Am I using it in a wrong way? Please help me take a look, thank you very much!!
Regard,
JayCleanShot 2024-01-13 at 15.50.51@2x.png

Dario Mangoni

unread,
Jan 15, 2024, 7:03:06 AM1/15/24
to ProjectChrono
Hi,
the problem is that, by removing only the bodies, the links that are bound to such bodies will have dangling pointers. For the time being you can remove the relative links by doing something like:

Before the simulation loop:

myfoot  = mysystem.SearchBody('M-410iB-300 -3/M-410iB-300-12-1')
myfoot_linklist = []
for link in mysystem.Get_linklist():
    if (chrono.CastToChLinkMateGeneric(link)):
        mate_link = chrono.CastToChLinkMateGeneric(link)
        if (mate_link.GetBody1() == myfoot or mate_link.GetBody2() == myfoot):
            myfoot_linklist.append(mate_link)

removed = False

and in the simulation loop

while(vis.Run()):
    vis.BeginScene()
    vis.Render()
    mysystem.DoStepDynamics(0.001)
    vis.EndScene()

    if mysystem.GetChTime() > 1 and not removed:
        mysystem.RemoveBody(myfoot)
        for link in myfoot_linklist:
            mysystem.RemoveLink(link)
        removed = True


However, we may add an option to ChSystem::RemoveBody to optionally take care also of attached links.

BTW, we are going to update that spider_robot demo soon with the latest API changes.



Jay Sun

unread,
Jan 21, 2024, 11:39:06 PM1/21/24
to ProjectChrono
Thank you very much for your reply. I have tried according to your method. There are some effects. Here's what I did: I removed the middle hinge of the second module and the third module, and the third module, first deleting the corresponding fit of the hinge and the third module, and then deleting the hinge, the third module and the wheel. The state appears as shown in the video, the third module and hinge are not set the collision model, so there is no collision with the ground, and the wheel is set the collision model, so it is on the ground. But they were not removed from the system.
Please tell me how to solve this problem. Thank you so much!!

Jay

Reply all
Reply to author
Forward
0 new messages