Page 1 of 1

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

Posted: Tue Oct 31, 2023 5:37 am
by anacsousa
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

---

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

Posted: Wed Nov 01, 2023 3:37 pm
by kernalnet
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).