Removing a body from the model

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Caitlin Edgar
Posts: 12
Joined: Thu Mar 17, 2022 2:23 am

Removing a body from the model

Post by Caitlin Edgar » Thu May 12, 2022 8:29 am

Hi there,

I was just wondering whether it was possible to remove a body from a generic model using API on matlab.

I wish to remove the calcaneus, talus and toes and replace with a prosthetic foot.

Is there a function to achieve this on matlab, I can only find API suggestions on adding a body.

Many thanks,
Caitlin

User avatar
Colin Smith
Posts: 53
Joined: Fri Feb 24, 2012 11:50 am

Re: Removing a body from the model

Post by Colin Smith » Sat May 14, 2022 9:04 am

Hopefully someone has a better answer for you... I'm not sure if a solution has been implemented recently.

I have found the API is well designed for adding components to models, but not as streamlined for removing components.

In the "Set" class there is a function "remove" that works... sometimes (ie remove a force from ForceSet).

Bodies have a lot of dependencies in the model (key part of underlying multibody system, joints connect them to other bodies, muscles attach to them etc), so it is not straightforward to just remove them.

One thought on how to do this in MATLAB is to build up a second model from scratch and just don't add the bodies you don't want.

So create a new model, then loop over the BodySet, JointSet, ForceSet etc in the first model, clone the components and add them to the second model.

User avatar
Adam Kewley
Posts: 4
Joined: Mon Sep 21, 2020 2:37 am

Re: Removing a body from the model

Post by Adam Kewley » Mon May 16, 2022 7:24 am

Another thing you could try is OpenSim Creator, which includes basic support for deleting things from a model:
The support for it is super basic. It will probably encounter an issue deleting a body that other components are (indirectly) dependent on (e.g. joints, which can be (in)directly dependent on bodies). However, it *should* print an error message to the log, which should help identify what needs to be deleted first.

The reason why support is basic is because the current implementation doesn't attempt to recursively delete everything that's connected to the to-be-deleted element. I found that supporting that behavior causes mayhem. E.g. deleting a "root" body in a model tree may logically require deleting almost everything else in the model. I decided it would be too complicated to explain that via a basic UI operation.

As Colin writes, the API is fine for *adding* things to the model but isn't so great for *deleting* things. In order to even get basic UI support I ended up having to perform a bunch of explicit type tests to figure out how to delete the component from its parent:
I'm sure there's easier ways--and we can add them in later versions of OpenSim--but that's the best I could come up with inside of a couple of hours.

POST REPLY