Passive Fiber force-length curve problem

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
mohamad mahdavian
Posts: 28
Joined: Tue Mar 04, 2014 11:47 am

Passive Fiber force-length curve problem

Post by mohamad mahdavian » Wed Jul 08, 2015 8:48 am

Hello.I am trying to change passive fiber force-length curve properties in millard model.But it isn't possible to change some of its parameters in the program.I tried to change this parameters in the model script.But there is a problem whenever you try to open the model.There is the message:

Exception caught in RightMuscle::buildMuscle()
SimTK Exception thrown at FiberForceLengthCurve.cpp:155:
Error detected by Simbody method FiberForceLengthCurve::ensureCurveUpToDate(): RightMuscle_FiberForceLengthCurve: Optional parameters stiffnessAtLowForce, stiffnessAtOneNormForce, and curviness must either all be set or all be empty.
(Required condition 'false' was not met.)

How can I change the parameters?!

User avatar
Matthew Millard
Posts: 25
Joined: Fri Aug 01, 2008 7:17 am

Re: Passive Fiber force-length curve problem

Post by Matthew Millard » Thu Jul 09, 2015 12:06 am

1. Make a new temporary FiberForceLengthCurve object using the detailed constructor:

FiberForceLengthCurve fpeCurve = FiberForceLengthCurve ( strainAtZeroForce, strainAtOneNormForce, stiffnessAtLowForce, stiffnessAtOneNormForce, curviness );

*Make sure you check out the doxygen for the FiberForceLengthCurve as all of the above
arguments are in normalized units.

2. Using the equilibrium muscle's member function 'setFiberForceLengthCurve' update
the muscle's passive force length curve object. For a Millard2012EquilibriumMuscle object
named eqMuscle this would look like:

eqMuscle.setFiberForceLengthCurve(fpeCurve);

This should fix your problem.

User avatar
mohamad mahdavian
Posts: 28
Joined: Tue Mar 04, 2014 11:47 am

Re: Passive Fiber force-length curve problem

Post by mohamad mahdavian » Thu Jul 09, 2015 3:29 am

Thank you dear Dr Millard for responding. Unfortunately you are explaining too professional and I can't understand all the details.
Am i suppose to reconstruct the whole Opnesim program?!
Am i suppose to change the details in main constructor codes (such as FiberForceLengthCurve code) and construct the program!?

Best Regards

User avatar
Matthew Millard
Posts: 25
Joined: Fri Aug 01, 2008 7:17 am

Re: Passive Fiber force-length curve problem

Post by Matthew Millard » Thu Jul 09, 2015 4:42 am

Perhaps I should back up a bit: what programming language are you using?

User avatar
mohamad mahdavian
Posts: 28
Joined: Tue Mar 04, 2014 11:47 am

Re: Passive Fiber force-length curve problem

Post by mohamad mahdavian » Thu Jul 09, 2015 6:16 am

I know the main program code is in C++.But i was trying to make changes in Tug_of_War model and it doesn't need any programs. I made many other changes in different code without using C++ and reconstruction and it was ok. But once I tried to make changes in a main code and reconstruct the opensim program and I encountered many problems. I wounder if you could give the information more detailed that could help me more.
Best Regards

User avatar
Matthew Millard
Posts: 25
Joined: Fri Aug 01, 2008 7:17 am

Re: Passive Fiber force-length curve problem

Post by Matthew Millard » Fri Jul 10, 2015 1:57 am

I think I see the problem: Tug Of War is completely defined in its *.osim file, and so everything about that model is hidden from you in your C++ program. To learn how to edit a model there are two paths you can take: editing the model using the C++ api, or editing the model using the OpenSim GUI + a text editor. You should get familiar with both approaches - they are both useful to know.

--------------------
Path 1: Editing the model using the C++ api
--------------------
1. Start with the `Simple Example' which appears on opensim-core's github page (https://github.com/opensim-org/opensim-core). This model is a pendulum that is actuated by a single muscle. This model is completely built using the C++ api, and so its much easier to modify it directly.

a. Copy the code for this model from opensim-core's github page and save it to 'simpleExample.cpp' and put this in a folder of your choosing (say `simpleExampleFolder').
b. Follow the instructions in the link below to build the simple example
http://simtk-confluence.stanford.edu:80 ... ep+Example
c. Run it. Make sure that you see the animation of the arm moving before proceeding.

2. To change the FiberForceLengthCurve use the advice offered in my previous post. I suggest adding the code for the FiberForceLengthCurve following the line `muscle->addNewPathPoint("point2", *link2, Vec3(0, 0.7, 0));'

Try this. If you get stuck write back and I'll post a version of this model with the FiberForceLengthCurve modified.

--------------------
Path 2: Editing the model using the GUI & text editing
--------------------
You can also edit the model by editing the text of the *.osim file. Use the guide to below to help you do this:

1. Open tugOfWar_model.osim (I think it's currently in OpenSim/Examples/ExampleMain/OutputReference/ )

2. Search for <ForceSet> - this is where all of the XML for the muscles are defined.

3. Note that currently the muscles used are Thelen2003Muscle. If you search for <max_isometric_force> you will find a block of properties. These are the architectural properties of the muscles (fiber length, tendon slack length, pennation angle, maximum isometric force).
a. If you edit the values of these properties in the *.osim file and save it, the next time you load this file (either from a C++ program or the GUI) your edits will be used.
b. Note: not all of the properties are here. Any property that takes its default value is not written out to the XML file.

4. If you want to change the muscle model,
a. Replace all occurrences of 'Thelen2003Muscle' with 'Millard2012EquilibriumMuscle'.
b. Load the *.osim file using the GUI, or your C++ program, and then save it as 'tugOfWar_upd0.osim'
c. Now open 'tugOfWar_upd.osim' using a text editor and search for <ForceSet> and read down. You should see that all of muscle models have been changed.

5. If you want to write a property of a muscle model that is currently hidden (because it has its default value) to the text file:
a. Open the osim model using the OpenSim GUI
b. Use the Navigator Window to find 'Forces'.
c. Go into forces and find the muscles, and open up the properties for a muscle.
d. Change a property in the FiberForceLengthCurve - now its different from the default.
e. Save the model to 'tugOfWar_upd1.osim'.
f. Open 'tugOfWar_upd1.osim'. Now if you scroll to the XML for the muscle you just edited you should find that there is an addtional block of XML that is related to the FiberForceLengthCurve. You can edit the properties in a text editor and save the file. The next time you load it the curve properties you added will be used.

POST REPLY