Page 1 of 1

Custom getExcitation method for a muscle

Posted: Sun May 15, 2022 2:28 pm
by soheil2021
Hi there,

I'm new to OpenSim and currently working on a project related to Synergy Optimization techniques.

I actually need to define a custom Excitation (getExcitation method) for a muscle. I managed to define a custom muscle based on FatigableMuscle example but I need to customise the getExcitation method and calculate the excitation based on some Synergy Optimization technique. As far as I noticed, getExcitation method is not a virtual method in Muscle class, so I can't override it:

Code: Select all

double Muscle::getExcitation( const SimTK::State& s) const {
    return( getControl(s) );
}
I was wondering how I can add a customised Excitation for a muscle? Is it right to add a new custom muscle class?
I also noticed that getExcitaion calls getControl(s) which is a virtual method in Actuator class, but I'm not sure if this is the right solution to define a custom Actuator and then inherit a new muscle class from the custom Actuator.

Please advise if there are any solutions for this.
Thanks in advance.
Soh

Re: Custom getExcitation method for a muscle

Posted: Tue May 17, 2022 12:32 am
by adamkewley
Hi Soh,

Although this doesn't answer your question directly (in terms of overriding `getExcitation` specifically), one thing you can try is to override `OpenSim::ScalarActuator::getControl` instead:
From what I understand (a modelling veteran should double-check), the use of the term "control" is used because `OpenSim::Actuator`s are a more generic concept (e.g. you can "control" a motor with a signal). "Excitation" is a muscle-specific term, but it doesn't appear that the `OpenSim::Muscle` base class does anything different with the control signal, so it might be possible to use the two interchangeably.

So you might just be able to create your derived class and declare `double getControl(const SimTK::State&) override { return yourAlgorithm(); }`