This is an example using the MocoInverse tool with a complex model to prescribe walking. This example also shows how to track electromyography data.
#include <OpenSim/Actuators/ModelOperators.h>
#include <OpenSim/Common/Adapters.h>
#include <OpenSim/Moco/osimMoco.h>
void solveMocoInverse() {
inverse.
setName(
"example3DWalking_MocoInverse");
"example3DWalking_MocoInverse_solution.sto");
}
void solveMocoInverseWithEMG() {
inverse.
setName(
"example3DWalking_MocoInverseWithEMG");
tracking->setReference(controlsRef);
tracking->setReferenceLabel("/forceset/soleus_r", "soleus");
tracking->setReferenceLabel("/forceset/gasmed_r", "gastrocnemius");
tracking->setReferenceLabel("/forceset/gaslat_r", "gastrocnemius");
tracking->setReferenceLabel("/forceset/tibant_r", "tibialis_anterior");
solution.
write(
"example3DWalking_MocoInverseWithEMG_solution.sto");
"/forceset/tibant_r"});
}
int main() {
solveMocoInverse();
solveMocoInverseWithEMG();
return EXIT_SUCCESS;
}