Missing Parameters when Adding Ligaments / Wrap Sphere

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Aaron Fox
Posts: 294
Joined: Sun Aug 06, 2017 10:54 pm

Missing Parameters when Adding Ligaments / Wrap Sphere

Post by Aaron Fox » Mon Sep 09, 2019 5:19 pm

Hi All,

I have attempted running some code (via both Matlab and Python) to add a ligament to a models forceset. This works, however not all of the parameters for the ligament end up written in the model - only the resting length and PCSA force parameters go across. This is despite additional information, such as a spline function, seemingly being present within the object in Matlab/Python (i.e. when running the '.dump()' command the information is there). I have been adding the ligament to the model using the '.adoptAndAppend()' and '.finalizeConnections()' command to the forceset, which obviously works but doesn't take across all the parameters when printing the model. Has anyone had a similar experience or any advice in changing the approach to get all of the parameters across?

One additional problem I've also come across in this process is in he creation of a wrap sphere, there doesn't appear to be a command to set the radius of the sphere programatically (i.e. there is no '.setRadius()' or '.set_radius()' type commands for this class). When added to the model this parameter defaults to a -1 and can be changed manually in the printed model file. Is there such a method to do this in Matlab/Python?

Thanks,

Aaron

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Missing Parameters when Adding Ligaments / Wrap Sphere

Post by Dimitar Stanev » Tue Sep 10, 2019 12:03 am

Hi,

In this case you can navigate the source code to check there are some bugs in the internal implementation. For the ligament everything seems ok.

https://github.com/opensim-org/opensim- ... ment.h#L59

The above are the properties of the class, which you can set. These are macros that create setters and getters for the properties. They use the underscore and not the camel case convention. Therefore, to change the parameters of the ligament you do something like:

Code: Select all

ligament = Ligament()
ligament.set_rest_length(0.2)
ligament.set_pcsa_force(100)
function = GCVSpline(3, 10, X, Y)
ligament.set_force_length_curve(function)
model.addForce(ligament)


For the second issue, sometimes the code is not updated, therefore the old convention is used

https://github.com/opensim-org/opensim- ... here.h#L53

For you to update you have to access the property:

Code: Select all

sphere.updPropertyByName("radius").updValue() = 0.1
or setValue, I am not sure what is exposed for the bindings

User avatar
Aaron Fox
Posts: 294
Joined: Sun Aug 06, 2017 10:54 pm

Re: Missing Parameters when Adding Ligaments / Wrap Sphere

Post by Aaron Fox » Thu Sep 19, 2019 4:06 am

Hi Dimitar (and others),

As a follow-up question to this, do you know why the set parameters would not print to file/save in the model? I can create the ligament class and set all of the parameters (i.e. force, resting length, force function etc. etc.), and when I view (i.e. .dump()) the class object in Python all of the parameters are there. Even when I add it to the model and .dump() this all of these parameters are there. As soon as I either (1) print the model to file; or (2) print the ligament object to XML - the majority of the parameters disappear (I think only resting length and PCSA force is left). I haven't come across this weird behaviour before.

Any ideas?

Thanks,

Aaron

User avatar
Ayman Habib
Posts: 2254
Joined: Fri Apr 01, 2005 12:24 pm

Re: Missing Parameters when Adding Ligaments / Wrap Sphere

Post by Ayman Habib » Thu Sep 19, 2019 10:08 am

Hi Aaron,

The key maybe the actual values assigned to the properties being written. The code tries to avoid writing values that are equal to the defaults in the code in order to reduce the file size and to give class writers the opportunity to change the defaults if needed. Please compare the values you set to the defaults to see if this is the case.

-Ayman

User avatar
Aaron Fox
Posts: 294
Joined: Sun Aug 06, 2017 10:54 pm

Re: Missing Parameters when Adding Ligaments / Wrap Sphere

Post by Aaron Fox » Thu Sep 19, 2019 5:33 pm

Hi Ayman,

I'm not sure this was the case, as I changed a number of things (i.e. path points added, force function changed etc.) - and these do not match the default values.

I've developed a lazy work-around in writing the dumped model text to string and passing it to an XML parser in Python. This has allowed me to write and edit the parameters that weren't showing when using the internal print to XML function. An imperfect solution, but one that works nonetheless.

Thanks,

Aaron

POST REPLY