Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Soh Saif
- Posts: 5
- Joined: Sun Jul 04, 2021 2:49 pm
Post
by Soh Saif » Sun May 15, 2022 2:28 pm
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
Tags:
-
Adam Kewley
- Posts: 4
- Joined: Mon Sep 21, 2020 2:37 am
Post
by Adam Kewley » Tue May 17, 2022 12:32 am
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(); }`