Is there a way to remove a WeldJoint using the API?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Ana de Sousa
Posts: 58
Joined: Thu Apr 07, 2016 4:21 pm

Is there a way to remove a WeldJoint using the API?

Post by Ana de Sousa » Tue Oct 31, 2023 5:37 am

Hello everyone,

I would like to know if there is a way to remove a WeldJoint from a model using the API.

I have successfully added the WeldJoint using the following code snippet:
Code

Code: Select all

joint = osim.WeldJoint("joint_1_2",
                       model.getBodySet().get("body1"),
                       osim.Vec3(0, 0, 0),
                       osim.Vec3(0, 0, 0),
                       model.getBodySet().get("body2"),
                       osim.Vec3(0, 0, 0),
                       osim.Vec3(0, 0, 0))
model.addJoint(joint)

However, I am uncertain about the procedure to remove it.

I attempted to delete the <WeldJoint name="joint"> from the osim file, but encountered an error when loading the model into OpenSim: "Attempting to assign an invalid SimTK::MobilizedBodyIndex in Object 'x' of type Physical OffsetFrame. Thrown at PhysicalFrame.cpp73 in setMobilizedBodyIndex()".

If anyone can provide insight into the correct method for deleting the <WeldJoint name="joint">, I would greatly appreciate your assistance.
I would prefer learning how to do it in the API, but if it is just easier messing with the osim file, that is fine by me.

Thank you in advance for your assistance!

Best regards,
Ana

---

Tags:

User avatar
Mohammadreza Rezaie
Posts: 367
Joined: Fri Nov 24, 2017 12:48 am

Re: Is there a way to remove a WeldJoint using the API?

Post by Mohammadreza Rezaie » Wed Nov 01, 2023 3:37 pm

I attempted to delete the <WeldJoint name="joint"> from the osim file, but encountered an error when loading the model into OpenSim: "Attempting to assign an invalid SimTK::MobilizedBodyIndex in Object 'x' of type Physical OffsetFrame. Thrown at PhysicalFrame.cpp73 in setMobilizedBodyIndex()".
Hi, the error is probably due to a disconnection in the multibody tree (please check the topology view). It depends on your research, e.g., if you intend to remove a joint completely (e.g., ankle), you must remove the child body (talus) and all of its connections (subtalar joint, calcn body, mtp joint, toes body).

POST REPLY