Page 1 of 1

new muscle class in version 2.2 or later

Posted: Fri Oct 07, 2011 8:50 am
by mitsu
hello
at the version 1.x, I could make new muscle class taking after [muscle.h].
however, if I try same thing with version 2.2, it gives me error
like STATE_ACTIVATION' : dllimport definition problem of static data member

in previous version, it was not necessary to use [OSIMACTUATORS_API]. but now, I think it is necessary.
I tried without [OSIMACTUATORS_API], but the state seems not be initialized in this case.
and if I use [OSIMACTUATORS_API], the declaration of existing state seems making problem.

in fact, liuthelenmuscle class tells us how to make new class, but it is adding only new states, not changing the dynamics of hill model itself.

but I would like to modify the dynamics then I need to make new class taking after [muscle.h] like thelenmodel.

could you advise me how to avoid such error?
at the time of version 1.x, even without OSIMACTUATORS_API, and making new class like thelen from muscle.h, it worked.
and I just want to do same thing.
thank you

Re: new muscle class in version 2.2 or later

Posted: Tue Oct 11, 2011 12:07 am
by aseth
Hi Mitsu,

We apologize for the inconvenience. Muscles have gone through and are going through significant refactoring.

If your muscle class is part of a plugin you must use OSIMPLUGIN_API macro (to specify that your class is exported as part of the dll which is your plugin) and NOT OSIMACTUATORS_API since that is for exporting classes contained in osimActuators.dll and unless you are building from source you cannot extend that library. This has always been the case.

To add states and dynamics to an existing class (like Thelen2003Muscle) refer to the MuscleExample in sdk/APIExamples. The LiuThelen2003Muscle adds states and dynamics for those new states. I don't think it generates very meaningful results but it does demonstrate how new states are specified in OpenSim 2.4.

As of 2.4 the base Muscle class no longer provides any states and ActivationFiberLength is a new intermediate class that adds activation and fiber-length states and its subclasses (Thelen2003Muscle, Schutte1993Muscle, ...) define the state derivatives by implementing computeStateVariableDerivatives. This is part of the ModelComponent interface that enables any opensim component (Joint, Constraint, Force->Actuator->Muscle, etc...) to have states and dynamics for those states to be specified.

Please look at the MuscleExample and continue to post any questions you might have. Thanks.